mirror of
https://github.com/Rezmason/matrix.git
synced 2026-04-14 12:29:30 -07:00
Ripples pass now supports five simultaneous clicks; the ripples are circular, accounting for the aspect ratio; click event is handled within the ripples pass module.
This commit is contained in:
@@ -1,22 +1,25 @@
|
||||
precision mediump float;
|
||||
varying vec2 vUV;
|
||||
uniform float width, height;
|
||||
uniform float aspectRatio;
|
||||
uniform float time;
|
||||
uniform float intensity;
|
||||
uniform float centerW;
|
||||
uniform float centerH;
|
||||
uniform vec3 clicks[5];
|
||||
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D bloomTex;
|
||||
|
||||
void main() {
|
||||
vec2 iResolution = vec2(height,width);
|
||||
vec2 cp = vec2(
|
||||
-1. + 2.* gl_FragCoord.x /iResolution.x - centerW,
|
||||
-1. + 2.* gl_FragCoord.y /iResolution.y + centerH
|
||||
);
|
||||
float cl = length(cp);//*(intensity+1.)*.9;
|
||||
vec2 uv = gl_FragCoord.xy / iResolution.xy + (cp / cl / 2. ) * sin(cl*15. - time * 10.) * intensity*.5;
|
||||
vec3 col = texture2D(tex, uv).xyz + texture2D(bloomTex, uv).xyz;;
|
||||
col.y = col.x; col.x = 0.; col.z = 0.;
|
||||
gl_FragColor = vec4(col,1.0);
|
||||
}
|
||||
|
||||
float total = 0.0;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
vec3 click = clicks[i];
|
||||
float distanceToClick = length((click.xy - vUV) * vec2(aspectRatio, 1.0));
|
||||
total += (1.0 - distanceToClick)
|
||||
* sin(distanceToClick * 50.0 - time * 12.0)
|
||||
* pow(1.0 - min(1.0, (time - click.z) / 3.0), 2.0);
|
||||
}
|
||||
total *= 0.2;
|
||||
|
||||
vec2 uv = vUV + total * 0.03;
|
||||
gl_FragColor = vec4(mix(vec3(0.0), vec3(0.3, 1.0, 0.2), texture2D(tex, uv).r + texture2D(bloomTex, uv).r * 0.5), 1.0);
|
||||
// gl_FragColor = vec4(uv, 0.5, 1.0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user