30 lines
No EOL
1.2 KiB
Text
30 lines
No EOL
1.2 KiB
Text
shader_type canvas_item;
|
|
|
|
uniform sampler2D SCREEN_TEXTURE: hint_screen_texture, filter_linear_mipmap;
|
|
uniform float distortionView : hint_range(0.0, 0.3, 0.005) = 0.03;
|
|
uniform float speedView : hint_range(0.0, 1.0, 0.005) = 0.5;
|
|
uniform sampler2D noiseViewX;
|
|
uniform sampler2D noiseViewY;
|
|
|
|
// vertex uniforms
|
|
uniform float distortionVertex : hint_range(0.0, 0.3, 0.005) = 0.03;
|
|
uniform float speedVertex : hint_range(0.0, 1.0, 0.005) = 0.1;
|
|
uniform sampler2D noiseVertex;
|
|
|
|
void vertex() {
|
|
VERTEX += vec2(sin(TIME * 15.0f) * 7.5f, 0);
|
|
}
|
|
|
|
void fragment() {
|
|
vec4 pixel_color = texture(TEXTURE, UV);
|
|
|
|
float noiseValueX = (texture(noiseViewX, UV + (TIME * speedView)).r * 2.0) - 1.0; // Range: -1.0 to 1.0
|
|
float noiseValueY = (texture(noiseViewY, UV + (TIME * speedView)).r * 2.0) - 1.0; // Range: -1.0 to 1.0
|
|
vec2 noiseDistort = vec2(noiseValueX, noiseValueY) * distortionView;
|
|
vec3 distortedScreenTexture = vec3(texture(SCREEN_TEXTURE, SCREEN_UV + noiseDistort).rgb);
|
|
|
|
if (pixel_color.a > 0.6f) {
|
|
vec4 new_color = vec4(0.2f, 0.1f, 0.3f, 0.4f);
|
|
COLOR = vec4(new_color.r + distortedScreenTexture.r, new_color.r + distortedScreenTexture.r, new_color.r + distortedScreenTexture.r, 0.4f);
|
|
}
|
|
} |