Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/Example/GLSLES/HeatBlurFp.glsles @ 12091

Last change on this file since 12091 was 12091, checked in by wiesep, 6 years ago

Updated programs and adjusted Material to work with GLSL>150

File size: 1.4 KB
Line 
1#version 100
2
3precision mediump int;
4precision mediump float;
5
6uniform sampler2D Input;
7uniform vec4 blurAmount;
8
9varying vec2 uv;
10
11void main()
12{
13   int i;
14   vec4 tmpOutColor;
15   float  diffuseGlowFactor;
16   vec2 offsets[4];
17/*
18                // hazy blur
19                -1.8, -1.8,
20                -1.8, 1.8,
21                1.8, -1.8,
22                1.8, 1.8
23*/
24/*
25                // less-hazy blur
26          -1.0,  2.0,
27          -1.0, -1.0,
28           1.0, -1.0,
29           1.0,  1.0
30*/
31/*
32      -0.326212, -0.405805,
33      -0.840144, -0.073580,
34      -0.695914,  0.457137,
35      -0.203345,  0.620716
36*/
37
38   offsets[0] = vec2(-0.3,  0.4);
39   offsets[1] = vec2(-0.3,  -0.4);
40   offsets[2] = vec2(0.3,  -0.4);
41   offsets[3] = vec2(0.3,  0.4);
42
43   tmpOutColor = texture2D( Input, uv );        // UV coords are in image space
44
45   // calculate glow amount
46   diffuseGlowFactor = 0.0113 * (2.0 - max( tmpOutColor.r, tmpOutColor.g ));
47
48   // basic blur filter
49   for (i = 0; i < 4; i++) {
50      tmpOutColor += texture2D( Input, uv + blurAmount.x * diffuseGlowFactor * offsets[i] );
51   }
52
53   tmpOutColor *= 0.25;
54
55   // TIPS (old-skool strikes again!)
56   // Pay attention here! If you use the "out float4 outColor" directly
57   // in your steps while creating the output color (like you remove
58   // the "tmpOutColor" var and just use the "outColor" directly)
59   // your pixel-color output IS CHANGING EACH TIME YOU DO AN ASSIGNMENT TOO!
60   // A temporary variable, instead, acts like a per-pixel double buffer, and
61   // best of all, lead to better performance.
62   gl_FragColor = tmpOutColor;
63}
Note: See TracBrowser for help on using the repository browser.