dora/scenes/Goal.tscn

99 lines
3.0 KiB
Plaintext
Raw Normal View History

2018-11-07 13:25:04 +01:00
[gd_scene load_steps=8 format=2]
2018-07-19 15:37:11 +02:00
2018-07-19 15:37:14 +02:00
[ext_resource path="res://models/flag.glb" type="PackedScene" id=1]
2018-08-08 14:23:35 +02:00
[ext_resource path="res://scenes/Goal.gd" type="Script" id=2]
2018-07-19 15:37:14 +02:00
[sub_resource type="BoxShape" id=1]
2018-07-19 15:37:11 +02:00
extents = Vector3( 0.584547, 2.22627, 0.659734 )
2018-07-19 15:37:11 +02:00
2018-08-27 14:04:36 +02:00
[sub_resource type="Shader" id=2]
code = "shader_type spatial;
2018-11-04 17:57:36 +01:00
uniform float PI = 3.1415;
2018-09-03 13:53:23 +02:00
// 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));
}
2018-11-04 17:57:36 +01:00
float shine_ray(vec2 center_coords, float time, float offset, float speed) {
// atan() is in [-pi, pi[
2018-11-04 18:14:21 +01:00
float angle = atan(center_coords.x, center_coords.y);
bool on_ray = abs(angle - offset) < 0.1;
2018-11-04 17:57:36 +01:00
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;
2018-11-04 18:14:21 +01:00
float intensity = 1.0 + (sin(time * 3.0) / 3.0);
2018-11-04 17:57:36 +01:00
return clamp((1.0 - center_dist) * intensity, 0.0, 1.0);
}
2018-09-27 15:00:23 +02:00
void fragment() {
2018-09-27 15:00:23 +02:00
ALBEDO = vec3(1.0, 1.0, 0);
vec2 center_coords = vec2(UV.x - 0.5, UV.y - 0.5);
2018-11-04 17:57:36 +01:00
ALPHA = clamp(
2018-11-04 18:14:21 +01:00
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),
2018-11-04 17:57:36 +01:00
0.0, 1.0);
}
"
2018-08-27 14:04:36 +02:00
[sub_resource type="ShaderMaterial" id=3]
2018-08-27 14:04:36 +02:00
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
2018-11-07 13:25:04 +01:00
[node name="Scene Root" instance=ExtResource( 1 )]
2018-07-19 15:37:14 +02:00
script = ExtResource( 2 )
2018-07-19 15:37:11 +02:00
[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 )
2018-08-08 13:50:23 +02:00
[node name="Flag.001" parent="Pole" index="1"]
transform = Transform( 5, 0, 0, 0, -4.37114e-08, -0.5, 0, 1, -2.18557e-08, 5.99137, 0.443566, -0.191931 )
[node name="Lamp" parent="." index="1"]
2018-07-19 15:37:14 +02:00
visible = false
[node name="Camera" parent="." index="2"]
editor/display_folded = true
2018-07-19 15:37:14 +02:00
visible = false
[node name="Area" type="Area" parent="." index="3"]
2018-07-19 15:37:14 +02:00
[node name="CollisionShape" type="CollisionShape" parent="Area" index="0"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.2251, 0 )
2018-07-19 15:37:14 +02:00
shape = SubResource( 1 )
2018-07-19 15:37:11 +02:00
2018-11-05 14:01:52 +01:00
[node name="ShineRays" type="Sprite3D" parent="." index="4"]
transform = Transform( 250, 0, 0, 0, 500, 0, 0, 0, 1, 0, 0, 0 )
2018-08-27 14:04:36 +02:00
material_override = SubResource( 3 )
texture = SubResource( 5 )
2018-11-04 17:57:36 +01:00
__meta__ = {
"_edit_lock_": true
}