Render mesh between sprites using sorting layers
Hello!
My isometric game consists mostly of sprites which are all on the X-Z plane, all sorted by sortingOrder.
Now I want to render an 3D object between those sprites, and assign that mesh an rendering order so it renders before and behind some sprites. Example:
For that I have an script that exposes the sorting layer and sorting order of meshes.
Now there are 2 ways, but each have a dealbreaking problem:
a) I set the Material to Unlit->Transparent, which makes me able to change the sortingOrder, but the mesh itself "draws behind itself" as can be seen here ->
b) I set the Material to Unlit->Texture, which renders it correctly, however changing the sortingOrder has no effect anymore and it gets rendered depending if it's in front or behind the sprites in World Position as can be seen here -> https://gyazo.com/33a7f6661c6e2499b164d9c42b3a1268
I need the mesh and texture to render correctly, but then get correctly sorted in the SortingLayers. And I'm really running into a wall here, because I don't know enough of the renderpipeline to find a solution.
Which shader? I've tried a mixture of ZWrite and ZTest on and off and all are giving similar outcomes like A or B.
I have the same problem. Did you find a way to achieve this ? An alternative could be to render the mesh in a RenderTexture then applying it to a sorting-ordered quad. But getting transparency on RenderTextures seems to be tricky.
Sadly, no, I didn't find any solutions. Everything that was available on the net did not satisfy the requirements I needed. I ended up scrapping the idea and using something else.
Your answer
Follow this Question
Related Questions
Only render mesh over other mesh 1 Answer
My game develops strange artifacts on sprites when running on certain devices 0 Answers
Control and Render massive sprites in a single Gameobject 0 Answers
How do I render Particlesystems in front of 2D sprites? 2 Answers
Pre rendered game (Resident evil Final Fantasy etc) 0 Answers