aboutsummaryrefslogtreecommitdiff
path: root/shaders/dissolve_mat.tres
blob: c8e210359931105d839e9ec2165e11d7290d94f0 (plain)
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
[gd_resource type="ShaderMaterial" load_steps=6 format=2]

[sub_resource type="Shader" id=1]
code = "shader_type spatial;
render_mode cull_disabled;

uniform sampler2D texture;
uniform sampler2D blendTexture;
uniform sampler2D noiseTexture;

uniform float offset = 0.;
uniform bool up = true;
uniform vec4 borderColor: hint_color = vec4(1., 1., 0., 1.);
uniform float borderHeight = 0.1;
uniform float waveAmplitude = 1.;
uniform float waveFrequency = 1.;
uniform float wavePhase = 0.1;
uniform float emissionIntensity = 1.;
uniform float noiseSpeed = .01;
uniform float noiseInfluence = 1.;

uniform vec2 blendUVScale = vec2(1.);
uniform vec2 noiseUVScale = vec2(1.);
uniform vec2 textureUVScale = vec2(1.);

const float tao = 2. * 3.14;

// https://github.com/godotengine/godot/issues/19800
uniform mat4 global_transform;

varying vec3 world_pos;

void vertex(){
    world_pos = (global_transform * vec4(VERTEX, 1.0)).xyz;
}

void fragment() {
	vec3 position = world_pos;
	vec4 text = texture(texture, UV);
	vec4 blend = texture(blendTexture, UV * blendUVScale);

	vec2 st = UV;
	st.y -= TIME * noiseSpeed;
	vec4 noise = texture(noiseTexture, st * noiseUVScale);

	float x = tao * position.x;
	float waveFrequency1 = waveFrequency;
	float waveFrequency2 = waveFrequency + 2. - wavePhase;
	float waveFrequency3 = waveFrequency + 3. - wavePhase;
	
	position.y += waveAmplitude * (sin(x / waveFrequency1) + sin(x / waveFrequency2) + sin(x / waveFrequency3));
	position.y += (noise.r * noiseInfluence);

	float direction = up ? 1. : -1.;
	float upperBorder = smoothstep(offset, offset, (position.y * direction) + 1.);
	float bottomBorder = smoothstep(offset, offset, (position.y * direction) - borderHeight + 1.);
	float borderPart = upperBorder - bottomBorder;

	vec4 color = mix(blend, borderColor, upperBorder);
	color = mix(color, text, bottomBorder);
	
	ALBEDO = color.rgb;

	if (!FRONT_FACING) {
		ALBEDO = borderColor.rgb;
		NORMAL = VIEW;
	}

	ALPHA = color.a;
	ALPHA_SCISSOR = 1.0;
	EMISSION = vec3(borderPart) * borderColor.rgb * emissionIntensity;
}
"

[sub_resource type="Gradient" id=2]
offsets = PoolRealArray( 0, 0.996575, 1 )
colors = PoolColorArray( 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0 )

[sub_resource type="GradientTexture" id=3]
gradient = SubResource( 2 )

[sub_resource type="OpenSimplexNoise" id=5]

[sub_resource type="NoiseTexture" id=4]
seamless = true
noise = SubResource( 5 )

[resource]
resource_local_to_scene = true
shader = SubResource( 1 )
shader_param/offset = 0.369
shader_param/up = true
shader_param/borderColor = Color( 1, 1, 1, 0 )
shader_param/borderHeight = 0.255
shader_param/waveAmplitude = 1.0
shader_param/waveFrequency = 1.0
shader_param/wavePhase = 0.1
shader_param/emissionIntensity = 1.0
shader_param/noiseSpeed = 0.0
shader_param/noiseInfluence = 1.0
shader_param/blendUVScale = Vector2( 1, 1 )
shader_param/noiseUVScale = Vector2( 1, 1 )
shader_param/textureUVScale = Vector2( 1, 1 )
shader_param/global_transform = null
shader_param/blendTexture = SubResource( 3 )
shader_param/noiseTexture = SubResource( 4 )