This commit is contained in:
RealMelwei 2025-09-16 19:20:21 +02:00
commit a556897413
3 changed files with 15 additions and 18 deletions

View file

@ -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.);
}

View file

@ -1,25 +1,16 @@
[gd_scene load_steps=7 format=3 uid="uid://djawvtdwp423v"]
[gd_scene load_steps=3 format=3 uid="uid://djawvtdwp423v"]
[ext_resource type="Script" uid="uid://b2ji03ekijjnn" path="res://buildings/building.gd" id="1_5j34s"]
[ext_resource type="Texture2D" uid="uid://cy70quh6k3s1j" path="res://icon.svg" id="2_2yopf"]
[ext_resource type="Shader" uid="uid://c7gb1nqwvkr37" path="res://buildings/building.gdshader" id="2_f1gjg"]
[ext_resource type="Script" uid="uid://dj7d4d2xs3nci" path="res://buildings/building_mesh.gd" id="4_qnfc1"]
[ext_resource type="PackedScene" uid="uid://dpv1w56yr1xue" path="res://traps/morning_star.tscn" id="5_xr4t5"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_qnfc1"]
resource_local_to_scene = true
shader = ExtResource("2_f1gjg")
shader_parameter/ground_height = 3000.0
shader_parameter/cell_height = 300.0
shader_parameter/num_cells = 60
[node name="Building" type="Node2D"]
modulate = Color(0.352941, 0, 0.00784314, 0.00784314)
script = ExtResource("1_5j34s")
[node name="Sprite2D" type="Sprite2D" parent="."]
self_modulate = Color(0.176471, 0, 0.00392157, 0.00392157)
material = SubResource("ShaderMaterial_qnfc1")
scale = Vector2(15, 15)
scale = Vector2(250, 250)
texture = ExtResource("2_2yopf")
script = ExtResource("4_qnfc1")

View file

@ -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)