浏览代码

More dfraft

/feature-ReflectionProbeFit
sebastienlagarde 7 年前
当前提交
db2bdfc0
共有 6 个文件被更改,包括 49 次插入70 次删除
  1. 14
      ScriptableRenderPipeline/HDRenderPipeline/Camera/HDAdditionalCameraData.cs
  2. 37
      ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplay.cs
  3. 6
      ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
  4. 14
      ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipelineAsset.cs
  5. 13
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightLoop/LightLoopSettings.cs
  6. 35
      ScriptableRenderPipeline/HDRenderPipeline/RenderPipeline/FrameSettings.cs

14
ScriptableRenderPipeline/HDRenderPipeline/Camera/HDAdditionalCameraData.cs


};
public RenderingPath renderingPath;
public FrameSettings frameSettings = new FrameSettings();
// To be able to turn on/off FrameSettings properties at runtime for debugging purpose without affecting the original one
// we create a runtime copy (m_effectiveFrameSettings that is used, and any parametrization is done on serialized frameSettings)
public FrameSettings frameSettings = new FrameSettings(); // Serialize frameSettings
// Not serialized, not visible
FrameSettings m_effectiveFrameSettings = new FrameSettings();
public FrameSettings GetEffectiveFrameSettings()
{
return m_effectiveFrameSettings;
}
Camera m_camera;

// What should be done is just in our Post process we convert to sRGB and store in a linear 10bit, but require C++ change...
m_camera = GetComponent<Camera>();
m_camera.allowHDR = false;
m_effectiveFrameSettings = frameSettings;
}
}
}

37
ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplay.cs


