diff --git a/NoteHandler.gd b/NoteHandler.gd index 5c86565..2760684 100644 --- a/NoteHandler.gd +++ b/NoteHandler.gd @@ -115,7 +115,7 @@ func make_slide_trail_mesh(note: Dictionary) -> ArrayMesh: var vertices := PoolVector2Array() var uvs := PoolVector2Array() var colors := PoolColorArray() - var size := theme.sprite_size2*SQRT2 + var size := theme.sprite_size2 # First we need to determine how many arrows to leave. # Chord length is 2r*sin(theta/2) # Arc length is r*theta (in rads) @@ -126,7 +126,7 @@ func make_slide_trail_mesh(note: Dictionary) -> ArrayMesh: var trail_length: int match note.slide_type: Note.SlideType.CHORD: - unit_length = 2*abs(sin(RADIAL_COL_ANGLES[note.column_release] - RADIAL_COL_ANGLES[note.column])) + unit_length = 2*abs(sin((RADIAL_COL_ANGLES[note.column_release] - RADIAL_COL_ANGLES[note.column])/2)) Note.SlideType.ARC_CW: unit_length = fposmod(RADIAL_COL_ANGLES[note.column_release] - RADIAL_COL_ANGLES[note.column], TAU) Note.SlideType.ARC_ACW: @@ -136,21 +136,23 @@ func make_slide_trail_mesh(note: Dictionary) -> ArrayMesh: # uvs.resize(3*trail_length) colors.resize(3*trail_length) for i in trail_length: - uvs.append_array(UV_ARRAY_SLIDE_ARROW if i%2 else UV_ARRAY_SLIDE_ARROW2) + uvs.append_array(UV_ARRAY_SLIDE_ARROW if i%3 else UV_ARRAY_SLIDE_ARROW2) for j in 3: # uvs[i*3+j] = UV_ARRAY_SLIDE_ARROW[j] if i%2 else UV_ARRAY_SLIDE_ARROW2[j] - colors[i*3+j] = Color(1.0, 1.0, 1.0, 1.0+float(i)) + colors[i*3+j] = Color(0.67, 0.67, 1.0, 1.0+float(i)) match note.slide_type: Note.SlideType.CHORD: - var angle : float = RADIAL_UNIT_VECTORS[note.column].angle_to_point(RADIAL_UNIT_VECTORS[note.column_release]) +# var angle : float = RADIAL_UNIT_VECTORS[note.column].angle_to_point(RADIAL_UNIT_VECTORS[note.column_release]) var start : Vector2 = RADIAL_UNIT_VECTORS[note.column] * theme.receptor_ring_radius var end : Vector2 = RADIAL_UNIT_VECTORS[note.column_release] * theme.receptor_ring_radius +# var angle : float = start.angle_to_point(end) # seems to be out by 180° for no good reason + var angle : float = (end-start).angle() var uv1o : Vector2 = polar2cartesian(size, angle) var uv2o : Vector2 = polar2cartesian(size, angle+PI/2.0) var uv3o : Vector2 = polar2cartesian(size, angle-PI/2.0) for i in trail_length: - var offset : Vector2 = lerp(start, end, (i+1)/float(trail_length)) + var offset : Vector2 = lerp(start, end, i/float(trail_length)) vertices[i*3] = offset + uv1o vertices[i*3+1] = offset + uv2o vertices[i*3+2] = offset + uv3o @@ -420,8 +422,8 @@ func _process(delta): if active_notes[-1].type == Note.NOTE_SLIDE: slide_trail_mesh_instances.push_back(MeshInstance2D.new()) slide_trail_mesh_instances[-1].set_mesh(slide_trail_meshes.pop_front()) - slide_trail_mesh_instances[-1].set_position(screen_center) - add_child(slide_trail_mesh_instances[-1]) +# slide_trail_mesh_instances[-1].set_position(screen_center) + $SlideTrailHandler.add_child(slide_trail_mesh_instances[-1]) slide_trail_mesh_instances[-1].set_material(slide_trail_shadermaterial) slide_trail_mesh_instances[-1].material.set_shader_param("trail_progress", 0.0) slide_trail_mesh_instances[-1].set_texture(tex_slide_arrow) diff --git a/main.tscn b/main.tscn index 5317290..583d73e 100644 --- a/main.tscn +++ b/main.tscn @@ -54,6 +54,9 @@ script = ExtResource( 4 ) [node name="NoteHandler" type="Node2D" parent="."] script = ExtResource( 5 ) +[node name="SlideTrailHandler" type="Node2D" parent="NoteHandler"] +position = Vector2( 960, 540 ) + [node name="notelines" type="MeshInstance2D" parent="NoteHandler"] material = SubResource( 1 ) diff --git a/shaders/slidetrail.shader b/shaders/slidetrail.shader index e9f975b..b009394 100644 --- a/shaders/slidetrail.shader +++ b/shaders/slidetrail.shader @@ -2,6 +2,7 @@ shader_type canvas_item; //render_mode blend_premul_alpha; uniform float trail_progress = 0.0; +uniform float base_alpha = 0.88; uniform float bps = 1.0; // The idea here is to create a static mesh for each slide trail at scorefile load. @@ -15,6 +16,8 @@ void vertex() { void fragment() { vec4 sample = texture(TEXTURE, UV); - COLOR.rgb = sample.rgb; - COLOR.a *= sample.a; + COLOR.rgb *= sample.r; + COLOR.rgb = mix(COLOR.rgb, vec3(1.0), (sample.g+sample.b)/2.0); +// if (sample.rgb == vec3(1.0)) COLOR.rgb = vec3(1.0); + COLOR.a *= sample.a * base_alpha; } \ No newline at end of file diff --git a/shaders/slidetrail.tres b/shaders/slidetrail.tres index b57cfcb..2a28659 100644 --- a/shaders/slidetrail.tres +++ b/shaders/slidetrail.tres @@ -5,4 +5,5 @@ [resource] shader = ExtResource( 1 ) shader_param/trail_progress = 0.0 +shader_param/base_alpha = 0.88 shader_param/bps = 1.0