Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

"transparent bumped diffuse" z index problem

Discussion in 'Editor & General Support' started by asger, Sep 8, 2008.

  1. asger

    asger

    Joined:
    Apr 6, 2006
    Posts:
    38
    Hello forum
    I'm having a problem when using transparent images as plane textures. It seems like Unity can't handle the z-index of the planes when they they are masked, sometime the ones in the back jump to the front and vice versa.
    I can make the problem go away if I use the "cutout transparent" shader, but then the edges aren't antialiased and that is a shame.

    Is there a way to get this problem solved?
     
  2. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
  3. asger

    asger

    Joined:
    Apr 6, 2006
    Posts:
    38
    Thanks for your reply. I read your link, but I'm not sure that I understand it all completely.. Just to sum it up:
    It is not possible to have overlapping planes that use transparent shaders and have them render correctly?
     
  4. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    It really depends... right out of the box overlapping semi-transparent objects will always have sorting issues.

    However, if, you're only using semi-transparent geometry for static elements like windows, water, etc, it is possible to manually force the sorting of these objects by making custom shaders that manipulate the rendering queue.

    For instance:
    Code (csharp):
    1. Tags {"Queue"="Transparent"}
    Will render before:
    Code (csharp):
    1. Tags {"Queue"="Transparent + 1"}
    So it's possible to manually sort the objects if you know that object A will always be in front of object B. I did a bit of this for the sewer demo on Unity's example page if you want to see an example of this.

    Ethan
     
  5. asger

    asger

    Joined:
    Apr 6, 2006
    Posts:
    38
    hi thanks again.
    I have looked at the sewer project, but I'm not sure where it is that you set the z-index. Is it done in script or in the editor?
     
  6. Marc

    Marc

    Joined:
    Oct 4, 2007
    Posts:
    499
    Look at the shader used on the transparent objects, some of them are not the same i would reckon.
     
  7. asger

    asger

    Joined:
    Apr 6, 2006
    Posts:
    38
    ok I think i got it.. I need to make my own shader which has the code
    Code (csharp):
    1. Tags { "Queue" = "Geometry+1" }
     
  8. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
  9. asger

    asger

    Joined:
    Apr 6, 2006
    Posts:
    38
    it seems like I'm only able to make a cutout transparent shader, and then I'm back to where I started. How can I make a transparent shader with antialiased edges? Can you maybe point me in the right direction?
     
  10. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    Post a picture of what you mean because I think we're starting to talk about 2 separate issues :wink:

    Have you tried the Vegetation 2 Pass Shader? This does a cutout pass and then a transparent pass to "soften" the edges.
     
  11. asger

    asger

    Joined:
    Apr 6, 2006
    Posts:
    38
    yes the vegetation shader was actually what I was after. I modified it a little so I can force the z-index and it looks really good.
    But it seem like my new shader doesn't handle lightning the same way as the old (transparent diffuse)..
    It would be nice to be able to open that shader so I could see the difference, but unfortunately it doesn't seem to be anywhere on my computer.
     
  12. asger

    asger

    Joined:
    Apr 6, 2006
    Posts:
    38