This is what my script looks like:
Code:
function mat_model_event();
material mat_model_depth
{
flags = enable_tree;
event = mat_model_event;
effect = "renderdepthmap.fx";
}
function mat_model_event()
{
if(render_view == depth_cam)
{
my.material = mat_model_depth;
}else
{
my.material = mat_model;
mtl.skill1 = float(front);
mtl.skill2 = float(back);
}
}
mat_model has the same flag and event then mat_model_depth.
The .fx file looks like this:
Code:
//---------------------------------------------------------
// Depthmap shader by ello
//---------------------------------------------------------
struct VS_IN
{
float4 position : POSITION;
};
struct VS_OUT
{
float4 position : POSITION;
float depth : TEXCOORD0;
};
float mtlSkill1;
float mtlSkill2;
float4x4 matWorldViewProj : WorldViewProjection;
VS_OUT mainVS (VS_IN In)
{
VS_OUT Out;
Out.position = mul(In.position, matWorldViewProj);
Out.depth = ((Out.position.z - mtlSkill1)/1000) * ((Out.position.z - mtlSkill2)/1000);
return Out;
}
float4 mainPS (VS_OUT In) : COLOR0
{
return In.depth;
}
technique depth
{
pass p0
{
VertexShader = compile vs_2_0 mainVS();
PixelShader = compile ps_2_0 mainPS();
}
}
If front and back are both 0 everything is fine but if they are above 0 it seems as if they are very big.
What have I done wrong?
Thanks,
Slin