浏览代码

Merge pull request #1846 from Unity-Technologies/HDRP/staging

Merge Hdrp/staging
/main
GitHub 6 年前
当前提交
5c6caff1
共有 13 个文件被更改,包括 42 次插入36 次删除
  1. 2
      com.unity.render-pipelines.core/CoreRP/Editor/CameraEditorUtils.cs
  2. 1
      com.unity.render-pipelines.core/CoreRP/Shadow/ShadowBase.cs
  3. 9
      com.unity.render-pipelines.core/CoreRP/Utilities/CoreUtils.cs
  4. 5
      com.unity.render-pipelines.high-definition/CHANGELOG.md
  5. 2
      com.unity.render-pipelines.high-definition/HDRP/Debug/DebugDisplay.cs
  6. 2
      com.unity.render-pipelines.high-definition/HDRP/Editor/RenderPipeline/Settings/SerializedShadowInitParameters.cs
  7. 1
      com.unity.render-pipelines.high-definition/HDRP/Editor/RenderPipeline/Settings/ShadowInitParametersUI.cs
  8. 4
      com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/GlobalLightLoopSettings.cs
  9. 14
      com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoop.cs
  10. 4
      com.unity.render-pipelines.high-definition/HDRP/Lighting/ScreenSpaceShadow.compute
  11. 11
      com.unity.render-pipelines.high-definition/HDRP/Material/NormalBuffer.hlsl
  12. 4
      com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDCustomSamplerId.cs
  13. 19
      com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs

2
com.unity.render-pipelines.core/CoreRP/Editor/CameraEditorUtils.cs


return;
}
GL.sRGBWrite = QualitySettings.activeColorSpace == ColorSpace.Linear;
GL.sRGBWrite = false;
Graphics.DrawTexture(cameraRect, previewCamera.targetTexture, new Rect(0, 0, 1, 1), 0, 0, 0, 0, GUI.color, GUITextureBlit2SRGBMaterial);
}
}

1
com.unity.render-pipelines.core/CoreRP/Shadow/ShadowBase.cs


public int shadowAtlasWidth = kDefaultShadowAtlasSize;
public int shadowAtlasHeight = kDefaultShadowAtlasSize;
public bool shadowMap16Bit;
public int maxPointLightShadows = kDefaultMaxPointLightShadows;
public int maxSpotLightShadows = kDefaultMaxSpotLightShadows;

9
com.unity.render-pipelines.core/CoreRP/Utilities/CoreUtils.cs


public static void DisplayUnsupportedAPIMessage()
{
string msg = "Platform " + SystemInfo.operatingSystem + " with device " + SystemInfo.graphicsDeviceType.ToString() + " is not supported, no rendering will occur";
// If we are in the editor they are many possible targets that does not matches the current OS so we use the active build target instead
#if UNITY_EDITOR
string currentPlatform = UnityEditor.EditorUserBuildSettings.activeBuildTarget.ToString();
#else
string currentPlatform = SystemInfo.operatingSystem;
#endif
string msg = "Platform " + currentPlatform + " with device " + SystemInfo.graphicsDeviceType.ToString() + " is not supported, no rendering will occur";
DisplayUnsupportedMessage(msg);
}

5
com.unity.render-pipelines.high-definition/CHANGELOG.md


### Added
- Added a luminance meter in the debug menu
- Added support of Light, reflection probe, emissive material, volume settings related to lighting to Lighting explorer
- Added support for 16bit shadows
### Fixed
- Fix issue with package upgrading (HDRP resources asset is now versionned to worarkound package manager limitation)

- Fix planar reflections that were not working with tile/cluster (olbique matrix)
- Fix debug menu at runtime not working after nested prefab PR come to trunk
- Fix scrolling issue in density volume
- Fix an issue where the screen where darken when rendering camera preview
- Fix display correct target platform when showing message to inform user that a platform is not supported
- Remove workaround for metal and vulkan in normal buffer encoding/decoding
- Change screen space shadow rendertarget format from ARGB32 to RG16
## [3.1.0-preview]

2
com.unity.render-pipelines.high-definition/HDRP/Debug/DebugDisplay.cs


// Lighting
MinLightingFullScreenDebug,
SSAO,
DeferredShadows,
ScreenSpaceShadows,
PreRefractionColorPyramid,
DepthPyramid,
FinalColorPyramid,

2
com.unity.render-pipelines.high-definition/HDRP/Editor/RenderPipeline/Settings/SerializedShadowInitParameters.cs


public SerializedProperty shadowAtlasWidth;
public SerializedProperty shadowAtlasHeight;
public SerializedProperty shadowMap16Bit;
public SerializedProperty maxPointLightShadows;
public SerializedProperty maxSpotLightShadows;

shadowAtlasWidth = root.Find((ShadowInitParameters s) => s.shadowAtlasWidth);
shadowAtlasHeight = root.Find((ShadowInitParameters s) => s.shadowAtlasHeight);
shadowMap16Bit = root.Find((ShadowInitParameters s) => s.shadowMap16Bit);
maxPointLightShadows = root.Find((ShadowInitParameters s) => s.maxPointLightShadows);
maxSpotLightShadows = root.Find((ShadowInitParameters s) => s.maxSpotLightShadows);
maxDirectionalLightShadows = root.Find((ShadowInitParameters s) => s.maxDirectionalLightShadows);

1
com.unity.render-pipelines.high-definition/HDRP/Editor/RenderPipeline/Settings/ShadowInitParametersUI.cs


++EditorGUI.indentLevel;
EditorGUILayout.PropertyField(d.shadowAtlasWidth, _.GetContent("Atlas Width"));
EditorGUILayout.PropertyField(d.shadowAtlasHeight, _.GetContent("Atlas Height"));
EditorGUILayout.PropertyField(d.shadowMap16Bit, _.GetContent("16-bit Shadow Maps"));
--EditorGUI.indentLevel;
EditorGUILayout.Space();

4
com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/GlobalLightLoopSettings.cs


public int planarReflectionProbeCacheSize = 2;
public PlanarReflectionResolution planarReflectionTextureSize = PlanarReflectionResolution.PlanarReflectionResolution1024;
public int reflectionProbeCacheSize = 128;
public CubeReflectionResolution reflectionCubemapSize = CubeReflectionResolution.CubeReflectionResolution128;
public int reflectionProbeCacheSize = 64;
public CubeReflectionResolution reflectionCubemapSize = CubeReflectionResolution.CubeReflectionResolution256;
public bool reflectionCacheCompressed = false;
public bool planarReflectionCacheCompressed = false;
public SkyResolution skyReflectionSize = SkyResolution.SkyResolution256;

14
com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoop.cs


atlasInit.baseInit.width = (uint)shadowInit.shadowAtlasWidth;
atlasInit.baseInit.height = (uint)shadowInit.shadowAtlasHeight;
atlasInit.baseInit.slices = 1;
atlasInit.baseInit.shadowmapBits = 32;
atlasInit.baseInit.shadowmapBits = shadowInit.shadowMap16Bit ? 16u : 32u;
atlasInit.baseInit.shadowmapFormat = RenderTextureFormat.Shadowmap;
atlasInit.baseInit.samplerState = SamplerState.Default();
atlasInit.baseInit.comparisonSamplerState = ComparisonSamplerState.Default();

m_ShadowMgr = new ShadowManager(shadowSettings, ref scInit, ref budgets, m_Shadowmaps);
// set global overrides - these need to match the override specified in LightLoop/Shadow.hlsl
bool useGlobalOverrides = true;
m_ShadowMgr.SetGlobalShadowOverride(GPUShadowType.Point , ShadowAlgorithm.PCF, ShadowVariant.V2, ShadowPrecision.High, useGlobalOverrides);
m_ShadowMgr.SetGlobalShadowOverride(GPUShadowType.Spot , ShadowAlgorithm.PCF, ShadowVariant.V2, ShadowPrecision.High, useGlobalOverrides);
m_ShadowMgr.SetGlobalShadowOverride(GPUShadowType.Directional , ShadowAlgorithm.PCF, ShadowVariant.V3, ShadowPrecision.High, useGlobalOverrides);
m_ShadowMgr.SetGlobalShadowOverride(GPUShadowType.Point , ShadowAlgorithm.PCF, ShadowVariant.V2, shadowInit.shadowMap16Bit ? ShadowPrecision.Low : ShadowPrecision.High, useGlobalOverrides);
m_ShadowMgr.SetGlobalShadowOverride(GPUShadowType.Spot , ShadowAlgorithm.PCF, ShadowVariant.V2, shadowInit.shadowMap16Bit ? ShadowPrecision.Low : ShadowPrecision.High, useGlobalOverrides);
m_ShadowMgr.SetGlobalShadowOverride(GPUShadowType.Directional , ShadowAlgorithm.PCF, ShadowVariant.V3, shadowInit.shadowMap16Bit ? ShadowPrecision.Low : ShadowPrecision.High, useGlobalOverrides);
m_ShadowMgr.SetShadowLightTypeDelegate(HDShadowLightType);

