Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by fo_fo · Jan 03, 2019 at 12:36 PM · graphicsrenderqueuedrawcall

Why the opaque is rendered not in the order of front to back?

Why the opaque is rendered not in the order of front to back? Underside is screenshot of my test scene. alt text

There are 3 cubes in the scene(red cube is scaled). Their names are 1,3,2 from right to left. And the camera is in the far right. Two green cubes have the same material, the red cub has another one. The only difference of two materials is color. And their shader is Standard. At first, I put the red cube is near to right green cube. The render order is fully from front to back (i.e. 1-3-2). Then i drag the red cube to left to let it more close to left green cube. see the screenshot alt text

Now the render order becomes not fully from front to back. It becomes right green cube is first, left green cube is secone, middle red cube is last (i.e. 1-2-3). I dont know why unity sort gameobjects in this way.

More strange things is if I replace the red cubes material with the green cubes material, letting the three cubes have a same material, the render order become fully from front to back. I really dont know the reason. Hoping someone can tell me.

111.png (110.4 kB)
222.png (96.1 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Bunny83 · Jan 03, 2019 at 04:38 PM

Opaque geometry is generally rendered from front to back to avoid unnecessariy overdraw which consumes fillrate. Since opaque objects are opaque you can't see through them. So rendering the closest objects first you will ensure that overlapping fragments can be discarded early by the z-test.


Transparent geometry generally has to be drawn back to front since each triangle depends on what's behind the object. You can't render an object behind an already rendered object. When a triangle is rendered it can only be mixed with what is already on screen based on the used shader. When you render transparent objects in the wrong order the resulting color would be wrong.


When you set a custom render order (based on the fundamental render groups) you just force rendering of a certain material before another. However all opaque objects with the same material are always rendered front to back while transparent objects with the same material are always rendered back to front. Though keep in mind that Unity only sorts the objects based on their pivot positions. There are many transparency sorting situations that can't be handled automatically or would be extremely difficult to pull off.


Finally you should keep in mind that a single object that is rendered with a transparent shader that has self overlapping triangles can be have strange. Transparent shaders usually do not write into the depth buffer, but they perform depth testing. Since the individual triangles of an object are rendered in the order they are specified in the mesh, the order in which 2 overlapping triangles are rendered can't be sorted properly. If the object is very tranclucent this usually can barely be noticed. However if they are almost opaque a triangle further away could be rendered in front of a closer one. Transparency generally gives you the most problems. Opaque geometry usually can be rendered in any order you like. The only difference is the performance hit due to overdraw.


edit
I forgot another important thing: Batching. Batching can also mess with the rendering order. So the green cubes (since they use the same material) could be dynamically batch into a single object to reduce drawcalls / setpass calls.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image TreyH · Jan 03, 2019 at 07:49 PM 0
Share

informative, ty.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

113 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Problem with rendering? 0 Answers

Strange Render Order Issue 0 Answers

Rendering Order 4 Answers

Sprite behind semi transparent mesh 0 Answers

What is the expected behaviour of Dynamic Batching? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges