1. We've introduced thread tags, search within a thread and similar thread search. Read more here.
    Dismiss Notice
  2. We've released our first Timeline Experimental Preview, our new tool for creating cutscenes and more! To check it out click here.
    Dismiss Notice
  3. All Unity Pro perpetual license customers: your special offer to subscribe is ready! Click here.
    Dismiss Notice
  4. Unity 5.5 is now released.
    Dismiss Notice
  5. Check out all the fixes for 5.5 in patch releases 1 & 2.
    Dismiss Notice
  6. Unity 5.6 beta is now available for download.
    Dismiss Notice
  7. Get prepared for the Tizen Mobile App Incentive Program! Read more about the upcoming program here.
    Dismiss Notice
  8. Enter the Microsoft Developer Challenge for a chance to win prizes. Read more about it here.
    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
    Messages:
    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
    Messages:
    5,325
  3. asger

    asger

    Joined:
    Apr 6, 2006
    Messages:
    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
    Messages:
    5,325
    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
    Messages:
    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
    Messages:
    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
    Messages:
    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
    Messages:
    5,325
  9. asger

    asger

    Joined:
    Apr 6, 2006
    Messages:
    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
    Messages:
    5,325
    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
    Messages:
    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
    Messages:
    38