-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CrossProductDemo.tscn
67 lines (49 loc) · 2.12 KB
/
CrossProductDemo.tscn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
[gd_scene load_steps=7 format=2]
[ext_resource path="res://Arrow.tscn" type="PackedScene" id=1]
[ext_resource path="res://CameraGimbal.tscn" type="PackedScene" id=2]
[ext_resource path="res://CrossProductDemo.gd" type="Script" id=3]
[sub_resource type="Shader" id=1]
code = "shader_type spatial;
render_mode blend_mix, depth_draw_alpha_prepass;
uniform vec4 grid_color : hint_color = vec4(vec3(0.0),1.0);
uniform vec4 background_color : hint_color = vec4(vec3(0.0),0.0);
uniform vec4 emission_color : hint_color = vec4(vec3(0.0),1.0);
uniform float emission_strength : hint_range(0.0, 10.0) = 1.0;
uniform float line_thickness : hint_range(0.001, 0.5) = 0.01;
uniform int cell_count = 10;
void fragment()
{
float x = fract(UV.x * float(cell_count));
x = min(x, 1.0 - x);
x = smoothstep(x - fwidth(x), x + fwidth(x), line_thickness);
float y = fract(UV.y * float(cell_count));
y = min(y, 1.0 - y);
y = smoothstep(y - fwidth(y), y + fwidth(y), line_thickness);
float grid = clamp(x + y, 0.0, 1.0);
vec4 color = mix(background_color, grid_color, grid);
ALBEDO = color.rgb;
EMISSION = emission_color.rgb * emission_strength * color.a;
ALPHA = color.a;
}"
[sub_resource type="ShaderMaterial" id=2]
shader = SubResource( 1 )
shader_param/grid_color = Color( 0.94902, 0.913725, 0.905882, 1 )
shader_param/background_color = Color( 0.0705882, 0.0705882, 0.0705882, 0 )
shader_param/emission_color = Color( 0.992157, 0.980392, 0.980392, 1 )
shader_param/emission_strength = 1.0
shader_param/line_thickness = 0.01
shader_param/cell_count = 16
[sub_resource type="PlaneMesh" id=3]
material = SubResource( 2 )
size = Vector2( 50, 50 )
[node name="CrossProductDemo" type="Spatial"]
script = ExtResource( 3 )
[node name="CameraGimbal" parent="." instance=ExtResource( 2 )]
[node name="A" parent="." instance=ExtResource( 1 )]
color = Color( 0.854902, 0.121569, 0.0470588, 1 )
[node name="B" parent="." instance=ExtResource( 1 )]
[node name="C" parent="." instance=ExtResource( 1 )]
color = Color( 0.0745098, 0.556863, 0.980392, 1 )
[node name="MeshInstance" type="MeshInstance" parent="."]
mesh = SubResource( 3 )
material/0 = null