Skip to content

Commit a2792de

Browse files
adrien-de-tocquevilleEvergreen
authored andcommitted
[HDRP] Fixed volumetric fog not rendering underwater
When placing volumetric fog under a water surface, it wouldn't render correcly. Fixed that and also added support of sampling the caustics texture in the volumetric fog to have nice caustics underwater. |Analytic|Volumetric| |--|--| | ![image](https://media.github.cds.internal.unity3d.com/user/2154/files/f19351bd-a4ab-41d4-9cf5-5f11925385d0) | ![image](https://media.github.cds.internal.unity3d.com/user/2154/files/b9cc1009-a6a0-40d3-9c63-3d591c707e74) |
1 parent b3a1243 commit a2792de

File tree

179 files changed

+112828
-17570
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

179 files changed

+112828
-17570
lines changed

Packages/com.unity.render-pipelines.core/Editor/PostProcessing/LensFlareComponentSRPEditor.cs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
using System;
12
using System.IO;
3+
using System.Reflection;
24
using UnityEngine;
35
using UnityEngine.Rendering;
46

@@ -22,8 +24,7 @@ class LensFlareComponentSRPEditor : Editor
2224
SerializedProperty m_AttenuationByLightShape;
2325
SerializedProperty m_RadialScreenAttenuationCurve;
2426
SerializedProperty m_UseOcclusion;
25-
SerializedProperty m_fogOcclusion;
26-
SerializedProperty m_WaterOcclusion;
27+
SerializedProperty m_EnvironementOcclusion;
2728
SerializedProperty m_OcclusionRadius;
2829
SerializedProperty m_SamplesCount;
2930
SerializedProperty m_OcclusionOffset;
@@ -57,8 +58,7 @@ void OnEnable()
5758
m_AttenuationByLightShape = entryPoint.Find(x => x.attenuationByLightShape);
5859
m_RadialScreenAttenuationCurve = entryPoint.Find(x => x.radialScreenAttenuationCurve);
5960
m_UseOcclusion = entryPoint.Find(x => x.useOcclusion);
60-
m_fogOcclusion = entryPoint.Find(x => x.useFogOpacityOcclusion);
61-
m_WaterOcclusion = entryPoint.Find(x => x.useWaterOcclusion);
61+
m_EnvironementOcclusion = entryPoint.Find(x => x.environmentOcclusion);
6262
m_OcclusionRadius = entryPoint.Find(x => x.occlusionRadius);
6363
m_SamplesCount = entryPoint.Find(x => x.sampleCount);
6464
m_OcclusionOffset = entryPoint.Find(x => x.occlusionOffset);
@@ -80,6 +80,15 @@ void OnDisable()
8080
/// </summary>
8181
public override void OnInspectorGUI()
8282
{
83+
var renderPipelineAssetType = GraphicsSettings.currentRenderPipelineAssetType;
84+
if (renderPipelineAssetType != null && renderPipelineAssetType.Name == "HDRenderPipelineAsset")
85+
{
86+
if (!(bool)Type.GetType("UnityEditor.Rendering.HighDefinition.HDEditorUtils,Unity.RenderPipelines.HighDefinition.Editor")
87+
.GetMethod("DataDrivenLensFlareHelpBox", BindingFlags.Static | BindingFlags.NonPublic)
88+
.Invoke(null, null))
89+
return;
90+
}
91+
8392
LensFlareComponentSRP lensFlareData = m_Intensity.serializedObject.targetObject as LensFlareComponentSRP;
8493
bool attachedToLight = false;
8594
bool lightIsDirLight = false;
@@ -155,18 +164,15 @@ public override void OnInspectorGUI()
155164
}
156165
EditorGUILayout.PropertyField(m_RadialScreenAttenuationCurve, Styles.radialScreenAttenuationCurve);
157166
}
158-
EditorGUILayout.LabelField(Styles.occlusionData.text, EditorStyles.boldLabel);
167+
159168
EditorGUILayout.PropertyField(m_UseOcclusion, Styles.enableOcclusion);
160169
if (m_UseOcclusion.boolValue)
161170
{
162171
++EditorGUI.indentLevel;
163172
EditorGUI.BeginDisabledGroup(m_AttachedLight != null && m_AttachedLight.type != LightType.Directional);
164173
{
165174
if (RenderPipelineManager.currentPipeline is ICloudBackground)
166-
EditorGUILayout.PropertyField(m_fogOcclusion, Styles.fogAndCloudOpacityOcclusion);
167-
if (RenderPipelineManager.currentPipeline is IWaterRendering waterRendering &&
168-
waterRendering.IsWaterRenderingUsable())
169-
EditorGUILayout.PropertyField(m_WaterOcclusion, Styles.waterOcclusion);
175+
EditorGUILayout.PropertyField(m_EnvironementOcclusion, Styles.environmentOcclusion);
170176
}
171177
EditorGUI.EndDisabledGroup();
172178

@@ -193,7 +199,6 @@ public override void OnInspectorGUI()
193199
static class Styles
194200
{
195201
static public readonly GUIContent generalData = EditorGUIUtility.TrTextContent("General");
196-
static public readonly GUIContent occlusionData = EditorGUIUtility.TrTextContent("Screen Space Occlusion");
197202

198203
static public readonly GUIContent lensFlareData = EditorGUIUtility.TrTextContent("Lens Flare Data", "Specifies the SRP Lens Flare Data asset this component uses.");
199204
static public readonly GUIContent newButton = EditorGUIUtility.TrTextContent("New", "Create a new SRP Lens Flare Data asset.");
@@ -206,16 +211,15 @@ static class Styles
206211
static public readonly GUIContent scaleByDistanceCurve = EditorGUIUtility.TrTextContent("Scale Distance Curve", "Specifies the curve used to calculate the size of the lens flare based on the distance between the GameObject this asset is attached to, and the Camera.");
207212
static public readonly GUIContent attenuationByLightShape = EditorGUIUtility.TrTextContent("Attenuation By Light Shape", "When enabled, if the component is attached to a light, automatically reduces the effect of the lens flare based on the type and shape of the light.");
208213
static public readonly GUIContent radialScreenAttenuationCurve = EditorGUIUtility.TrTextContent("Screen Attenuation Curve", "Specifies the curve that modifies the intensity of the lens flare based on its distance from the edge of the screen.");
209-
static public readonly GUIContent enableOcclusion = EditorGUIUtility.TrTextContent("Enable", "When enabled, the renderer uses the depth buffer to occlude (partially or completely) the lens flare. Partial occlusion also occurs when the lens flare is partially offscreen.");
210-
static public readonly GUIContent fogAndCloudOpacityOcclusion = EditorGUIUtility.TrTextContent("Fog And Cloud Opacity", "When enabled, the occlusion is attenuated by the Background Clouds, Volumetric Clouds and the Fog.");
214+
static public readonly GUIContent enableOcclusion = EditorGUIUtility.TrTextContent("Screen Space Occlusion", "When enabled, the renderer uses the depth buffer to occlude (partially or completely) the lens flare. Partial occlusion also occurs when the lens flare is partially offscreen.");
215+
static public readonly GUIContent environmentOcclusion = EditorGUIUtility.TrTextContent("Environment Occlusion", "When enabled, environment effects supported by the render pipeline can be used to occlude lens flares.\nThis may include opacity from volumetric clouds, background clouds, fog and water.");
211216
static public readonly GUIContent occlusionRadius = EditorGUIUtility.TrTextContent("Occlusion Radius", "Sets the radius, in meters, around the light used to compute the occlusion of the lens flare. If this area is half occluded by geometry (or half off-screen), the intensity of the lens flare is cut by half.");
212217
static public readonly GUIContent sampleCount = EditorGUIUtility.TrTextContent("Sample Count", "Sets the number of random samples used inside the Occlusion Radius area. A higher sample count gives a smoother attenuation when occluded.");
213218
static public readonly GUIContent occlusionOffset = EditorGUIUtility.TrTextContent("Occlusion Offset", "Sets the offset of the occlusion area in meters between the GameObject this asset is attached to, and the Camera. A positive value moves the occlusion area closer to the Camera.");
214219
static public readonly GUIContent occlusionRemapCurve = EditorGUIUtility.TrTextContent("Occlusion Remap Curve", "Specifies the curve used to remap the occlusion of the flare. By default, the occlusion is linear, between 0 and 1. This can be specifically useful to occlude flare more drastically when behind clouds.");
215220
static public readonly GUIContent allowOffScreen = EditorGUIUtility.TrTextContent("Allow OffScreen", "When enabled, allows the lens flare to affect the scene even when it is outside the Camera's field of view.");
216221
static public readonly GUIContent volumetricCloudOcclusion = EditorGUIUtility.TrTextContent("Volumetric Clouds", "When enabled, HDRP uses the volumetric clouds texture (in screen space) for the occlusion.");
217222
static public readonly GUIContent lightOverride = EditorGUIUtility.TrTextContent("Light Override", "Specifies the light component where the color and shape values are fetched from when using \"Modulate By Light Color\" or \"Attenuation By Light Shape\" properties on a Lens Flare Element. If nothing is specified, the light component from this gameobject is used.");
218-
static public readonly GUIContent waterOcclusion = EditorGUIUtility.TrTextContent("Water", "When enabled, HDRP uses the Water Rendering (in screen space) for the occlusion.");
219223
}
220224
}
221225
}

0 commit comments

Comments
 (0)