I’ve just about got my engine converted from XNA to Monogame with a few headaches.
Shadows don’t work and animation is broken too (models just don’t appear for some reason i can’t fathom).
My engine uses deferred lighting which seems to be working nicely but for somer reason my debug shadowmap render target and depth buffers don’t contain anything sensible or there’s some new way of displaying them in Monogame.
Currently my depthmap and shadowmap targets (multiple due to cascaded shadow mapping) are defined as:
shadowHQRT = new RenderTarget2D(GraphicsDevice, 4096, 4096, false, SurfaceFormat.Single, DepthFormat.Depth24);
And I render my little debug boxes (so i can visualize the depthRT and ShadowRTs) with:
_debugSB.Begin(SpriteSortMode.Immediate, BlendState.Opaque, SamplerState.PointClamp, DepthStencilState.DepthRead, RasterizerState.CullNone, debugshadowRTeffect); _debugSB.Draw(shadowHQRT, new Rectangle(1200, 300, 300, 150), Color.White); _debugSB.End();
The shadow used for SpriteBath is just:
uniform extern texture ScreenTexture;
sampler screen = sampler_state
Texture = ;
float4 PixelShaderFunction(float2 inCoord: TEXCOORD0) : COLOR
float4 color = tex2D(screen, inCoord);
color.rgb = (color.r+color.g+color.b)/3.0f;
//color = pow(color, 30.0f);
PixelShader = compile ps_4_0 PixelShaderFunction();
My depthRT just renders as a grey square.