Working on cascaded variance shadow mapping for my game.
It works except MipMap functionality doesn’t seem to work for the RenderTarget2D into which I drew my shadows. I tested this by rendering the RenderTarget2D with a simple isolated shader that draws the first mip level. The screen appears black. If I draw mip level zero, I see the exact shadow map.
I found this old bug when I was looking for answers:
https://github.com/mono/MonoGame/issues/1001.
https://monogame.codeplex.com/discussions/440282
These are pretty old. Is this still the case? Do I need a hack or something to enable mipmapping? BTW, this is Windows platform with the Windows8 environment variable, so I’m using DirectX11
Here’s my RenderTarget2D definition. I’ve tried tweaking quite a few parameters:
ShadowMap = new RenderTarget2D(GraphicsDevice,
ShadowMapSize * NumSplits,
ShadowMapSize,
true,
SurfaceFormat.Vector2,
DepthFormat.Depth24);
Here’s my simple shader:
Texture2D TestTex;
SamplerState DiffuseSampler
{
Filter = MIN_MAG_MIP_LINEAR;
AddressU = Clamp;
AddressV = Clamp;
};
float4 ps_pixelshader(float4 pos : SV_POSITION, float4 color1 : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0
{
return TestTex.SampleLevel(DiffuseSampler, texCoord, 1);
}
technique TestShader
{
pass Pass1
{
PixelShader = compile ps_4_0 ps_pixelshader();
}
}