#Order Independent Transparency

1 messages · Page 1 of 1 (latest)

late lion
#

I have a lego brick model. It is split into 3 meshes, internals, externals, and studs.

I want to make a transparent material but when I do, the internal mesh renders over the external mesh sometimes.

I have tried double sided, depth write, changing depth test settings, etc. Nothing seems to work.

Depth write does make it render in the right order, but the internal mesh just disappears now.

The problem is that I essentially have a semi-transparent mesh inside of a semi-transparent mesh with a semi-transparent mesh next to it also inside. Which is creating these artifacts.

How can I make my shader/materials handle transparency correctly? I just want to create a semi-translucent material like the translucent lego colours.

dire pewter
#

Transparents sort by pivot/bounding box so not the easiest to sort unless forced. Potentially submeshing can help, forcing a draw order between each transparent material, but I've not really tested that myself.

honest wind
#

An other way to do it, but that kind of requires manual editing of the mesh, is to have all the parts in a single mesh and order the triangles indices of the mesh, to have the inside ones first, to be always drawn first when this mesh is rendered.

There is no out of hte box way in Unity to have real order independent transparency.

faint hamlet
#

Vertex winding order and such workarounds might not be an option because the blocks when attached are interlocking
The stem of top block has to be somehow between the teeth of the bottom block, for example

late lion
late lion
faint hamlet
#

I believe true OIT is the only real way to make it work, but it'd be even more expensive than overdraw which would already be high in this scenario

faint hamlet
late lion
#

But right now it is seeming too hard to get transparent pieces in the first place haha...

It is basically like a transparent object in a transparent chest I guess. Which unless I look into figuring out true OIT, sounds like it may not be possible.

Otherwise I will just have standard/matte colours and metalic colours.

faint hamlet
# late lion But right now it is seeming too hard to get transparent pieces in the first plac...

OIT is possible, but requires a custom implementation and is very expensive
Because there have been a lot of lego games over the years, you might find some hints or even resources that their developers have posted online about how they tackled this issue
Transparency shouldn't necessarily even be your goal, because plastic like that is not really transparent but translucent and refractive
Translucency and refraction also pose challenges but there's perhaps more workarounds for them

molten herald
#

Order independent approximations like Blended Weighted OIT could be a potential solution too. Probably much more efficient though it has a certain visual look to it (the depth only visible through the weights) different from true OIT. Also can't be done in a single shader alone either so not as streamlined as just using a custom shader

faint hamlet
#

If I was tasked with this I'd look into faking the internal refraction using parallax, similar to what ice shaders and fake interiors tend to use
Could be good especially with translucent light in the mix and scene color refraction, but takes some tech artistry
And ultimately the refraction should be strong enough that you really couldn't see the blocks transparently through each other, which would be both a limitation and the goal