GLSL Desert Mirage/Heat Wave Effect

Here is another GLSL code sample from my project. This one was fairly easy after they gave us the formula to use. Here is the code and image of the results.


Vert Shader

uniform sampler2D my_color_texture;
uniform float time;
varying vec2 texc;

void main()
{
  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
  texc = vec2(gl_MultiTexCoord0);
}

Frag Shader

varying vec2 texc;
uniform sampler2D my_color_texture;
uniform float time;

const float A = 0.03;
const float B = 200.0;
const float C = 5.0;

const float D = 0.003;
const float E = 13.0;
const float F = 9.0;
float x;
float y;

void main()
{
  gl_FragColor =  texture2D(my_color_texture, texc);
  gl_FragColor.a = 1.0; //Best to make sure nothing seems transparent
  float x =  A * sin(B * texc.x) * sin(C * time);
  float y =  D * sin(E * texc.y) * sin(F * time);
  vec2 c = vec2(texc.x + x, texc.y +y);
  vec4 diffuse_color =  texture2D(my_color_texture, c);
  gl_FragColor = diffuse_color;
}

Mess with the variables to get different affects.


Graveyard Database Logo

Has everything you want to know about grave yards. Plus has many celebrites and world leaders graves. Pssst it is my other site

Google + Profile
Check out Android Photo Mapping, its a app/site I been working on

  • wholesale nfl jerseys
  • wholesale nfl jerseys china
  • wholesale sports jerseys