Hi,
So currently i am rendering a sprite behind a tilemap layer using the depth buffer(as suggested here).
The problem i am facing is that the tiles that should have transparent pixels are not rendered correctly when another sprite is drawn behind it.
Here is an example:
(The statues and rock pile are all part of the same tilemap layer. When drawing loose sprites with the depth buffer it works fine)
And this is the code that is used to draw the layer and sprite:
_spriteBatch.Begin(samplerState: SamplerState.PointClamp, depthStencilState: DepthStencilState.Default, transformMatrix: Camera.GetViewMatrix());
_motwSprite.Depth = 0.3f;
_spriteBatch.Draw(_motwSprite, _motwPosition);
foreach (TiledMapTileLayer layer in tiledMap.TileLayers)
{
if (layer.Name == "Layer 2")
{
tiledMapRenderer.Draw(layer, viewMatrix: Camera.GetViewMatrix(), null, null, 0.2f);
}
}
_spriteBatch.End();
I know painters algorithm is also an option, but for my use case i want to provide the depth value dynamically so the players depth is based on Y value.
I read all over the monogame forums but cant seem to find a solution to this problem, any help is greatly appreciated.
-Thanks