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,938
    Yes, that is actually the case, the rendering of the waterline relies on having a base water level to work with. For something like a river, the height of the mesh's vertices tends to vary over it surface, which can't easily be translated to shaderland.

    Some one got around this by performing a downward raycast on a river's mesh collider from the position returned by the StylizedWater2.UnderwaterUtilities.GetNearPlaneBottomPosition() function. Then feeding the Y-value of the hit into the SetWaterLevel function. This'll make it work to some extent, but the outcome doesn't always look correct.

    I've been toying with a concept that'll allow reading the height of any an all water surfaces on both a CPU and GPU level. That'll remove the need for using a water level value for both underwater rendering and the Buoyancy API, and a reference to a specific water material. It's practically an ideal solution, and makes things much simpler, so it's definitely something I'm aiming to explore further.
     
    TwoSidesSameGemini likes this.
  2. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,938
    Version 1.0.5 of the Underwater Rendering extension is now available! The minimum supported Unity version is now 2020.3.



    Unity 2022.1 (URP 13) did a rug-pull on part of the rendering API, which affects any kind of screen-space effects. Everything still works, but a few consistent warnings are being thrown about an obsolete API. I'm in the process of refactoring the rendering code for the SC Post Effects asset, in order to abstract the API to work across different URP versions. Once I have solidified it there, I'll backport the same changes to the Underwater Rendering asset.

    Side notes:
    • There's definitely a bug in 2020.3 regarding the VR occlusion mesh, hence VR requires Unity 2021.2 where everything works perfectly.
    • I've tested VR on the Oculus Quest, but it's simply not capable of maintaining proper framerates with underwater rendering enabled, even at the bare minimum. It works, but still isn't suitable.

    Added:
    - Support for Single Pass Instanced/Multi-view VR rendering (requires Unity 2021.2+).

    Changed:
    - Optimized blur to use fewer samples.
    - Minor improvements to distortion. Now also renders at 1/4th resolution without a noticeable quality loss.
    - Directional Caustics no longer require an intermediary rendering step.
    - Values for the Water level field in the inspector are now always updated.

    Fixed:
    - Directional Caustics not taking effect in Unity 2020.3, unless accurate option was enabled.
    - Improvement to water mask rendering, where some times a triangle would render in front of it.
     
    makaolachsiungca likes this.
  3. nomiswerdnek

    nomiswerdnek

    Joined:
    Jul 14, 2017
    Posts:
    5
    I am making a vertically scrolling game (with a top down view), that will see the player fly above and over the water. The player can move around the screen bounds, the camera position is stationary, above the player, looking down towards the water. The environment will move continuously from the top to the bottom of the screen to create the illusion of vertical movement.

    I've just bought Stylized Water 2 and configured a water object that I like the look of. However, while the waves look really good, it doesn't give the illusion of the player flying over the water, it looks like player is moving around above the same area of water.

    I have since looked at using the WaterGrid component to allow the water tiles to be repositioned, to give the illusion of flying endlessly over the water, and this does indeed look good, however, the WaterGrid needs to follow a moving object. To make this work, I could constantly move the camera in the forward direction and have the WaterGrid follow it, but this also means that I would need to reorganise my hierarchy to have my player, enemies and all other objects childed to (or positioned relative to) to the camera. If I keep moving the camera in a constant direction, the camera position will eventually reach the maximum possible position. Is there a simpler way to achieve endless scrolling waves tiles, to give the illusion of flying over the water, but still keeping my camera position stationary?
     
  4. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,938
    If I understand it correctly, your camera is stationary but the water geometry is moving in a scrolling fashion.

    By default, the water uses a top-down projection for the texture UV's and waves. This mean when the water mesh moves around the actual water effects stay in the same place. The benefit here is that you can move/scale the mesh without actually affecting the scale of the water effects.

    In your case, you'd want the opposite, so that the water effects appear to actually move with the mesh. For this you'd have to change the UV Source under the "General" tab to Mesh UV:
    upload_2022-5-16_14-46-5.png
    It's likely you'd have to readjust things like tiling values for different effects at this point.

    On the Water Grid component you could actually just disable the following behaviour options. Instead, parent it under an already moving Transform.
     
  5. nomiswerdnek

    nomiswerdnek

    Joined:
    Jul 14, 2017
    Posts:
    5
    Thank you for the suggestions. I had already tried the 'Mesh UV' setting with my stationary camera, but have looked at it again following your suggestion. I have 2 water objects (both HighPoly_Planes) aligned next to each other, and I am moving these in front of the camera to create a seamless ocean. With 'Mesh UV' enabled, I do need to readjust the tiling settings (as you suggested) to make the textures look seamless across the 2 water objects. However, I cannot make the meshes seamless across the 2 water objects once I start adding height to the waves. Should it be possible to make the meshes seamless with waves while using 'Mesh UV'?
     
  6. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,938
    Ah, that makes sense. When you rely on the mesh's UV's the tiling of the effects can definitely break along the edges.

    This may be a better option, where you can keep the "World XZ Projected" option, but still have the water move around.

    In the Stylized Water 2/Shaders/Libraries/Common.hlsl file, you can modify the "GetSourceUV" function so that it adds an offset controllable through C#.

    Change
    Code (CSharp):
    1. float2 GetSourceUV(float2 uv, float2 wPos, float state)
    2. {
    3.     float2 output =  lerp(uv, wPos, state);
    4. }
    to

    Code (CSharp):
    1. float3 _PositionOffset;
    2. float2 GetSourceUV(float2 uv, float2 wPos, float state)
    3. {
    4.     float2 output =  lerp(uv, wPos - _PositionOffset.xz, state);
    5. }
    After which you can use a specific transform to shift the water around (visually).
    Code (CSharp):
    1. public class WaterPositionOffset : MonoBehaviour
    2. {
    3.     void Update()
    4.     {
    5.         Shader.SetGlobalVector("_PositionOffset", this.transform.position);
    6.     }
    7. }
    What value you pass in here is something specific to your set up, so I'm just using the script's transform here.

    At this point the water geometry is entirely stationary and tiles seamlessly, but it still appears to move: https://gyazo.com/81aa628ebd354a593fa204fa851116ae
     
  7. marckv

    marckv

    Joined:
    Sep 19, 2013
    Posts:
    59
    Is there a way to confine the underwater effect to a Volume like a pond area? Currently when I walk around the pond (which is lower than the water line) the effect is enabling on the landscape?
    I have enabled the volume stuff and added the fog settings to a volume with collider, but it doesnt seem to confine it to an area as I expected.
    If I use a second global underwater volume with all the settings turned off, it disables the fog, but not the water line. Would doing it that way use up rendering performance while outside of the water? And how would I disable the water line outside of the water area?
     
    Last edited: May 18, 2022
  8. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,938
    The rendering isn't volumetric in nature, but rather takes effect when the bottom of the screen touches the configured water level. So it inadvertently also takes effect when the sits on the side of a the water body.

    What you could do in your situation is add a box/sphere trigger that encapsulates the pond, then attach this script to it. This will force the rendering to skip once the camera leaves the trigger, and allows rendering only when it enters it.

    For this to work the "Toggle Rendering" checkbox must be ticked. You may want to add "UnderwaterRenderer.EnableRendering = false;" to the Start function.

    Side note, for the camera to respond to physics triggers it needs to have a RigidBody component on it (with the kinematic option enabled), as well as a Collider to act as a trigger.

    The pond is likely an irregular shape, but you can use multiple triggers to cover the area.
     
  9. nomiswerdnek

    nomiswerdnek

    Joined:
    Jul 14, 2017
    Posts:
    5
    Thank you, I will have a look at this.
     
  10. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    141
    Hi!

    Is it possible to use the underwater effect with several different water heights?

    Furthermore, I have a large sea with an island. Does it make more sense to make a big water tarp, split it with the grid or use follow?

    With the size I noticed that Grid gets performance problems here.
     
  11. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,938
    It's possible to switch to a different water level on the fly. Though the rendering won't work across different water levels. You can use this script to change the water level based on physics triggers.

    Ideally, for something like an island you'd create a custom mesh that's large enough and only has a high vertex density around the beach. It's an interesting subject to do this procedurally, but it falls outside of the scope of this asset.

    The best option would be to use the Water Grid component, and have it follow the camera around. But keeping the vertex count relative low. Instead you can enable Tessellation (under the Advanced tab) to achieve a high detail mesh only near the camera, where it's needed the most.
     
  12. lawsonh

    lawsonh

    Joined:
    Jul 25, 2018
    Posts:
    80
    hello @StaggartCreations , trying to use the planar reflections on a URP 12.x project , nothing is being reflected.

    I'm using the StylizedWater2_Ocean prefab and I disabled the waves. then I added a Planar reflection renderer from the window menu and dragged the water into it. Is there anything else I need to do?
     
  13. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,938
    There is likely nothing wrong with your set up! But the reflection strength is somewhat based on the viewing angle by default. On a larger body of water you would see the reflected objects more clearly.

    This behaviour is controlled by the "Curvature Mask" parameter.
    upload_2022-6-1_12-37-42.png

    If you were to bring it down to 0, the water basically behaves like a mirror. From there on, you can increase the value to the point where you're satisfied with the appearance. The ocean material for example, isn't very reflective by default.
     
  14. lawsonh

    lawsonh

    Joined:
    Jul 25, 2018
    Posts:
    80
    Awesome that fixed it!
     
  15. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    141
    Hi @StaggartCreations !

    I use Enviro together with Stylized Water 2. I have both renderer feautures set up. Fog and Underwater Render Feature. I have also activated the support for Enviro.

    Problem is, both work fine as long as I start the scene myself. If my player comes from another map, my scene is black like on the picture and only the water is in colour.

    Fog.jpg

    I have to deactivate the fog in the renderer features once and then activate it again. After that it works.

    Do you have any help for this incompatibility?

    EDIT:

    Another problem. When I load the scene with the water, the underwater works, but the water on the surface is white.
     
    Last edited: Jun 7, 2022
  16. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,938
    I can't say I've encountered this before, but it seems like the skybox is simply black. If you have time/weather simulation off, and switch the scene, Enviro would need a nudge to update the environment again.

    The white water is something that can occur when the Enviro fog integration is active, yet a scene is opened without Enviro in it. At this point the water gets shaded using uninitialized fog settings, which results in a white cover.
     
  17. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    141
    OK, I could look for that.

    The point is now strange. Because first I have a Login Scene in which Enviro is active, then a Character Selection Scene in which Enviro is active and then the Main Scene in which Enviro is also active.

    Only Enviro is restarted in the Main Scene. Is it possible that the water is finished loading sooner than Enviro?

    If so, do you see a possibility to change the order of loading?
     
  18. wechat_os_Qy09VpiDaSiV8EETWQqNeGZuk

    wechat_os_Qy09VpiDaSiV8EETWQqNeGZuk

    Joined:
    Oct 11, 2021
    Posts:
    9
    Can planar reflection automatically calculate the bounds when using water grid?
     
  19. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,938
    Not at the moment, at least through the included functionality, mainly because there's a few viable solutions to consider.

    You can however shift the bounds in realtime, by centering it around another transform (could be a water grid):
    Code (CSharp):
    1. using System;
    2. using StylizedWater2;
    3. using UnityEngine;
    4.  
    5. public class MovePlanarReflections : MonoBehaviour
    6. {
    7.     public Transform followTarget;
    8.     public PlanarReflectionRenderer planarReflectionRenderer;
    9.  
    10.     private void Reset()
    11.     {
    12.         planarReflectionRenderer = this.GetComponent<PlanarReflectionRenderer>();
    13.     }
    14.    
    15.     void Update()
    16.     {
    17.         planarReflectionRenderer.bounds.center = followTarget.transform.position;
    18.     }
    19. }
     
  20. Derptastic

    Derptastic

    Joined:
    Mar 11, 2017
    Posts:
    14
    Hey Staggart,

    A bit of an embarrassing problem, I've updated to latest version and lost an effect that I liked and can't find in the settings.:(

    Here's the effect pre-update (the white-line water bottom reflections):
    With.png

    And here's after (also the light is a different 'time of day', thus the slight color change but the effect is missing at all times):
    Without.png

    Where can I find it again in the settings? And apologies for the silly issue... (For the record, I made a copy of the material that I was using and stored it separately, but with the shader update the changes still got applied)
     
  21. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,938
    That would the caustics effect, you can find this under the "Underwater" tab:
    upload_2022-6-20_13-8-44.png

    Previously the effect was always visible, even if the sun light had an intensity of 0. You may want to increase the brightness x4 to make the effect more prominent.
     
  22. Derptastic

    Derptastic

    Joined:
    Mar 11, 2017
    Posts:
    14
    Ah, thank you! The screenshot helped - apparently the update somehow had set the texture to 'None', which is what threw me off (and I couldn't see anything, even when I was twiddling with it). Cheers!
     
  23. Derptastic

    Derptastic

    Joined:
    Mar 11, 2017
    Posts:
    14
    And, sorry to bother, another question (and I think I saw something related to it in the release notes), was this the intended effect with the caustics - Being visible in shadowed areas as well?

    Pre-update:
    CausticsInShade.png

    Post-update:
    CausticsInShade3.png
     
  24. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,938
    That's correct, it's a specific change that resolved some technical implications.

    If you're looking to hide effects like caustics/specular reflections in the shadows, this option needs to be enabled:
    upload_2022-6-29_13-14-1.png

    You can still set the Strength to 0, if you do not like the look of the shadows being cast on the water surface itself.
     
  25. marckv

    marckv

    Joined:
    Sep 19, 2013
    Posts:
    59
    Hey there, I see to be getting a weird bug when the mouse moves up and down real quick when just above the water level. I believe its the planar reflection doing it. Any ideas? To recreate it, get the mouse close to the surface, and look up and down super quick.

    For now we have copied UpdatePerspective(camera, reflectionCamera); to before the skip camera check on line 193. That might mean its running twice now, but seems to fix the issue. Can you let me know if there is a better way? Thanks

    Update: That fix introduced weird stuff, so we rolled back. Any assistance would be most welcome :D

    upload_2022-6-29_23-46-44.png
     
    Last edited: Jun 30, 2022
  26. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,938
    I have noticed this before, it seems like some part of the rendering process does not occur in the same frame, I've never been able to pinpoint how or where, despite shuffling things around.
     
  27. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    204
    hope for a selection for alpha blending mode
    so that i can make my lake color heavier with still transparency
     
  28. ComplicatedEgg

    ComplicatedEgg

    Joined:
    Dec 11, 2019
    Posts:
    8
    Hi, I have this problem where when the camera is just about to clip into the water, everything else is not rendered at all. If under this threshold it will start underwater render (but get reflections underwater). If over the threshold, everything renders normally. How can I fix this and the underwater reflections? Thanks.


    6.PNG 7.PNG
     
    Last edited: Jul 12, 2022
  29. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,938
    Thanks for attaching the screenshots. I can't say I've ever encountered this before. On which Unity version are you seeing this occur?

    A useful means of debugging is checking if this also happens in the demo scene. If not, try disabling anything that's rendering related, such as the minimap.
     
  30. ComplicatedEgg

    ComplicatedEgg

    Joined:
    Dec 11, 2019
    Posts:
    8
    Thank you for the reply!

    It does not happen in the demo scenes.

    Using 2019.4.33f1. The underwater rendering broke in my scene after updating to the latest version, I assume. It did say the previous version was going to be the last supported update... But it could be something to do with the cameras yes (I have one main perspective cam and one orthographic for a minimap), or it could be something to do with the water level parameters (changing the water level values in the underwater render script helps a bit but I cannot replicate demo scene or pre-update).

    Disabling the minimap camera does not help with the reflections.
     
  31. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,938
    Version 1.0.5 (latest) at least was developed for 2020.3+, but 2019 should technically still work.

    Either way I believe the underwater rendering will also take effect for the minimap camera. If this camera is using the same renderer as the main camera, this'll be the case.

    Even if its just for performance, it's worth using a separate renderer for the minimap camera. In turn, underwater rendering will never take effect on it.

    I've extended the documentation to outline the needed steps here: https://staggart.xyz/unity/stylized...dering-docs/?section=performance-guidelines-4
     
    ComplicatedEgg likes this.
  32. eastes

    eastes

    Joined:
    Sep 1, 2012
    Posts:
    57
    What a great shader system. Is there a way to make this a pure opaque shader? Is this simply achieved by disabling the depth texture?
     
    Last edited: Jul 13, 2022
  33. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,938
    Mostly, yes! This is an example of a material with the depth texture disabled, and vertex colors being used to drive effects:
    upload_2022-7-13_8-55-32.png

    Though if you technically want to render the shader as truly opaque, you can change the following in the shader file from:

    Code (CSharp):
    1. Tags { "RenderPipeline" = "UniversalPipeline" "RenderType" = "Transparent" "Queue" = "Transparent" }
    to:
    Code (CSharp):
    1. Tags { "RenderPipeline" = "UniversalPipeline" "RenderType" = "Opaque" "Queue" = "Geometry" }
     
  34. ComplicatedEgg

    ComplicatedEgg

    Joined:
    Dec 11, 2019
    Posts:
    8
    Hello! Thanks for the help. I followed your steps and used a separate renderer for the minimap camera. However, this still did not fix the main renderer's planar reflection appearing underwater for some odd reason (it wasn't like this before so I must've changed something wrongly).

    What I discovered:
    1.png
    When the planar reflection renderer is disabled, the underwater renderer renders the minimap camera's render texture above and below the water.

    2.png
    When it is enabled, the underwater renderer renders a solid colour above the water (either black or the horizon colour if the planar reflection renderer has 'Include Skybox' enabled) and the planar reflections appear underwater (overlaying everything including my character).
    But this is the closest to my old water which worked perfectly with no weird solid colour or underwater reflection.

    3.png
    Disabling the underwater renderer itself stops all the problems. But this isn't the outcome I want since I want the underwater rendering to occur.

    Screenshots of how the old water behaved before I updated some assets including StylizedWater2.
    Kyōtabi 13_07_2022 11_20_12 PM.png
    Kyōtabi 13_07_2022 11_20_04 PM.png

    Thanks again.
    Additional question: how do I increase the vertex density of the water? Enabling tesselation doesn't really help with the cracks but this could be a misconfiguration of the water level parameters.
     
    Last edited: Jul 13, 2022
  35. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,938
    Thanks for the additional details! As a test, I've set up a similar minimap camera, but this appears to pan out correctly:
    upload_2022-7-14_10-56-5.png

    This is in 2020.3 at least, I can't vouch for 2019 since support for this was retired. If v1.0.4 worked as expected, I think it's a safe assumption the changes made to support 2020-2022 are the root of the cause. If you're looking for the v1.0.4 package to downgrade, feel free to send me a message.

    In the Frame Debugger you'll see 4 camera's rendering: Minimap camera, main camera + reflection camera x2. In the PlanarReflectionRenderer class you'll want to add the following line, so that planar reflections aren't rendered for the minimap camera. Because you won't see the result, but otherwise will pay the performance cost.

    At line 189:
    Code (CSharp):
    1. if (camera.cameraType != CameraType.SceneView && camera.targetTexture) return;
    For the vertex density, you can also increase the subdivisions on the mesh used (double click it on the Mesh Filter component)
     
    ComplicatedEgg likes this.
  36. ComplicatedEgg

    ComplicatedEgg

    Joined:
    Dec 11, 2019
    Posts:
    8
    Hi,

    Quick update / Current Issues:
    - Water material's underwater caustics are fully visible above the water, no matter how foggy the water is or how shallow the vertical depth is.
    What else can I try?

    Update 2:
    - I have fixed the underwater rendering by updating my Unity project to 2021.3.6f1. Now all that's left is the above issue.

    Update 3:
    - Managed to fix the issue by using the Enviro fog integration ^^

    Thanks for the massive help! I managed to fix a few other miscellaneous issues with your camera render suggestion!
     
  37. carass

    carass

    Joined:
    Jul 18, 2022
    Posts:
    1
    I am using unity 2021.3.4 version and imported StylizedWater2 from urp project.
    But Assets\StylizedWater2\Runtime\Underwater\UnderwaterRenderer.cs(384,8): error CS1029: #error: 'Underwater Rendering extension is imported without either the "Stylized Water 2" asset or the "Universal Render Pipeline" installed. Will not be functional until these are both installed and set up.' There are asset error files with text. I am not a programmer. What is the workaround?
     

    Attached Files:

  38. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,938
    Great! I was going to suggest consulting the Frame Debugger, since this provides a step-by-step insight into what's happening.

    It's basically like the error message says, you've imported the Underwater Rendering extension asset, without actually having the Stylized Water 2 asset installed in the project. You can still do this afterwards tough, that's no problem!
     
    ComplicatedEgg likes this.
  39. shellyalon

    shellyalon

    Joined:
    Mar 26, 2013
    Posts:
    27
    Any workaround to get the planar reflections working in VR, too?
     
  40. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,938
    No workaround I'm afraid. This can't be made to work on account of a small, but pivotal, technicality.
     
  41. marckv

    marckv

    Joined:
    Sep 19, 2013
    Posts:
    59
    Is there any way to get the refractions to distort the skydome? upload_2022-7-21_21-16-5.png
     
  42. marckv

    marckv

    Joined:
    Sep 19, 2013
    Posts:
    59
    Actually it doesnt matter what is behind it. It doesnt distort anything above the horizon line. Is there anything I can do about that? Im trying (and failing) to make a waterfall using the river mode) xD

    It happens in the demo scene too if you tilt the ocean plane

    upload_2022-7-21_21-46-2.png
     
  43. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,938
    Ah, good catch! The logic involved checks between the geometry and water's y-position to do a comparison check. But this evidently doesn't hold up on slopes.

    In the StylizedWater2/Shaders/Libraries/ForwardPass.hlsl you can change line 75 from:
    Code (CSharp):
    1. //Reject any offset pixels in front of the water surface
    2. half refractionMask = saturate((water.positionWS.y - opaqueWorldPosRefracted.y));
    to:
    Code (CSharp):
    1. half refractionMask = saturate(SurfaceDepth(depthRefracted, input.positionCS));
    This resolve the issue and still appears to hold up.
     
  44. marckv

    marckv

    Joined:
    Sep 19, 2013
    Posts:
    59
    Legend once again, thanks so much.
     
  45. MathiasUnity1

    MathiasUnity1

    Joined:
    Oct 4, 2020
    Posts:
    5
    Update 31/07: nevermind, found the solution by finding that the error came from another package, that had a shader conflict. Sorry and thanks!

    Old message:

    I'm not entirely sure why, but I have this error message in the console, when using Unity version 2020.3.19f1

    Shader error in 'CTI/URP Billboard': invalid subscript 'shadowCoord' at line 129 (on d3d11)

    Compiling Fragment program with _ADDITIONAL_LIGHTS _MAIN_LIGHT_SHADOWS _NORMALMAP _SHADOWS_SOFT Platform defines: SHADER_API_DESKTOP UNITY_ENABLE_DETAIL_NORMALMAP UNITY_ENABLE_REFLECTION_BUFFERS UNITY_LIGHTMAP_FULL_HDR UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BLENDING UNITY_SPECCUBE_BOX_PROJECTION UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS Disabled keywords: FOG_EXP FOG_EXP2 FOG_LINEAR INSTANCING_ON LOD_FADE_CROSSFADE SHADER_API_GLES30 UNITY_ASTC_NORMALMAP_ENCODING UNITY_COLORSPACE_GAMMA UNITY_ENABLE_NATIVE_SHADOW_LOOKUPS UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_RGBM_ENCODING UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_DXT5nm UNITY_NO_FULL_STANDARD_SHADER UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_VIRTUAL_TEXTURING _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MIXED_LIGHTING_SUBTRACTIVE

    It redirects me to CTI URP Billboard.shader, at line 129. Does anyone know how I can fix it?
    It seems to put a black screen when I'm trying to play the exported build on PC Windows.

    Code (CSharp):
    1. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
    2.                     inputData.shadowCoord = input.shadowCoord;
    3.                 #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
    4.                     inputData.shadowCoord = TransformWorldToShadowCoord(inputData.positionWS);
    5.                 #else
    6.                     inputData.shadowCoord = float4(0, 0, 0, 0);
    7.                 #endif
    A million thanks to anyone willing to help out a noob trying to learn
     
    Last edited: Jul 31, 2022
  46. Predulus

    Predulus

    Joined:
    Feb 5, 2018
    Posts:
    76
    Hi, my water is generated proceurally at runtime - is there any way to get reflections working? TIA
     
  47. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,938
    The Planar Reflection Renderer component has two public AddWaterObject and RemoveWaterObject functions. You could attached a script to each water body that calls these OnEnable/OnDisable, or handle this in the logic that creates the water in the first place.
     
    Predulus likes this.
  48. Dagos32

    Dagos32

    Joined:
    Aug 22, 2015
    Posts:
    3
    Hi everyone! I know this isn't a supported feature, but maybe I can get some tips here for what I'm trying to achieve.

    I need to be able to mask out parts of the underwater fog - e.g. if some characters are at the bottom of the ocean (fog is very dense, so everything looks dark), they should have a kind of spherical mask around them so the player can see what's in that radius.

    I think render textures could be a solution, rendering a top-down black texture that gets the location of each object and creates this mask around them, but I guess all areas in that XZ position would be masked out, even if it's way above/below the object, right?

    Does anyone have any suggestions? Thanks!
     
  49. Qilbby

    Qilbby

    Joined:
    Nov 7, 2017
    Posts:
    5
    Stylized Water 2 - Configure underwater rendering through triggers

    I'm having trouble getting the Underwater Trigger script to work, it doesn't give any error, but the underwater effect disappears and I can't get the configuration right.
    Do you have a demo video?
     
  50. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,938
    You could try adding debug messages in the OnTriggerEnter/OnTriggerExit functions to check if Unity if your camera is actually triggering them. It needs to have a Trigger+RigidBody component on it for this to work.

    I've attached a test scene, where two different water bodies are set up with the example script
    upload_2022-8-8_10-27-24.png
     

    Attached Files:

    makaolachsiungca and Qilbby like this.