Draw pixel only in polygon

Well what im describing is a bit different i think? It would be a real shadow buffer.
You would draw the scene twice clip alpha drawn pixels to get a a rendered z depth in two render targets.
These would be depth samplers for the scene when drawn normally with a pixel shader.

(the cavet is that the normally drawn scene would calculate polar coordinates to get the sampled depth then comparing that to its depth from camera so it would be exactly how you shadow in 3d but in 2d.

The depth would conform to the shape of the sprites themselves Not the corners of polygons that contain them or any generated polygons. Basically in 2d you would be finding edges of whats in the sprites not the sprites polygon.

edit this is the idea.

1 Like

Okay, I get what you mean now. That approach is a lot more complex IMO because now you’re working with 2 different views and have to map stuff from one view to the other and back. It also does not give you a full occluder map, only the distance to the closest occluder from the perspective of the character you rendered the depth map for. You can get the same result by computing it from the vertices of the view polygon.

If you do have sprites with transparent parts or that otherwise can be seen through, I’d recommend manually building the occluder shapes.

My problem is now solved. With the help of Mattlekim.

He kindly give me his library, we used the RenderTarget2D approach :slight_smile:

Thanks you all for your implication in my question :relaxed:

5 Likes

I’d also love to have the same @Mattlekim ‘s library, it’s exactly what I’m looking for, it sounds perfect for my project!