- Home /
shader/layer overlapping problem
Hello Unity Answers Community.
I've got the following problem: My current Project is a 2D side scrolling game that uses the parallax effect with some Planes as Layers in the Background. The Problem is that they are overlapping at some times whats an very odd behaviour. I just have no clue how to fix this.
Ive attached also some screens so it might be clearer whats my problem. I tried also different spaces between the planes in the background without any success.
http://s7.directupload.net/file/d/2407/xpq8pz43_jpg.htm
http://s13.directupload.net/file/d/2407/exnrfqqw_jpg.htm
Some tips here as well ... http://answers.unity3d.com/questions/707/rendering-order
Answer by Jessy · Jan 17, 2011 at 06:34 PM
It's easy to fix this, because they're flat an in the same plane. Put the ones you want in front in a later queue. You don't need need to worry about positioning them in the Z axis (as long as your shader uses ZWrite Off, which is typical).
http://unity3d.com/support/documentation/ScriptReference/Material-renderQueue.html
There really is no thing as transparency. Instead, meshes just blend their colors into what's already been rendered. So, you have to ensure that the rendering occurs in the proper order, or weird-looking things happens. I talk about the problem near the end of this video.
how should I set up the script? I'm new to scripting and have no clue how to write that script. As far as I understand there are predefined classes like # Background # Geometry # Transparent and # Overlay but I can also define custom ones in between. So should I write a script with those new render queques i want to have or should I edit/add the specific tags to the shaders I use?
I specifically linked to that documentation page, because you don't need to worry about editing shaders for this. The shaders you're using are probably in the Transparent queue, which as the docs say, is 3000. You could base your new values off of that, but you might get better performance using values between 2001-2499. Those queues are not sorted by depth, so they yield possibly better performance; you'd have to test.
Your answer
Follow this Question
Related Questions
Layer Dependent Reflections 1 Answer
Pages overlapping problem 1 Answer
MeshRenderer with GUI/Text Shader is always in front of my 3D objects, how do I fix this? 0 Answers
[2D]X-Ray Sprites 0 Answers
Writing Parallax Terrain shader 0 Answers