Search Unity

Transparent water problem

Discussion in 'Shaders' started by User340, Aug 20, 2007.

  1. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    I'm using this shader for my water. It is a transparent water shader. Whenever there are particles over it, it seems like the particles are more transparent than they are when they're over any other texture. Is it a bug in the shader?

    In this picture all of the particles are in front of the water
     

    Attached Files:

  2. MetroidHunter

    MetroidHunter

    Joined:
    May 22, 2007
    Posts:
    213
    I'm With Him. :(
     
  3. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    This is the classic "it's hard to render transparent objects correctly" problem. Unity sorts transparent objects (in your case, both water and particles are) by distance from the camera to the object center, and then renders them back to front. This is all ok if that produces the correct sorting. However, because water is quite large, it's center might be about anywhere, so it might happen that particles are drawn before the water (while they should be drawn after it).

    Possible solutions would be: try changing the particle shader; make it use the "Overlay" render queue. This way they will be always drawn after water (which is using the "Transparent" render queue).
     
  4. AaronC

    AaronC

    Joined:
    Mar 6, 2006
    Posts:
    3,552
    I wonder if rendering to multple cameras would work in this scenario? Merely a suggestion...
    AC
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Another solution which has been mentioned a few times is to add a bit of geometry to the water to force the center to be more distant from the camera. This works quite well.

    --Eric
     
  6. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    Thanks Aras, I checked the water shader and it's "Queue" = "Overlay", i changed the "Overlay" to "Transparent" and now it seems to work properly. :)
     

    Attached Files: