- Home /
Manually z-sorting opaque geometry
I need to control the order in which some opaque geometry is rendered, such that two objects can occupy more or less the same space, but one object will always be rendered over top of the other. The RenderQueue tag in my shaders is working fine with transparent objects, but not with opaque objects; I need transparent objects in a higher renderqueue to be able to render over opaque objects and visi versa.
it's also worth mentioning that the opaque objects are often characters that need to occlude themselves (such as a character's arm over it's body), so simply setting ZWrite Off isn't a solution :(
Is there a solution for this? I'm currently doing it with multiple camera passes, but the extra RenderTextures involved is a waste of memory, and is hurting my performance.
Answer by hypnoslave · Mar 10, 2014 at 02:03 AM
I've got a solution, for anyone who finds this question. Not sure if it's a fix in all cases, but it looks okay so far. I'm adjusting the "offset" value of my shader, as shown here:
https://www.youtube.com/watch?v=MlLvQxZv3h4
Since my game is a side scroller, I'm using Offset -100,-100 for a start and will adjust as needed.
Looks like there may be some question as to the support of this Offset value on other platforms. I'm still looking into a solution.
Your answer
Follow this Question
Related Questions
Fresnel shader and mixed textures 0 Answers
Basic gradient vert shader weirdness with 2+ objects 1 Answer
Dynamic batching breaks with the material Mobile/Alpha Blended. 0 Answers
Shader errors in Windows build ( renders black ) but not in Editor 2 Answers
Accidentally assigned shader to default sprite material, how to revert it back to Sprites/Default? 0 Answers