[Solved] Weird small bug. Sampler State maybe?

Hi guys,

I have a rather strange problem. When i’m debugging I have it so I can press tab to see all my render targets for various things. depth, shadow map levels etc which is all fine. BUT for some reason rendering the render target for the depth map using a debugging SpriteBatch with these lines:

  _debugSB.Begin(SpriteSortMode.Immediate, BlendState.Opaque, SamplerState.PointClamp,  DepthStencilState.DepthRead, null, debugshadowRTeffect);
  _debugSB.Draw(depthRT, new Rectangle(900, 0, 300, 150), Color.White);
  _debugSB.End();

causes some of the shadows to disappear in the game itself. They reappear again when I stop showing the depth render target but I can’t work out what’s changing. The shadows are fine for most models but not some of the ones that have some areas of transparency in their textures. But not all models, most are fine. I’m a bit stumped. It’s such a simple shader:

texture ScreenTexture;  

SamplerState TextureSampler = sampler_state
{
    Texture = <ScreenTexture>;
};

float contrast = 10.0f;

float4 PixelShaderFunction(float4 position : SV_Position, float4 color : COLOR0, float2 texCoord : TEXCOORD0) : 
SV_TARGET0
{
float4 tex = tex2D(TextureSampler, texCoord);

tex = pow(tex, contrast);

return tex;
}

technique
{
    pass P0
    {
    PixelShader = compile ps_4_0 PixelShaderFunction();
    }
}

Any ideas? Seems like something is getting fudged and needs resetting afterwards. It’s not screwing up the depth buffer completely or anything because most of the shadows etc are still working fine.

If i render my render targets using the built-in/default shadow everything is fine.

Thanks

Edit: RasterizerState.CullNone was needed rather than just “null” in the SpriteBatch.Begin command because this seemed to be leaving Rasterization state as default. I had assumed that passing in null would leave it was before.