Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by ThePilgrim · Apr 03, 2015 at 03:23 PM · shaderocclusionrenderqueuedepthmask

Why does this cube occlude this sphere? (with pictures)

In front, I have a plane with the depth mask shader, which sets the render queue value to Geometry+10 (2010). This shader makes the plane not change any pixels, but still write to the depth buffer.

Behind the plane, I have a with the SetRenderQueue script attached (from the link above), and set its render queue value to 2020.

Behind the cube and slightly off center, I have a sphere with just the default material, giving it a render queue value of 2000.

Here is a picture of the scene

Here is a picture of the results through the camera

Why is the cube occluding the sphere?

Even though the cube is in front of the sphere, I didn't expect it to occlude it. Here is why:

  • I expected the sphere was drawn first since it has the lowest render queue value.

  • Next, the plane is drawn since it has a queue value of 2010. It doesn't change the already drawn sphere, but it does write new values to the depth buffer.

  • Last, it's the cube's turn who has a queue value of 2020. However, since the plane is closer to the camera than the cube is, and it wrote to the depth buffer, the cube should be completely occluded.

Everything seems to be as I expect, except for the fact that the cube is occluding the sphere. Why is this?

It might also be helpful to note that if I change the render queue value of the cube to above 2500, everything works exactly as I originally expected it to - the cube is completely occluded and the sphere is completely visible.

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
Best Answer

Answer by maccabbe · Apr 03, 2015 at 05:27 PM

This is because there is a culling depth test which happens before the fragments are actually drawn that stops anything behind the cube from being drawn in the first place. You need to turn ZWrite off in the cube's shader if you expect things behind the cube to be drawn.

http://docs.unity3d.com/Manual/SL-CullAndDepth.html

Comment
Add comment · 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

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

2 People are following this question.

avatar image avatar image

Related Questions

How to change terrain shader 0 Answers

Render sprite only on top of a specific sorting layer 1 Answer

Material that punches transparent hole in camera's view? 0 Answers

How to Set Custom UI Image Material Render Order? 0 Answers

Render mesh in front of another mesh but not in general 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