public bool outputSplitLighting;
}
public void RenderDeferredDirectionalShadow(HDCamera hdCamera, RTHandleSystem.RTHandle deferredShadowRT, RenderTargetIdentifier depthTexture, CommandBuffer cmd)
public void RenderScreenSpaceShadows(HDCamera hdCamera, RTHandleSystem.RTHandle deferredShadowRT, RenderTargetIdentifier depthTexture, CommandBuffer cmd)
{
bool sunLightShadow = m_CurrentSunLight != null && m_CurrentSunLight.GetComponent<AdditionalShadowData>() != null && m_CurrentSunLightShadowIndex >= 0;

return;
}
using (new ProfilingSample(cmd, "Deferred Directional Shadow", CustomSamplerId.TPDeferredDirectionalShadow.GetSampler()))
using (new ProfilingSample(cmd, "Deferred Directional Shadow", CustomSamplerId.TPScreenSpaceShadows.GetSampler()))
{
Vector4 lightDirection = Vector4.zero;
Vector4 lightPosition = Vector4.zero;

// - if there is a sun light casting shadow, we need to use comput directional light shadows
// - if there is a sun light casting shadow, we need to use compute directional light shadows
// and contact shadows of the dominant light (or the directional if contact shadows are enabled on it)
// - if there is no sun or it's not casting shadows, we don't need to compute it's costy directional
// shadows so we only compute contact shadows for the dominant light

4
com.unity.render-pipelines.high-definition/HDRP/Lighting/ScreenSpaceShadow.compute


contactShadow = ComputeContactShadow(posInput, direction);
#endif
_DeferredShadowTextureUAV[pixelCoord] = float4(shadow, contactShadow, 1.0, 1.0);
_DeferredShadowTextureUAV[pixelCoord] = float4(shadow, contactShadow, 1.0, 1.0); // Note: RT is RG16 format
}
[numthreads(DEFERRED_SHADOW_TILE_SIZE, DEFERRED_SHADOW_TILE_SIZE, 1)]

contactShadow = ComputeContactShadow(posInput, direction);
_DeferredShadowTextureUAV[pixelCoord] = float4(1.0, contactShadow, 1.0, 1.0);
_DeferredShadowTextureUAV[pixelCoord] = float4(1.0, contactShadow, 1.0, 1.0); // Note: RT is RG16 format
}

11
com.unity.render-pipelines.high-definition/HDRP/Material/NormalBuffer.hlsl


// RT1 - 8:8:8:8
// Our tangent encoding is based on our normal.
#if defined(SHADER_API_METAL) || defined(SHADER_API_VULKAN)
// With octahedral quad packing we get an artifact for reconstructed tangent at the center of this quad. We use rect packing instead to avoid it.
float2 octNormalWS = PackNormalOctRectEncode(normalData.normalWS);
#else
float2 octNormalWS = PackNormalOctQuadEncode(normalData.normalWS);
#endif
float2 octNormalWS = PackNormalOctQuadEncode(normalData.normalWS);
float3 packNormalWS = PackFloat2To888(saturate(octNormalWS * 0.5 + 0.5));
// We store perceptualRoughness instead of roughness because it is perceptually linear.
outNormalBuffer0 = float4(packNormalWS, normalData.perceptualRoughness);

{
float3 packNormalWS = normalBuffer.rgb;
float2 octNormalWS = Unpack888ToFloat2(packNormalWS);
#if defined(SHADER_API_METAL) || defined(SHADER_API_VULKAN)
normalData.normalWS = UnpackNormalOctRectEncode(octNormalWS * 2.0 - 1.0);
#else
#endif
normalData.perceptualRoughness = normalBuffer.a;
}

