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 Water

Discussion in 'Shaders' started by bcas, Apr 22, 2010.

  1. bcas

    bcas

    Joined:
    Apr 22, 2010
    Posts:
    1
    Hi,

    This might be a stupid question, but I searched and couldn't find the topic which addresses this issue in a simple manner.

    I want to make transparent water from "simple daylight water" in Unity (not Pro).

    Is it possible?

    Thanks
     
  2. SrBilyon

    SrBilyon

    Joined:
    Jul 13, 2010
    Posts:
    291
    I want to bump this, I'm curious of if this is possible...
     
  3. bgivenb

    bgivenb

    Joined:
    Sep 15, 2010
    Posts:
    449
  4. 7loop7

    7loop7

    Joined:
    Oct 29, 2009
    Posts:
    40
    I gonna have to bump this too... shame on me.
     
  5. 7loop7

    7loop7

    Joined:
    Oct 29, 2009
    Posts:
    40
    well, after some searching...

    http://forum.unity3d.com/threads/2106-Transparent-water-for-indie/page2?highlight=transparent+water

    solution is:
    at line 58-59 of the FX-Water Simple shader, after
    replace
    with
    the transparency value you can change it at the alpha value of the horizon color
     
    ChewyMicha likes this.
  6. TechnicalPirate

    TechnicalPirate

    Joined:
    Feb 3, 2011
    Posts:
    4
    Cheers 7Loop7... your method worked for me.

    Minor syntax change to get it working on Unity 3.2 :)

    replace :
    with
     
    engeen likes this.
  7. afalk

    afalk

    Joined:
    Jun 21, 2010
    Posts:
    164
    Thanks for the tip TP :)
     
  8. eko1892

    eko1892

    Joined:
    Mar 28, 2011
    Posts:
    139
    Hi guys It's been few weeks since I started to use Unity, so I am abit newbiee.. trying to figure out how to make a transparent water using the standard water shader comes with unity 3.2. I have checked the forums to find a decent answer and I have tried every single thing that I have found but I still couldn't figure it out :( When I put the highlighted script in picture-2 all my water effects dissapears for some reason.. most probably I am doing something wrong, so I am putting some 3 screenshots from my current project file and maybe someone could figure out what I am doing wrong. Thanks in advance.

    PIcture-1 (how its look like)
    http://www.box.net/shared/8xv4djcyp8

    Picture-2 (putting transparent script given for unity 3x)
    http://www.box.net/shared/y8s16itcik

    Picture-3 (after putting the transparancy script)
    http://www.box.net/shared/6j1fu628p2
     
  9. eko1892

    eko1892

    Joined:
    Mar 28, 2011
    Posts:
    139
  10. afalk

    afalk

    Joined:
    Jun 21, 2010
    Posts:
    164
    Eko -- just curious what you used that ended up working - can you share your code changes?
     
  11. eko1892

    eko1892

    Joined:
    Mar 28, 2011
    Posts:
    139
    Hello afalk, I have used water pro assets that only comes with Unity Pro. I think that's the only solution atm. I have found package somewhere in the forums while I was searching. However, I can re-upload the example package that I am currently using if you like.
     
  12. afalk

    afalk

    Joined:
    Jun 21, 2010
    Posts:
    164
    Sure - certainly couldn't hurt!
     
    cruisex87 likes this.
  13. eko1892

    eko1892

    Joined:
    Mar 28, 2011
    Posts:
    139
  14. jordo834

    jordo834

    Joined:
    Mar 20, 2011
    Posts:
    61
    i found water3 works great once you change the materials and stuff, it looks better than this
     
    RobDawson likes this.
  15. g2mediagroup

    g2mediagroup

    Joined:
    Jun 25, 2011
    Posts:
    98
  16. Gumpert

    Gumpert

    Joined:
    Dec 30, 2012
    Posts:
    38
    Hi, erm I like used this thing right, and it went funny...
    Ok, I changed the shader and all that, and it works, and my water is translucent, but now when I look through it, My render distance is lowered like. So normally, if I look at some mountain or something thats miles away like, then I can see it, but when I look at something through the water, anything (well, any terrain) that is more that like whats about 100 metres away is completely invisible! What do I need to change in the shader or what to fix this please??!?!?!?
     
  17. TheDarkVoid

    TheDarkVoid

    Joined:
    Jul 11, 2012
    Posts:
    3
    The transparency works nicely but is there a way to also add specular to it as well.
     
  18. lumbert

    lumbert

    Joined:
    Mar 19, 2014
    Posts:
    24
    Worked, Thanks a lot !
     
  19. AlucardJay

    AlucardJay

    Joined:
    May 28, 2012
    Posts:
    328
    It was brought to my attention this method doesn't render anything behind the water, I have modified the answer to hopefully fix this.

    solution is: at line 58-59 of the FX-Water Simple shader, after

    Code (csharp):
    1.  
    2.     // -----------------------------------------------------------
    3.     // Fragment program
    4.  
    replace :

    Code (csharp):
    1.  
    2.     Subshader {
    3.         Tags { "RenderType"="Opaque" }
    4.         Pass {
    5.  
    with :

    Code (csharp):
    1.  
    2.     Subshader {
    3.         Tags { "Queue"="Transparent" "RenderType" = "Transparent" }
    4.         Blend SrcAlpha OneMinusSrcAlpha
    5.         ColorMask RGB
    6.         Pass {
    7.