Slide trails render correctly.
Still need to modulate their alpha based on time and position.
This commit is contained in:
parent
27964ab955
commit
1d6aa6472f
|
@ -115,7 +115,7 @@ func make_slide_trail_mesh(note: Dictionary) -> ArrayMesh:
|
||||||
var vertices := PoolVector2Array()
|
var vertices := PoolVector2Array()
|
||||||
var uvs := PoolVector2Array()
|
var uvs := PoolVector2Array()
|
||||||
var colors := PoolColorArray()
|
var colors := PoolColorArray()
|
||||||
var size := theme.sprite_size2*SQRT2
|
var size := theme.sprite_size2
|
||||||
# First we need to determine how many arrows to leave.
|
# First we need to determine how many arrows to leave.
|
||||||
# Chord length is 2r*sin(theta/2)
|
# Chord length is 2r*sin(theta/2)
|
||||||
# Arc length is r*theta (in rads)
|
# Arc length is r*theta (in rads)
|
||||||
|
@ -126,7 +126,7 @@ func make_slide_trail_mesh(note: Dictionary) -> ArrayMesh:
|
||||||
var trail_length: int
|
var trail_length: int
|
||||||
match note.slide_type:
|
match note.slide_type:
|
||||||
Note.SlideType.CHORD:
|
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:
|
Note.SlideType.ARC_CW:
|
||||||
unit_length = fposmod(RADIAL_COL_ANGLES[note.column_release] - RADIAL_COL_ANGLES[note.column], TAU)
|
unit_length = fposmod(RADIAL_COL_ANGLES[note.column_release] - RADIAL_COL_ANGLES[note.column], TAU)
|
||||||
Note.SlideType.ARC_ACW:
|
Note.SlideType.ARC_ACW:
|
||||||
|
@ -136,21 +136,23 @@ func make_slide_trail_mesh(note: Dictionary) -> ArrayMesh:
|
||||||
# uvs.resize(3*trail_length)
|
# uvs.resize(3*trail_length)
|
||||||
colors.resize(3*trail_length)
|
colors.resize(3*trail_length)
|
||||||
for i in 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:
|
for j in 3:
|
||||||
# uvs[i*3+j] = UV_ARRAY_SLIDE_ARROW[j] if i%2 else UV_ARRAY_SLIDE_ARROW2[j]
|
# 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:
|
match note.slide_type:
|
||||||
Note.SlideType.CHORD:
|
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 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 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 uv1o : Vector2 = polar2cartesian(size, angle)
|
||||||
var uv2o : Vector2 = polar2cartesian(size, angle+PI/2.0)
|
var uv2o : Vector2 = polar2cartesian(size, angle+PI/2.0)
|
||||||
var uv3o : Vector2 = polar2cartesian(size, angle-PI/2.0)
|
var uv3o : Vector2 = polar2cartesian(size, angle-PI/2.0)
|
||||||
for i in trail_length:
|
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] = offset + uv1o
|
||||||
vertices[i*3+1] = offset + uv2o
|
vertices[i*3+1] = offset + uv2o
|
||||||
vertices[i*3+2] = offset + uv3o
|
vertices[i*3+2] = offset + uv3o
|
||||||
|
@ -420,8 +422,8 @@ func _process(delta):
|
||||||
if active_notes[-1].type == Note.NOTE_SLIDE:
|
if active_notes[-1].type == Note.NOTE_SLIDE:
|
||||||
slide_trail_mesh_instances.push_back(MeshInstance2D.new())
|
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_mesh(slide_trail_meshes.pop_front())
|
||||||
slide_trail_mesh_instances[-1].set_position(screen_center)
|
# slide_trail_mesh_instances[-1].set_position(screen_center)
|
||||||
add_child(slide_trail_mesh_instances[-1])
|
$SlideTrailHandler.add_child(slide_trail_mesh_instances[-1])
|
||||||
slide_trail_mesh_instances[-1].set_material(slide_trail_shadermaterial)
|
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].material.set_shader_param("trail_progress", 0.0)
|
||||||
slide_trail_mesh_instances[-1].set_texture(tex_slide_arrow)
|
slide_trail_mesh_instances[-1].set_texture(tex_slide_arrow)
|
||||||
|
|
|
@ -54,6 +54,9 @@ script = ExtResource( 4 )
|
||||||
[node name="NoteHandler" type="Node2D" parent="."]
|
[node name="NoteHandler" type="Node2D" parent="."]
|
||||||
script = ExtResource( 5 )
|
script = ExtResource( 5 )
|
||||||
|
|
||||||
|
[node name="SlideTrailHandler" type="Node2D" parent="NoteHandler"]
|
||||||
|
position = Vector2( 960, 540 )
|
||||||
|
|
||||||
[node name="notelines" type="MeshInstance2D" parent="NoteHandler"]
|
[node name="notelines" type="MeshInstance2D" parent="NoteHandler"]
|
||||||
material = SubResource( 1 )
|
material = SubResource( 1 )
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ shader_type canvas_item;
|
||||||
//render_mode blend_premul_alpha;
|
//render_mode blend_premul_alpha;
|
||||||
|
|
||||||
uniform float trail_progress = 0.0;
|
uniform float trail_progress = 0.0;
|
||||||
|
uniform float base_alpha = 0.88;
|
||||||
uniform float bps = 1.0;
|
uniform float bps = 1.0;
|
||||||
|
|
||||||
// The idea here is to create a static mesh for each slide trail at scorefile load.
|
// The idea here is to create a static mesh for each slide trail at scorefile load.
|
||||||
|
@ -15,6 +16,8 @@ void vertex() {
|
||||||
|
|
||||||
void fragment() {
|
void fragment() {
|
||||||
vec4 sample = texture(TEXTURE, UV);
|
vec4 sample = texture(TEXTURE, UV);
|
||||||
COLOR.rgb = sample.rgb;
|
COLOR.rgb *= sample.r;
|
||||||
COLOR.a *= sample.a;
|
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;
|
||||||
}
|
}
|
|
@ -5,4 +5,5 @@
|
||||||
[resource]
|
[resource]
|
||||||
shader = ExtResource( 1 )
|
shader = ExtResource( 1 )
|
||||||
shader_param/trail_progress = 0.0
|
shader_param/trail_progress = 0.0
|
||||||
|
shader_param/base_alpha = 0.88
|
||||||
shader_param/bps = 1.0
|
shader_param/bps = 1.0
|
||||||
|
|
Loading…
Reference in New Issue