2024-12-27 10:57:48 +04:00
|
|
|
#version 330
|
|
|
|
|
|
|
|
in vec2 fragTexCoord; // Fragment input attribute: texture coordinate
|
|
|
|
in vec4 fragColor; // Fragment input attribute: color
|
|
|
|
out vec4 finalColor; // Fragment output: color
|
|
|
|
uniform sampler2D texture0; // Fragment input texture (always required, could be a white pixel)
|
|
|
|
uniform vec4 colDiffuse; // Fragment input color diffuse (multiplied by texture color)
|
|
|
|
|
|
|
|
// Custom variables
|
2024-12-27 23:52:27 +04:00
|
|
|
uniform sampler2D waterBumpMap;
|
2024-12-27 10:57:48 +04:00
|
|
|
uniform float seconds;
|
2024-12-27 23:52:27 +04:00
|
|
|
uniform vec2 resolution;
|
|
|
|
|
2024-12-28 18:59:16 +04:00
|
|
|
const float blurScale = 0.3;
|
2024-12-27 23:52:27 +04:00
|
|
|
const float waveWidth = 0.1;
|
|
|
|
const float waveHeight = 0.1;
|
2024-12-27 14:05:23 +04:00
|
|
|
|
2024-12-27 16:44:44 +04:00
|
|
|
vec4 blur13(sampler2D image, vec2 uv, vec2 resolution, vec2 direction)
|
2024-12-27 14:05:23 +04:00
|
|
|
{
|
2024-12-27 16:44:44 +04:00
|
|
|
vec4 color = vec4(0.0);
|
|
|
|
vec2 off1 = vec2(1.411764705882353) * direction;
|
|
|
|
vec2 off2 = vec2(3.2941176470588234) * direction;
|
|
|
|
vec2 off3 = vec2(5.176470588235294) * direction;
|
2024-12-27 23:52:27 +04:00
|
|
|
color += texture(image, uv) * 0.1964825501511404;
|
|
|
|
color += texture(image, uv + (off1 / resolution)) * 0.2969069646728344;
|
|
|
|
color += texture(image, uv - (off1 / resolution)) * 0.2969069646728344;
|
|
|
|
color += texture(image, uv + (off2 / resolution)) * 0.09447039785044732;
|
|
|
|
color += texture(image, uv - (off2 / resolution)) * 0.09447039785044732;
|
|
|
|
color += texture(image, uv + (off3 / resolution)) * 0.010381362401148057;
|
|
|
|
color += texture(image, uv - (off3 / resolution)) * 0.010381362401148057;
|
2024-12-27 16:44:44 +04:00
|
|
|
return color;
|
2024-12-27 14:05:23 +04:00
|
|
|
}
|
|
|
|
|
2024-12-27 10:57:48 +04:00
|
|
|
void main()
|
|
|
|
{
|
2024-12-31 16:25:55 +04:00
|
|
|
vec4 bumpColor = texture(waterBumpMap, fragTexCoord/5 + sin(seconds / 2.0) / 20.0);
|
2024-12-27 23:52:27 +04:00
|
|
|
bumpColor = (bumpColor + texture(waterBumpMap, fragTexCoord*1.5 + cos(seconds / 2.0) / 20.0)) * 0.5;
|
2024-12-27 10:57:48 +04:00
|
|
|
|
|
|
|
vec2 samplePos = fragTexCoord;
|
2024-12-27 23:52:27 +04:00
|
|
|
samplePos.x += (bumpColor.r - 0.5) * waveWidth * fragColor.r;
|
|
|
|
samplePos.y += (bumpColor.g - 0.5) * waveHeight * fragColor.g;
|
2024-12-27 10:57:48 +04:00
|
|
|
|
2024-12-27 23:52:27 +04:00
|
|
|
vec4 xBlur = blur13(texture0, samplePos, resolution, vec2(blurScale, 0));
|
|
|
|
vec4 yBlur = blur13(texture0, samplePos, resolution, vec2(0, blurScale));
|
2024-12-27 16:44:44 +04:00
|
|
|
vec4 result = (xBlur + yBlur) * 0.5;
|
|
|
|
|
2024-12-27 23:52:27 +04:00
|
|
|
finalColor = result*colDiffuse*fragColor;
|
2024-12-27 10:57:48 +04:00
|
|
|
}
|