//**************************************************************************/ // Copyright 2014 Autodesk, Inc. // All rights reserved. // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. //**************************************************************************/ // World-view-projection transformation. uniform mat4 gWVPXf : WorldViewProjection; uniform vec4 gUVTransform : RelativeViewportDimensions; // The source texture uniform texture2D gSourceTex : SourceTexture; // Sampler of source texture uniform sampler2D gSourceSamp = sampler_state { Texture = ; }; uniform float gBrightThreshold = 0.8f; // Vertex shader input structure. attribute VS_INPUT { vec4 Pos: POSITION; vec2 UV: TEXCOORD0; }; // Vertex shader output structure. attribute VS_TO_PS { vec2 VSUV: TEXCOORD0; }; // Vertex shader. GLSLShader VS_Threshold { void main() { gl_Position = gWVPXf*Pos; // Pass the texture coordinates unchanged. VSUV = UV; } } // Pixel shader output structure. attribute pixelOut { vec4 colorOut: COLOR0; } // Pixel shader. GLSLShader PS_Threshold { void main() { vec4 val = texture2D(gSourceSamp, VSUV * gUVTransform.zw + gUVTransform.xy); vec4 brightnessFactor = vec4(0.212671f, 0.715160f, 0.072169f, 1.0f); float brightness = dot(brightnessFactor.xyz, val.xyz); if( brightness > gBrightThreshold) colorOut = vec4(val.xyz, 1.0f); else colorOut = vec4(0.0f, 0.0f, 0.0f, 1.0f); } } // The main technique. technique Main { pass p0 { VertexShader (in VS_INPUT, out VS_TO_PS) = VS_Threshold; PixelShader (in VS_TO_PS, out pixelOut) = PS_Threshold; } }