- Timestamp:
- Nov 9, 2018, 1:06:05 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
data/branches/Shader_HS18/programs/Example/GLSL150/HeatBlurFp.glsl
r12083 r12091 9 9 void main() 10 10 { 11 int i;12 vec4 tmpOutColor;13 float diffuseGlowFactor;14 vec2 offsets[4];15 /*16 17 18 19 20 21 */22 /*23 24 25 26 27 28 */29 /*11 int i; 12 vec4 tmpOutColor; 13 float diffuseGlowFactor; 14 vec2 offsets[4]; 15 /* 16 // hazy blur 17 -1.8, -1.8, 18 -1.8, 1.8, 19 1.8, -1.8, 20 1.8, 1.8 21 */ 22 /* 23 // less-hazy blur 24 -1.0, 2.0, 25 -1.0, -1.0, 26 1.0, -1.0, 27 1.0, 1.0 28 */ 29 /* 30 30 -0.326212, -0.405805, 31 31 -0.840144, -0.073580, 32 32 -0.695914, 0.457137, 33 33 -0.203345, 0.620716 34 */34 */ 35 35 36 offsets[0] = vec2(-0.3, 0.4);37 offsets[1] = vec2(-0.3, -0.4);38 offsets[2] = vec2(0.3, -0.4);39 offsets[3] = vec2(0.3, 0.4);36 offsets[0] = vec2(-0.3, 0.4); 37 offsets[1] = vec2(-0.3, -0.4); 38 offsets[2] = vec2(0.3, -0.4); 39 offsets[3] = vec2(0.3, 0.4); 40 40 41 tmpOutColor = texture( Input, uv );// UV coords are in image space41 tmpOutColor = texture( Input, uv ); // UV coords are in image space 42 42 43 // calculate glow amount44 diffuseGlowFactor = 0.0113 * (2.0 - max( tmpOutColor.r, tmpOutColor.g ));43 // calculate glow amount 44 diffuseGlowFactor = 0.0113 * (2.0 - max( tmpOutColor.r, tmpOutColor.g )); 45 45 46 // basic blur filter47 for (i = 0; i < 4; i++) {48 tmpOutColor += texture( Input, uv + blurAmount.x * diffuseGlowFactor * offsets[i] );49 }46 // basic blur filter 47 for (i = 0; i < 4; i++) { 48 tmpOutColor += texture( Input, uv + blurAmount.x * diffuseGlowFactor * offsets[i] ); 49 } 50 50 51 tmpOutColor *= 0.25;51 tmpOutColor *= 0.25; 52 52 53 // TIPS (old-skool strikes again!)54 // Pay attention here! If you use the "out float4 outColor" directly55 // in your steps while creating the output color (like you remove56 // the "tmpOutColor" var and just use the "outColor" directly)57 // your pixel-color output IS CHANGING EACH TIME YOU DO AN ASSIGNMENT TOO!58 // A temporary variable, instead, acts like a per-pixel double buffer, and59 // best of all, lead to better performance.60 fragColour = tmpOutColor;53 // TIPS (old-skool strikes again!) 54 // Pay attention here! If you use the "out float4 outColor" directly 55 // in your steps while creating the output color (like you remove 56 // the "tmpOutColor" var and just use the "outColor" directly) 57 // your pixel-color output IS CHANGING EACH TIME YOU DO AN ASSIGNMENT TOO! 58 // A temporary variable, instead, acts like a per-pixel double buffer, and 59 // best of all, lead to better performance. 60 fragColour = tmpOutColor; 61 61 }
Note: See TracChangeset
for help on using the changeset viewer.