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 gameplay4all · Jul 30, 2013 at 10:30 AM · transparencybackgroundtreeleaves

Why do my tree leafs(transparent diffuse textures) take over the color of the background?

Hello,

I made some trees in blender using a basic mesh for the tree trunk and planes with transparent/diffuse materials on them for the leaves. the image is saved in .png .

but when it is getting evening in my game the sunset starts to come(I have made that by using a big orange sphere with 70% transparency, it is not that the leaves start to get behind it because the trunk is still visible ) and the background changes to orange but my leaves also start to become orange when they are far away. when I walk to them they switch back to their original color.

how do i solve this? here is an image: http://tinypic.com/r/54jeau/5

You can see in the background on the right a tree with this problem

Comment
Add comment · Show 4
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 bompi88 · Jul 30, 2013 at 08:09 PM 0
Share

tried to tweek your camera settings?

avatar image perchik · Jul 30, 2013 at 08:26 PM 0
Share

From my experience, transparency in unity is a little bit funky. Sometimes it seems like a transparent object shows up in front of everything, regardless of depth. $$anonymous$$y guess is that's what you're running into

avatar image gameplay4all · Jul 30, 2013 at 08:26 PM 0
Share

how do you mean?

avatar image perchik · Jul 30, 2013 at 08:34 PM 0
Share

Never$$anonymous$$d, I just tested it and that's not a problem anymore. I don't know why I thought that...

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by gameplay4all · Dec 26, 2014 at 01:28 PM

I don't know if people are still visiting this question, but I'm cleaning up my profile so I'm answering my own questions.

The problem just lies with the build-in transparent shader, so I used the cut-out shader and all was looking fine :)

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 unitymic · Jun 02, 2019 at 05:42 PM 0
Share

Thank you, i had the same problem

avatar image
0

Answer by Bunny83 · Jun 02, 2019 at 06:15 PM

Since this question already got bumped I'll post an actual explanation what happens. The issue is the rendering order of objects and that the leaves are drawn "behind" your orange sphere.


The way geometry is rendered has to be seperated into two main categories:

  • opaque geometry

  • transparent geometry


Unity first draws all opaque geometry and usually sorts the objects front-to-back. The front to back ordering minimizes overdraw since a big object close to the camera most likely covers a large portion of the screen. So things drawn further away will fail quickly thanks to the depth buffer.


Transparent geometry is where it gets really tricky. This OpenGL wiki article is always a good start. We need to draw transparent objects back-to-front in order to correctly blend the colors. For this purpose Unity sorts all transparent objects back to front. However it does not sort individual triangles of the objects but always the objects as a whole. The depth sorting is done based on the objects pivot point. So an object that has a pivot further away from the camera is drawn first and those objects which are closer to the camera are drawn last.


As you can read in the article there is no general solution for the sorting issue since even when you would sort individual triangles, 3 triangles could overlap each other in a circular fashion so it's impossible to sort them in a meaningful order. The only (correct) solution would be to split at least one of the triangles into two parts. So the now 4 parts can be sorted correctly as they are no longer circular dependent.


What happened in your case specifically is that your orange sky dome sphere has its pivot more or less in the center of your scene. So if you (the camera) is close to the center, the sphere is "closer" to the camera than the leaves of the tree, even when all the triangles of the sphere are actually much further away. Therefore the leaves are drawn before your sphere and therefore appear behind the sphere. As soon as you get closer to the trees (and further away from the sphere center) the order will switch around and the leaves are drawn correctly after the sphere since now the sphere is further away than the leaves.


Cutout shaders are not transparent shaders. They are actually opaque shaders and are rendered during the opaque pass. Since cutout shaders do not need any kind of blending it's perfectly fine to draw them front to back as the areas that are "cut out" simply aren't written at all into the render buffers.


If you need actual transparency when using such a sky dome, you just have to make sure the sky dome is always rendered before your other transparent objects. This can be done by adjusting the render queue, either of the material of your sphere directly or inside the used shader. If you do

 Tags { "Queue" = "Transparent-1" }

in the sphere's shader it will always be rendered before all other transparent shaders and therefore your leaves would appear on top of it.

If you want to set the materials renderqueue from outside the shader, you should know that the transparent queue is equivalent to a value of 3000. So assigning 2999 to the sphere material renderqueue would have the same effect and ensures it's rendered before any other transparent shaders (at least as long as they don't force their own render queue to be even lower).

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

19 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

Related Questions

Adjust the scale of leaves at Runtime 0 Answers

How can i get background tranparency ? 2 Answers

Linear color space give tree leaves a white shine. 0 Answers

White trees in a dark scene 3 Answers

Tree Creator Shader will not fade 0 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