Depth Shader with Alpha transparency information

Posted By: jumpman

Depth Shader with Alpha transparency information - 09/04/17 05:48

Hello, Im using the depth.fx file to generate a depth map for my scene, to be used for post processing.

Is there a shader I can apply to the camera/.fx that also takes into account entity alpha maps? I use a shader that cuts off alpha information as well as PASS_SOLID which looks nice. But I want a depth shader that takes this into account, not just polygons.

What can I add to this shader to make it account for alpha transparency?

Code:
////////////////////////////////////////////////////
// Depth rendering shader
// Copyright (c) 2007 Conitec. All rights reserved.
////////////////////////////////////////////////////
	
// Application fed data:
const float4x4 matWorldViewProj;

//////////-----------------------

//////////------------------	
	
	
void DepthVS (in float4 InPos	: POSITION,
				out float4 OutPos	: POSITION,
				out float OutDepth: TEXCOORD0)
{
// Output the transformed position
	OutPos = mul(InPos,matWorldViewProj);

// Output the scene depth
OutDepth = (OutPos.z)*.002;




	//	OutDepth = OutPos.z;
	

	//OutDepth -= OutDepth;
}

float4  DepthPS( in float InDepth: TEXCOORD0 ) : COLOR0
{

	
	

	
// Output the scene depth to a R32 floating point texture
//	return float4( InDepth, 0.0, 0.0, 1.0 );	

return float4(InDepth, 0.0, 0.0, 1.0 );	
	
	
}

technique DepthTechnique
{
	pass p0
	{
		Lighting	= False;			
		VertexShader = compile vs_2_0 DepthVS();
		PixelShader  = compile ps_2_0 DepthPS();
	}
}

Posted By: Ezzett

Re: Depth Shader with Alpha transparency information - 09/04/17 09:34

Are you looking for something like this:

http://www.rastertek.com/dx10tut49.html
Posted By: jumpman

Re: Depth Shader with Alpha transparency information - 09/04/17 13:43

thats almost exactly what Im looking for Ezzett, thank you. Its in DX10 though, and im having trouble trying to get it to work, but its the right principle
Posted By: Matt_Aufderheide

Re: Depth Shader with Alpha transparency information - 09/05/17 23:53

This is easy, just sample the texture in your depth shader for each object and do something like this:

clip(tex.a-0.5);
Posted By: jumpman

Re: Depth Shader with Alpha transparency information - 09/07/17 19:47

thanks matt!
© 2024 lite-C Forums