Advertisement

Rendering semi-opaque objects (DirectX 11)

Started by March 02, 2019 11:31 AM
3 comments, last by DexterZ101 5 years, 6 months ago

My understanding is that one way to render transparent objects is to first render all opaque objects and then to render transparent objects back to front with depth write disabled.

Problem I'm having with this is if there are multiple front facing triangles that overlap (from same object or from different objects) but are out of order results end up being incorrect.

Can I somehow fix this without taking a considerable performance hit?

Yeah there's a wide variety of order independent transparency techniques that solve this in the general case, but they're often a bit more expensive...

If you can merge all your materials together (texture atlases, sparse virtual texturing, etc) then you can draw all your objects in a single draw call. If you get yourself into that situation, you can use a compute shader to write the triangles into depth order. That solves a lot of issues, but intersecting triangles are still an issue.

Advertisement
27 minutes ago, Hodgman said:

If you can merge all your materials together (texture atlases, sparse virtual texturing, etc) then you can draw all your objects in a single draw call. If you get yourself into that situation, you can use a compute shader to write the triangles into depth order. That solves a lot of issues, but intersecting triangles are still an issue.

I have no idea how to draw all my objects in a single draw call (different vertex/index buffers, shaders, states, etc.).

27 minutes ago, Hodgman said:

Yeah there's a wide variety of order independent transparency techniques that solve this in the general case, but they're often a bit more expensive...

I'll look into this. I don't have a large amount of these semi-transparent objects (at this point, at least) so I might get away with it.

For polyhedron object with alpha-blend I ended up rendering it twice push it my alphasorteddrawable with different cull mode CCW and CCCW  and distance to camera. imagine a box with alpha-blend and another box inside.

One thing I've noticed if there's an alpha-additive only on the scene I don't need to sort it out, but if there a alpha-blend material object on the scene both alpha-blend and alpha-additive materials should be put on sorted draw list.

For object with many quads like trees I've seen many games overlapping the leaves or grass but not that obvious.

Compute shader to write triangle into the depth order as Hodgman said is interesting ^_^y

This topic is closed to new replies.

Advertisement