Search Unity

Stylized Water Shader - Desktop/Mobile/VR [Built-in RP]

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

  1. Psychotoke

    Psychotoke

    Joined:
    Oct 11, 2022
    Posts:
    2
    I'm getting an error. Material doesn't have a texture property "_MainTex". All I did was apply the shader to a plane. It looks fine in the scene view, but keeps blinking in and out of existence. I get the error at runtime.
     
  2. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    There has to be a script attached to the plane object that calls something like Material.mainTexture or Material.SetTexture("_MainTex", Texture2D).

    The water shader doesn't contain a parameter called "_MainTex", hence the error is thrown.
     
  3. takashi-kunn

    takashi-kunn

    Joined:
    Jul 10, 2020
    Posts:
    4
    I got black water on lower end iOS devices (6+ for example), can you help me out?

    Here is screenshot
    upload_2023-6-3_20-13-15.png
     

    Attached Files:

  4. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    A black material is usually the graphics hardware's way of saying some part of the shading calculations failed. Unfortunately, without being specific to what.

    It could be a wide range of things I'm afraid, and would require debugging on the device. The shader was last tested on an iPhone 6s, where it rendered correctly. You'd have to make sure OpenGLES 2.0 is not being used, since its too old for the shader to render with.
     
  5. takashi-kunn

    takashi-kunn

    Joined:
    Jul 10, 2020
    Posts:
    4
    Since I knew the shader using ASE to create, can I change some properties to correct the problem?
     
  6. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    223
    if i tick the check box that turns on "tile reduction" on the "normals" module, and then save the file, it reverts back to NOT having tile reduction. why isn't it saving my settings? im on the latest update. i was on 2.1.6 and it wasnt working there either.
     
  7. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    223

    Any ideas?
     
  8. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    That may be attributed to the same issue that was addressed in last update, but for the lighting mode parameter.

    When you say, saving the file, do you mean the scene, project or a prefab?
     
  9. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    223

    Saving the scene triggers this issue.
     
  10. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    Thanks for clarying. I can indeed reproduce the same issue, it in is fact the "bug" that Unity 2022.2 introduced. The fix is rather straightforward, so I'll be able to fix this in an update soon.
     
  11. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    223

    AwesomeThanks bro!
     
  12. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    223
    hell yea. i just got the update and its working perfectly it seems thanks bro!
     
  13. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    223
    welp, this created another bug i didn't have before. if for any reason i hit undo (control + z) the water material intersection effect resets and i have to set it up all over again.

    It doesn't even matter if i/m trying to undo something else.

    i set up my water material. started working on something else (tress and rocks) and wanted to undo a rock or anything else and whenever i hit undo, without fail, it resets the intersection settings.
     
  14. Volkerku

    Volkerku

    Joined:
    Nov 23, 2016
    Posts:
    114
    Love this shader, great work.
    An issue I have, using the Underwater package together with the Stylized Water in VR, the underwater caustics (and it seems everything submereged) is only visible in one VR eye camera.
    I got the StylizedWater2 and StylizedWater2Underwater render features added to my URP settings.
    Any workaround?
     
  15. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    VR is a particular nuisance that can have issues in specific Unity/URP versions. Could you outline what hardware/platform you are running on, and which versions you are using?

    Note that the most recent update fixes an issue with VR that prevented it from working altogether in Unity 2022, if you haven't updated yet, please try to do so.

    PS: The thread for Stylized Water 2 is here: https://forum.unity.com/threads/stylized-water-2-urp-desktop-mobile-consoles-vr.999132
     
  16. Volkerku

    Volkerku

    Joined:
    Nov 23, 2016
    Posts:
    114
    Thanks.
    I'm on Unity 2022.3.18f1, working on a Win11 PC for meta Quest platform with the Meta XR packages.
    The asset and URP packages are uptodate.
    I tried multi-pass and multi-view Oculus XR settings, but no luck with either of them.
     
  17. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    Thanks for the details!

    I have a test set up for underwater rendering, targeting Android VR. In a few minor 2022.3 versions I'm seeing correct rendering in both eyes.

    If you have the Directional Caustics option enabled that does make a difference, as both this option and the "Accurate" checkbox introduce more dependencies that may break.
     
  18. Volkerku

    Volkerku

    Joined:
    Nov 23, 2016
    Posts:
    114
    Ok, I'll try that. However, I have not enabled Directional caustic. Will play a bit more and report back.
     
  19. nicolasdemauroy

    nicolasdemauroy

    Joined:
    Nov 11, 2020
    Posts:
    23
    Hi, I am using the Stylized Water Shader with the Azure Skybox, and I have a problem that the water does not interact correctly with the fog generated by the Azure Skybox. It seems this is because the water does not use the depth buffer, or not as Azure Skybox intended.

    Do you have any tip on how to fix that ?
     
  20. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    This is true, transparent materials do not write to the depth texture, so typically receive an amount of fog based on the geometry behind them instead. Though, Azure renders before transparent geometry does, in this case they appear to be completely unfogged. The solution here to is incorporate the fog effect into the transparent shader directly.

    Azure has a "Transparent support" PDF that outlines the changes needed to a shader.

    For this water shader specifically, that would look like this:
    upload_2024-3-19_10-19-57.png
    Copy/paste:
    #include "Assets/Azure[Sky] Dynamic Skybox/Shaders/Transparent/AzureFogCore.cginc"


    and

    upload_2024-3-19_10-21-13.png
    Copy/paste:
    return ApplyAzureFog(c, ase_worldPos);


    After making these modifications to the shader file, you'll find the water blends in correctly with the environment fog :)
     
  21. nicolasdemauroy

    nicolasdemauroy

    Joined:
    Nov 11, 2020
    Posts:
    23
    Thanks, that works perfectly. The support you guys are providing to your assets is always impressive.
     
  22. pbiesek92

    pbiesek92

    Joined:
    Feb 9, 2016
    Posts:
    11
    Hi,
    It looks beautiful and works fine in the editor, but when I build it for meta quest it's just invisible. I tried in a scene with and without shadows, I tried single pass and multi pass, I do have enable depth buffer script on my camera.
    The only reason I bought it is because it says it supports single pass on meta quest...
    Can you please help?

    below photos on quest (water invisible) and in editor (water visible)
     

    Attached Files:

  23. pbiesek92

    pbiesek92

    Joined:
    Feb 9, 2016
    Posts:
    11
    never mind, it does work in an empty scene. turns out it just doesn't work with enviro sky :(
     
  24. SlickFox

    SlickFox

    Joined:
    Jul 30, 2017
    Posts:
    14
    Hey @StaggartCreations, I bought your water shader, it's excellent.

    However, even after hours of tinkering I'm still not able to get the intersection foam to look right. It's does not produce realistic ripples along edges of geometry like rocks.

    Here's the kind of ripples I'm looking for:



    Notice how they move outward radially from objects like rocks.

    How can I create such an effect? Is it a matter of using a certain texture or certain settings? Or a lack of capacity of the shader? I've tried what seems like every setting but it doesn't give me this kind of smooth, radial, lapping effect.

    Secondly, is there a way to get the color of objects in the water to show up better? For example, if I place a black cube under the water surface the cube appears white, not black. The color of objects doesn't show through well. Notice how in the 1st video I linked above the black grid lines on the white spheres show through the water clearly. How do I achieve that with your shader?

    Thanks!
     
    Last edited: Apr 22, 2024 at 3:37 AM
  25. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    The effect you're describing won't be possible unfortunately, the "ripples" are a specific type of calculation. It's an effect that is featured in Stylized Water 2.

    It's important to understand that the intersection foam effect is based on the depth-value of opaque geometry behind the water. So for a partially submerged sphere, the effect appears to draw in a circle around it. While in fact, it is drawing onto the sphere's surface, an optical illusion. Which is also why it is not drawing around the back of the sphere. It is likely also why your cube is flooded with a white color, it being the intersection effect.

    Unreal Engine has a Distance Field buffer readily available in its rendering loop, making it possible to base such an effect on the actual distance to/from an object intersection with the water. This is inherently more stable, but Unity never added this feature sadly.
     
  26. SlickFox

    SlickFox

    Joined:
    Jul 30, 2017
    Posts:
    14
    @StaggartCreations Stylized Water 2 for URP is what I'm using. Sorry, I posted my question in the wrong thread. I didn't realize you had two separate threads for these shaders. Are you saying the ripples are possible with Stylized Water 2 for URP or not?

    I know this ripple effect is possible in Unity because plenty of games made with Unity have it. For example:



    Also, the issue with the cube being flooded with white color is not related to the intersection foam because I'm talking about a cube that's fully submerged in the water, so it has no intersection foam but its black color does not show through well, it's whited out.
     
  27. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    Ah, different story indeed :p

    Take a look at the water in the demo scene, this has a subtle ripple effect. When the "Ripple Strength" parameter is turned up, solely ripples are shown.
    upload_2024-4-24_10-19-10.png

    Note that games like Bad North and Windwaker (GC) use a strip of geometry, tailored to fit the shoreline, where the effect is added through a separate material.

    Similarly, it can be achieved using vertex colors:

    (This too requires tailored geometry, the example here uses a set of tile meshes)

    Regarding the black cube, typically if you want more of the underwater geometry's color to come through, you can decrease the fog density, or lower the alpha value of the deep/shallow colors:
    upload_2024-4-24_10-26-10.png