zbuffer problems?

Started by
2 comments, last by devronious 13 years, 11 months ago
I'm running slimdx and I have a shader that runs. And for some reason the zbuffer is not appearing to work. I have set zenable to true. Is there some inherint problem in slimdx that stops it from performing standard zbuffer testing? So do I need to perform zbuffer testing in my hlsl program?
Advertisement
Firstly make sure zwriteenable and zfunc are also set appropriately.

You don't need to do anything special in the hlsl.
Thanks, I'll check that now.
I think I found the problem. Its in the shader. It calcs on a float4 which is causing trouble with the w coordinate in the vertex. Can anyone help me figure out how to work on only a float3 instead of a float4, I just get errors.

float4x4 wvp;float4x4 w;float4x4 v;float3 eyedir;float3 lightdir;float4 ambient;float4 linecolor;texture tex;sampler samp = sampler_state { texture = (tex); };struct vmI{	float4 p : POSITION0;	float3 n : NORMAL0;	float4 c : COLOR0;	float2 t : TEXCOORD0;};struct vmO{	float4 p : POSITION0;	float3 n : TEXCOORD1;	float4 c : COLOR0;	float2 t : TEXCOORD0;};struct pmI{	float3 n : TEXCOORD1;	float4 c : COLOR0;	float2 t : TEXCOORD0;};vmO VShader(vmI i){	vmO o;			o.p = mul(i.p, wvp);//position		o.n = mul(i.n, w);//mul(i.n0, view);//normal	o.c = i.c;//material diffuse	o.t = i.t;//texture coordinate    return o;}float4 PShader(pmI i) : COLOR{   	//normalize input	float3 ld = normalize(lightdir);	float3 nd = normalize(i.n);	float3 ed = normalize(eyedir);	//calc diffuse component	//float3 ref = ld - nd + nd;	//float4 litpow = dot(ref, ed);	float4 litpow = dot(nd, ld);	float4 spec = litpow;// * i.c;//	spec += ambient;	//return the color composition	float4 o = spec;	o.a = 1;	//float4 s = tex2D(samp, i.t);	//o *= s;	return o;}technique Shader{	pass p0{		//BlendOp=Subtract;		//SrcBlend=ONE;		//DestBlend=DESTCOLOR;    		//CullMode = CCW;		//ZEnable = true;		//ZWriteEnable = true;		//Lighting = true;		VertexShader = compile vs_2_0 VShader();		PixelShader = compile ps_2_0 PShader();	}	}

This topic is closed to new replies.

Advertisement