When the shields were all one piece they interacted badly with other semi transparent objects (like engine thrust exhaust particles); the old “there is no consistent order for intersecting transparent objects” problem. So I cut my shield into octants to give a better chance for correct ordering. This broadly sorted the problem (and the remaining issues actually look like shield distortion so arguably not a problem at all).
However, I want to create some shader based impact effects on these shields.
That means I need to turn off face culling so you can see the shield’s opposite sides (so you can see these impact effects when they occur on the far side of the shield)
But if I turn off face culling I get triangle sorting issues between parts of the shield itself at certain angles
I could try cutting the shield into more pieces but I think I will always have these problems. So I wanted to ask if anyone had any suggestions for this sort of semi transparent shield effect.
I understand the problem (transparency sorting and there being no right sort order) but I’m less sure what people normally do about this; do I just leave face culling on and accept that I can’t see the shield through itself.
Shields may be another case where BlendMode.AlphaAdditive is ok… then all of your issues disappear magically by turning off depth write (though it will create one new one if you ever want things to intersect with the shields.)
Else you might play with writing a custom shader that uses screen door techniques. (Fully opaque pixels but don’t draw every one… discard all fragments where screen x % 2 == screen y % 2 for example. [should be a checkerboard])
…though in that case, the far shields will be obscured by the near shields but I bring it up because it is a very effective technique.
If it were me… for glowing shields, I’d try AlphaAdditive because then sort order doesn’t matter.
Very cool! I had read elsewhere about AlphaAdditive and had tried it but didn’t realise it needed to be combined with shieldMaterial.getAdditionalRenderState().setDepthWrite(false);. Yes all my issues did disappear magically!
That is a useful source of ideas, thanks! I’ve implemented a more subtle version of the edge highlighting and it has made the shield look a lot less flat!