浏览代码
Merge pull request #1270 from Unity-Technologies/feature/SSR
Merge pull request #1270 from Unity-Technologies/feature/SSR
Screen Space Reflection (Scene Proxy raycasting)/main
GitHub
7 年前
当前提交
bdeba039
共有 37 个文件被更改,包括 1817 次插入 和 400 次删除
-
43ScriptableRenderPipeline/Core/CoreRP/Debugging/MousePositionDebug.cs
-
1ScriptableRenderPipeline/HDRenderPipeline/CHANGELOG.md
-
3ScriptableRenderPipeline/HDRenderPipeline/HDRP/Camera/HDCamera.cs
-
8ScriptableRenderPipeline/HDRenderPipeline/HDRP/Camera/HDCameraFrameHistoryType.cs
-
228ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugDisplay.cs
-
45ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugDisplay.cs.hlsl
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugDisplay.hlsl
-
83ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugFullScreen.shader
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/LightingDebug.cs
-
19ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/LightingDebug.cs.hlsl
-
37ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Reflection/ScreenSpaceRefractionEditor.cs
-
16ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Lit/LitUI.cs
-
50ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs
-
22ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/GlobalIlluminationUtils.cs
-
12ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.cs
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Reflection/PlanarReflectionProbe.cs
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Reflection/ProbeWrapper.cs
-
34ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Reflection/ScreenSpaceRefraction.cs
-
846ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Reflection/ScreenSpaceTracing.hlsl
-
13ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Reflection/Volumes/ProxyVolume.cs
-
5ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.cs
-
9ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.cs.hlsl
-
369ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.shader
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/LitTessellation.shader
-
19ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderVariables.hlsl
-
16Tests/UTF_Suites_HDRP/Resources/HDRP_Deferred.asset
-
16Tests/UTF_Suites_HDRP/Resources/HDRP_Forward.asset
-
44ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Reflection/HDScreenSpaceReflectionEditor.cs
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Reflection/HDScreenSpaceReflectionEditor.cs.meta
-
73ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Reflection/ScreenSpaceLightingEditor.cs
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Reflection/ScreenSpaceLightingEditor.cs.meta
-
69ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Reflection/ScreenSpaceLighting.cs
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Reflection/ScreenSpaceLighting.cs.meta
-
70ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Reflection/ScreenSpaceReflection.cs
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Reflection/ScreenSpaceReflection.cs.meta
|
|||
using System.Collections; |
|||
using UnityEngine; |
|||
using UnityEditor; |
|||
using UnityEditor.Experimental.Rendering; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
namespace UnityEngine.Experimental.Rendering.HDPipeline |
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
public class ScreenSpaceRefractionEditor : VolumeComponentEditor |
|||
public class ScreenSpaceRefractionEditor : ScreenSpaceLightingEditor |
|||
SerializedDataParameter m_RayMinLevel; |
|||
SerializedDataParameter m_RayMaxLevel; |
|||
SerializedDataParameter m_RayMaxIterations; |
|||
SerializedDataParameter m_RayDepthSuccessBias; |
|||
SerializedDataParameter m_ScreenWeightDistance; |
|||
|
|||
public override void OnEnable() |
|||
{ |
|||
var o = new PropertyFetcher<ScreenSpaceRefraction>(serializedObject); |
|||
|
|||
m_RayMinLevel = Unpack(o.Find(x => x.rayMinLevel)); |
|||
m_RayMaxLevel = Unpack(o.Find(x => x.rayMaxLevel)); |
|||
m_RayMaxIterations = Unpack(o.Find(x => x.rayMaxIterations)); |
|||
m_RayDepthSuccessBias = Unpack(o.Find(x => x.rayDepthSuccessBias)); |
|||
m_ScreenWeightDistance = Unpack(o.Find(x => x.screenWeightDistance)); |
|||
} |
|||
|
|||
public override void OnInspectorGUI() |
|||
{ |
|||
EditorGUILayout.LabelField(CoreEditorUtils.GetContent("HiZ Settings")); |
|||
PropertyField(m_RayMinLevel, CoreEditorUtils.GetContent("Ray Min Level")); |
|||
PropertyField(m_RayMaxLevel, CoreEditorUtils.GetContent("Ray Max Level")); |
|||
PropertyField(m_RayMaxIterations, CoreEditorUtils.GetContent("Ray Max Iterations")); |
|||
PropertyField(m_RayDepthSuccessBias, CoreEditorUtils.GetContent("Ray Depth Success Bias")); |
|||
|
|||
EditorGUILayout.Separator(); |
|||
EditorGUILayout.LabelField(CoreEditorUtils.GetContent("Common Settings")); |
|||
PropertyField(m_ScreenWeightDistance, CoreEditorUtils.GetContent("Screen Weight Distance")); |
|||
} |
|||
|
|||
} |
|||
} |
|
|||
using System.Collections; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
[CanEditMultipleObjects] |
|||
[VolumeComponentEditor(typeof(ScreenSpaceReflection))] |
|||
public class HDScreenSpaceReflectionEditor : ScreenSpaceLightingEditor |
|||
{ |
|||
SerializedDataParameter m_DeferredProjectionModel; |
|||
|
|||
public override void OnEnable() |
|||
{ |
|||
base.OnEnable(); |
|||
|
|||
var o = new PropertyFetcher<ScreenSpaceReflection>(serializedObject); |
|||
m_DeferredProjectionModel = Unpack(o.Find(x => x.deferredProjectionModel)); |
|||
} |
|||
|
|||
public override void OnInspectorGUI() |
|||
{ |
|||
OnCommonInspectorGUI(); |
|||
var projectionModel = (Lit.ProjectionModel)m_DeferredProjectionModel.value.enumValueIndex; |
|||
switch (projectionModel) |
|||
{ |
|||
case Lit.ProjectionModel.HiZ: |
|||
EditorGUILayout.Separator(); |
|||
OnHiZInspectorGUI(); |
|||
break; |
|||
case Lit.ProjectionModel.Proxy: |
|||
EditorGUILayout.Separator(); |
|||
OnProxyInspectorGUI(); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
protected override void OnCommonInspectorGUI() |
|||
{ |
|||
base.OnCommonInspectorGUI(); |
|||
PropertyField(m_DeferredProjectionModel, CoreEditorUtils.GetContent("Projection Model")); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: e1a6d5f7801c9c749a3f7d3bf4294e87 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
public class ScreenSpaceLightingEditor : VolumeComponentEditor |
|||
{ |
|||
protected SerializedDataParameter m_RayLevel; |
|||
protected SerializedDataParameter m_RayMinLevel; |
|||
protected SerializedDataParameter m_RayMaxLevel; |
|||
protected SerializedDataParameter m_RayMaxIterations; |
|||
protected SerializedDataParameter m_DepthBufferThickness; |
|||
protected SerializedDataParameter m_ScreenWeightDistance; |
|||
protected SerializedDataParameter m_RayMaxScreenDistance; |
|||
protected SerializedDataParameter m_RayBlendScreenDistance; |
|||
protected SerializedDataParameter m_RayMarchBehindObjects; |
|||
|
|||
public override void OnEnable() |
|||
{ |
|||
var o = new PropertyFetcher<ScreenSpaceLighting>(serializedObject); |
|||
|
|||
m_RayLevel = Unpack(o.Find(x => x.rayLevel)); |
|||
m_RayMinLevel = Unpack(o.Find(x => x.rayMinLevel)); |
|||
m_RayMaxLevel = Unpack(o.Find(x => x.rayMaxLevel)); |
|||
m_RayMaxIterations = Unpack(o.Find(x => x.rayMaxIterations)); |
|||
m_DepthBufferThickness = Unpack(o.Find(x => x.depthBufferThickness)); |
|||
m_ScreenWeightDistance = Unpack(o.Find(x => x.screenWeightDistance)); |
|||
m_RayMaxScreenDistance = Unpack(o.Find(x => x.rayMaxScreenDistance)); |
|||
m_RayBlendScreenDistance = Unpack(o.Find(x => x.rayBlendScreenDistance)); |
|||
m_RayMarchBehindObjects = Unpack(o.Find(x => x.rayMarchBehindObjects)); |
|||
} |
|||
|
|||
public override void OnInspectorGUI() |
|||
{ |
|||
OnCommonInspectorGUI(); |
|||
EditorGUILayout.Separator(); |
|||
OnHiZInspectorGUI(); |
|||
EditorGUILayout.Separator(); |
|||
OnProxyInspectorGUI(); |
|||
} |
|||
|
|||
protected virtual void OnHiZInspectorGUI() |
|||
{ |
|||
EditorGUILayout.LabelField(CoreEditorUtils.GetContent("HiZ Settings")); |
|||
PropertyField(m_RayMinLevel, CoreEditorUtils.GetContent("Ray Min Level")); |
|||
PropertyField(m_RayMaxLevel, CoreEditorUtils.GetContent("Ray Max Level")); |
|||
PropertyField(m_RayMaxIterations, CoreEditorUtils.GetContent("Ray Max Iterations")); |
|||
PropertyField(m_DepthBufferThickness, CoreEditorUtils.GetContent("Depth Buffer Thickness")); |
|||
PropertyField(m_RayMaxScreenDistance, CoreEditorUtils.GetContent("Max Raymarched Distance (NDC)")); |
|||
PropertyField(m_RayBlendScreenDistance, CoreEditorUtils.GetContent("Blended Raymarched Distance (NDC)")); |
|||
PropertyField(m_RayMarchBehindObjects, CoreEditorUtils.GetContent("Ray March Behind Objects")); |
|||
|
|||
m_RayMinLevel.value.intValue = Mathf.Clamp(m_RayMinLevel.value.intValue, 0, m_RayMaxLevel.value.intValue); |
|||
m_RayMaxLevel.value.intValue = Mathf.Max(0, m_RayMaxLevel.value.intValue); |
|||
m_RayMaxIterations.value.intValue = Mathf.Max(0, m_RayMaxIterations.value.intValue); |
|||
m_DepthBufferThickness.value.floatValue = Mathf.Max(0.001f, m_DepthBufferThickness.value.floatValue); |
|||
m_RayMaxScreenDistance.value.floatValue = Mathf.Clamp(m_RayMaxScreenDistance.value.floatValue, 0.001f, 1.0f); |
|||
m_RayBlendScreenDistance.value.floatValue = Mathf.Clamp(m_RayBlendScreenDistance.value.floatValue, 0.0f, m_RayMaxScreenDistance.value.floatValue); |
|||
} |
|||
|
|||
protected virtual void OnProxyInspectorGUI() |
|||
{ |
|||
|
|||
} |
|||
|
|||
protected virtual void OnCommonInspectorGUI() |
|||
{ |
|||
EditorGUILayout.LabelField(CoreEditorUtils.GetContent("Common Settings")); |
|||
PropertyField(m_ScreenWeightDistance, CoreEditorUtils.GetContent("Screen Weight Distance")); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 5a0cc6d88bd0be54283043dc53877a64 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using UnityEngine.Rendering; |
|||
|
|||
namespace UnityEngine.Experimental.Rendering.HDPipeline |
|||
{ |
|||
[Serializable] |
|||
public abstract class ScreenSpaceLighting : VolumeComponent |
|||
{ |
|||
int m_RayLevelID; |
|||
int m_RayMinLevelID; |
|||
int m_RayMaxLevelID; |
|||
int m_RayMaxIterationsID; |
|||
int m_DepthBufferThicknessID; |
|||
int m_InvScreenWeightDistanceID; |
|||
int m_RayMaxScreenDistanceID; |
|||
int m_RayBlendScreenDistanceID; |
|||
int m_RayMarchBehindObjectsID; |
|||
|
|||
public IntParameter rayLevel = new IntParameter(2); |
|||
public IntParameter rayMinLevel = new IntParameter(2); |
|||
public IntParameter rayMaxLevel = new IntParameter(6); |
|||
public IntParameter rayMaxIterations = new IntParameter(32); |
|||
public FloatParameter depthBufferThickness = new FloatParameter(1f); |
|||
public ClampedFloatParameter screenWeightDistance = new ClampedFloatParameter(0.1f, 0, 1); |
|||
public ClampedFloatParameter rayMaxScreenDistance = new ClampedFloatParameter(0.3f, 0, 1); |
|||
public ClampedFloatParameter rayBlendScreenDistance = new ClampedFloatParameter(0.1f, 0, 1); |
|||
public BoolParameter rayMarchBehindObjects = new BoolParameter(true); |
|||
|
|||
public virtual void PushShaderParameters(CommandBuffer cmd) |
|||
{ |
|||
cmd.SetGlobalInt(m_RayLevelID, rayLevel.value); |
|||
cmd.SetGlobalInt(m_RayMinLevelID, rayMinLevel.value); |
|||
cmd.SetGlobalInt(m_RayMaxLevelID, rayMaxLevel.value); |
|||
cmd.SetGlobalInt(m_RayMaxIterationsID, rayMaxIterations.value); |
|||
cmd.SetGlobalFloat(m_DepthBufferThicknessID, depthBufferThickness.value); |
|||
cmd.SetGlobalFloat(m_InvScreenWeightDistanceID, 1f / screenWeightDistance.value); |
|||
cmd.SetGlobalFloat(m_RayMaxScreenDistanceID, rayMaxScreenDistance.value); |
|||
cmd.SetGlobalFloat(m_RayBlendScreenDistanceID, rayBlendScreenDistance.value); |
|||
cmd.SetGlobalInt(m_RayMarchBehindObjectsID, rayMarchBehindObjects.value ? 1 : 0); |
|||
} |
|||
|
|||
protected abstract void FetchIDs( |
|||
out int rayLevelID, |
|||
out int rayMinLevelID, |
|||
out int rayMaxLevelID, |
|||
out int rayMaxIterationsID, |
|||
out int DepthBufferThicknessID, |
|||
out int invScreenWeightDistanceID, |
|||
out int rayMaxScreenDistanceID, |
|||
out int rayBlendScreenDistanceID, |
|||
out int rayMarchBehindObjectsID |
|||
); |
|||
|
|||
void Awake() |
|||
{ |
|||
FetchIDs( |
|||
out m_RayLevelID, |
|||
out m_RayMinLevelID, |
|||
out m_RayMaxLevelID, |
|||
out m_RayMaxIterationsID, |
|||
out m_DepthBufferThicknessID, |
|||
out m_InvScreenWeightDistanceID, |
|||
out m_RayMaxScreenDistanceID, |
|||
out m_RayBlendScreenDistanceID, |
|||
out m_RayMarchBehindObjectsID |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: abafd8c0d3ca56d44b9469b2b67fc7cc |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using UnityEngine.Rendering; |
|||
|
|||
namespace UnityEngine.Experimental.Rendering.HDPipeline |
|||
{ |
|||
[Serializable] |
|||
public sealed class LitProjectionModelParameter : VolumeParameter<ScreenSpaceReflection.AvailableProjectionModel> |
|||
{ |
|||
public LitProjectionModelParameter() : base(ScreenSpaceReflection.AvailableProjectionModel.Proxy, false) { } |
|||
} |
|||
|
|||
[Serializable] |
|||
public class ScreenSpaceReflection : ScreenSpaceLighting |
|||
{ |
|||
// Values must be in sync with Lit.ProjectionModel
|
|||
public enum AvailableProjectionModel |
|||
{ |
|||
None = 0, |
|||
Proxy = 1, |
|||
HiZ = 2 |
|||
} |
|||
|
|||
static ScreenSpaceReflection s_Default = null; |
|||
public static ScreenSpaceReflection @default |
|||
{ |
|||
get |
|||
{ |
|||
if (s_Default == null) |
|||
{ |
|||
s_Default = ScriptableObject.CreateInstance<ScreenSpaceReflection>(); |
|||
s_Default.hideFlags = HideFlags.HideAndDontSave; |
|||
} |
|||
return s_Default; |
|||
} |
|||
} |
|||
|
|||
int m_DeferredProjectionModel; |
|||
|
|||
public LitProjectionModelParameter deferredProjectionModel = new LitProjectionModelParameter(); |
|||
|
|||
protected override void FetchIDs( |
|||
out int rayLevelID, |
|||
out int rayMinLevelID, |
|||
out int rayMaxLevelID, |
|||
out int rayMaxIterationsID, |
|||
out int depthBufferThicknessID, |
|||
out int screenWeightDistanceID, |
|||
out int rayMaxScreenDistanceID, |
|||
out int rayBlendScreenDistanceID, |
|||
out int rayMarchBehindObjectsID |
|||
) |
|||
{ |
|||
rayLevelID = HDShaderIDs._SSReflectionRayLevel; |
|||
rayMinLevelID = HDShaderIDs._SSReflectionRayMinLevel; |
|||
rayMaxLevelID = HDShaderIDs._SSReflectionRayMaxLevel; |
|||
rayMaxIterationsID = HDShaderIDs._SSReflectionRayMaxIterations; |
|||
depthBufferThicknessID = HDShaderIDs._SSReflectionDepthBufferThickness; |
|||
screenWeightDistanceID = HDShaderIDs._SSReflectionInvScreenWeightDistance; |
|||
rayMaxScreenDistanceID = HDShaderIDs._SSReflectionRayMaxScreenDistance; |
|||
rayBlendScreenDistanceID = HDShaderIDs._SSReflectionRayBlendScreenDistance; |
|||
rayMarchBehindObjectsID = HDShaderIDs._SSReflectionRayMarchBehindObjects; |
|||
} |
|||
|
|||
public override void PushShaderParameters(CommandBuffer cmd) |
|||
{ |
|||
base.PushShaderParameters(cmd); |
|||
cmd.SetGlobalInt(HDShaderIDs._SSReflectionProjectionModel, (int)deferredProjectionModel.value); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 384c4d03a551c44448145f4093304119 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue