   Shader ignoring depth buffer
float4x4 worldViewProj : WorldViewProjection;texture theTexturesampler2D sampTexture =sampler_state{    Texture = <theTexture>;    AddressU = Wrap;    AddressV = Wrap;    MinFilter = Point;    MagFilter = Linear;    MipFilter = Linear;};float3  LightDirView = float3( 1.0f, 0.3f, 1.0f );struct VS_INPUT{   float3 position : POSITION;float3 normal   : NORMAL;float2 Tex  : TEXCOORD0;};struct VS_OUTPUT{    float4 hposition : POSITION;    float4 Diffuse   : COLOR;    float3 normal    : TEXCOORD1;    float2 Tex: TEXCOORD0;};struct PS_OUTPUT{float4 color : COLOR;};VS_OUTPUT myvs( VS_INPUT IN ) {    VS_OUTPUT OUT;    OUT.normal = mul( IN.normal, (float3x3)worldViewProj );OUT.hposition = mul( worldViewProj, float4(IN.position, 1) );   OUT.Diffuse = dot( LightDirView , IN.normal);  OUT.Tex = IN.Tex;return OUT;}PS_OUTPUT myps( VS_OUTPUT IN ) {    PS_OUTPUT OUT;OUT.color = tex2D( sampTexture , IN.Tex ) * IN.Diffuse;    return OUT;}technique Technique0{    pass Pass0    {Lighting = TRUE;ZEnable = TRUE;VertexShader = compile vs_2_0 myvs();PixelShader  = compile ps_2_0 myps();    }}Hi, will writing my shader in run into a problem, the shader is ignoring the depth buffer. backface culling is working and everything renders fine without shader. does anyone have a advise how to fix this?[Edited by - free27 on July 11, 2010 1:26:16 PM]
  Do you compile this as effect and use the effect framework?Have you create your device with a depth buffer?;  I'm not sure if this is related to your problem butOUT.hposition = mul( worldViewProj, float4(IN.position, 1) );isn't that supposed to beOUT.hposition = mul( float4(IN.position, 1), worldViewProj );Try changing this, and as Demirug mentionned, make sure you've actually created a depth buffer.   ;  switching it around gives the same resultsand yes i have a depth buffer, without the shader the rendering works fine.   ;  found out what I did wrong.during some copying around a SetDepthStencilSurface went to the wrong place.so the StencilSurface was set to 0 instead of the StencilSurface buffer.   