From 00e2793a53dbcc564d5c552344a34fe241d5a633 Mon Sep 17 00:00:00 2001 From: Florian Date: Tue, 16 Sep 2025 18:11:54 +0200 Subject: [PATCH] Made rendering buildings more efficient --- buildings/building.gdshader | 16 +++++++++++----- buildings/building.tscn | 4 ++-- buildings/building_mesh.gd | 2 +- player/player_walk.png.import | 6 ++++++ 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/buildings/building.gdshader b/buildings/building.gdshader index 2c950f1..81934b9 100644 --- a/buildings/building.gdshader +++ b/buildings/building.gdshader @@ -11,11 +11,16 @@ varying vec2 world_position; void vertex() { + location = ivec2(128. * COLOR.xy); + dimension = ivec2(128. * COLOR.zw); + + vec2 myloc = vec2(location) + UV * (vec2(dimension) + vec2(0., .5)); + float angle = float(myloc.x) * TAU / 60.; + float height = float(myloc.y) * cell_height + ground_height; + VERTEX = vec2(cos(angle), sin(angle)) * height; + //VERTEX = myloc; + VERTEX = (inverse(MODEL_MATRIX) * vec4(VERTEX, 0, 1)).xy; world_position = (MODEL_MATRIX * vec4(VERTEX, 0.0, 1.0)).xy; - location = ivec2(256. * COLOR.xy); - dimension = ivec2(256. * COLOR.zw); - //location = ivec2(45, 1); - //dimension = ivec2(1, 1); } void fragment() { @@ -29,7 +34,8 @@ void fragment() { discard; } COLOR = texture(TEXTURE, vec2(sample_x, sample_y)); - //COLOR = vec4(ivec4(location, dimension)); + //COLOR = vec4(ivec4(location, dimension))/16.; + //COLOR = vec4(1., 1., 1., 1.); } diff --git a/buildings/building.tscn b/buildings/building.tscn index d388b25..15bbbdc 100644 --- a/buildings/building.tscn +++ b/buildings/building.tscn @@ -13,11 +13,11 @@ shader_parameter/cell_height = 300.0 shader_parameter/num_cells = 60 [node name="Building" type="Node2D"] +modulate = Color(0.3529412, 0, 0.007843138, 0.007843138) script = ExtResource("1_5j34s") [node name="Sprite2D" type="Sprite2D" parent="."] -self_modulate = Color(0.1764706, 0, 0.003921569, 0.003921569) material = SubResource("ShaderMaterial_qnfc1") -scale = Vector2(15, 15) +scale = Vector2(250, 250) texture = ExtResource("2_2yopf") script = ExtResource("4_qnfc1") diff --git a/buildings/building_mesh.gd b/buildings/building_mesh.gd index f2b5c32..f7ddabf 100644 --- a/buildings/building_mesh.gd +++ b/buildings/building_mesh.gd @@ -3,4 +3,4 @@ extends Sprite2D func _ready() -> void: var location = Vector2i(get_parent().location) var dimension = Vector2i(get_parent().dimension) - self_modulate = Color8(location.x, location.y, dimension.x, dimension.y) + self_modulate = 2 * Color8(location.x, location.y, dimension.x, dimension.y) diff --git a/player/player_walk.png.import b/player/player_walk.png.import index 418970e..ab112ae 100644 --- a/player/player_walk.png.import +++ b/player/player_walk.png.import @@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/player_walk.png-59515d82f701e5545419ecd7b3460 compress/mode=0 compress/high_quality=false compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 @@ -25,6 +27,10 @@ mipmaps/generate=false mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 process/fix_alpha_border=true process/premult_alpha=false process/normal_map_invert_y=false