//**************************************************************************/ // 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; // The single filter input, i.e. the image to be filtered. uniform texture2D gInputTex : InputTexture; // Filter input sampler. uniform sampler2D gInputSamp = sampler_state { Texture = ; //MinFilter = Point; //MagFilter = Point; //MipFilter = Point; }; // 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_FilterMonochrome { 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_FilterMonochrome { void main() { // The luminance conversion factors for RGB. vec3 luminanceConv = vec3(0.2125f, 0.7154f, 0.0721f); // The color of the output pixel is the dot product of the input texture sample and the // luminance conversion factors, applied to all components. float result = dot(texture2D(gInputSamp, VSUV).xyz, luminanceConv); colorOut = vec4(result, result, result, 1.0f); } } // The main technique. technique Main { pass p0 { VertexShader (in VS_INPUT, out VS_TO_PS) = VS_FilterMonochrome; PixelShader (in VS_TO_PS, out pixelOut) = PS_FilterMonochrome; } }