//**************************************************************************/ // 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. //**************************************************************************/ #include "Common.cgh" // Color texture. Assumed to be 4 channel texture gColorTex : SourceTexture < string UIName = "Color Texture"; >; // Color texture sampler. sampler2D gColorSampler = sampler_state { Texture = ; MinFilter = Point; MagFilter = Point; MipFilter = Point; }; // Disable alpha output. bool gDisableAlpha; // Depth texture. Assumed to be 1 channel normalized between 0 and 1 texture gDepthTex : SourceTexture2 < string UIName = "Depth Texture"; >; // Depth texture sampler. sampler2D gDepthSampler = sampler_state { Texture = ; MinFilter = Point; MagFilter = Point; MipFilter = Point; }; // Pixel shader outputs both color and depth struct PS_OUTPUT { float4 color : COLOR0; float depth : DEPTH; }; // Pixel shader for color + depth // PS_OUTPUT PS_BlitColorDepth(VS_TO_PS_ScreenQuad In) { PS_OUTPUT outputStruct; // Output color // In.UV.y = 1.0f - In.UV.y; float4 output = tex2D(gColorSampler, In.UV); if (gDisableAlpha) { outputStruct.color = float4( output.xyz, 1.0 ); } else { outputStruct.color = output; } // Output depth // float4 outputDepth = tex2D(gDepthSampler, In.UV); outputStruct.depth = outputDepth.r; return outputStruct; } // Debug depth to color. Assumes a R32 single channel texture. // float4 PS_BlitDepthToColor(VS_TO_PS_ScreenQuad In) : COLOR0 { In.UV.y = 1.0f - In.UV.y; float4 outputDepth = tex2D(gDepthSampler, In.UV); return float4(outputDepth.rrr, 1.0f); } // The main technique technique Main { pass p0 { VertexProgram = compile glslv VS_ScreenQuad(); FragmentProgram = compile glslf PS_BlitColorDepth(); } } // Debug by putting depth to color technique DepthToColor { pass p0 { VertexProgram = compile glslv VS_ScreenQuad(); FragmentProgram = compile glslf PS_BlitDepthToColor(); } }