4
com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDCustomSamplerId.cs


Forward,
RenderSSAO,
RenderShadows,
RenderDeferredDirectionalShadow,
ScreenSpaceShadows,
BuildLightList,
BlitToFinalRT,
Distortion,

TPPrepareLightsForGPU,
TPPushGlobalParameters,
TPTiledLightingDebug,
TPDeferredDirectionalShadow,
TPScreenSpaceShadows,
TPTileSettingsEnableTileAndCluster,
TPForwardPass,
TPForwardTiledClusterpass,

19
com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs


RTHandleSystem.RTHandle m_CameraStencilBufferCopy;
RTHandleSystem.RTHandle m_VelocityBuffer;
RTHandleSystem.RTHandle m_DeferredShadowBuffer;
RTHandleSystem.RTHandle m_ScreenSpaceShadowsBuffer;
RTHandleSystem.RTHandle m_AmbientOcclusionBuffer;
RTHandleSystem.RTHandle m_DistortionBuffer;

m_DistortionBuffer = RTHandles.Alloc(Vector2.one, filterMode: FilterMode.Point, colorFormat: Builtin.GetDistortionBufferFormat(), sRGB: Builtin.GetDistortionBufferSRGBFlag(), name: "Distortion");
// TODO: For MSAA, we'll need to add a Draw path in order to support MSAA properly
m_DeferredShadowBuffer = RTHandles.Alloc(Vector2.one, filterMode: FilterMode.Point, colorFormat: RenderTextureFormat.ARGB32, sRGB: false, enableRandomWrite: true, name: "DeferredShadow");
// TODO: For MSAA, we'll need to add a Draw path in order to support MSAA properlye
// Use RG16 as we only have one deferred directional and one screen space shadow light currently
m_ScreenSpaceShadowsBuffer = RTHandles.Alloc(Vector2.one, filterMode: FilterMode.Point, colorFormat: RenderTextureFormat.RG16, sRGB: false, enableRandomWrite: true, name: "ScreenSpaceShadowsBuffer");
if (Debug.isDebugBuild)
{

RTHandles.Release(m_AmbientOcclusionBuffer);
RTHandles.Release(m_VelocityBuffer);
RTHandles.Release(m_DistortionBuffer);
RTHandles.Release(m_DeferredShadowBuffer);
RTHandles.Release(m_ScreenSpaceShadowsBuffer);
RTHandles.Release(m_DebugColorPickerBuffer);
RTHandles.Release(m_DebugFullScreenTempBuffer);

hdCamera.SetupGlobalStereoParams(cmd);
}
using (new ProfilingSample(cmd, "Deferred directional shadows", CustomSamplerId.RenderDeferredDirectionalShadow.GetSampler()))
using (new ProfilingSample(cmd, "Screen space shadows", CustomSamplerId.ScreenSpaceShadows.GetSampler()))
if (m_CurrentDebugDisplaySettings.fullScreenDebugMode == FullScreenDebugMode.DeferredShadows)
if (m_CurrentDebugDisplaySettings.fullScreenDebugMode == FullScreenDebugMode.ScreenSpaceShadows)
HDUtils.SetRenderTarget(cmd, hdCamera, m_DeferredShadowBuffer, ClearFlag.Color, CoreUtils.clearColorAllBlack);
HDUtils.SetRenderTarget(cmd, hdCamera, m_ScreenSpaceShadowsBuffer, ClearFlag.Color, CoreUtils.clearColorAllBlack);
m_LightLoop.RenderDeferredDirectionalShadow(hdCamera, m_DeferredShadowBuffer, GetDepthTexture(), cmd);
PushFullScreenDebugTexture(hdCamera, cmd, m_DeferredShadowBuffer, FullScreenDebugMode.DeferredShadows);
m_LightLoop.RenderScreenSpaceShadows(hdCamera, m_ScreenSpaceShadowsBuffer, GetDepthTexture(), cmd);
PushFullScreenDebugTexture(hdCamera, cmd, m_ScreenSpaceShadowsBuffer, FullScreenDebugMode.ScreenSpaceShadows);
}
if (hdCamera.frameSettings.enableAsyncCompute)

正在加载...
取消
保存