Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/old_trunk/shaders/heat_haze.frag @ 4476

Last change on this file since 4476 was 4405, checked in by snellen, 18 years ago

added heat haze shader

File size: 925 bytes
Line 
1uniform sampler2D ParticlesShot;
2uniform sampler2D FinalRender;
3uniform vec4      parameters;
4 
5float getGrey(vec4 color)
6{
7  return dot(color, vec4(0.30, 0.59, 0.11, 0.0));
8}
9
10void main(void)
11{
12  float yComponents[4];
13  vec3  normal;
14 
15  vec2  offsets[4],
16  sampler;
17
18  offsets[0] = vec2(-parameters.x, 0.0);
19  offsets[1] = vec2( parameters.x, 0.0);
20  offsets[2] = vec2(         0.0,-parameters.y);
21  offsets[3] = vec2(         0.0, parameters.y);
22 
23  for(int i = 0; i < 4; i++)
24    yComponents[i] = getGrey(texture2D(ParticlesShot, gl_TexCoord[0].xy + offsets[i]));
25
26  normal.x     = yComponents[0] - yComponents[1];
27  normal.z     = yComponents[2] - yComponents[3];
28  normal.y     = 0.05;
29 
30  normal       = normalize(normal);
31       
32  sampler      = vec2(normal.x*parameters.z +  gl_TexCoord[0].x,
33                        normal.z*parameters.w +  gl_TexCoord[0].y);
34
35  gl_FragColor = texture2D(FinalRender, sampler);
36}
Note: See TracBrowser for help on using the repository browser.