//**************************************************************************/ // Copyright 2012 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. //**************************************************************************/ // // Sample shader useful for rendering a "depth" pass. // // World-view-projection transformation. float4x4 gWVPXf : WorldViewProjection < string UIWidget = "None"; bool rowMajor = true; >; // Depth priority, which shifts the model a bit forward in the z-buffer float gDepthPriority : DepthPriority < string UIName = "Depth Priority"; string UIWidget = "Slider"; float UIMin = -16/1048576.0f; // divide by 2^24/16 by default float UIMax = 16/1048576.0f; float UIStep = 1/1048576.0f; > = 0.0f; // Vertex shader input structure. struct VS_INPUT { float3 Pos : POSITION; }; // Vertex shader output structure. struct VS_TO_PS { // The vertex position in clip space. float4 HPos : POSITION; }; // Vertex shader. VS_TO_PS VS_Depth(VS_INPUT In) { VS_TO_PS Out; // Transform the position from object space to clip space for output. Out.HPos = mul(float4(In.Pos, 1.0f), gWVPXf); // modify the HPos a bit by biasing the Z a bit forward, based on depth priority Out.HPos.z -= Out.HPos.w*gDepthPriority; return Out; } // Pixel shader. float4 PS_Depth(VS_TO_PS In) : COLOR0 { return float4(0.0f, 0.0f, 0.0f, 0.0f); } // The main technique. technique Main { pass P0 { VertexProgram = compile glslv VS_Depth(); FragmentProgram = compile glslf PS_Depth(); } }