Skip to content

Commit 0b8e4e9

Browse files
svc-reach-platform-supportEvergreen
authored andcommitted
[Port] [6000.3] [HDRP] Fix water decal sampling in Sample Water Surface VFX Graph Node
1 parent e3bca0d commit 0b8e4e9

3 files changed

Lines changed: 121 additions & 146 deletions

File tree

Packages/com.unity.render-pipelines.high-definition/Documentation~/water-vfx-interaction.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,17 @@ However there are several simulations that are important to be aware of.
66
As the water surface gameobject is saved inside a scene, and the VFX graph is an asset on disk, it is not possible to directly reference the surface from within the graph. This means data of the water surface need to be set globally by the user before the VFX can sample the water.
77
As a result, only a single surface can be sampled from any VFX Graph at any given time.
88

9-
Additionally, the settings on the Sample node in the VFX Graph needs to be set according to what water surfaces will be bound globally at runtime. This inclues setting the proper **Surface Type** and enabling **Include Current** if a current map is assigned on the water surface.
9+
Additionally, the settings on the Sample node in the VFX Graph needs to be set according to what water surfaces will be bound globally at runtime. This includes setting the proper **Surface Type** and enabling **Include Current** if a current map is assigned on the water surface.
1010
The **Evaluate Ripples** needs to be disabled if the surface doesn't have ripples, but can be disabled on purpose for performance reasons even if the surface has ripplies, at the cost of slighly lower precision in the results. The same applies to the **Include Deformation** option.
11+
Finally, to ensure proper masking is applied, the option **Use Mask and Current Water Decals Workflow** must be set to match the **Enable Mask And Current Water Decals** setting in the Graphics settings.
12+
1113

