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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by Lexoka · Apr 30, 2013 at 03:50 PM · transparencytransparentcullingdepthsort

Objects behind transparent objects (sometimes) not drawn.

Hi,

I have a couple of non-convex, intersecting transparent objects. I was having problems with the rendering order, which I understand is due to the fact that Unity only sorts transparent objects on a per-object basis.

So I decided to use the "Transparent/Diffuse ZWrite" shader described in ShaderLabs, which enables the ZBuffer / Depth Buffer on a first pass: http://docs.unity3d.com/Documentation/Components/SL-CullAndDepth.html

 Shader "Transparent/Diffuse ZWrite" {
 Properties {
     _Color ("Main Color", Color) = (1,1,1,1)
     _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
 }
 SubShader {
     Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
     LOD 200
 
     // extra pass that renders to depth buffer only
     Pass {
         ZWrite On
         ColorMask 0
     }
 
     // paste in forward rendering passes from Transparent/Diffuse
     UsePass "Transparent/Diffuse/FORWARD"
 }
 Fallback "Transparent/VertexLit"
 }

Now that did solve my rendering order problem, but it introduced a new one:

Sometimes, depending on the positions of the objects, the parts of object A that are behind parts of object B are just not drawn. And vice-versa. I also have particles in there, behind the transparent objects, and they behave the exact same way: sometimes being drawn, sometimes not (they appear/disappear simultaneously with object B).

Note that the basic Transparent/Diffuse shader did not seem to have this problem. Definitely not with the particles.

I get the feeling that this is something simple, like Unity figuring "OK, this object is hidden, I don't need to draw it". But it's only partially hidden, and for some sets of positions, the engine actually gets it right. Some kind of culling, perhaps?

Any clues?

Comment
Add comment · Show 9
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 whydoidoit · Apr 30, 2013 at 04:07 PM 1
Share

Actually I pretty sure you're screwed on that. All my self transparent shaders have vertex colours to put them in different passes.

avatar image Lexoka · Apr 30, 2013 at 11:27 PM 0
Share

And does that help? Sorry if that's a silly question, I'm very new to shaders (and Unity, for that matter).

In this instance I'm more worried about rendering something that's correct than about rendering it fast, so I'll take any solution, even a costly one.

avatar image whydoidoit · May 01, 2013 at 04:50 AM 1
Share

Well if you want to have something be transparent over itself, you pretty much have to separate it into different passes and control the ordering. That can be done in a shader, but it pretty much only works for effects like windows, wind shields etc. It does also work for things which are effectively surrounding each other (so bone, muscle, skin etc in something where those become transparent to see inside).

There's a non-perfect approach using Cut Out shaders too, but without depth sorted triangles in the graphics hardware: self transparency is a problem.

avatar image whydoidoit · May 01, 2013 at 04:51 AM 0
Share

And I'm really hoping someone proves me wrong :)

avatar image Lexoka · May 01, 2013 at 09:25 AM 0
Share

Ah, I see, but in order to do that, I would have to know beforehand what parts of the object are behind other parts, which would be difficult in this case.

I was under the impression that "ZWrite On" forced triangle depth sorting, (and it does help) but since it's not working quite as I hoped, I guess not. Is there really no way to force it?

Thank you for your help.

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

13 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

Related Questions

Adding Materials to an object. 1 Answer

Occlusion, hiding an object within a transparent box. 0 Answers

What's the best way to animate a transparent image descending over a circular image? 0 Answers

Rendering an entire object as transparent 1 Answer

Text Mesh - Ignores Backface culling & Depth Test? 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