lightingDebugSettings.debugLightingMode = value;
}
public void RegisterDebug(FrameSettings debugSettings, FrameSettings defaultFrameSettings)
public void RegisterDebug(FrameSettings defaultFrameSettings)
{
DebugMenuManager.instance.AddDebugItem<float>("Display Stats", "Frame Rate", () => 1.0f / Time.smoothDeltaTime, null, DebugItemFlag.DynamicDisplay);
DebugMenuManager.instance.AddDebugItem<float>("Display Stats", "Frame Time (ms)", () => Time.smoothDeltaTime * 1000.0f, null, DebugItemFlag.DynamicDisplay);

DebugMenuManager.instance.AddDebugItem<Attributes.DebugViewProperties>("Material", "Properties", () => materialDebugSettings.debugViewProperties, (value) => SetDebugViewProperties((Attributes.DebugViewProperties)value));
DebugMenuManager.instance.AddDebugItem<int>("Material", "GBuffer",() => materialDebugSettings.debugViewGBuffer, (value) => SetDebugViewGBuffer((int)value), DebugItemFlag.None, new DebugItemHandlerIntEnum(MaterialDebugSettings.debugViewMaterialGBufferStrings, MaterialDebugSettings.debugViewMaterialGBufferValues));
DebugMenuManager.instance.AddDebugItem<bool>("Rendering", "Enable Subsurface Scattering", () => debugSettings.lightingSettings.enableSSSAndTransmission, (value) => debugSettings.lightingSettings.enableSSSAndTransmission = (bool)value);
DebugMenuManager.instance.AddDebugItem<LightingDebugPanel, bool>(kEnableShadowDebug, () => debugSettings.lightingSettings.enableShadow, (value) => debugSettings.lightingSettings.enableShadow = (bool)value);
DebugMenuManager.instance.AddDebugItem<LightingDebugPanel, ShadowMapDebugMode>(kShadowDebugMode, () => lightingDebugSettings.shadowDebugMode, (value) => lightingDebugSettings.shadowDebugMode = (ShadowMapDebugMode)value);
DebugMenuManager.instance.AddDebugItem<LightingDebugPanel, bool>(kShadowSelectionDebug, () => lightingDebugSettings.shadowDebugUseSelection, (value) => lightingDebugSettings.shadowDebugUseSelection = (bool)value, DebugItemFlag.EditorOnly);
DebugMenuManager.instance.AddDebugItem<LightingDebugPanel, uint>(kShadowMapIndexDebug, () => lightingDebugSettings.shadowMapIndex, (value) => lightingDebugSettings.shadowMapIndex = (uint)value, DebugItemFlag.None, new DebugItemHandlerShadowIndex(1));

DebugMenuManager.instance.AddDebugItem<LightingDebugPanel, LightLoop.TileClusterDebug>(kTileClusterDebug,() => lightingDebugSettings.tileClusterDebug, (value) => lightingDebugSettings.tileClusterDebug = (LightLoop.TileClusterDebug)value);
DebugMenuManager.instance.AddDebugItem<LightingDebugPanel, LightLoop.TileClusterCategoryDebug>(kTileClusterCategoryDebug,() => lightingDebugSettings.tileClusterDebugByCategory, (value) => lightingDebugSettings.tileClusterDebugByCategory = (LightLoop.TileClusterCategoryDebug)value);
DebugMenuManager.instance.AddDebugItem<bool>("Rendering", "Enable Opaque", () => debugSettings.renderSettings.enableOpaqueObjects, (value) => debugSettings.renderSettings.enableOpaqueObjects = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>("Rendering", "Enable Transparent", () => debugSettings.renderSettings.enableTransparentObjects, (value) => debugSettings.renderSettings.enableTransparentObjects = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>("Rendering", "Enable Atmospheric Scattering",() => debugSettings.renderSettings.enableAtmosphericScattering, (value) => debugSettings.renderSettings.enableAtmosphericScattering = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>("Rendering", "Enable Distortion",() => debugSettings.renderSettings.enableDistortion, (value) => debugSettings.renderSettings.enableDistortion = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>("Rendering", "Enable Stereo Rendering",() => debugSettings.renderSettings.enableStereo, (value) => debugSettings.renderSettings.enableStereo = (bool)value);
// Following settings are overwrite of defaultFrameSettings instead of using debugSettings as otherwise we can't have a correct rendering (as debugSettings will always be enabled)
// These need to be Runtime Only because those values are held by the HDRenderPipeline asset so if user change them through the editor debug menu they might change the value in the asset without noticing it.
DebugMenuManager.instance.AddDebugItem<bool>("HDRP", "Forward Only", () => defaultFrameSettings.renderSettings.enableForwardRenderingOnly, (value) => debugSettings.renderSettings.enableForwardRenderingOnly = (bool)value, DebugItemFlag.RuntimeOnly);
DebugMenuManager.instance.AddDebugItem<bool>("HDRP", "Deferred Depth Prepass", () => defaultFrameSettings.renderSettings.enableDepthPrepassWithDeferredRendering, (value) => debugSettings.renderSettings.enableDepthPrepassWithDeferredRendering = (bool)value, DebugItemFlag.RuntimeOnly);
DebugMenuManager.instance.AddDebugItem<bool>("HDRP", "Deferred Depth Prepass ATest Only", () => defaultFrameSettings.renderSettings.enableAlphaTestOnlyInDeferredPrepass, (value) => debugSettings.renderSettings.enableAlphaTestOnlyInDeferredPrepass = (bool)value, DebugItemFlag.RuntimeOnly);
DebugMenuManager.instance.AddDebugItem<bool>("Default Framesettings", "Enable Subsurface Scattering", () => defaultFrameSettings.lightingSettings.enableSSSAndTransmission, (value) => defaultFrameSettings.lightingSettings.enableSSSAndTransmission = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>("Default Framesettings", "EnableShadow", () => defaultFrameSettings.lightingSettings.enableShadow, (value) => defaultFrameSettings.lightingSettings.enableShadow = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>("Default Framesettings", "Enable Opaque", () => defaultFrameSettings.renderSettings.enableOpaqueObjects, (value) => defaultFrameSettings.renderSettings.enableOpaqueObjects = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>("Default Framesettings", "Enable Transparent", () => defaultFrameSettings.renderSettings.enableTransparentObjects, (value) => defaultFrameSettings.renderSettings.enableTransparentObjects = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>("Default Framesettings", "Enable Atmospheric Scattering",() => defaultFrameSettings.renderSettings.enableAtmosphericScattering, (value) => defaultFrameSettings.renderSettings.enableAtmosphericScattering = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>("Default Framesettings", "Enable Distortion",() => defaultFrameSettings.renderSettings.enableDistortion, (value) => defaultFrameSettings.renderSettings.enableDistortion = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>("Default Framesettings", "Enable Stereo Rendering",() => defaultFrameSettings.renderSettings.enableStereo, (value) => defaultFrameSettings.renderSettings.enableStereo = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>("Default Framesettings", "Enable Async Compute", () => defaultFrameSettings.renderSettings.enableAsyncCompute, (value) => defaultFrameSettings.renderSettings.enableAsyncCompute = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>("HDRP", "Enable Tile/Cluster", () => defaultFrameSettings.lightLoopSettings.enableTileAndCluster, (value) => debugSettings.lightLoopSettings.enableTileAndCluster = (bool)value, DebugItemFlag.RuntimeOnly);
DebugMenuManager.instance.AddDebugItem<bool>("HDRP", "Enable Big Tile", () => defaultFrameSettings.lightLoopSettings.enableBigTilePrepass, (value) => debugSettings.lightLoopSettings.enableBigTilePrepass = (bool)value, DebugItemFlag.RuntimeOnly);
DebugMenuManager.instance.AddDebugItem<bool>("HDRP", "Enable Compute Lighting", () => defaultFrameSettings.lightLoopSettings.enableComputeLightEvaluation, (value) => debugSettings.lightLoopSettings.enableComputeLightEvaluation = (bool)value, DebugItemFlag.RuntimeOnly);
DebugMenuManager.instance.AddDebugItem<bool>("HDRP", "Enable Light Classification", () => defaultFrameSettings.lightLoopSettings.enableComputeLightVariants, (value) => debugSettings.lightLoopSettings.enableComputeLightVariants = (bool)value, DebugItemFlag.RuntimeOnly);
DebugMenuManager.instance.AddDebugItem<bool>("HDRP", "Enable Material Classification", () => defaultFrameSettings.lightLoopSettings.enableComputeMaterialVariants, (value) => debugSettings.lightLoopSettings.enableComputeMaterialVariants = (bool)value, DebugItemFlag.RuntimeOnly);
DebugMenuManager.instance.AddDebugItem<bool>("Default Framesettings", "Forward Only", () => defaultFrameSettings.renderSettings.enableForwardRenderingOnly, (value) => defaultFrameSettings.renderSettings.enableForwardRenderingOnly = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>("Default Framesettings", "Deferred Depth Prepass", () => defaultFrameSettings.renderSettings.enableDepthPrepassWithDeferredRendering, (value) => defaultFrameSettings.renderSettings.enableDepthPrepassWithDeferredRendering = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>("Default Framesettings", "Deferred Depth Prepass ATest Only", () => defaultFrameSettings.renderSettings.enableAlphaTestOnlyInDeferredPrepass, (value) => defaultFrameSettings.renderSettings.enableAlphaTestOnlyInDeferredPrepass = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>("HDRP", "Enable Async Compute", () => debugSettings.renderSettings.enableAsyncCompute, (value) => debugSettings.renderSettings.enableAsyncCompute = (bool)value, DebugItemFlag.RuntimeOnly);
DebugMenuManager.instance.AddDebugItem<bool>("Default Framesettings", "Enable Tile/Cluster", () => defaultFrameSettings.lightLoopSettings.enableTileAndCluster, (value) => defaultFrameSettings.lightLoopSettings.enableTileAndCluster = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>("Default Framesettings", "Enable Big Tile", () => defaultFrameSettings.lightLoopSettings.enableBigTilePrepass, (value) => defaultFrameSettings.lightLoopSettings.enableBigTilePrepass = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>("Default Framesettings", "Enable Compute Lighting", () => defaultFrameSettings.lightLoopSettings.enableComputeLightEvaluation, (value) => defaultFrameSettings.lightLoopSettings.enableComputeLightEvaluation = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>("Default Framesettings", "Enable Light Classification", () => defaultFrameSettings.lightLoopSettings.enableComputeLightVariants, (value) => defaultFrameSettings.lightLoopSettings.enableComputeLightVariants = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>("Default Framesettings", "Enable Material Classification", () => defaultFrameSettings.lightLoopSettings.enableComputeMaterialVariants, (value) => defaultFrameSettings.lightLoopSettings.enableComputeMaterialVariants = (bool)value);
}
public void OnValidate()

6
ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs


static DebugDisplaySettings s_NeutralDebugDisplaySettings = new DebugDisplaySettings();
DebugDisplaySettings m_CurrentDebugDisplaySettings;
FrameSettings m_debugSettings = new FrameSettings();
FrameSettings m_FrameSettings; // Init every frame
int m_DebugFullScreenTempRT;

m_SkyManager.Build(asset, m_IBLFilterGGX);
m_SkyManager.skySettings = skySettingsToUse;
m_DebugDisplaySettings.RegisterDebug(m_debugSettings, m_Asset.defaultFrameSettings);
m_DebugDisplaySettings.RegisterDebug(m_Asset.GetEffectiveDefaultFrameSettings());
m_DebugFullScreenTempRT = HDShaderIDs._DebugFullScreenTexture;

var additionalCameraData = camera.GetComponent<HDAdditionalCameraData>();
// Note: the scene view camera will never have additionalCameraData
m_FrameSettings = FrameSettings.InitializeFrameSettings( camera, m_Asset.GetGlobalFrameSettings(),
(additionalCameraData && additionalCameraData.renderingPath != HDAdditionalCameraData.RenderingPath.Default) ? additionalCameraData.frameSettings : m_Asset.defaultFrameSettings,
(camera.cameraType != CameraType.Preview && camera.cameraType != CameraType.Preview) ? m_debugSettings : null);
(additionalCameraData && additionalCameraData.renderingPath != HDAdditionalCameraData.RenderingPath.Default) ? additionalCameraData.GetEffectiveFrameSettings() : m_Asset.GetEffectiveDefaultFrameSettings());
// This is the main command buffer used for the frame.
var cmd = CommandBufferPool.Get("");

14
ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipelineAsset.cs


set { m_RenderPipelineResources = value; }
}
// To be able to turn on/off FrameSettings properties at runtime for debugging purpose without affecting the original one
// we create a runtime copy (m_effectiveFrameSettings that is used, and any parametrization is done on serialized frameSettings)
// Not serialized, not visible
FrameSettings m_defaultEffectiveFrameSettings = new FrameSettings();
public FrameSettings GetEffectiveDefaultFrameSettings()
{
return m_defaultEffectiveFrameSettings;
}
// Return the current use GlobalFrameSettings (i.e for the current platform
// Return the current use GlobalFrameSettings (i.e for the current platform)
public GlobalFrameSettings GetGlobalFrameSettings()
{
return globalFrameSettings;

public void OnValidate()
{
// Modification of defaultFrameSettings in the inspector will call OnValidate().
// At this time we copy the settings to those effectively used
m_defaultEffectiveFrameSettings = defaultFrameSettings.deepCopy();
}
}
}

13
ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightLoop/LightLoopSettings.cs


// aggregateFrameSettings already contain the aggregation of RenderPipelineSettings and FrameSettings (regular and/or debug)
static public LightLoopSettings InitializeLightLoopSettings(Camera camera, FrameSettings aggregateFrameSettings,
GlobalFrameSettings globalFrameSettings, FrameSettings frameSettings, FrameSettings debugSettings)
GlobalFrameSettings globalFrameSettings, FrameSettings frameSettings)
{
LightLoopSettings aggregate = new LightLoopSettings();

aggregate.enableComputeMaterialVariants = frameSettings.lightLoopSettings.enableComputeMaterialVariants;
aggregate.enableFptlForForwardOpaque = frameSettings.lightLoopSettings.enableFptlForForwardOpaque;
aggregate.enableBigTilePrepass = frameSettings.lightLoopSettings.enableBigTilePrepass;
// Don't take into account debug settings for reflection probe or preview
if (debugSettings != null && camera.cameraType != CameraType.Reflection && camera.cameraType != CameraType.Preview)
{
aggregate.enableTileAndCluster = aggregate.enableTileAndCluster && debugSettings.lightLoopSettings.enableTileAndCluster;
aggregate.enableComputeLightEvaluation = aggregate.enableComputeLightEvaluation && debugSettings.lightLoopSettings.enableComputeLightEvaluation;
aggregate.enableComputeLightVariants = aggregate.enableComputeLightVariants && debugSettings.lightLoopSettings.enableComputeLightVariants;
aggregate.enableComputeMaterialVariants = aggregate.enableComputeMaterialVariants && debugSettings.lightLoopSettings.enableComputeMaterialVariants;
aggregate.enableFptlForForwardOpaque = aggregate.enableFptlForForwardOpaque && debugSettings.lightLoopSettings.enableFptlForForwardOpaque;
aggregate.enableBigTilePrepass = aggregate.enableBigTilePrepass && debugSettings.lightLoopSettings.enableBigTilePrepass;
}
// Deferred opaque are always using Fptl. Forward opaque can use Fptl or Cluster, transparent use cluster.
// When MSAA is enabled we disable Fptl as it become expensive compare to cluster

35
ScriptableRenderPipeline/HDRenderPipeline/RenderPipeline/FrameSettings.cs


// Init a FrameSettings from renderpipeline settings, frame settings and debug settings (if any)
// This will aggregate the various option
static public FrameSettings InitializeFrameSettings(Camera camera, GlobalFrameSettings globalFrameSettings, FrameSettings frameSettings, FrameSettings debugSettings)
static public FrameSettings InitializeFrameSettings(Camera camera, GlobalFrameSettings globalFrameSettings, FrameSettings frameSettings)
{
FrameSettings aggregate = new FrameSettings();

aggregate.renderSettings.enableMaterialDisplayDebug = false;
aggregate.renderSettings.enableShadowMask = globalFrameSettings.lightingSettings.supportShadowMask;
// Don't display any debug information in reflection probe or preview
if (debugSettings != null && camera.cameraType != CameraType.Reflection && camera.cameraType != CameraType.Preview)
{
// Ignore diffuseGlobalDimmer and specularGlobalDimmer
aggregate.lightingSettings.enableShadow = aggregate.lightingSettings.enableShadow && debugSettings.lightingSettings.enableShadow;
aggregate.lightingSettings.enableSSR = aggregate.lightingSettings.enableSSR && debugSettings.lightingSettings.enableSSR;
aggregate.lightingSettings.enableSSAO = aggregate.lightingSettings.enableSSAO && debugSettings.lightingSettings.enableSSAO;
aggregate.lightingSettings.enableSSSAndTransmission = aggregate.lightingSettings.enableSSSAndTransmission && debugSettings.lightingSettings.enableSSSAndTransmission;
aggregate.renderSettings.enableForwardRenderingOnly = aggregate.renderSettings.enableForwardRenderingOnly && debugSettings.renderSettings.enableForwardRenderingOnly;
aggregate.renderSettings.enableDepthPrepassWithDeferredRendering = aggregate.renderSettings.enableDepthPrepassWithDeferredRendering && debugSettings.renderSettings.enableDepthPrepassWithDeferredRendering;
aggregate.renderSettings.enableAlphaTestOnlyInDeferredPrepass = aggregate.renderSettings.enableAlphaTestOnlyInDeferredPrepass && debugSettings.renderSettings.enableAlphaTestOnlyInDeferredPrepass;
aggregate.renderSettings.enableTransparentPrePass = aggregate.renderSettings.enableTransparentPrePass && debugSettings.renderSettings.enableTransparentPrePass;
aggregate.renderSettings.enableMotionVectors = aggregate.renderSettings.enableMotionVectors && debugSettings.renderSettings.enableMotionVectors;
aggregate.renderSettings.enableDBuffer = aggregate.renderSettings.enableDBuffer && debugSettings.renderSettings.enableDBuffer;
aggregate.renderSettings.enableAtmosphericScattering = aggregate.renderSettings.enableAtmosphericScattering && debugSettings.renderSettings.enableAtmosphericScattering;
aggregate.renderSettings.enableRoughRefraction = aggregate.renderSettings.enableRoughRefraction && debugSettings.renderSettings.enableRoughRefraction;
aggregate.renderSettings.enableTransparentPostPass = aggregate.renderSettings.enableTransparentPostPass && debugSettings.renderSettings.enableTransparentPostPass;
aggregate.renderSettings.enableDistortion = aggregate.renderSettings.enableDistortion && debugSettings.renderSettings.enableDistortion;
aggregate.renderSettings.enablePostprocess = aggregate.renderSettings.enablePostprocess && debugSettings.renderSettings.enablePostprocess;
aggregate.renderSettings.enableStereo = aggregate.renderSettings.enableStereo && debugSettings.renderSettings.enableStereo && UnityEngine.XR.XRSettings.isDeviceActive;
aggregate.renderSettings.enableAsyncCompute = aggregate.renderSettings.enableAsyncCompute && debugSettings.renderSettings.enableAsyncCompute;
aggregate.renderSettings.enableOpaqueObjects = aggregate.renderSettings.enableOpaqueObjects && debugSettings.renderSettings.enableOpaqueObjects;
aggregate.renderSettings.enableTransparentObjects = aggregate.renderSettings.enableTransparentObjects && debugSettings.renderSettings.enableTransparentObjects;
// ignore for enableMaterialDisplayDebug and enableShadowMask
}
aggregate.lightLoopSettings = LightLoopSettings.InitializeLightLoopSettings(camera, aggregate, globalFrameSettings, frameSettings, debugSettings);
aggregate.lightLoopSettings = LightLoopSettings.InitializeLightLoopSettings(camera, aggregate, globalFrameSettings, frameSettings);
return aggregate;
}
正在加载...
取消
保存