Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [HEADER]
- VERSION 01.00.00.00
- DESCRIPTION Post-processing examples
- COPYRIGHT 2013-2014, The Brenwill Workshop Ltd. All rights reserved.
- [/HEADER]
- // Using a texture attached to a rendering surface
- [TEXTURES]
- [/TEXTURES]
- ///////////////////////////////////////////////
- // In post-processing, draw a single texture in clip-space.
- // after converting the texture to grayscale.
- ///////////////////////////////////////////////
- [EFFECT]
- NAME Grayscale
- VERTEXSHADER ClipSpace_vsh
- FRAGMENTSHADER Grayscale_fsh
- [/EFFECT]
- ///////////////////////////////////////////////
- // Draws a single texture in clip-space.
- // In clip-space, we need no transform matrices, because all locations
- // are taken to be between +/-1.0 in all three dimensions.
- ///////////////////////////////////////////////
- [VERTEXSHADER]
- NAME ClipSpace_vsh
- FILE CC3ClipSpaceTexturable.vsh
- [/VERTEXSHADER]
- ///////////////////////////////////////////////
- // Draws a single texture as grayscale.
- // Grayscale rendering is processed via the ITU-R BT.709 conversion used for
- // high-definition television (HDTV) signals. The alpha component is unchanged.
- ///////////////////////////////////////////////
- [FRAGMENTSHADER]
- NAME Grayscale_fsh
- [GLSL_CODE]
- uniform sampler2D s_cc3Texture; // 0
- uniform float vx_offset;
- uniform float rt_w; // GeeXLab built-in
- uniform float rt_h; // GeeXLab built-in
- uniform float pixel_w; // 15.0
- uniform float pixel_h; // 10.0
- void main()
- {
- vec2 uv = gl_TexCoord[0].xy;
- vec3 tc = vec3(1.0, 0.0, 0.0);
- if (uv.x < (vx_offset-0.005))
- {
- float dx = pixel_w*(1./rt_w);
- float dy = pixel_h*(1./rt_h);
- vec2 coord = vec2(dx*floor(uv.x/dx), dy*floor(uv.y/dy));
- tc = texture2D(sceneTex, coord).rgb;
- }
- else if (uv.x>=(vx_offset+0.005))
- {
- tc = texture2D(s_cc3Texture, uv).rgb;
- }
- gl_FragColor = vec4(tc, 1.0);
- }
- [/GLSL_CODE]
- [/FRAGMENTSHADER]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement