Replies: 1 comment 1 reply
-
DepthStencilState: First, what is the depth buffer? When you render e.g. a triangle, it's vertices are transformed in the vertex shader, then rasterized to pixels in the pixel/fragment shader. Usually, between vertex and pixel/fragment shader, the depth buffer is used to decide if a pixel/fragment is already overlapped by another pixel (in depth) and thus may not be processed by the pixel/fragment shader. This way, 3D objects also are depth sorted correctly (on a per pixel/fragment basis, not on a per object basis).
In the context of 2D, you can avoid needing a depth buffer by controlling the drawing order of things exactly as you wish as 2D is often more akin to layers of paper on top of each other. RasterizerState: To improve rendering speed, one technique is to only draw (or rasterize) triangles which are considered pointing 'towards' the camera. For that, the concept of winding order of the triangle's vertices is used, clockwise or counter-clockwise. You can now decide, if one or the other is considered pointing towards the camera or if it is ignored entirely, hence
In the context of 2D, this is most of the time RasterizerState.CullNone. |
Beta Was this translation helpful? Give feedback.
-
Hello, I'm new to monogame v3.8.1
I don't understand how the "DepthStencilState" and "RasterizerState" works in SpriteBatch.Begin()
I would like visual examples to better understand how they can affect my objects on the screen.
I tried searching the documentation at https://monogame.net/documentation/ but apparently the site is down
Beta Was this translation helpful? Give feedback.
All reactions