Correct way to handle 2D indexing in 3D scene (DirectX)

I need to do the following:

The two 2D squares look as if they were stacked on top of each other (like two halves of the same texture), but are actually separated by the z-axis by n coordinates. So if a 3D object passes between them, one half appears in front of the object and the other half appears behind.

Can I achieve this by applying orthographic projection to two quads and then normal perspective to the rest of the 3D data? Will this lose depth data?

I hope my example is not too deceiving!

0


source to share


1 answer


The simple answer is yes, if you have z entry enabled when rendering your quads. Your z data will never be discarded unless you explicitly do so.

Getting orthogonal depths to play well with projection depths can be tricky. (I've never tried it, but I think it won't line up well). In this case, it would be better to do one of the following:



  • Display all geometry in perspective view
  • Display all geometry in full view
  • Render orthogonal geometry in un-z-checked sorted layers (back to front), rendering perspective geometry in between.

I am assuming you already know the cons of the first two methods, so it is up to you if applicable. I think the third method is the most traditional.

+1


source







All Articles