Advertisement
snake5

5x5 gaussian

Feb 14th, 2015
595
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. varying vec4 Color;
  3. varying vec2 TexCoord0;
  4.  
  5. #ifdef VSHADER
  6.  
  7. void main()
  8. {
  9.     gl_Position = ProjectionMatrix * ViewMatrix * GLVertex;
  10.     TexCoord0 = GLTexCoord0.xy;
  11.     Color = GLColor;
  12. }
  13.  
  14.  
  15.  
  16. #elif defined PSHADER
  17.  
  18. #define TEX2DLOD textureLod
  19.  
  20. uniform sampler2D Tex0;
  21.  
  22. void main()
  23. {
  24.     vec4 color = vec4( 0, 0, 0, 0 );
  25.     vec2 hrange = ( abs( dFdx( TexCoord0 ) ) + abs( dFdy( TexCoord0 ) ) ) * 0.75;
  26.    
  27.     // LINE 1
  28.     color += TEX2DLOD( Tex0, TexCoord0 + vec2( -hrange.x, -hrange.y ), 0 ) * ( 0.1 * 0.1 );
  29.     color += TEX2DLOD( Tex0, TexCoord0 + vec2( -hrange.x * 0.5, -hrange.y ), 0 ) * ( 0.2 * 0.1 );
  30.     color += TEX2DLOD( Tex0, TexCoord0 + vec2( 0, -hrange.y ), 0 ) * ( 0.4 * 0.1 );
  31.     color += TEX2DLOD( Tex0, TexCoord0 + vec2( hrange.x * 0.5, -hrange.y ), 0 ) * ( 0.2 * 0.1 );
  32.     color += TEX2DLOD( Tex0, TexCoord0 + vec2( hrange.x, -hrange.y ), 0 ) * ( 0.1 * 0.1 );
  33.  
  34.     // LINE 2
  35.     color += TEX2DLOD( Tex0, TexCoord0 + vec2( -hrange.x, -hrange.y * 0.5 ), 0 ) * ( 0.1 * 0.2 );
  36.     color += TEX2DLOD( Tex0, TexCoord0 + vec2( -hrange.x * 0.5, -hrange.y * 0.5 ), 0 ) * ( 0.2 * 0.2 );
  37.     color += TEX2DLOD( Tex0, TexCoord0 + vec2( 0, -hrange.y * 0.5 ), 0 ) * ( 0.4 * 0.2 );
  38.     color += TEX2DLOD( Tex0, TexCoord0 + vec2( hrange.x * 0.5, -hrange.y * 0.5 ), 0 ) * ( 0.2 * 0.2 );
  39.     color += TEX2DLOD( Tex0, TexCoord0 + vec2( hrange.x, -hrange.y * 0.5 ), 0 ) * ( 0.1 * 0.2 );
  40.  
  41.     // LINE 3
  42.     color += TEX2DLOD( Tex0, TexCoord0 + vec2( -hrange.x, 0 ), 0 ) * ( 0.1 * 0.4 );
  43.     color += TEX2DLOD( Tex0, TexCoord0 + vec2( -hrange.x * 0.5, 0 ), 0 ) * ( 0.2 * 0.4 );
  44.     color += TEX2DLOD( Tex0, TexCoord0 + vec2( 0, 0 ), 0 ) * ( 0.4 * 0.4 );
  45.     color += TEX2DLOD( Tex0, TexCoord0 + vec2( hrange.x * 0.5, 0 ), 0 ) * ( 0.2 * 0.4 );
  46.     color += TEX2DLOD( Tex0, TexCoord0 + vec2( hrange.x, 0 ), 0 ) * ( 0.1 * 0.4 );
  47.  
  48.     // LINE 4
  49.     color += TEX2DLOD( Tex0, TexCoord0 + vec2( -hrange.x, hrange.y * 0.5 ), 0 ) * ( 0.1 * 0.2 );
  50.     color += TEX2DLOD( Tex0, TexCoord0 + vec2( -hrange.x * 0.5, hrange.y * 0.5 ), 0 ) * ( 0.2 * 0.2 );
  51.     color += TEX2DLOD( Tex0, TexCoord0 + vec2( 0, hrange.y * 0.5 ), 0 ) * ( 0.4 * 0.2 );
  52.     color += TEX2DLOD( Tex0, TexCoord0 + vec2( hrange.x * 0.5, hrange.y * 0.5 ), 0 ) * ( 0.2 * 0.2 );
  53.     color += TEX2DLOD( Tex0, TexCoord0 + vec2( hrange.x, hrange.y * 0.5 ), 0 ) * ( 0.1 * 0.2 );
  54.  
  55.     // LINE 5
  56.     color += TEX2DLOD( Tex0, TexCoord0 + vec2( -hrange.x, hrange.y ), 0 ) * ( 0.1 * 0.1 );
  57.     color += TEX2DLOD( Tex0, TexCoord0 + vec2( -hrange.x * 0.5, hrange.y ), 0 ) * ( 0.2 * 0.1 );
  58.     color += TEX2DLOD( Tex0, TexCoord0 + vec2( 0, hrange.y ), 0 ) * ( 0.4 * 0.1 );
  59.     color += TEX2DLOD( Tex0, TexCoord0 + vec2( hrange.x * 0.5, hrange.y ), 0 ) * ( 0.2 * 0.1 );
  60.     color += TEX2DLOD( Tex0, TexCoord0 + vec2( hrange.x, hrange.y ), 0 ) * ( 0.1 * 0.1 );
  61.  
  62.     gl_FragColor = color * Color;
  63. }
  64.  
  65.  
  66.  
  67. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement