diff --git a/addons/discord-rpc-gd/bin/windows/~discord_game_sdk_binding_debug.dll b/addons/discord-rpc-gd/bin/windows/~discord_game_sdk_binding_debug.dll deleted file mode 100644 index 2b52a76..0000000 Binary files a/addons/discord-rpc-gd/bin/windows/~discord_game_sdk_binding_debug.dll and /dev/null differ diff --git a/notes/shaders/base.md b/notes/shaders/base.md new file mode 100644 index 0000000..d2547b3 --- /dev/null +++ b/notes/shaders/base.md @@ -0,0 +1,28 @@ +# Read texture from image + +```glsl +uniform sampler2D TEXTURE; + +void freagment() { + vec4 my_texture = texture(TEXTURE, UV); + + ALBEDO = my_texture.rgb; +} +``` + +## Retain color in a next pass shader + +```glsl +uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest; + +void freagment() { + vec4 currentColor = textureLod(screen_texture, SCREEN_UV, 0.0); + ALBEDO = currentColor.rgb; +} + +``` + +## Smoothstep + +https://godotshaders.com/snippet/interpolation/ +https://thebookofshaders.com/glossary/?search=Smoothstep diff --git a/src/components/controls/MenuControls.gd b/src/components/controls/MenuControls.gd index 8732c3a..71d266a 100644 --- a/src/components/controls/MenuControls.gd +++ b/src/components/controls/MenuControls.gd @@ -48,7 +48,7 @@ func call_menu_action(): controlledNode, { items = LevelPatterns.get_menu_levels( - clampi(G.settings.MAX_LEVEL, 0, LevelPatterns.levels.size - 1) + clampi(G.settings.MAX_LEVEL, 0, LevelPatterns.levels.size() - 1) ) } ) diff --git a/src/models/icosahedron/Icosahedron.tscn b/src/models/icosahedron/Icosahedron.tscn index 0b32fc2..6482344 100644 --- a/src/models/icosahedron/Icosahedron.tscn +++ b/src/models/icosahedron/Icosahedron.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=19 format=3 uid="uid://c28nbcejwepp8"] +[gd_scene load_steps=20 format=3 uid="uid://c28nbcejwepp8"] [ext_resource type="ArrayMesh" uid="uid://dh3qpoqqgdct5" path="res://src/models/icosahedron/assets/icosahedron_Solid.res" id="1_kd7xu"] [ext_resource type="Script" path="res://src/models/icosahedron/components/Icosahedron.gd" id="1_w7qn7"] @@ -11,6 +11,7 @@ [ext_resource type="Shader" path="res://src/models/icosahedron/shaders/outline_v1.gdshader" id="5_ucsrc1"] [ext_resource type="Texture2D" uid="uid://bpr01fnnfusau" path="res://src/models/icosahedron/resources/edge_noise.res" id="6_ai0t7"] [ext_resource type="Script" path="res://src/models/icosahedron/components/Collider.gd" id="7_6oydw"] +[ext_resource type="Texture2D" uid="uid://cixi1rd0a28e4" path="res://assets/build/textures/texture-test-v1.png" id="8_h5ail"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_rdyh1"] render_priority = 0 @@ -34,9 +35,9 @@ shader_parameter/noise_pattern = ExtResource("6_ai0t7") render_priority = 2 next_pass = SubResource("ShaderMaterial_4yeiy") shader = ExtResource("5_ucsrc1") -shader_parameter/enable = true -shader_parameter/outline_thickness = 0.05 -shader_parameter/color = Color(0.358796, 0.73469, 0.907072, 1) +shader_parameter/enable = false +shader_parameter/outline_thickness = 0.11 +shader_parameter/color = Color(0, 1, 0, 1) [sub_resource type="ShaderMaterial" id="ShaderMaterial_c0lt3"] render_priority = 1 @@ -46,6 +47,14 @@ shader_parameter/cutplane = Vector4(-0.577, -0.577, 0.577, 0.794) shader_parameter/color = Color(0, 1, 0, 1) shader_parameter/enable = true shader_parameter/outline_thickness = 0.0 +shader_parameter/uv_offset_x = 0.17 +shader_parameter/uv_offset_y = 2.71 +shader_parameter/ratio = 0.075 +shader_parameter/power = 2.775 +shader_parameter/time_speed = 3.61 +shader_parameter/max_speed = 90.0 +shader_parameter/uv_rot = Vector2(0.11, 0.375) +shader_parameter/cutlane_tex = ExtResource("8_h5ail") [sub_resource type="ShaderMaterial" id="ShaderMaterial_bjqtf"] render_priority = 0 diff --git a/src/models/icosahedron/shaders/cutplane_effect_v2.gdshader b/src/models/icosahedron/shaders/cutplane_effect_v2.gdshader index 4a1cd9f..758a4d5 100644 --- a/src/models/icosahedron/shaders/cutplane_effect_v2.gdshader +++ b/src/models/icosahedron/shaders/cutplane_effect_v2.gdshader @@ -14,6 +14,35 @@ uniform float outline_thickness = 0.0; // how thick is the outline? varying vec3 ver; +uniform sampler2D cutlane_tex; + +uniform float uv_offset_x = 0.; +uniform float uv_offset_y = 0.; + +uniform float ratio : hint_range(0.0, 1.0) = 0.1; + +uniform float power = 3.0; + +uniform float time_speed = 10.0; + +uniform float max_speed = 90.0; + +uniform vec2 uv_rot; + +vec2 rotate(vec2 uv, vec2 pivot, float angle) { + // clang-format off + mat2 rotation = mat2( + vec2(sin(angle), -cos(angle)), + vec2(cos(angle), sin(angle)), + ); + // clang-format on + + uv -= pivot; + uv = uv * rotation; + uv += pivot; + return uv; +} + void vertex() { if (enable) { // VERTEX += NORMAL * outline_thickness; // apply the outlines thickness @@ -22,6 +51,18 @@ void vertex() { } void fragment() { + vec2 uv = UV; + + uv *= 2.0; + uv -= vec2(1.0); + + float len = length(uv); + + vec2 modified_uv = rotate(UV, uv_rot, TIME * time_speed); + float t = sin(TIME); + modified_uv.x += uv_offset_x; + modified_uv.y += uv_offset_y; + vec4 aaa = texture(cutlane_tex, modified_uv * 5.); if (enable) { float dist = cutplane_dist(cutplane, ver); bool a = dist > 0.; @@ -33,7 +74,9 @@ void fragment() { // ALBEDO = a ? mix(vec3(1. - smoothstep(0.51, 0.9, r_sq) * 1.), color, // 0.01) : vec3(0.); ALBEDO = a ? vec3(smoothstep(0.58, 0.9, r_sq)) : // vec3(0.); - ALBEDO = color; + // vec2 rotated_uv = rotate(UV, vec2(0.5), TIME); + // ALBEDO = vec3(rotated_uv.g); + ALBEDO = color * (1. - vec3(aaa.a)); ALPHA = a ? 0.7 : 0.; } else { diff --git a/src/models/icosahedron/shaders/outline_v1.gdshader b/src/models/icosahedron/shaders/outline_v1.gdshader index 737b6f4..813ee5e 100644 --- a/src/models/icosahedron/shaders/outline_v1.gdshader +++ b/src/models/icosahedron/shaders/outline_v1.gdshader @@ -1,5 +1,5 @@ shader_type spatial; -render_mode unshaded, cull_front; +render_mode cull_front, unshaded; uniform bool enable = false; @@ -8,8 +8,8 @@ uniform sampler2D screen_texture : hint_screen_texture, filter_nearest; // outline costumization -uniform float outline_thickness = 0.05; -uniform vec4 color : source_color = vec4(0.0); +uniform float outline_thickness = 0.11; +uniform vec4 color : source_color = vec4(0., 1., 0., 1.); // pulse customization uniform float pulse_speed = 12.; @@ -17,6 +17,9 @@ uniform float pulse_amplitude = 2.; varying vec3 ver; +uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest; +uniform sampler2D outline_tex; + void vertex() { if (enable) { float t = sin(TIME * pulse_speed) / pulse_amplitude + 1.;