diff --git a/js/regl/main.js b/js/regl/main.js index abc2321..7df1d14 100644 --- a/js/regl/main.js +++ b/js/regl/main.js @@ -61,8 +61,8 @@ export default async (canvas, config) => { window.ripples = [0,0,0] window.onclick = (e) => { // ripple init console.log(e) - window.ripples = [Date.now(), e.clientX, e.clientY] - console.log(ripples) + window.ripples = [Date.now(), (e.clientX/e.srcElement.clientWidth*2)-1, (e.clientY/e.srcElement.clientHeight*2)-1] + // console.log(ripples) } diff --git a/js/regl/ripplesPass.js b/js/regl/ripplesPass.js index 3eff1f7..a5a88d0 100644 --- a/js/regl/ripplesPass.js +++ b/js/regl/ripplesPass.js @@ -18,9 +18,9 @@ export default ({ regl, config }, inputs) => { tex: inputs.primary, bloomTex: inputs.bloom, intensity: ()=>{ - let inten = 8 - (Date.now() - window.ripples[0])/500 + let inten = 2 - (Date.now() - window.ripples[0])/2000 if (inten < 0) inten = 0 - return inten / 50 + return inten / 10 }, height: regl.context("viewportWidth"), width: regl.context("viewportHeight"), diff --git a/shaders/glsl/ripplesPass.frag.glsl b/shaders/glsl/ripplesPass.frag.glsl index a031c88..2663b65 100644 --- a/shaders/glsl/ripplesPass.frag.glsl +++ b/shaders/glsl/ripplesPass.frag.glsl @@ -9,40 +9,13 @@ uniform sampler2D tex; uniform sampler2D bloomTex; void main() { - - // gl_FragColor = texture2D(tex, vUV); - // vec4 color = texture2D(bloomTex, vUV) + texture2D(tex, vUV); - - // float intensity = 0.1; - - vec2 iResolution = vec2(height,width); - //vec2 cp = -1. + 2. * gl_FragCoord.xy / iResolution.xy; - //cp = -1. + 2. * vec2(centerW, centerH) / iResolution.xy; vec2 cp = vec2( - -1. + 2.* gl_FragCoord.x /iResolution.x + -1.+ 2.*(iResolution.x-centerW)/iResolution.x, - -1. + 2.* gl_FragCoord.y /iResolution.y//gl_FragCoord.y //-1. + 2.*(gl_FragCoord.y)/iResolution.y + -1.+ 2.*(iResolution.y-centerH)/iResolution.y + -1. + 2.* gl_FragCoord.x /iResolution.x - centerW, + -1. + 2.* gl_FragCoord.y /iResolution.y + centerH ); - // cp.y = 1. - cp.y - 2. * centerH/iResolution.y; - - float cl = length(cp); - vec2 uv = gl_FragCoord.xy / iResolution.xy + (cp / cl / 4. ) * sin(cl*10. - time * 12.) * intensity*.5; - // vec4 col=smoothstep(0.1,.91,texture2D(color).xyz); - vec3 col = texture2D(tex, uv).xyz + texture2D(bloomTex, uv).xyz;; - - - gl_FragColor = vec4(col,1.0); -} - -// void main( out vec4 fragColor, in vec2 fragCoord ) -// { -// vec2 cp = -1.0 + 2.0 * fragCoord / iResolution.xy; -// float cl = length(cp); -// vec2 uv = fragCoord / iResolution.xy + (cp / cl) * cos(cl * 12.0 - iTime * 4.0) * 0.02; -// vec3 col = texture(iChannel0, uv).xyz; -// fragColor = vec4(col, 1.0); -// } \ No newline at end of file +} \ No newline at end of file