-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWaterShader2.tres
113 lines (80 loc) · 2.71 KB
/
WaterShader2.tres
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
[gd_resource type="ShaderMaterial" load_steps=6 format=2]
[sub_resource type="Shader" id=29]
code = "shader_type spatial;
render_mode blend_mix, specular_phong, cull_back, diffuse_lambert;
uniform float speed : hint_range(-1,1) = 0.0;
//colors
uniform sampler2D noise1; //add Godot noise here
uniform sampler2D noise2; //add Godot noise here
uniform vec4 color : hint_color;
uniform vec4 edge_color : hint_color;
//foam
uniform float edge_scale = 0.25;
uniform float near = 0.1;
uniform float far = 100.0;
//waves
uniform vec2 wave_strengh = vec2(0.5, 0.25);
uniform vec2 wave_frequency = vec2(12.0, 12.0);
uniform vec2 time_factor = vec2(1.0, 2.0);
float rim(float depth){
depth = 2.0 * depth - 1.0;
return near * far / (far + depth * (near - far));
}
float waves(vec2 pos, float time){
return (wave_strengh.y * sin(pos.y * wave_frequency.y + time * time_factor.y)) + (wave_strengh.x * sin(pos.x * wave_frequency.x + time * time_factor.x));
}
void vertex(){
VERTEX.y += waves(VERTEX.xy, TIME);
}
void fragment(){
float time = TIME * speed;
vec3 n1 = texture(noise1, UV + time).rgb;
vec3 n2 = texture(noise2, UV - time * 0.2).rgb;
vec2 uv_movement = UV;
uv_movement += sin(TIME * speed * 1.0);
float sum = (n1.r + n2.r) - 1.0;
//float z_depth = rim(texture(DEPTH_TEXTURE, SCREEN_UV).x);
float z_pos = rim(FRAGCOORD.z);
//float diff = z_depth - z_pos;
vec2 displacement = vec2(sum * 0.05);
//diff += displacement.x * 50.0;
vec4 stuff = texture(SCREEN_TEXTURE, SCREEN_UV);
vec4 col = mix(edge_color, color, stuff.r); //step(edge_scale, diff));
vec4 alpha = texture(SCREEN_TEXTURE, SCREEN_UV + displacement);
float fin = 0.0;
if (sum > 0.0 && sum < 0.4) fin = 0.1;
if (sum > 0.4 && sum < 0.8) fin = 0.0;
if (sum > 0.8) fin = 1.0;
ALBEDO = vec3(fin) + mix(alpha.rgb, col.rgb, color.a);
//NORMALMAP = texture(normalmap, uv_movement).rgb;
ROUGHNESS = 0.1;
SPECULAR = 1.0;
}"
[sub_resource type="OpenSimplexNoise" id=30]
period = 4.4
[sub_resource type="NoiseTexture" id=31]
width = 128
height = 128
seamless = true
noise = SubResource( 30 )
[sub_resource type="OpenSimplexNoise" id=33]
seed = 1
period = 6.0
[sub_resource type="NoiseTexture" id=32]
width = 128
height = 128
seamless = true
noise = SubResource( 33 )
[resource]
shader = SubResource( 29 )
shader_param/speed = 0.01
shader_param/color = Color( 0.494118, 0.592157, 0.439216, 1 )
shader_param/edge_color = Color( 0.137255, 0.352941, 0.388235, 1 )
shader_param/edge_scale = 0.25
shader_param/near = 0.1
shader_param/far = 100.0
shader_param/wave_strengh = Vector2( 0.1, 0.1 )
shader_param/wave_frequency = Vector2( 6, 6 )
shader_param/time_factor = Vector2( 1, 1 )
shader_param/noise1 = SubResource( 31 )
shader_param/noise2 = SubResource( 32 )