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
  4. Dismiss Notice

Water texturing of caustics effects

Discussion in 'General Graphics' started by Kjell-Andersson, Jun 3, 2015.

  1. Kjell-Andersson

    Kjell-Andersson

    Joined:
    Oct 15, 2014
    Posts:
    14
    If you are interested in rendering water, I just posted a new article on how to do texturing of caustics patterns to improve the look of rendered water.

    The article focuses on the caustics texturing and provides complete shader code that can be downloaded and used in your own projects.

    http://www.dualheights.se/caustics/caustics-water-texturing-using-unity3d.shtml

    I have also posted a video of how the final result looks.



    Happy reading!
     
    Last edited: Aug 9, 2015
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Cool Kjell. Thanks for information. Will store it away for later use.
     
  3. -Singularity-

    -Singularity-

    Joined:
    Jul 27, 2014
    Posts:
    122
    This looks great - are you happy for people to use this commercially?
     
  4. Kjell-Andersson

    Kjell-Andersson

    Joined:
    Oct 15, 2014
    Posts:
    14
    The source code in the article is free to use even commercially if you want.
     
    -Singularity- and theANMATOR2b like this.
  5. -Singularity-

    -Singularity-

    Joined:
    Jul 27, 2014
    Posts:
    122
    Great, thanks for posting!
     
  6. Zicandar

    Zicandar

    Joined:
    Feb 10, 2014
    Posts:
    388
    Awesome!
    I really like it, and will likely use it.

    At the end you write it's freely usable within unity projects, however that still creates a slightly limiting copyright. And I don't think posting here is enough for usage outside that.
    It would be awesome if you could take the time and update all the files to include a copyright notice at the top of Each file, with a type of license that allows them to be used freely. (There are a few of those out there).
    ex: http://opensource.org/licenses/MIT
     
  7. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,068
    Yay!! :D
    Thank you!
    Been looking for something like this for a while now! :D
     
  8. Kjell-Andersson

    Kjell-Andersson

    Joined:
    Oct 15, 2014
    Posts:
    14
    I have put a bit of clarification at the end of the article now that my modifications are released as Public Domain. As for the original Unity shader code, I haven't found any licensing information for that so I can't really claim any license on it. Since Unity publishes the standard shader code for us to modify I assume it is ok to use it freely.
     
  9. Zicandar

    Zicandar

    Joined:
    Feb 10, 2014
    Posts:
    388
    Actually that means default copywrite, so read but not use... My guess is that they mean for people to be allowed to modify it, but...
     
  10. pluMmet

    pluMmet

    Joined:
    Jul 18, 2015
    Posts:
    133
    This might also suit my needs.. Thank you very much :)
     
  11. pluMmet

    pluMmet

    Joined:
    Jul 18, 2015
    Posts:
    133
    Could you please show a screenshot of the shader in use (with any of the (9 possible) maps plugged in) from your pool example.

    Once I see that I will understand how it is used :)
     
  12. Kjell-Andersson

    Kjell-Andersson

    Joined:
    Oct 15, 2014
    Posts:
    14
    Does this screenshot answer your question?
    The Emission map is updated by the CausticsProjector script every frame to animate the caustics.

    upload_2015-8-8_21-47-9.png
     

    Attached Files:

  13. pluMmet

    pluMmet

    Joined:
    Jul 18, 2015
    Posts:
    133
    I'm a little confused so there are 2 textures on the pool bottom?

    I'm still new to Unity but I did not think you could do that in Unity.

    The Tiles are one texture and this is a second?

    On another UV channel?

    Nice to know Unity can do that...?

    Ohh and Thank You ;)
     
  14. Kjell-Andersson

    Kjell-Andersson

    Joined:
    Oct 15, 2014
    Posts:
    14
    The tiles are on the Albedo channel. The caustics light pattern is on the Emission channel, which lights up the Albedo texture.
    Normally the other texture channels use the same UV but if you read the article that I linked to above you will notice that I have modified the code of the standard shader, so the Emission channel is a bit special in this example. It does not use the object's UV but instead it calculates new world-projected coordinates.
     
    theANMATOR2b likes this.
  15. pluMmet

    pluMmet

    Joined:
    Jul 18, 2015
    Posts:
    133
    I have it now. Thank you. It looked to be a blue and white version of the caustic map. It all makes sense now :D
     
  16. the_motionblur

    the_motionblur

    Joined:
    Mar 4, 2008
    Posts:
    1,774
    Regardless of the technique used for this effect - Unity can do this. It's just a matter of creating the shaders.
    Unity by default uses the newish standard shader which can't do it out of the box. But if you are willing to create a shader of your own there are not really many limits other than current technology.
    If you want to create custom shaders without coding them yourself you might want to give ShaderForge a try. It's basically the Unreal Shader Editor for Unity and an all around awesome tool. The sky's the limit ;)
     
    theANMATOR2b likes this.
  17. rhys31

    rhys31

    Joined:
    Jun 20, 2017
    Posts:
    3
    Hi Kjell-Andersson,

    I'm very new to Unity and wonder if you could detail in a bit more of a step-by-step way regarding how you implement the code you have made available (on https://www.dualheights.se/caustics/caustics-water-texturing-using-unity3d.shtml) and what parameters need to be in check? I only wish to create a close-up of some caustics projecting on to a plane and a target sphere (as if it were resting on the bottom of a pool - like your original demo clip) and haven't had much luck visualizing the effect yet...

    Cheers!
     
  18. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    330
    @Kjell-Andersson, thanks for sharing your work! May I ask, will this asset still be updated to work in Unity 2018.1+? The following Console Rrrors are shown in Unity 2018.1.6:

    Code (CSharp):
    1. Shader error in 'Standard Caustics': 'AdditiveLight': no matching 0 parameter function at Assets/Unity5CausticsShader/UnityStandardCausticsCore.cginc(455) (on d3d11)
    2.  
    3. Compiling Vertex program with POINT
    4. Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_RGBM_ENCODING
    Code (CSharp):
    1. Shader error in 'Standard Caustics': syntax error: unexpected token ')' at Assets/Unity5CausticsShader/UnityStandardCausticsCore.cginc(455) (on d3d11)
    2.  
    3. Compiling Vertex program with POINT
    4. Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_RGBM_ENCODING
     
  19. Roman_Keivan

    Roman_Keivan

    Joined:
    May 31, 2019
    Posts:
    21
    Huge thanks to the author for providing the solution.