new shaders

This commit is contained in:
Luca 2025-01-07 17:11:41 +01:00
parent c4115b3569
commit 7ada6a0f2c
24 changed files with 567 additions and 124 deletions

View file

@ -0,0 +1,32 @@
shader_type spatial;
uniform vec2 resolution = vec2(600.0, 400.0);
uniform vec3 line_color: source_color = vec3(0.2, 0.6, 0.2);
uniform float line_thickness: hint_range(0.01, 1.0, 0.01) = 0.05;
uniform float speed = 0.5;
uniform float amp_coef = 0.1;
uniform float freq_coef = 0.5;
uniform float iterations: hint_range(1.0, 20.0, 1.0) = 5.0;
uniform float brightness: hint_range(0.1, 20.0, 0.1) = 0.5;
vec3 draw_line(vec2 uv, vec3 color, float shift, float freq) {
uv.y += (1.0 - smoothstep(0.0, 1.0, abs(uv.x))) * sin(uv.x + shift * freq) * amp_coef * sin(uv.x + shift);
return (1.0 - smoothstep(0.0, line_thickness * (smoothstep(-0.2, 0.9, abs(uv.x))), abs(uv.y))) * color;
}
void fragment() {
// Move the center of the uv to the center of the Mesh
vec2 uv = UV - 0.5;
// Apply the aspect ratio
uv.x *= resolution.x / resolution.y;
float shift = TIME * speed;
vec3 color = vec3(0.0);
for (float i = 0.0; i < iterations; i += 1.0) {
color += draw_line(uv, line_color, shift + i * 0.4, 1.0 + freq_coef);
}
ALBEDO = color * brightness;
}

View file

@ -0,0 +1,23 @@
[gd_scene load_steps=4 format=3 uid="uid://omdbnbi707f8"]
[ext_resource type="Shader" path="res://shaders/016_line/line.gdshader" id="1_wsdq7"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_jjsaw"]
render_priority = 0
shader = ExtResource("1_wsdq7")
shader_parameter/resolution = Vector2(600, 400)
shader_parameter/line_color = Color(0.860779, 0.546136, 0.207257, 1)
shader_parameter/line_thickness = 0.02
shader_parameter/speed = 0.065
shader_parameter/amp_coef = 0.26
shader_parameter/freq_coef = 4.175
shader_parameter/iterations = 20.0
shader_parameter/brightness = 1.0
[sub_resource type="QuadMesh" id="QuadMesh_ldsi7"]
material = SubResource("ShaderMaterial_jjsaw")
[node name="Line" type="Node3D"]
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
mesh = SubResource("QuadMesh_ldsi7")