Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Simple underwater light effect

Discussion in 'General Graphics' started by laur-ganta, Jun 6, 2015.

  1. laur-ganta

    laur-ganta

    Joined:
    Oct 22, 2014
    Posts:
    24
    Hello! I am working on a 3D game for mobile in which all the gameplay is placed at the bottom of the sea, so underwater.

    I want the atmosphere to be a tropical one, close to the beach.

    To simulate the sunlight effect on the bottom of the sea, I divided a GIF into frames(edited them a bit in gimp to add some alpha), created a script that loops through those frames and placed the script on a plane just above the terrain. The only problem is, obviously, this only covers the terrain, all the objects/ characters will be just above it and won't be affected by it.

    Here is what the result looks like(the software I used to record as GIF is a bit slow, looks better in real time, but you get the point) :
    http://giphy.com/gifs/underwater-effect-light-unity-l41lNCFBc2dAtuokE?message=uploaded

    My question is: Is this method viable? Is there any way this can be done that is more optimal, performance wise, for mobile platforms? I suppose this can be done with shaders, but I am ashamed to say I don`t know the first thing about creating a shader.

    Here is an effect that looks similar to what I would like to achieve.


    Any tip would be much appreciated,

    Thank you!
     
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    That lighting effect is called caustics.

    Look into water caustics. I've created this several times in Max just for fun using the procedural noise material and animating it. It's pretty simple to do in Max - so I'd think it could be done in Unity pretty easily. Check into some procedural noise stuff in Unity. If you can't find anything - jump into a 3D authoring software and modify a procedural noise material - I think they all should have them since Max has had it since birth - and render out an animated sequence.
    You can probably put this on as an animated projector light to project it onto everything in the scene.

    Hope this puts you on the correct path.
     
    laur-ganta likes this.
  3. laur-ganta

    laur-ganta

    Joined:
    Oct 22, 2014
    Posts:
    24
    Thanks for the info! I did a little bit of research and found a caustics generator (bmp frames) for animation and I'll use a projector in Unity.
     
    theANMATOR2b likes this.
  4. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Cool - glad I could help out.
     
  5. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    687
    I did something like this before and what I ended up doing was was using two animated lights with light cookie textures to make the pattern. The rays could either use the actual light rays image effect or a simple particle system.
     
    theANMATOR2b likes this.