dora/scenes/Goal.tscn

94 lines
2.9 KiB
Plaintext

[gd_scene load_steps=8 format=2]
[ext_resource path="res://models/flag.glb" type="PackedScene" id=1]
[ext_resource path="res://scenes/Goal.gd" type="Script" id=2]
[sub_resource type="BoxShape" id=1]
extents = Vector3( 0.584547, 2.22627, 0.659734 )
[sub_resource type="Shader" id=2]
code = "shader_type spatial;
uniform float PI = 3.1415;
// BILLBOARD_FIXED_Y
// from: https://github.com/godotengine/godot/blob/master/scene/resources/material.cpp#L552
void vertex() {
MODELVIEW_MATRIX = INV_CAMERA_MATRIX * mat4(CAMERA_MATRIX[0],WORLD_MATRIX[1],vec4(normalize(cross(CAMERA_MATRIX[0].xyz,WORLD_MATRIX[1].xyz)),0.0),WORLD_MATRIX[3]);
MODELVIEW_MATRIX = MODELVIEW_MATRIX * mat4(vec4(length(WORLD_MATRIX[0].xyz),0,0,0),vec4(0,1,0,0),vec4(0,0,length(WORLD_MATRIX[2].xyz),0),vec4(0,0,0,1));
}
float shine_ray(vec2 center_coords, float time, float offset, float speed) {
// atan() is in [-pi, pi[
float angle = atan(center_coords.x, center_coords.y);
bool on_ray = abs(angle - offset) < 0.1;
if (!on_ray) {
return 0.0;
}
float max_dist = 0.5; // maximum orthogonal distance from center in a [0,1] rectangle
float center_dist = sqrt(pow(center_coords.x, 2) + pow(center_coords.y, 2)) / max_dist;
float intensity = 1.0 + (sin(time * 3.0) / 3.0);
return clamp((1.0 - center_dist) * intensity, 0.0, 1.0);
}
void fragment() {
ALBEDO = vec3(1.0, 1.0, 0);
vec2 center_coords = vec2(UV.x - 0.5, UV.y - 0.5);
ALPHA = clamp(
shine_ray(center_coords, TIME, 0.5 * PI, 0.3) +
shine_ray(center_coords, TIME, (-1.0 + 0.5) * PI, 0.3) +
shine_ray(center_coords, TIME, 0.3 * PI, 0.5) +
shine_ray(center_coords, TIME, (-1.0 + 0.3) * PI, 0.4) +
shine_ray(center_coords, TIME, 0.8 * PI, 0.5) +
shine_ray(center_coords, TIME, (-1.0 + 0.8) * PI, 0.4),
0.0, 1.0);
}
"
[sub_resource type="ShaderMaterial" id=3]
shader = SubResource( 2 )
shader_param/PI = 3.1415
[sub_resource type="Gradient" id=4]
[sub_resource type="GradientTexture" id=5]
gradient = SubResource( 4 )
width = 2
[node name="Goal" instance=ExtResource( 1 )]
script = ExtResource( 2 )
[node name="Pole" parent="." index="0"]
editor/display_folded = true
[node name="Flag" parent="Pole" index="0"]
transform = Transform( 5, 0, 0, 0, -4.37114e-08, -0.5, 0, 1, -2.18557e-08, 4.02201, 0.453122, 0 )
[node name="Lamp" parent="." index="1"]
visible = false
[node name="Camera" parent="." index="2"]
editor/display_folded = true
visible = false
[node name="Area" type="Area" parent="." index="3"]
[node name="CollisionShape" type="CollisionShape" parent="Area" index="0"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.2251, 0 )
shape = SubResource( 1 )
[node name="ShineRays" type="Sprite3D" parent="." index="4"]
transform = Transform( 250, 0, 0, 0, 500, 0, 0, 0, 1, 0, 2.91655, 0 )
material_override = SubResource( 3 )
texture = SubResource( 5 )
[connection signal="body_entered" from="Area" to="." method="_on_Area_body_entered"]