Hello,
This is a follow-up question to the issue that I was having a few days ago (thank you guys again^^):
What I would like to do now is to add transparency to a 3D-Model that is enclosing a 2D-Sprite (which is also partly transparent).
I have reduced the issue as much as possible:
First, I´m drawing a ring-like 3D-Model (image 2) and then a sprite (image 1) with a depth that sets it in the middle (depth-wise) of the ring. As long as the Modell is entirely without transparency, everything looks fine (image 3).
In both drawing-operations, I use:
Game1.graphicsDevice.DepthStencilState = DepthStencilState.Default;
So the depth-handling is accurate.
However, if I reduce the transparency of the ring, the lower transparency is also applied to the sprite (Image 4).
Switching the drawing-order (first Sprite then Model) only turns the problem around and applies the transparency of the sprite to certain parts of the Modell (Image 5).
I think the core-problem is that the 3D-Model is simultaneously in front and behind the Sprite, because otherwise I could solve the issue by modifying the draw-order or/and the DepthStencilState like I have seen in other solution online.
So one solution would be if it was possible to only draw the front- and back-halve of the Model (depth-wise) individually. The Model is continuously rotating, so I cannot just cut the Model into two (e.g. in Blender) and render it as two models. The “cutting” has to happen at runtime.
I tried something similar in my first question by playing around with the far- and near-planes of the orthographic projection-Matrix, but I read here and in other places that this leads to a bunch of other problems… However, this does not seem to be a very elegant approach anyways.