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

Underwater Caustics projector

Discussion in 'Editor & General Support' started by Krisper, Sep 4, 2013.

  1. Krisper

    Krisper

    Joined:
    Mar 24, 2011
    Posts:
    20
    Not sure where the best place is to post this. I am working on an underwater scene. I am using some projectors and an AnimatedProjector script to show a series of caustic textures. I am using examples from a few different places but this page http://kostiantyn-dvornik.blogspot.com.au/2013/05/unity-worlds-coolest-tutorial-about.html shows what I am doing.

    I want to make it so the caustic effect on the terrain becomes less obvious the deeper underwater the terrain goes, some way to make the textures more transparent with depth and eventually fade out so they are no longer seen. I am guessing this would be possible by modifying the shader, but I have never worked with shaders before. Can anyone help with this? The shader I am using now is this:-

    Code (csharp):
    1. Shader "Underwater/ProjectorAdditive" {
    2.    Properties {
    3.       _ShadowTex ("Cookie", 2D) = "" { TexGen ObjectLinear }
    4.    }
    5.    Subshader {
    6.       Pass {
    7.          ZWrite off
    8.          Fog { Color (0, 0, 0) }       
    9.          //ColorMask RGB
    10.          Blend One One
    11.          SetTexture [_ShadowTex] {
    12.             combine texture, ONE - texture
    13.             Matrix [_Projector]
    14.          }
    15.       }
    16.    }
    17. }