Tweaked shadow mapping

WorldChunkRefactoring
Martin Felis 2022-08-25 23:40:19 +02:00
parent 761d9064e1
commit b9393a2b8a
5 changed files with 45 additions and 9 deletions

View File

@ -28,6 +28,7 @@ process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true

View File

@ -9,17 +9,17 @@
config_version=4
_global_script_classes=[ {
"base": "Reference",
"base": "Node",
"class": "ClickableComponent",
"language": "GDScript",
"path": "res://components/ClickableComponent.gd"
}, {
"base": "Reference",
"base": "KinematicBody2D",
"class": "CollisionLine",
"language": "GDScript",
"path": "res://utils/CollisionLine.gd"
}, {
"base": "Reference",
"base": "Node",
"class": "ColorComponent",
"language": "GDScript",
"path": "res://components/ColorComponent.gd"
@ -29,7 +29,7 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://utils/SpringDamper.gd"
}, {
"base": "Reference",
"base": "Sprite",
"class": "TintedSpriteComponent",
"language": "GDScript",
"path": "res://components/TintedSpriteComponent.gd"
@ -84,4 +84,5 @@ common/enable_pause_aware_picking=true
[rendering]
quality/directional_shadow/size=512
environment/default_environment="res://default_env.tres"

View File

@ -5,11 +5,14 @@ onready var HexTile3D = preload("res://scenes/HexTile3D.tscn")
onready var tiles = $Tiles
onready var fps_label = $CanvasLayer/HBoxContainer/FPSLabel
onready var player_pos_label = $CanvasLayer/HBoxContainer/PlayerPos
onready var tile_pos_label = $CanvasLayer/HBoxContainer/TilePos
onready var player = $Player
var player_velocity = Vector3.ZERO
var player_speed = 10
var target_coordinate = Vector3.ZERO
var target_tile = null
var current_tile = null
func _ready():
print (hexgrid)
@ -24,6 +27,7 @@ func _ready():
var height = (sin(pos.y * 0.3) * sin(pos.y * 0.8) * 0.8 + cos ((pos.x) * 0.9) * 1.24) * 0.5 - 0.5
tile.transform.origin = Vector3(pos.x, height, pos.y)
tile.connect("tile_selected", self, "on_tile_selected")
tile.connect("tile_mouse_entered", self, "on_tile_hover")
tiles.add_child(tile)
var pos = hexgrid.get_hex_center3(Vector3(0, 0, 0))
@ -53,7 +57,12 @@ func _physics_process(delta):
func on_tile_selected(tile):
target_coordinate = Vector3(tile.transform.origin.x, 0, tile.transform.origin.z)
target_tile = tile
target_coordinate = Vector3(tile.transform.origin.x, tile.transform.origin.z, tile.transform.origin.z)
var position_error = target_coordinate - player.transform.origin
print ("clicked on tile " + str(tile.transform.origin) + " error: " + str(position_error))
func on_tile_hover(tile):
current_tile = tile
tile_pos_label.text = "Tile: " + str(current_tile.transform.origin)

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=7 format=2]
[gd_scene load_steps=8 format=2]
[ext_resource path="res://scenes/HexTile3D.tscn" type="PackedScene" id=1]
[ext_resource path="res://scenes/HexGrid3DTest.gd" type="Script" id=2]
@ -67,6 +67,11 @@ shader_param/time_factor = Vector2( 2, 3 )
shader_param/beer_factor = 5.0
shader_param/refraction = 0.05
[sub_resource type="CapsuleMesh" id=4]
radius = 0.2
mid_height = 0.5
radial_segments = 16
[node name="HexGrid3DTest" type="Spatial"]
script = ExtResource( 2 )
@ -75,12 +80,13 @@ visible = false
[node name="DirectionalLight" type="DirectionalLight" parent="."]
transform = Transform( 0.83729, 0.174005, 0.518332, -0.54676, 0.266466, 0.793757, 0, -0.948008, 0.318248, 0, 8.03448, 0 )
visible = false
shadow_enabled = true
shadow_contact = 1.565
directional_shadow_mode = 0
directional_shadow_depth_range = 1
[node name="Water" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.568377, 0.0356998 )
transform = Transform( 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0.568377, 0.0356998 )
mesh = SubResource( 1 )
material/0 = SubResource( 3 )
@ -112,11 +118,27 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="TilePos" type="Label" parent="CanvasLayer/HBoxContainer"]
margin_left = 92.0
margin_top = 13.0
margin_right = 138.0
margin_bottom = 27.0
text = "TilePos"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Tiles" type="Spatial" parent="."]
[node name="Player" type="Spatial" parent="."]
[node name="Camera" type="Camera" parent="Player"]
transform = Transform( 1, 0, 0, 0, 0.511698, 0.859165, 0, -0.859165, 0.511698, -1.05655, 3.66248, 10.3074 )
transform = Transform( 1, 0, 0, 0, 0.511698, 0.859165, 0, -0.859165, 0.511698, 0, 2.72642, 1.60656 )
current = true
fov = 60.0
script = ExtResource( 3 )
[node name="MeshInstance" type="MeshInstance" parent="Player"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0.5, 0 )
mesh = SubResource( 4 )
material/0 = null

View File

@ -4,6 +4,8 @@ onready var is_mouse_over = false
var old_material_override = Material.new()
signal tile_selected
signal tile_mouse_entered
func _on_Area_mouse_entered():
is_mouse_over = true
@ -13,6 +15,7 @@ func _on_Area_mouse_entered():
var cloned_material = material.duplicate()
cloned_material.albedo_color = Color (1, 0, 0)
self.material_override = cloned_material
emit_signal("tile_mouse_entered", self)
func _on_Area_mouse_exited():