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.

Stylized Water 2 [URP] ☑️ Desktop/Mobile/Consoles/VR

Discussion in 'Assets and Asset Store' started by StaggartCreations, Nov 3, 2020.

  1. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,935
    I got stuck on two very important aspects of it. The Surface Modifiers I showed earlier will allow a similar effect, by piping in a particle effect that pushes the water up through a circle-like sprite. It's definitely not as lush, but seeing as the same system can this and much more effects, it is what I'm going to focus on instead.

    I've updated the Roadmap page for clarity ;)
     
  2. Rastapastor

    Rastapastor

    Joined:
    Jan 12, 2013
    Posts:
    355
    I guess for stylized effect we dont need super realsitic stuff :)

    Thanks for answer, its my most awiated thing, since it make water much more fun :)
     
  3. analogupstudios

    analogupstudios

    Joined:
    Jul 3, 2019
    Posts:
    14
    Good morning. I sent an email regarding seeing particle systems underwater looking beyond the sea plane. does anyone have a solution to this?
     

    Attached Files:

  4. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,935
    I can't quite make it out from your screenshots, but what's likely happening is that transparency sorting is getting in the way. Since both the water and the particle effect are transparent, one of the two will either draw first or last.

    For something like a smoke effect, you'd want to it to draw after the water, so it stays on top of it. Yet, when underwater the opposite is desired. There is unfortunately no way to control sorting differently for front- and backfaces. The best solution is to enable Depth Writing on the water material:


    The first item in the troubleshooting/faq documentation section has some more information about this.
     
  5. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    418
    @analogupstudios
    Do you mean the issue of particle systems not being rendered on the other side of water? I actually looked into this (also using Sea of Thieves to see how they did it) and it's a pretty common problem (happens in every game I've looked at so far). So I'll share my thoughts.

    This happens when looking through a refractive surface, because in order to do refraction we have to get a copy of the current frame buffer so we can use that to distort it and then use that as the final colour of our refractive surface. We don't actually see the "contents behind the surface" and render ontop of it like we would if it was a normal transparent shader, but rather we stamp on a copy of the frame colour behind our object first. Unity gives us this frame buffer AFTER all opaque objects have been rendered, but BEFORE transparents, and so there are no particles rendered to the screen yet for us to use in this distortion. This is why particles don't show up.

    This also happens when you place two refractive surfaces layered ontop of each other (as refractive is rendered after opaques and is not included in the frame buffer). You will not see the lower surface refracted in the top one (stacked refraction), only the ground below both of them. This tweet of mine shows this; https://twitter.com/DMeville/status/1453116752297033732?s=20

    So in Sea of Thieves this is also an issue, and they just don't worry about it. Most particles just disappear and it doesn't affect the experience and most people don't really notice. But that wasn't a good enough answer for me and with what I'm trying to do with my project. So I looked farther...and what's interesting is that if you're standing on a cliff looking through a WATERFALL (which is transparent, and also has refraction) at the ocean, you can see the water surface through the waterfall, and also see particles refracted correctly through the waterfall too, even the foam/splash/mist particles the wtaerfall was emitting was working on both sides! This intrigued me, as it was basically an issue I was trying to solve with the waterfalls I was working on.

    What I figured they do here is:
    1) Place waterfall mesh in scene. Mark it with a layer "LateRefraction". Have main camera set to NOT render this layer, so this mesh will not render at all by the default pipeline.
    2) After all the main render passes are complete, (opaques, transparents, particles) grab a new grabpass ("_GrabPassAfterTransparent"). This is basically the final frame with everything sorted correctly.
    3) Draw all the "LateRefraction" objects, pass in the _GrabPassAfterTransparent buffer, use that as the scene colour for refraction instead of the normal built in grabpass.
    4) Draw any important particles that may need resorting again.

    I recreated this in unity with a custom render feature.
    https://twitter.com/DMeville/status/1457163670094434308?s=20
    https://github.com/DMeville/RefractedTransparentRenderPass

    If you were to not have waterfalls and only one main water surface, I suppose you could use this _GrabPassAfterTransparent for the main surface water refraction, as this lets you actually use particles seen through the surface for like...whitewater foam and bubbles really nicely! But it does incur the cost currently of having to render (marked objects via layer) twice, so that the particles can redraw ontop of the custom refraction layer so they sort correctly. But is a neat concept, and using this I can make it so my players find caves hidden behind waterfalls and when looking out back at the ocean still see everything without surfaces or particles disappearing!

    I noticed this particle disappearing and also stacked refraction "issue" in Stylized Water 2 when there is a river flowing into an ocean. Since there are two meshes overlapping, if you make the river refractive you can see some artifacts. I'm not suggesting to add this second refraction layer to SW2 either, as it's a pretty niche need for gamesI think, and probably decently expensive performance wise, but might interest you to take a look.

    @StaggartCreations
    Surface modifiers look absolutely incredible. I can't wait to try it out. The only reason I started making my own water system (which you may have seen) is because this was one major major feature I needed more than anything else, and if this is now coming to SW2... and I can just use your incredibly polished system again and I'm thrilled because that means I can have underwater rendering back in my game too, and buoyancy!! You rock dude.

    A few suggestions/questions.
    1) Will it be possible to sample the surface modifier buffer(?) separately? I assume it's just some global textures with different channels representing different surface effects? I ask because, one super useful usecase for this I found was being able to sample the foam buffer directly on my shoreline geometry, this allowed for the shoreline waves to push up, past where the water surface geometry ended and blend the water surface and shoreline really well: https://twitter.com/DMeville/status/1463256267128905729?s=20 (ignore how the shoreline gets wet, that's a different effect/system of mine that's driven by the same foam decal)

    2) How does SW2 handle multiple water surfaces at different heights? Does it at all? If not, can any work be done to support that? I'm assuming that I can just put the material on two meshes and change the heights and things are fine, but does the underwater rendering extension work to support that somehow too? Or is there a single global "height" the waterline is drawn at?

    3) No rush, but please keep posting updates! Any expectation on when this might be available to play with?

    Keep up the great work!

    ps; sorry for the wall of text!
     
  6. ericxgao

    ericxgao

    Joined:
    Nov 11, 2021
    Posts:
    4
    How do you make sure the asset underneath the water isn't drawn and only the refraction shows up? The documentation says that Advanced shading should handle this but it doesn't seem to work for me - I can still see the underlying asset completely.
     
  7. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,935
    Every since you brought it up again, it got the proverbial wheels turning, and I made some strides :D

    Right now the water shader uses a few generic functions to sample the albedo/displacement/normal/foam buffers. So this could potentially be used in other shaders as well. A point of attention is to enable this in Shader Graph as well, so modifiers can do things like height or slope based foam. Or wetness decals, based on water height.

    Currently, the only things that require a water level to be specified is the Buoyancy API and Underwater Rendering. Any changes could be handled through scripting, through physics triggers for example. The usecase of an ocean, next to an inland lake come to mind.

    Appreciate the interest! I think I'll need a few more weeks for core functionality. Which currently hinges on CPU performance and is a tangent into developing fast culling and batching systems. The "asset store" part generally takes more time (UI/UX, documentation, trailer, etc..)

    I may be misunderstanding what you mean. But anything under the water surface will still be visible, if the water is transparant in the specific region (eg. shallow water). An object couldn't be refracted, unless it is visible.
     
    DMeville likes this.
  8. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    418
    I'm super thrilled you've made some strides. It's already looking super impressive! If you need a beta tester or anything let me know (I'll even preorder the asset if I can or something, take my money!) as this looks like the exact thing I need for my project.

    Thank you for the sample code, makes complete sense to control it through triggers and of course you've made it super easy, this was nearly my exact usecase too, putting together a waterfall scene with many small cascaded pools at different heights that I'd love to get underwater rendering working with. Perfect!

    Speaking of wetness decals, if you need some inspiration or something, I was playing with this kind of thing a few weeks ago; It's a pretty simple system but is what was making the beach shoreline wet in the gif I posted above (wetness decal is invisible but matches the flipbook animation of the shoreline waves and stamps to buffer). Also used in this waterfall gif (with just some really simple box volumes) to make behind the waterfall wet super easily. Buffer is read in shader and rocks/beach just lerp between wet/dry states.
    https://twitter.com/DMeville/status/1461058312204480512?s=20
    https://github.com/DMeville/DMDecalBuffer

    The river gif you posted earlier looks amazing. Crazy how when layering all these effects together just how awesome things start to look!
     
    Last edited: Dec 28, 2021
  9. ericxgao

    ericxgao

    Joined:
    Nov 11, 2021
    Posts:
    4
    I'm referring to an issue where refractions look like they're just superimposed over the object. As you can see, I can still make out the cube extremely clearly - I want to see the distorted refraction layer only if possible.
     

    Attached Files:

  10. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,935
    Ah, I see what you mean. This behaviour, though undesired, is actually by design. The information that controls the water depth, which in turn controls the color gradient isn't being distorted. The reason being that would introduce different kinds of artifacts. Turning everything into a whac-a-mole game. So it's the lesser of two evils. True refraction would end up requiring raytracing ;)
     
  11. ericxgao

    ericxgao

    Joined:
    Nov 11, 2021
    Posts:
    4
    I don't necessarily need true refraction - just some stylized distortion of the pixels underneath. I'm able to get this working via the Scene Color node in Shader Graph, which completely distorts the image below. But porting this over has been a nightmare. Would you have any other suggestions or ideas on how to achieve this effect?
     
  12. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,935
    In the ForwardPass.hlsl file, you could uncomment the line at the top that reads
    #define RESAMPLE_REFRACTION_DEPTH. This will also distort the water depth and thus the color gradient. The result would be that something underneath the surface is completely being distorted, but at the cost of objects above the surface creating artifacts.
     
  13. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    418
    I am curious about this too. I can't quite get refraction working as I'd expect. Looking through the water surface from below, things above the water refract completely and nicely, but when looking down into the water, it's almost as if refraction is ignored? Straight edges of objects going below the surface remain straight regardless of how strong refraction is: See the gifs linked below.
    I tried uncommenting the line you suggested, but I can't see a difference (on URP and latest version of SW2)
    Is there any tips on how to resolve this? I've done similar things before in ASE with great success and no artifacts, refracting only the objects below the surface by just distorting both the scene colour and depth (and uvs used for caustic projection).

    https://imgur.com/a/C7Yj5S5

    Edit: After further testing I did get this working, just had to twist the right knobs :)
     
    Last edited: Jan 4, 2022
  14. Friks

    Friks

    Joined:
    Jun 29, 2014
    Posts:
    3
  15. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,935
    Sorry, could have sworn I had replied to your post already, but I don't see it :confused:

    It would be best to use the static StylizedWater2.UnderwaterRenderer.SetCurrentWaterMaterial function to change the material, rather than changing the water material field on the component directly. This function also prompts the script to (re)update properties, which tie into the underwater rendering itself. For the water level transform, the same applies but the StylizedWater2.UnderwaterRenderer.SetCurrentWaterLevel function can be used.

    For something like changing fog settings, the UpdateProperties() function must be called on the renderer component.
     
  16. LumaPxxx

    LumaPxxx

    Joined:
    Oct 3, 2010
    Posts:
    316
    Hi,i want to know does this water system support the fog in UniStorm?
    Thank you.
     
  17. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,935
    Not presently, though I see it now supports URP, so it may be possible. It entirely depends on how UniStorm's file and code structure is set up. I've emailed the author to check if this is possible ;)
     
    LumaPxxx likes this.
  18. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    418
    @StaggartCreations Any update on surface modifiers? Working on a tiny game for a client and am in dire need of being able to add some dynamic foam and ripple decals ontop of your water system. Even if it's not super optimized yet...any possibility of an early access or something? (happy to pay for early access too as it's pretty crucial for client, and I'd rather not reinvent the wheel if you have something working already!) :rolleyes:
     
  19. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,935
    Still underway! But I'm having to prototype a few different approaches to find the best method that balances performance, flexibility and usability, each with its own set of limitations and compromises. I don't have a sharable version at the moment I'm afraid, since dependencies are between dev project files and packages.
     
    DMeville likes this.
  20. directusgames

    directusgames

    Joined:
    May 8, 2015
    Posts:
    14
    @StaggartCreations thanks for producing such an amazing asset! I have a quick question regarding the visibility/colour of objects underwater. I have some dark-coloured fish that almost instantly turn blue when submerged, even if only just underneath the surface.

    I've attached a sample showing Stylized Water 2 (a) and what I'm hoping to achieve (b). (b) is with Crest, you can see the fish retain their dark colour once submerged (up to a much greater depth) even though the water colours are similar.

    Any ideas on how to achieve this using SW2?

    Underwater_colour.png
     
  21. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,935
    The color gradient is based on the depth texture, essentially this means the further away something is from the water surface the fog color leans more towards the "Deep" water color. I can see how this creates a discontinuity for small objects like the fish, but this is inherent to the technique. Adjusting the water depth may get around this, but it'll affect the water as a whole.

    Perhaps a viable alternative is to bake the depth values into the mesh's vertex colors, this way it can be based solely on the distance to the terrain.

    Here is a script that can automatically bake in vertex colors, based on downward raycasts, the distance between a collider and the water surface makes up the weight. Here, the color gradient, intersection foam and wave height are all based on vertex colors. In effect, this also means any submerged object receives the same fog color as the terrain, which is what you're after.
    upload_2022-2-23_10-50-9.png

    For this to work, the mesh needs a sufficient vertex density (eg. a quad won't do), and the "Vertex color opacity" option must be enabled under the Color tab.

    Script: https://pastebin.com/csT6AmYQ
     
  22. FluffyPashy

    FluffyPashy

    Joined:
    Mar 25, 2021
    Posts:
    4
    Hey @StaggartCreations and other community members.

    I'm currently running into a problem which turns everything into Black/White mode, while using Planar Reflections and Underwater Render together.

    If someone else having this issue or already solved it, I would like to hear about it. :)

    Currently testing it on a fresh scene, copied the base enviroment just for visual testings.
    Unity 2021.2.13f1


    upload_2022-2-28_22-18-18.png
     
  23. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,935
    Ah yes, I noticed this recently. It's definitely unintended and happens when HDR is enabled. Strangely, only for the scene-view camera (which I can't debug). There's bound to be an explanation for it, I just haven't found it.

    In the PlanarReflectionRenderer.cs file, you can add this line to fix it for the time being:
    View attachment 1013674
    CTRL C:
    Code (CSharp):
    1. if(source.cameraType == CameraType.SceneView) colorFormat = RenderTextureFormat.Default;
     
  24. FluffyPashy

    FluffyPashy

    Joined:
    Mar 25, 2021
    Posts:
    4
    Thanks for the quick reply, but I can't figure out where to put the line of code in the cs file.
    Giving me serverall errors of missing the source or colorformat, other lines won't give out any OutPut/Changes to the problem. Am I missing something?

    Does this problem only appear in 2021.x or is this a "known" issue of the shader and HDR render?
     
  25. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,935
    I've meanwhile found the root of the problem, and why it's specific to the scene-view only. It occurs in Unity 2020.3+ and up apparently.

    Sorry, the forum was giving me all kinds of permission warnings. It seem the screenshot I attached has gone missing, it showed where the line would have been added :p

    In the PlanarRelfectionRenderer.cs file, adding these two lines is a definite fix (note the line number to find where it should go)
    upload_2022-3-1_14-49-26.png
    Code (CSharp):
    1. newCamera.cameraType = CameraType.Game;
    2. newCamera.backgroundColor = Color.clear;
    I'll be sure to include this fix with next update.
     
    FluffyPashy and MuntyMcFly like this.
  26. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,935
    Version 1.1.8 is now available! This has been in the barrel for a while, due to a large amount of shader code being refactored, had to make sure nothing broke along the way.

    Minimum supported version is now Unity 2020.3.1 and URP 10.3.2. Support for 2020.3 LTS is retiring pretty soon by Unity, hence moving forward 2019 LTS is no longer being developed for or tested on. That said, this version still works there, but it'll break some content used in the demo scene. URP 7.x is by all means an obsolete version nowadays.

    Added:
    - Fog integration for COZY Weather.
    - Sharp and Stream waves normal map.
    - River mode, slope threshold parameter.

    Changed:
    - Updated smooth waves normal map to show less repetition.
    - Alpha channels of deep/shallow colors no longer control opacity, but water depth instead. Clear water is now made possible.
    - Simple shading now also masks out objects above the water for refraction.
    - Advanced shading now also refracts the fog gradient (requires more calculations, hence limited to this mode).
    - Reflections are now laid over translucency shading. Added a parameter to control this behaviour.
    - Optimized wave shader calculations for vertex animations.
    - Double-clicking a water mesh in an inspector now properly selects it, rather than the OS trying to open the file.

    Fixed:
    - Planar Reflection with Underwater Rendering causing a black/white image when used together.
    - Blue vertex color painting not affecting horizontal wave movements.
    - Horizontal displacement created by waves not affecting UV's. Normal map now also moves back and forth.

    Planned updates

    1.1.9

    Buoyancy update. Slight rework of the API, so that it returns a struct (containing both wave height and normal). Under the hood this'll also support buoyancy readback for the WIP Surface Modifiers extension.
    • Improved waves, by using a precomputed set of parameters. More variation per wave layer.
    • Coupling of vertical movement with horizontal movement. Higher waves should mean that they start to create crests.
    • Addition of a “Global Water Level” component. Script using the Buoyancy API can up to use this as a reference for the water level.
    (This version will be see an update for the Underwater Rendering extension, in order to keep it functional)

    1.2.0

    Material editor update. Support for multi-selection will be added, allowing a single property to be modified across multiple materials.. And in turn also enables support for the upcoming Material Variants. This is necessary for futureproofing the asset.
    • This requires some breaking changes. Some material parameters will revert to their default values (all materials included in the asset will be corrected!). It's a necessary evil moving forward.
     
    FluffyPashy likes this.
  27. FluffyPashy

    FluffyPashy

    Joined:
    Mar 25, 2021
    Posts:
    4
    @StaggartCreations
    So the problem with the Plana Reflection with Underwater Rendering is solved but might have causes a ft. to dissapear.. This might just be me, so I tested it out.

    Unity 2021.2.14f && Unity 2020.3.27f1 LTS
    Removed all SW2 components from the Project. (dw I made a backup)
    Imported SW2 and SW2 Underwater Shader to give it a shot.
    Reflection Probe ✓

    The "problem" or ft. missing since the update:
    You were able to see through the water from underground what objects are close/reflecting into the water.
    Like this:
    upload_2022-3-8_23-28-28.png
    upload_2022-3-8_23-27-56.png

    But now it's like this:

    upload_2022-3-8_23-29-39.png
    upload_2022-3-8_23-30-7.png

    So now nothing from the surface is beeing displayed.


    Am I missing something?
    Or is it just a mask not beeing displayed due to the planar fix?
     

    Attached Files:

    Last edited: Mar 9, 2022
  28. m4robb

    m4robb

    Joined:
    Aug 2, 2017
    Posts:
    21
    hi compiling a build to android (quest 2) with URP 2021.2.14 and am getting this error:

    ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
    System.Collections.Generic.List`1[T].get_Item (System.Int32 index) (at <feaaa6313e32495d9f259b175aa6b597>:0)
    StylizedWater2.KeywordStripper.StripKeyword (UnityEngine.Shader shader, UnityEngine.Rendering.ShaderKeyword keyword, System.Collections.Generic.IList`1[UnityEditor.Rendering.ShaderCompilerData]& compilerDataList, System.Int32& i, UnityEditor.Rendering.ShaderSnippetData snippet) (at Assets/StylizedWater2/Editor/ShaderConfigurator.cs:388)
    StylizedWater2.KeywordStripper.OnProcessShader (UnityEngine.Shader shader, UnityEditor.Rendering.ShaderSnippetData snippet, System.Collections.Generic.IList`1[T] compilerDataList) (at Assets/StylizedWater2/Editor/ShaderConfigurator.cs:365)
    UnityEditor.Build.BuildPipelineInterfaces.OnPreprocessShaders (UnityEngine.Shader shader, UnityEditor.Rendering.ShaderSnippetData snippet, UnityEditor.Rendering.ShaderCompilerData[] data) (at <5c8f1172115149e593ecad20a23a7816>:0)
    UnityEditor.EditorApplication:Internal_CallGlobalEventHandler()


    this didnt happen with the earlier version of Stylized Water with the samee unity version? Any ideas?
     
  29. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,935
    That's definitely not suppose to happen, it seems this was something particular that broke along the way. I have already identified the issue and will submit a hotfix later today. Flew under my radar, so thanks for the reporting!

    Curious, the script in question was reworked for last update, though I have been able to build without any errors in a number of different projects. That unfortunately leaves a lot of potential factors open. I'll have to dig around and see if I can reproduce the error.
     
  30. Caetleo

    Caetleo

    Joined:
    Mar 19, 2019
    Posts:
    18
    Staggart, How would you about using this asset to create lava? Possibly changing the textures for normals/foam? the colors from blue/baby blue to a fitting red? Any suggestions would be great, Thank you
     
  31. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,935
    In the StylizedWater2/Materials folder there is a lava material. It's about as far as I could push water towards a lava-like appearance, but it should provide a good starting point.

    I suspect it'll look more convincing if you were to use a magma-like grayscale texture for the surface foam, and set the alpha value of the color to 1.
     
  32. VincentStk

    VincentStk

    Joined:
    Feb 14, 2018
    Posts:
    9
    Hi when i build android project and i have this issue, like above post
    my unity version is 2020.3.20 LTS
    upload_2022-3-22_22-23-25.png
     
  33. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,935
    Version 1.1.8b is now available, this simply includes two hotfixes:

    - Underwater reflections not showing objects above the water surface
    - Build error caused by keyword stripping under certain conditions
     
  34. Caetleo

    Caetleo

    Joined:
    Mar 19, 2019
    Posts:
    18
    Staggart, I fixed the Lava thing, Another question is how can I use stylized water 2 Ocean prefab to create a nice wave for a surfing game? Also, you have the "floating transform" however, Im gonna be using a char controller, or a movement based on axis to make the surfer go up and down the wave. Any suggestions how to get a realistic looking wave that a surfer would use? I know my questions are vague, just curious how you would personally go about creating nice surf able waves using this asset.

    EDIT: Also do you have discord ? or a discord server for this asset where others can come and help each other out?
     
  35. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,935
    Something long the lines of breaking shoreline waves wouldn't be achievable I'm afraid, this is a highly specialized form of waves, whilst the waves in this shader are best suited for lakes and calm oceans.

    You can, however, configure the waves to move in a single direction, which would result in long "rows". Either by setting the X/Y of the direction close to 0.
    upload_2022-3-24_10-10-0.png

    A ship/boat controller would require buoyancy physics, this is quite a complex subject on its own. I've personally dabbled with it, but along the way I started realizing I'd need to know way more about physics and the concept of buoyancy itself. I've been able to make an object bounce of the water, and ships capsize, but nothing gameplay ready :p

    This is what I ended up with so far: https://pastebin.com/0TvBPiH6 which may be a good starting point. It uses the Buoyancy API included in the asset, in order to read the wave height/normal and applies forces if a point is below the water. The Floating Transform component merely snaps an object to the water surface, meaning there's no physics involved.

    No Discord at the moment, have been putting it off really, but I intended to create one in the future (particularly for beta tests)
     
  36. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,626
    I'm trying to create a large lake/ocean in my game, but it seems the calculations cut of at some point in the distance. I attach a screenshot. The horizon setting seems to only change the color mix but as you can see, at certain distance even the normal map is not calculated anymore making it look pretty ugly. Any ideas?

    oceanurp.jpg
     
  37. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,935
    When viewing the water from large distance, it's best to also enable "Distance Normals". This'll blend in a 2nd normal map sample between a given start/end range:
    upload_2022-3-28_10-2-10.png

    But I suspect what you're seeing is mipmaps in effect, to the point where the resolution gets so low, the normal map simply appears flat. When you select the normal map texture in the inspector you could play with this setting, which'll control the distance at which mipmaps are selected:
    upload_2022-3-28_10-5-1.png

    Possibly the "Aniso Level" slider should also be increased
     
  38. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,626
    I tried your settings and still same result. it seems something is hardcoded to that distance. My lake is about 2km long since it's a fly simulator. You can't tell unless you see long distances.
     
  39. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,935
    Make sure anisotropic filtering is actually enabled in your Quality settings profile. Without this texture filtering can get pretty aggressive if the surface a texture is applied to is very far away.
    upload_2022-3-29_10-44-53.png

    After which, you can increase the filtering quality for the normal map textures you're using:
    upload_2022-3-29_10-48-39.png

    The difference being visible banding between mipmaps. Without anisotropic filtering, textures eventually gets downscaled to just a single color
    upload_2022-3-29_10-45-54.png

    If the water is viewed from afar most of the time, it's best to lower the tiling of the normal map so the individual waves don't appear too small. Which also affects the mipmap Unity's rendering selects.
    upload_2022-3-29_10-53-19.png

    By default, all the materials are configured for best appearance in first/third person perspectives. But can be adjusted freely to suit other needs.
     
  40. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,935
    Had another stab at VR compatibility for Underwater Rendering, which is the most requested feature. I had little confidence in it, but managed to make sense of it all eventually. Ironically it didn't require any major adjustments.

    I'm pretty sure there's a bug in Unity 2020.3 regarding the occlusion mesh. It ends up cutting out a large triangle in render textures, this otherwise works perfectly in 2021.2, so that'll be the minimum required version for VR support.



    This'll be included in version 1.0.5, which'll be released alongside of v1.1.9 of the Stylized Water 2 asset, since there's a dependency.
     
  41. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,626
    I tried the aniso settings, playing around with everything. It still won't work. Did you try switching to Android?
    Here is a screenshot. I made the normals huge so you can see them clearly. You can also see my texture settings. I tried adding "details" normals to the water. Same result.

    Even if i disable the Normals, you still see the water color change on a circle.


    water.jpg

    I don't think it's related to aniso settings or texture settings at all, but a problem with the shader.

    Here I just went ahead and changed the horizon color to red, so it's more obvious. You can see it's not the texture downgrading to a single color because of aniso but the whole texture getting replaced by the horizon color. There is not even the directional light bright circular spot once you hit that color.

    waterred.jpg

    Remember, this is setting on Android build and setup for opengl 3.0.

    I also wrote to you an email last week asking for a refund but you never replied. To me, this water doesn't work as expected.
     
    Last edited: Apr 8, 2022
  42. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,935
    Thanks for the screenshots, the horizon color being perfectly sharp hints at a specific rendering issue. Though I can't seem to reproduce the same behavior on any devices running on OpenGLES. That's always the difficult thing with mobile hardware, since hardware and drivers differ.

    If you could send me the material you're using, I'd have a better shot at pinpointing the cause (Right-click->Export package (untick Include Dependencies)). If I can't find anything to fix, I suppose a refund is still in order, but you'd be left with no water.
     
  43. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,626
    The behavior from the screenshots is in the editor, not the device. Although I get exactly the same behavior in the device. As of right now, I have no water from your package because I cannot release with a water that looks like a flat color, for that I just create a plane and paint it blue. You didn't even reply to my email requesting a refund, you just ignored me completely and it's been more than 12 days already since that email. I understand things don't always work as expected, but not replying to a customer's email is not cool.
     
    Last edited: Apr 11, 2022
  44. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,935
    Apologies, I replied to your forum post instead with a potential solution, which I assumed was more helpful. When it comes to refunding an asset, it's at least needed to verify where the issue in question lies. Though I wouldn't want to stretch anyone's patience thin with too much debugging. I'm pretty sure I've identified the issue now, I'll send you an email shortly.
     
  45. unitygnoob008

    unitygnoob008

    Joined:
    Sep 17, 2016
    Posts:
    107
    hello dev, some questions if you dont mind, also great work on this asset.

    1. how do we do infinite ocean with your asset? i cant find it in the docs
    2. which part of docs describe replacement of water texture? i wish to change colors/texture on the fly using code in-game

    3. also, the docs say waves buoyancy is not supported
    i know some of how to do this (getting height of normal at certain point in wave,
    translate simplified physics body along point in wave to physics body

    but is it included in some way with dynamic water physics 2 asset? (the boats one)

    thx again!
     
  46. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,935
    1. How far the water is visible pretty much depends on how large the water mesh is. If you have a 10x10km world, you don't necessarily need a mesh just as large. For instance, the Water Grid component can generate a mesh, and it follows the camera around. In which case, it only needs to be large enough to cover the camera's rendering range.

    2. You can use Material.SetTexture("_ParameterName", Texture2D); to assign specific textures to a material. This'll work in the same as it does for any other material.

    You'd need to know what the parameter name is for the specific texture slot you're looking to change. When you select the shader file, a list of parameters will be displayed in the inspector (starting with "_").
    upload_2022-4-12_16-7-46.png
    Anything with "2D" in the name on the right is a texture parameter.

    3. That's right, the DWP2 asset does all the complex physics stuff. It samples the water's height through the Buoyancy API provided in this asset.
     
  47. shellyalon

    shellyalon

    Joined:
    Mar 26, 2013
    Posts:
    27
    Hej there. On Oculus Quest 2 (Android Mobile VR) the Intersection Foam doesn't work and the water is opaque. Transparent planes work and Depth Texture is enabled. Any ideas?
     
  48. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,935
    It’s likely, when the game is running on the device, a different Quality profile is used than in the editor.

    If you have different pipeline assets assigned, per quality level, ensure the “Depth Texture” option is enabled on them as well. The "Opaque texture" option should also be enabled if refraction is enabled on the water material.
     
  49. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,935
    Version 1.1.9 is now available!

    Added:
    - Planar Reflection Renderer, API to add/remove specific water objects

    Changed:
    - Updated fog integration for COZY Weather
    - The distance normals texture now uses the same import settings as the regular normal map (eg. filtering settings)

    Fixed:
    - Horizon color appearing as a sharp circle on Mobile at large distances
    - Underwater reflection not appearing entirely correct (regression since v1.1.8)
    - Edge fading canceling out translucency shading when viewed from underwater

    A reminder that the focus of next update is refitting the material inspector. Support for multi-selection will be added, allowing a single property to be modified across multiple materials.. And in turn also enables support for the upcoming Material Variants. This is necessary for futureproofing the asset, but will cause some parameters to be reverted to their default settings.
     
    makaolachsiungca likes this.
  50. TwoSidesSameGemini

    TwoSidesSameGemini

    Joined:
    Jun 13, 2018
    Posts:
    2
    Maybe I'm missing something in the documentation, but is there any way to use the underwater renderer given a slope (something like you might run into with the river option). The SetWaterLevel works perfectly for "flat" bodies of water, but the second we're using a spline that descends at some angle it's no good.

    Is this already supported functionality and I'm missing it somewhere? If not, is this something you've already got on the roadmap?

    Thanks!