🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Need help with GLSL heat distortion shader

Started by
2 comments, last by trsh 4 years, 6 months ago

Can I create something like this https://www.shadertoy.com/view/XsVSRd , with out distortion (second) texture?

Advertisement

You can if you generate the distortion procedurally.

Here's a quick attempt at something that looks similar:

I've essentially replaced the texture with the noise function.

float noise(float x)
{
    return     sin(x * 100.0) * .1 +
            sin((x * 200.0) + 3.0) * 0.05 +
            fract(sin((x * 19.0) + 1.0) * 33.33) * 0.13;
}

void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
    vec2 p_m = fragCoord.xy / iResolution.xy;
    vec2 p_d = p_m;

    p_d.xy -= iTime * 0.1;
    
//    vec4 dst_map_val = texture(iChannel1, p_d);
    vec2 dst_map_val = vec2(noise(p_d.y), noise(p_d.x));
    
    vec2 dst_offset = dst_map_val.xy;
    dst_offset -= vec2(.5,.5);
    dst_offset *= 2.;
    dst_offset *= 0.01;
    
    //reduce effect towards Y top
    dst_offset *= (1. - p_m.t);
    
    vec2 dist_tex_coord = p_m.st + dst_offset;
    fragColor = texture(iChannel0, dist_tex_coord);
}

Thanks bro

This topic is closed to new replies.

Advertisement