orthographic camera rendering order?

I am trying to render some quads using a mesh with a spritesheet as texture (the reason I use a mesh is that I’m basically drawing a ton of static stuff on the game map that have no behavior; in other contexts the same spritesheet is used with a SpriteRenderer, animation, etc).
The sprites on the sheet have transparent pixels, and the quads for the sprites overlap (the spritesheet has gear options for equipping the characters, so I would draw a head, the draw a helmet on top, etc).

I have an orthographic camera pointing down the Y axis.
The issue is that when I try to layer the sprites using a mesh, with e.g. a quad for head at Y = 10 and a quad for helmet at Y = 20 (or 200), the orthographic camera seems to ignore Y. I can see in scene view that the helmet quad is “above” the head quad with respect to the camera, and yet the camera renders the head over the helmet; the defining factor seems to be the order in the vertex/triangle/uv arrays of the mesh - whatever quads are added later to the arrays (i.e. are at higher indices), gets rendered on top, regardless of Y…
Why is that?

Unity draws things a few different ways, regardless of ortho vs perspective.

The default 3D Renderers draw stuff according to Z depth - distance from camera.

Sprites draw according to Sorting Layer and Sorting Depth (properties of the Sprite Renderer)

UI Canvas Renderers draw in linear sequence, as if you were pasting papers atop each other

When you mix and match you can get these issues. There are workarounds for all combinations. Google up mixing sprites with 3D objects, and mixing 3D objects with UIs.

How to display TextMeshPro text (not UI) over 2D sprite?
Sprite objects rendering on top of UI elements.
Sprite vs UI for character customization/selection and prefab
Why my leantween animation works in Unity editor but not on my Android device
2D Character has no depth
2D Sprite Appearing Through 3D Objects in URP
Sprite shape for UI
3D Model Being "Culled" by 2D Background Layer
some Sprites not displaying
Positioning assets in editor - textmeshpro
How to draw text on top of one sprite and below another sprite?
Sprites vs Images
I can't figure out how to handle front and behind layering with a tilemap
Sprites with different Z positions still gets mixed up while rendering game
World position UI and Perspective Camera
How can I get a mesh renderer sprite to display over a sprite renderer sprite?
2d object goes behind background when applying a material
How to set sprite rendering order for a card game
Images on 2D project
TextMeshPro&Button in a Panel is behind Images from another panel
Props Help
Sprite lit shaders are going black after exporting to android (945657)
Creating Triangulation Mesh from Line Renderer Shape
Particle trails wont render behind sprite.
Render sprite over a render texture
All objects have moved out on coordinate Z
Problem with position Prefab
2D Line Renderer z position problem
Weird thing happening with sorting layers
How to build a accurate sorting order in ECS?
UI or not UI
How do I fix crossed sprites
Help with sort layers
Prevent UI text showing through images.
UI and Particle
UI sprite renderer behind background?
Why can't we set a custom Sprite Sort Point ?
My enemy boss goes Invisible
Keep object, attached to parent Camera, visible in front of canvas
How to do 2D like VFX sorting?
Enemy dash, aoe, danger zone
How do i make an object render in front of another for a lock on target
Fixing Rendering Behind/Below/Above/In-Front for Pseudo-2D Top Down Platforming
Graphical intersection of 2 perpendicular sprites.
Player always on top because of nested gameobjects
The sorting layer in the middle appears as first
Particle System is spawning but not visible
LineRenderer sorting order / layer problem - Can LineRenderers be layered in between UI elements?
Sprite transparency stencil rendering backwards
Why does the button in front of the background disappear?
How correctly Rendering a 2D Game with Tiles and Free Gameobjects?
Use tilemap as mask for sprite
Planes disappearing in-game and scene
Render 2d Line renderer behind UI Buttons
How to make Objects with a Canvas component hidden outside of a scroll panel?
Bullet travels behind weapon
Object & UI Ordering & Sorting in 3D Space
Rendering a mesh properly amongst other sprite renderers?
Camera shake using cinemachine is changing the layers of overlapping objects. (2d)
UI is covering my Sprite
Same mesh showing vertices at farther depth
Adding text(mesh/pro) to sprite
Add TextMeshPro text to Sprite Screenshot
Wrong RenderOrder with WorldSpace-Canvas and Sprites in Prefab Mode
My sprite is invisible on the backgroud
Particles don't show up above anything
How can I fix sorting issues with multi-page atlases?
How can I add a text centered inside a square Sprite?
How do I move the center of an image?
Handling Image and Sprite Layers
Best way managing panels
line renderer below background even with higher order in layer
Advanced Z-ordering hell
top down player going in front and behind walls
can't get sorting layers to work the way i need.
Visual Bugs After Version Change in Android Builds
How to get one canvas(Screen Space Overlay) behind another canvas (Screen space camera)
Draw hundreds of identical sprites with sorting
Is there a way to create a Ultima online Game size window?
2D Isometric Player Behind Grid Tiles
Layers in sprite skin ( adding a sprite between the layers of a skinned sprite)
Quick Outline asset — how to ensure outline is at correct "depth"?
Rendering of a 2D Grid
how to change position of parent OR UI priority
layer ordering 2d and 3d
Sprites and Particles are not ordering properly
Can't get a line renderer to work on my canvas
Move object slightly back (2D Game) in its local axis
2D Animation's Sprite Skin and Object's Z Position problem
Is there a way to make a sprite be drawn in front of 3D geometry?
Occluding GameObjects in a specific layer, but being transparent to others
How to object behind an instantiated object
Dragged objects do not display at correct depth.
Have layer order a sprite over a meshrenderer.
2.5D Layering Issue
How do you put a background only visible from the back of a Canvas in 3D space ?
Sorting Group not sorting properly?
Add text to overlay unit sprite?
Line Renderer Layering
Apply lighting to sprite in 3D space?
Image and canvas with Health Bars
AimLine only sometimes rendering.
Can I make the Canvas transparent
URP standard SpriteRenderer sorting problem
Sprites Rendering above transparent unlit surfaces
How to fix the bug with the tiles?
UI, sorting multiple objects based on height, efficiently?
Sorting layers doesnt work
Are sprites which player never see a good idea?
Line renderer not visible at certain angles?
What is the best way to add text to UI elements that may overlap
Unity cinemachine tileset and 2d sprites flicking and tearing
Draw child above parent regardless of anything in 2D game
SpriteRenderer().sprite error when compiling to Windows - Unity 6 (6000.0.35f1)
What is the order of hierarchy for the layers in a Canvas GameObject?
LineRenderer ignoring Sorting Layers in 2D
The front and back occlusion relationship of multiple objects in a top-down perspective game
Open/Close sign with text
Showing gameobjects on top of UI, but bottom of dialog UI. What is best approach?
Possible Sprite Renderer / TextMeshPro or Mesh Renderer Conflict
Android sudden Rendering issue after change of Unity Version
Sprite and mesh render order different on Android
Sorting layer breaks the sorting
How do I sort the child GameObjects of two sorting groups

Are you using multiple cameras?, if so check out the depth of your camera to draw above other, also if you’re using orthographic projection be aware of camera pos z to be lower than object you want to render

1 Like