diff --git a/main.tscn b/main.tscn index d3e8d88..8debcf1 100644 --- a/main.tscn +++ b/main.tscn @@ -22,14 +22,14 @@ shader_param/num_receptors = 8 shader_param/receptor_offset = 0.392699 shader_param/line_color = Color( 0, 0, 1, 1 ) shader_param/dot_color = Color( 0, 0, 1, 1 ) -shader_param/shadow_color = Color( 0, 0, 0, 1 ) +shader_param/shadow_color = Color( 1, 1, 1, 0.568627 ) shader_param/line_thickness = 0.00434783 shader_param/dot_radius = 0.026087 shader_param/shadow_thickness = 0.0173913 -shader_param/shadow_thickness_taper = -0.75 shader_param/px = 0.00108696 +shader_param/px2 = 0.00217391 -[sub_resource type="ArrayMesh" id=2] +[sub_resource type="ArrayMesh" id=6] surfaces/0 = { "aabb": AABB( -481.834, -481.834, 0, 963.667, 963.667, 0 ), "array_data": PoolByteArray( 0, 0, 220, 67, 0, 0, 0, 0, 166, 59, 0, 0, 177, 234, 240, 67, 0, 0, 0, 0, 48, 60, 0, 0, 95, 168, 216, 67, 118, 207, 152, 66, 137, 59, 80, 49, 183, 65, 237, 67, 202, 86, 167, 66, 32, 60, 210, 49, 125, 187, 206, 67, 38, 125, 22, 67, 48, 59, 60, 53, 64, 99, 226, 67, 249, 203, 36, 67, 223, 59, 187, 53, 141, 134, 190, 67, 0, 0, 92, 67, 160, 58, 166, 55, 217, 163, 208, 67, 177, 234, 112, 67, 65, 59, 48, 56, 159, 135, 168, 67, 204, 105, 141, 67, 220, 57, 235, 56, 142, 141, 184, 67, 186, 219, 154, 67, 107, 58, 98, 57, 204, 105, 141, 67, 159, 135, 168, 67, 235, 56, 220, 57, 186, 219, 154, 67, 142, 141, 184, 67, 98, 57, 107, 58, 0, 0, 92, 67, 141, 134, 190, 67, 166, 55, 160, 58, 177, 234, 112, 67, 217, 163, 208, 67, 48, 56, 65, 59, 38, 125, 22, 67, 125, 187, 206, 67, 60, 53, 48, 59, 249, 203, 36, 67, 64, 99, 226, 67, 187, 53, 223, 59, 118, 207, 152, 66, 95, 168, 216, 67, 80, 49, 137, 59, 202, 86, 167, 66, 183, 65, 237, 67, 210, 49, 32, 60, 141, 172, 242, 40, 0, 0, 220, 67, 0, 0, 166, 59, 143, 223, 4, 41, 177, 234, 240, 67, 0, 0, 48, 60, 118, 207, 152, 194, 95, 168, 216, 67, 80, 177, 137, 59, 202, 86, 167, 194, 183, 65, 237, 67, 210, 177, 32, 60, 38, 125, 22, 195, 125, 187, 206, 67, 60, 181, 48, 59, 249, 203, 36, 195, 64, 99, 226, 67, 187, 181, 223, 59, 0, 0, 92, 195, 141, 134, 190, 67, 166, 183, 160, 58, 177, 234, 112, 195, 217, 163, 208, 67, 48, 184, 65, 59, 204, 105, 141, 195, 159, 135, 168, 67, 235, 184, 220, 57, 186, 219, 154, 195, 142, 141, 184, 67, 98, 185, 107, 58, 159, 135, 168, 195, 204, 105, 141, 67, 220, 185, 235, 56, 142, 141, 184, 195, 186, 219, 154, 67, 107, 186, 98, 57, 141, 134, 190, 195, 0, 0, 92, 67, 160, 186, 166, 55, 217, 163, 208, 195, 177, 234, 112, 67, 65, 187, 48, 56, 125, 187, 206, 195, 38, 125, 22, 67, 48, 187, 60, 53, 64, 99, 226, 195, 249, 203, 36, 67, 223, 187, 187, 53, 95, 168, 216, 195, 118, 207, 152, 66, 137, 187, 80, 49, 183, 65, 237, 195, 202, 86, 167, 66, 32, 188, 210, 49, 0, 0, 220, 195, 141, 172, 114, 41, 166, 187, 0, 0, 177, 234, 240, 195, 143, 223, 132, 41, 48, 188, 0, 0, 95, 168, 216, 195, 118, 207, 152, 194, 137, 187, 80, 177, 183, 65, 237, 195, 202, 86, 167, 194, 32, 188, 210, 177, 125, 187, 206, 195, 38, 125, 22, 195, 48, 187, 60, 181, 64, 99, 226, 195, 249, 203, 36, 195, 223, 187, 187, 181, 141, 134, 190, 195, 0, 0, 92, 195, 160, 186, 166, 183, 217, 163, 208, 195, 177, 234, 112, 195, 65, 187, 48, 184, 159, 135, 168, 195, 204, 105, 141, 195, 220, 185, 235, 184, 142, 141, 184, 195, 186, 219, 154, 195, 107, 186, 98, 185, 204, 105, 141, 195, 159, 135, 168, 195, 235, 184, 220, 185, 186, 219, 154, 195, 142, 141, 184, 195, 98, 185, 107, 186, 0, 0, 92, 195, 141, 134, 190, 195, 166, 183, 160, 186, 177, 234, 112, 195, 217, 163, 208, 195, 48, 184, 65, 187, 38, 125, 22, 195, 125, 187, 206, 195, 60, 181, 48, 187, 249, 203, 36, 195, 64, 99, 226, 195, 187, 181, 223, 187, 118, 207, 152, 194, 95, 168, 216, 195, 80, 177, 137, 187, 202, 86, 167, 194, 183, 65, 237, 195, 210, 177, 32, 188, 106, 1, 182, 169, 0, 0, 220, 195, 0, 0, 166, 187, 87, 79, 199, 169, 177, 234, 240, 195, 0, 0, 48, 188, 118, 207, 152, 66, 95, 168, 216, 195, 80, 49, 137, 187, 202, 86, 167, 66, 183, 65, 237, 195, 210, 49, 32, 188, 38, 125, 22, 67, 125, 187, 206, 195, 60, 53, 48, 187, 249, 203, 36, 67, 64, 99, 226, 195, 187, 53, 223, 187, 0, 0, 92, 67, 141, 134, 190, 195, 166, 55, 160, 186, 177, 234, 112, 67, 217, 163, 208, 195, 48, 56, 65, 187, 204, 105, 141, 67, 159, 135, 168, 195, 235, 56, 220, 185, 186, 219, 154, 67, 142, 141, 184, 195, 98, 57, 107, 186, 159, 135, 168, 67, 204, 105, 141, 195, 220, 57, 235, 184, 142, 141, 184, 67, 186, 219, 154, 195, 107, 58, 98, 185, 141, 134, 190, 67, 0, 0, 92, 195, 160, 58, 166, 183, 217, 163, 208, 67, 177, 234, 112, 195, 65, 59, 48, 184, 125, 187, 206, 67, 38, 125, 22, 195, 48, 59, 60, 181, 64, 99, 226, 67, 249, 203, 36, 195, 223, 59, 187, 181, 95, 168, 216, 67, 118, 207, 152, 194, 137, 59, 80, 177, 183, 65, 237, 67, 202, 86, 167, 194, 32, 60, 210, 177, 0, 0, 220, 67, 0, 0, 0, 0, 166, 59, 0, 0, 177, 234, 240, 67, 0, 0, 0, 0, 48, 60, 0, 0 ), @@ -99,9 +99,9 @@ script = ExtResource( 3 ) [node name="Receptors" type="MeshInstance2D" parent="."] material = SubResource( 1 ) -position = Vector2( 0, 1080 ) -mesh = SubResource( 2 ) +mesh = SubResource( 6 ) script = ExtResource( 5 ) +shadow_color = Color( 1, 1, 1, 0.568627 ) [node name="Tween" type="Tween" parent="Receptors"] @@ -109,15 +109,14 @@ script = ExtResource( 5 ) script = ExtResource( 6 ) [node name="Viewport" type="Viewport" parent="NoteHandler"] -size = Vector2( 540, 540 ) +size = Vector2( 1080, 1080 ) transparent_bg = true usage = 1 render_target_v_flip = true script = ExtResource( 7 ) [node name="Center" type="Node2D" parent="NoteHandler/Viewport"] -position = Vector2( 270, 270 ) -scale = Vector2( 0.5, 0.5 ) +position = Vector2( 540, 540 ) [node name="SlideTrailHandler" type="Node2D" parent="NoteHandler/Viewport/Center"] diff --git a/scripts/Receptors.gd b/scripts/Receptors.gd index 254f040..7872d73 100644 --- a/scripts/Receptors.gd +++ b/scripts/Receptors.gd @@ -6,7 +6,7 @@ export var receptor_px := 24 # Diameter export var shadow_px := 8 # Outer edge, analogous to radius export var line_color := Color.blue export var dot_color := Color.blue -export var shadow_color := Color.black +export var shadow_color := Color(0.0, 0.0, 0.0, 0.57) var center := Vector2(0.0, 0.0) var ring_vertex_count := 36 @@ -110,7 +110,7 @@ func update_ring_mesh(): func _draw(): # draw_old(true, true) - draw_tris() +# draw_tris() # var mesh_v = ring_vertex_count # var ring_thickness = receptor_px + shadow_px*2 # var estimated_area = circumscribe_polygon_area(GameTheme.receptor_ring_radius+ring_thickness*0.5, mesh_v) - inscribe_polygon_area(GameTheme.receptor_ring_radius-ring_thickness*0.5, mesh_v) @@ -121,7 +121,7 @@ func _draw(): material.set_shader_param("dot_radius", 0.5*receptor_px/GameTheme.receptor_ring_radius) material.set_shader_param("line_thickness", 0.5*ring_px/GameTheme.receptor_ring_radius) material.set_shader_param("shadow_thickness", shadow_px/GameTheme.receptor_ring_radius) - material.set_shader_param("shadow_thickness_taper", -0.75) +# material.set_shader_param("shadow_thickness_taper", -0.75) material.set_shader_param("px", 0.5/GameTheme.receptor_ring_radius) material.set_shader_param("px2", 1.0/GameTheme.receptor_ring_radius) material.set_shader_param("line_color", line_color) diff --git a/shaders/receptors.shader b/shaders/receptors.shader index 848536f..16b7175 100644 --- a/shaders/receptors.shader +++ b/shaders/receptors.shader @@ -4,16 +4,17 @@ render_mode blend_premul_alpha; const float TAU = 6.283185307; const float PI = 3.1415926536; +const vec4 dbg_color = vec4(1.0, 0.0, 0.0, 1.0); + uniform int num_receptors = 8; uniform float receptor_offset = 0.0; uniform vec4 line_color : hint_color = vec4(0.0, 0.0, 1.0, 1.0); uniform vec4 dot_color : hint_color = vec4(0.0, 0.0, 1.0, 1.0); -uniform vec4 shadow_color : hint_color = vec4(0.0, 0.0, 0.0, 1.0); +uniform vec4 shadow_color : hint_color = vec4(0.0, 0.0, 0.0, 0.57); //uniform float bps = 1.0; uniform float line_thickness = 0.006; uniform float dot_radius = 0.033; uniform float shadow_thickness = 0.01; -uniform float shadow_thickness_taper = 0.33; uniform float px = 0.002; // Represents 1px in UV space, for AA purposes uniform float px2 = 0.004; // Represents 2px in UV space, for AA purposes @@ -28,11 +29,8 @@ float angle_diff(float a, float b) { vec2 line_alpha(float dist) { // Returns [line, shadow] - vec2 output = vec2(0.0); float d = abs(dist - 1.0) - line_thickness; - output.x = clamp(-d/px - 1.0, 0.0, 1.0); - output.y = clamp(1.0 - (d/shadow_thickness - shadow_thickness_taper)/(1.0 - shadow_thickness_taper), 0.0, 1.0); - return output; + return clamp(vec2(-1.0 - d/px, 1.0 - d/shadow_thickness), 0.0, 1.0); } vec2 dot_alpha(vec2 uv) { @@ -44,13 +42,11 @@ vec2 dot_alpha(vec2 uv) { // Check for dot distance vec2 dot_uv = vec2(cos(rads), -sin(rads)); float d = distance(uv, dot_uv) - dot_radius; - output.x = clamp(-d/px - 1.0, output.x, 1.0); - output.y = clamp(1.0 - (d/shadow_thickness - shadow_thickness_taper)/(1.0 - shadow_thickness_taper), output.y, 1.0); + output = clamp(vec2(-1.0 - d/px, 1.0 - d/shadow_thickness), output, vec2(1.0)); } return output; } -const vec4 dbg_color = vec4(1.0, 0.0, 0.0, 1.0); void fragment() { if (COLOR.rgba != dbg_color) { // Can't use return in fragment() function COLOR.rgba = vec4(0.0); @@ -60,11 +56,12 @@ void fragment() { lds_alpha.yz = dot_alpha(UV); lds_alpha.xz = clamp(line_alpha(dist), vec2(0.0, lds_alpha.z), vec2(1.0-lds_alpha.y)); -// lds_alpha.x = clamp(line_alpha(dist).x, 0.0, 1.0-lds_alpha.y); lds_alpha = clamp(lds_alpha, 0.0, 1.0); + lds_alpha.z *= 1.0-min(dot(lds_alpha.xy, vec2(1.0)), 1.0); + lds_alpha.z *= shadow_color.a; - COLOR.rgb = (dot_color.rgb*lds_alpha.y) + (line_color.rgb*lds_alpha.x) + (shadow_color.rgb*lds_alpha.z); + COLOR.rgb = (line_color.rgb*lds_alpha.x) + (dot_color.rgb*lds_alpha.y) + (shadow_color.rgb*lds_alpha.z); COLOR.a = lds_alpha.y + lds_alpha.x*(1.0-lds_alpha.y); - COLOR.a = COLOR.a + lds_alpha.z*(1.0-COLOR.a); - COLOR.a = clamp(COLOR.a, 0.0, 1.0); } + COLOR.a += lds_alpha.z*(1.0-COLOR.a); + COLOR = clamp(COLOR, 0.0, 1.0); } } \ No newline at end of file