X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=shaders%2Fwater.fs;fp=shaders%2Fwater.fs;h=a8220a4446716f7e804878935be5dd0d4efefe80;hb=1f1d636056450dcd23cce55c0795ec6276272531;hp=0000000000000000000000000000000000000000;hpb=51a9d6b9321b951b79dff0d52a82116c678ad8aa;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/shaders/water.fs b/shaders/water.fs new file mode 100644 index 0000000..a8220a4 --- /dev/null +++ b/shaders/water.fs @@ -0,0 +1,20 @@ +out vec4 FragColor; + +uniform sampler2D uTexMain; +uniform sampler2D uTexDudv; +uniform vec2 uInvRes; +uniform float uTime; + +in vec2 aUv; + +void main() +{ + vec2 ssuv = gl_FragCoord.xy*uInvRes; + vec4 dudva = texture( uTexDudv, aUv + vec2(uTime*0.04f,uTime*0.03f) ); + vec4 dudvb = texture( uTexDudv, aUv - vec2(uTime*0.1,uTime*0.054) ); + + vec2 distortamt = (dudva.rg-0.5) * (dudvb.ba-0.5) * 2.0; + + vec4 reflected = texture( uTexMain, ssuv+distortamt ); + FragColor = vec4(reflected.rgb*0.9,reflected.a); +}