Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[Released] Stylized Water Shader - Desktop/Mobile/VR

Discussion in 'Assets and Asset Store' started by StaggartCreations, Sep 8, 2016.

  1. Augmented_Island_Studios

    Augmented_Island_Studios

    Joined:
    Feb 16, 2012
    Posts:
    60
    Hahaha You're right I confused it with another of your assets we're working with, I'm sorry :(
     
  2. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,403
    Is there a way to edit the shader so tree billboards intersect with the water?

    I had this issue with another water shader and the developer did something that made the shader intersect. Im asking them about it too, but I thought I should ask here since you know the shader best.

    Its great water by the way - very versatile and good performance.

    Screen Shot 2020-09-18 at 9.56.27 PM.png Screen Shot 2020-09-18 at 9.56.33 PM.png
     
    StaggartCreations likes this.
  3. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,183
    Setting the render queue value on the water material to 2899 will likely fix this. With the default value of 3000, the water renders over tree billboards (assuming the ones created by the terrain system). These have a render queue value of 2900, so having the water render before them will result in correct sorting. On my end, the water then properly intersects with the billboard meshes.
     
    protopop likes this.
  4. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,403

    Thank you:) I figured it out. I removed the alpha:fade from the shader and now it intersects with billboard trees.

    I have another question.

    How can I turn on and off the reflection by script. I was to do this in my options so people can choose.

    stylizedWater.useReflection = true/false turns planar reflections on and off in the script attached to my water object. But it doesn't actually turn the reflections on and off in the water.

    If I start the game with planar reflections on then this will turn it off, but not on again.

    If I start the game with planar reflections off it won't turn them on or off (although the checkmark in the stylized water script goes on and off in all cases)

    Would I have to make a operate water object with a. separate stylized water script with planar turned on and switch between them?
     
  5. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,183
    Glad to hear that works for you. I wasn't required to modify the shader, but who knows!

    Settings the "enableReflection" bool value on the water component will enabled/disable the rendering. And disabling it sets the reflection strength on the material to 0, otherwise it shows a gray reflection (default texture color). But it doesn't set it back to what it was, when enabled.

    So when you enable it again, you'll have to use StylizedWater.material.SetFloat("_ReflectionStrength", <value>); to set it back to whatever value it was. It's a little counter intuitive, since you'll have to save the desired reflection strength value somewhere beforehand, but it works :)
     
    protopop likes this.
  6. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,403
    thank you:) for the billboards I use a huge water plane like 2000x2000 - maybe that's why my billboards don't intersect. Unity is like love - full of mystery

    it's really wonderful water. I love diving and swimming in it - it feels so wet.

    if I disable the reflection during run time do you know if there any kind of performance hit, compared to if I disable it from the start and never enable it?
     
  7. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,183
    Happy to hear you like it!

    I don't think there will be a noticeable performance hit. But toggling reflections does involve the creating/destruction of an object and texture. But if the game is loading anyway, a fraction of a millisecond probably doesn't make a difference. Ideally, it would be disabled by default, and enabled when needed. But I don't think it's it would be causes for concern otherwise ;)
     
    protopop likes this.
  8. Duende

    Duende

    Joined:
    Oct 11, 2014
    Posts:
    143
  9. Harrenhall

    Harrenhall

    Joined:
    Mar 25, 2020
    Posts:
    5
    Any news on the URP version? Will it be for mobile as well?
     
  10. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,183
    I don't Overloud myself, so can't exactly test it. But judging by that page, it should be possible to add support for it. This requires some minor modifications to the shader. You can do this by opening the StylizedWater_Desktop.shader file.

    At line 66, add #include "Assets/OverCloud/OverCloudInclude.cginc" underneath it. Note that the file should actually be located there, if you've moved the Overcloud folder, adjust the file path to match the location in your project.

    At line 360, replace:
    Code (CSharp):
    1. c.rgb = staticSwitch857.rgb;
    2. c.a = OpacityFinal814;
    with:
    Code (CSharp):
    1. float4 finalRGBA = float4(staticSwitch857.rgb, OpacityFinal814);
    2. OVERCLOUD_FRAGMENT_FULL_ADD(finalRGBA, ase_worldPos.xyz);
    3. OVERCLOUD_OCEAN_ADD(finalRGBA, ase_screenPosNorm, ase_worldPos.xyz);
    4. c.rgb = finalRGBA.rgb;
    5. c.a = finalRGBA.a;
    With this in place, Overcloud's effect (I'm assuming volumetric lighting) will be drawn on the water surface correctly. Let me know if it throw's any errors ;)
     
    Duende likes this.
  11. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,183
    It's practically finished, except for some minor touch ups and polish. I'm currently down to screenshots and documentation, which is the final stretch! I decided to omit some of the advanced features (interactive water and underwater rendering) as separate extensions. Otherwise it just drives up the price, and takes much longer to finish.

    Like the original package, it's also mobile compatible. On low end devices (OnePlus One and iPhone 6s), it runs at about 36fps with all features enabled. Disabling the advanced features, which aren't targeting mobile anyway, brings it up to 60fps+. On newer devices (Galaxy S10/Nintendo Switch), all features can be enabled, without noticing a performance hit.

    It's a huge improvement over the current shader, since I'm not using a node-based shader editor, so was able to optimize it rigorously.
     
    alexanderameye likes this.
  12. shawnblais

    shawnblais

    Joined:
    Oct 11, 2012
    Posts:
    306
    Last edited: Oct 16, 2020
  13. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,183
    Yes, that's exactly what I meant ;)

    This technique uses particle systems. I made a prototype that uses this a few months ago, but it's fairly basic and difficult to translate full characters bodies and boats into ripples. The ripples also can't bounce off each other. What I'm looking to achieve is the same technique as used in AC Origins, Uncharted 4 and Fortnite (example). I've conceptually laid it out, but there's still a lot to figure out, so I'm leaving for it for a rainy day.
     
  14. shawnblais

    shawnblais

    Joined:
    Oct 11, 2012
    Posts:
    306
    Well our money is sitting here for the taking, please do take it :D
     
unityunity