1214
The following script can be used to bind the relevant textures in the global scope, so that the VFX Graph can access them.
15+
Alternatively, can also use the more complete script WaterSurfaceBindVFXEditor.cs, located in the HDRP Package Manager Water samples.
1316
```
17+
using UnityEngine;
18+
using UnityEngine.Rendering.HighDefinition;
19+
1420
public class WaterSurfaceBinder : MonoBehaviour
1521
{
1622
public WaterSurface waterSurface;

Packages/com.unity.render-pipelines.high-definition/Editor/Water/WaterSurface/VFX/SampleWaterSurface.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ class SampleWaterSurface : VFXOperator
4646
[VFXSetting(VFXSettingAttribute.VisibleFlags.Default)]
4747
[Tooltip("Specifies if the search should sample the current map.")]
4848
protected bool includeCurrent = false;
49+
[VFXSetting(VFXSettingAttribute.VisibleFlags.Default)]
50+
[Tooltip("Specifies if the system use mask and current water decal workflow. This has to be set in accordance with the same checkbox in the Graphics Settings.")]
51+
protected bool useMaskAndCurrentWaterDecalsWorkflow = false;
4952

5053
public class InputProperties
5154
{
@@ -107,6 +110,9 @@ protected override sealed VFXExpression[] BuildExpression(VFXExpression[] inputE
107110
if (!includeDeformation) baseCode += "#define IGNORE_WATER_DEFORMATION\n";
108111
if (includeCurrent) baseCode += "#define WATER_LOCAL_CURRENT\n";
109112

113+
// We need this because water decals can attenuate frequency bands using a water mask when Mask and Current Water Decals workflow is enabled.
114+
if (useMaskAndCurrentWaterDecalsWorkflow) baseCode += "#define WATER_DECAL_COMPLETE\n";
115+
110116
baseCode += $"#include \"{m_SampleWaterSurface}\"\n";
111117

112118
string FindVerticalDisplacements = $"float error; int steps; float3 normal; float2 current; float height = FindVerticalDisplacement(positionWS, {maxIterations}, {error.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)}, steps, error, normal, current);";

Packages/com.unity.render-pipelines.high-definition/Samples~/WaterSamples/VFX/VFX Graphs/VFX_Bubbles.vfx

Lines changed: 108 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ MonoBehaviour:
4040
x: -756
4141
y: -1433
4242
width: 2083
43-
height: 2555
43+
height: 2552
4444
--- !u!114 &114350483966674976
4545
MonoBehaviour:
4646
m_ObjectHideFlags: 1
@@ -79,7 +79,7 @@ MonoBehaviour:
7979
m_CustomAttributes: []
8080
m_ParameterInfo: []
8181
m_ImportDependencies: []
82-
m_GraphVersion: 18
82+
m_GraphVersion: 19
8383
m_ResourceVersion: 1
8484
m_SubgraphDependencies: []
8585
m_CategoryPath:
@@ -95,10 +95,6 @@ VisualEffectResource:
9595
m_RendererSettings:
9696
motionVectorGenerationMode: 0
9797
shadowCastingMode: 0
98-
rayTracingMode: 0
99-
receiveShadows: 0
100-
reflectionProbeUsage: 0
101-
lightProbeUsage: 0
10298
m_CullingFlags: 3
10399
m_UpdateMode: 0
104100
m_PreWarmDeltaTime: 0.05
@@ -531,6 +527,7 @@ MonoBehaviour:
531527
m_SubOutputs:
532528
- {fileID: 8926484042661614687}
533529
- {fileID: 8926484042661614833}
530+
useBaseColorMap: 3
534531
colorMapping: 0
535532
uvMode: 0
536533
flipbookLayout: 0
@@ -549,7 +546,7 @@ MonoBehaviour:
549546
enableRayTracing: 0
550547
decimationFactor: 1
551548
raytracedScaleMode: 0
552-
needsOwnSort: 0
549+
needsOwnSort: 1
553550
needsOwnAabbBuffer: 0
554551
shaderGraph: {fileID: 0}
555552
materialSettings:
@@ -2401,7 +2398,7 @@ MonoBehaviour:
24012398
m_UIIgnoredErrors: []
24022399
m_Parent: {fileID: 114350483966674976}
24032400
m_Children: []
2404-
m_UIPosition: {x: 107, y: 509}
2401+
m_UIPosition: {x: 249, y: 506}
24052402
m_UICollapsed: 0
24062403
m_UISuperCollapsed: 0
24072404
m_InputSlots:
@@ -3522,7 +3519,7 @@ MonoBehaviour:
35223519
- {fileID: 8926484042661615048}
35233520
- {fileID: 8926484042661615053}
35243521
- {fileID: 8926484042661615054}
3525-
- {fileID: 8926484042661615058}
3522+
- {fileID: 8926484042661615098}
35263523
error: 0.01
35273524
maxIterations: 8
35283525
surfaceType: 2
@@ -4038,142 +4035,6 @@ MonoBehaviour:
40384035
PublicKeyToken=b77a5c561934e089
40394036
m_Direction: 1
40404037
m_LinkedSlots: []
4041-
--- !u!114 &8926484042661615058
4042-
MonoBehaviour:
4043-
m_ObjectHideFlags: 0
4044-
m_CorrespondingSourceObject: {fileID: 0}
4045-
m_PrefabInstance: {fileID: 0}
4046-
m_PrefabAsset: {fileID: 0}
4047-
m_GameObject: {fileID: 0}
4048-
m_Enabled: 1
4049-
m_EditorHideFlags: 0
4050-
m_Script: {fileID: 11500000, guid: ac39bd03fca81b849929b9c966f1836a, type: 3}
4051-
m_Name:
4052-
m_EditorClassIdentifier:
4053-
m_UIIgnoredErrors: []
4054-
m_Parent: {fileID: 0}
4055-
m_Children:
4056-
- {fileID: 8926484042661615059}
4057-
- {fileID: 8926484042661615060}
4058-
- {fileID: 8926484042661615061}
4059-
m_UIPosition: {x: 0, y: 0}
4060-
m_UICollapsed: 1
4061-
m_UISuperCollapsed: 0
4062-
m_MasterSlot: {fileID: 8926484042661615058}
4063-
m_MasterData:
4064-
m_Owner: {fileID: 8926484042661615042}
4065-
m_Value:
4066-
m_Type:
4067-
m_SerializableType: UnityEngine.Vector3, UnityEngine.CoreModule, Version=0.0.0.0,
4068-
Culture=neutral, PublicKeyToken=null
4069-
m_SerializableObject: '{"x":0.0,"y":0.0,"z":0.0}'
4070-
m_Space: -1
4071-
m_Property:
4072-
name: currentDirectionWS
4073-
m_serializedType:
4074-
m_SerializableType: UnityEngine.Vector3, UnityEngine.CoreModule, Version=0.0.0.0,
4075-
Culture=neutral, PublicKeyToken=null
4076-
m_Direction: 1
4077-
m_LinkedSlots: []
4078-
--- !u!114 &8926484042661615059
4079-
MonoBehaviour:
4080-
m_ObjectHideFlags: 0
4081-
m_CorrespondingSourceObject: {fileID: 0}
4082-
m_PrefabInstance: {fileID: 0}
4083-
m_PrefabAsset: {fileID: 0}
4084-
m_GameObject: {fileID: 0}
4085-
m_Enabled: 1
4086-
m_EditorHideFlags: 0
4087-
m_Script: {fileID: 11500000, guid: f780aa281814f9842a7c076d436932e7, type: 3}
4088-
m_Name:
4089-
m_EditorClassIdentifier:
4090-
m_UIIgnoredErrors: []
4091-
m_Parent: {fileID: 8926484042661615058}
4092-
m_Children: []
4093-
m_UIPosition: {x: 0, y: 0}
4094-
m_UICollapsed: 1
4095-
m_UISuperCollapsed: 0
4096-
m_MasterSlot: {fileID: 8926484042661615058}
4097-
m_MasterData:
4098-
m_Owner: {fileID: 0}
4099-
m_Value:
4100-
m_Type:
4101-
m_SerializableType:
4102-
m_SerializableObject:
4103-
m_Space: -1
4104-
m_Property:
4105-
name: x
4106-
m_serializedType:
4107-
m_SerializableType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral,
4108-
PublicKeyToken=b77a5c561934e089
4109-
m_Direction: 1
4110-
m_LinkedSlots: []
4111-
--- !u!114 &8926484042661615060
4112-
MonoBehaviour:
4113-
m_ObjectHideFlags: 0
4114-
m_CorrespondingSourceObject: {fileID: 0}
4115-
m_PrefabInstance: {fileID: 0}
4116-
m_PrefabAsset: {fileID: 0}
4117-
m_GameObject: {fileID: 0}
4118-
m_Enabled: 1
4119-
m_EditorHideFlags: 0
4120-
m_Script: {fileID: 11500000, guid: f780aa281814f9842a7c076d436932e7, type: 3}
4121-
m_Name:
4122-
m_EditorClassIdentifier:
4123-
m_UIIgnoredErrors: []
4124-
m_Parent: {fileID: 8926484042661615058}
4125-
m_Children: []
4126-
m_UIPosition: {x: 0, y: 0}
4127-
m_UICollapsed: 1
4128-
m_UISuperCollapsed: 0
4129-
m_MasterSlot: {fileID: 8926484042661615058}
4130-
m_MasterData:
4131-
m_Owner: {fileID: 0}
4132-
m_Value:
4133-
m_Type:
4134-
m_SerializableType:
4135-
m_SerializableObject:
4136-
m_Space: -1
4137-
m_Property:
4138-
name: y
4139-
m_serializedType:
4140-
m_SerializableType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral,
4141-
PublicKeyToken=b77a5c561934e089
4142-
m_Direction: 1
4143-
m_LinkedSlots: []
4144-
--- !u!114 &8926484042661615061
4145-
MonoBehaviour:
4146-
m_ObjectHideFlags: 0
4147-
m_CorrespondingSourceObject: {fileID: 0}
4148-
m_PrefabInstance: {fileID: 0}
4149-
m_PrefabAsset: {fileID: 0}
4150-
m_GameObject: {fileID: 0}
4151-
m_Enabled: 1
4152-
m_EditorHideFlags: 0
4153-
m_Script: {fileID: 11500000, guid: f780aa281814f9842a7c076d436932e7, type: 3}
4154-
m_Name:
4155-
m_EditorClassIdentifier:
4156-
m_UIIgnoredErrors: []
4157-
m_Parent: {fileID: 8926484042661615058}
4158-
m_Children: []
4159-
m_UIPosition: {x: 0, y: 0}
4160-
m_UICollapsed: 1
4161-
m_UISuperCollapsed: 0
4162-
m_MasterSlot: {fileID: 8926484042661615058}
4163-
m_MasterData:
4164-
m_Owner: {fileID: 0}
4165-
m_Value:
4166-
m_Type:
4167-
m_SerializableType:
4168-
m_SerializableObject:
4169-
m_Space: -1
4170-
m_Property:
4171-
name: z
4172-
m_serializedType:
4173-
m_SerializableType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral,
4174-
PublicKeyToken=b77a5c561934e089
4175-
m_Direction: 1
4176-
m_LinkedSlots: []
41774038
--- !u!114 &8926484042661615062
41784039
MonoBehaviour:
41794040
m_ObjectHideFlags: 0
@@ -5339,3 +5200,105 @@ MonoBehaviour:
53395200
m_Direction: 0
53405201
m_LinkedSlots:
53415202
- {fileID: 8926484042661615038}
5203+
--- !u!114 &8926484042661615098
5204+
MonoBehaviour:
5205+
m_ObjectHideFlags: 0
5206+
m_CorrespondingSourceObject: {fileID: 0}
5207+
m_PrefabInstance: {fileID: 0}
5208+
m_PrefabAsset: {fileID: 0}
5209+
m_GameObject: {fileID: 0}
5210+
m_Enabled: 1
5211+
m_EditorHideFlags: 0
5212+
m_Script: {fileID: 11500000, guid: 1b2b751071c7fc14f9fa503163991826, type: 3}
5213+
m_Name:
5214+
m_EditorClassIdentifier: Unity.VisualEffectGraph.Editor::UnityEditor.VFX.VFXSlotFloat2
5215+
m_UIIgnoredErrors: []
5216+
m_Parent: {fileID: 0}
5217+
m_Children:
5218+
- {fileID: 8926484042661615099}
5219+
- {fileID: 8926484042661615100}
5220+
m_UIPosition: {x: 0, y: 0}
5221+
m_UICollapsed: 1
5222+
m_UISuperCollapsed: 0
5223+
m_MasterSlot: {fileID: 8926484042661615098}
5224+
m_MasterData:
5225+
m_Owner: {fileID: 8926484042661615042}
5226+
m_Value:
5227+
m_Type:
5228+
m_SerializableType: UnityEngine.Vector2, UnityEngine.CoreModule, Version=0.0.0.0,
5229+
Culture=neutral, PublicKeyToken=null
5230+
m_SerializableObject: '{"x":0.0,"y":0.0}'
5231+
m_Space: -1
5232+
m_Property:
5233+
name: currentDirectionWS
5234+
m_serializedType:
5235+
m_SerializableType: UnityEngine.Vector2, UnityEngine.CoreModule, Version=0.0.0.0,
5236+
Culture=neutral, PublicKeyToken=null
5237+
m_Direction: 1
5238+
m_LinkedSlots: []
5239+
--- !u!114 &8926484042661615099
5240+
MonoBehaviour:
5241+
m_ObjectHideFlags: 0
5242+
m_CorrespondingSourceObject: {fileID: 0}
5243+
m_PrefabInstance: {fileID: 0}
5244+
m_PrefabAsset: {fileID: 0}
5245+
m_GameObject: {fileID: 0}
5246+
m_Enabled: 1
5247+
m_EditorHideFlags: 0
5248+
m_Script: {fileID: 11500000, guid: f780aa281814f9842a7c076d436932e7, type: 3}
5249+
m_Name:
5250+
m_EditorClassIdentifier: Unity.VisualEffectGraph.Editor::UnityEditor.VFX.VFXSlotFloat
5251+
m_UIIgnoredErrors: []
5252+
m_Parent: {fileID: 8926484042661615098}
5253+
m_Children: []
5254+
m_UIPosition: {x: 0, y: 0}
5255+
m_UICollapsed: 1
5256+
m_UISuperCollapsed: 0
5257+
m_MasterSlot: {fileID: 8926484042661615098}
5258+
m_MasterData:
5259+
m_Owner: {fileID: 0}
5260+
m_Value:
5261+
m_Type:
5262+
m_SerializableType:
5263+
m_SerializableObject:
5264+
m_Space: -1
5265+
m_Property:
5266+
name: x
5267+
m_serializedType:
5268+
m_SerializableType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral,
5269+
PublicKeyToken=b77a5c561934e089
5270+
m_Direction: 1
5271+
m_LinkedSlots: []
5272+
--- !u!114 &8926484042661615100
5273+
MonoBehaviour:
5274+
m_ObjectHideFlags: 0
5275+
m_CorrespondingSourceObject: {fileID: 0}
5276+
m_PrefabInstance: {fileID: 0}
5277+
m_PrefabAsset: {fileID: 0}
5278+
m_GameObject: {fileID: 0}
5279+
m_Enabled: 1
5280+
m_EditorHideFlags: 0
5281+
m_Script: {fileID: 11500000, guid: f780aa281814f9842a7c076d436932e7, type: 3}
5282+
m_Name:
5283+
m_EditorClassIdentifier: Unity.VisualEffectGraph.Editor::UnityEditor.VFX.VFXSlotFloat
5284+
m_UIIgnoredErrors: []
5285+
m_Parent: {fileID: 8926484042661615098}
5286+
m_Children: []
5287+
m_UIPosition: {x: 0, y: 0}
5288+
m_UICollapsed: 1
5289+
m_UISuperCollapsed: 0
5290+
m_MasterSlot: {fileID: 8926484042661615098}
5291+
m_MasterData:
5292+
m_Owner: {fileID: 0}
5293+
m_Value:
5294+
m_Type:
5295+
m_SerializableType:
5296+
m_SerializableObject:
5297+
m_Space: -1
5298+
m_Property:
5299+
name: y
5300+
m_serializedType:
5301+
m_SerializableType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral,
5302+
PublicKeyToken=b77a5c561934e089
5303+
m_Direction: 1
5304+
m_LinkedSlots: []

0 commit comments

Comments
 (0)