浏览代码

another round of change

/feature-ReflectionProbeFit
sebastienlagarde 7 年前
当前提交
feabd543
共有 15 个文件被更改,包括 123 次插入131 次删除
  1. 22
      ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineInspector.Styles.cs
  2. 18
      ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineInspector.cs
  3. 9
      ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineMenuItems.cs
  4. 4
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Material/Lit/LitUI.cs
  5. 2
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Material/SubsurfaceScattering/SubsurfaceScatteringSettingsEditor.cs
  6. 45
      ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
  7. 58
      ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipelineAsset.asset
  8. 29
      ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipelineAsset.cs
  9. 9
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightLoop/LightLoop.cs
  10. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs
  11. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/RenderPipelineMaterial.cs
  12. 14
      ScriptableRenderPipeline/HDRenderPipeline/Material/SubsurfaceScattering/SubsurfaceScatteringManager.cs
  13. 8
      ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyManager.cs
  14. 21
      ScriptableRenderPipeline/HDRenderPipeline/RenderPipeline/RenderPipelineSettings.cs
  15. 11
      ScriptableRenderPipeline/HDRenderPipeline/RenderPipeline/RenderPipelineSettings.cs.meta

22
ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineInspector.Styles.cs


public readonly GUIContent settingsLabel = new GUIContent("Settings");
public readonly GUIContent globalFrameSettings = new GUIContent("Global Frame Settings");
// Texture Settings
public readonly GUIContent textureSettings = new GUIContent("Texture Settings");
public readonly GUIContent spotCookieSize = new GUIContent("Spot Cookie Size");
public readonly GUIContent pointCookieSize = new GUIContent("Point Cookie Size");
public readonly GUIContent reflectionCubemapSize = new GUIContent("Reflection Cubemap Size");
public readonly GUIContent reflectionCacheCompressed = new GUIContent("Compress Reflection Probe Cache");
public readonly GUIContent sssSettings = new GUIContent("Subsurface Scattering Settings");
public readonly GUIContent enableAsyncCompute = new GUIContent("Enable Async Compute");
// Shadow Settings
public readonly GUIContent shadowSettings = new GUIContent("Shadow Settings");
public readonly GUIContent shadowsAtlasWidth = new GUIContent("Atlas Width");
public readonly GUIContent shadowsAtlasHeight = new GUIContent("Atlas Height");
// Tile pass Settings
// LightLoop Settings
public readonly GUIContent lightLoopSettings = new GUIContent("Light Loop Settings");
public readonly GUIContent enableTileAndCluster = new GUIContent("Tile/Clustered");
public readonly GUIContent enableComputeLightEvaluation = new GUIContent("Compute Light Evaluation");

public readonly GUIContent enableBigTilePrepass = new GUIContent("Big tile prepass");
public readonly GUIContent enableAsyncCompute = new GUIContent("Enable Async Compute");
public readonly GUIContent sssSettings = new GUIContent("Subsurface Scattering Settings");
}
static Styles s_Styles;

18
ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineInspector.cs


SerializedProperty m_DefaultDiffuseMaterial;
SerializedProperty m_DefaultShader;
// Global Frame Settings
SerializedProperty m_GlobalFrameSettings;
// LightLoop settings
SerializedProperty m_enableTileAndCluster;
SerializedProperty m_enableSplitLightEvaluation;

m_RenderPipelineResources = properties.Find("m_RenderPipelineResources");
m_DefaultDiffuseMaterial = properties.Find("m_DefaultDiffuseMaterial");
m_DefaultShader = properties.Find("m_DefaultShader");
// Global FrameSettings
m_GlobalFrameSettings = properties.Find(x => x.globalFrameSettings);
// LightLoop settings
m_enableTileAndCluster = properties.Find(x => x.defaultFrameSettings.lightLoopSettings.enableTileAndCluster);

EditorGUI.indentLevel--;
}
void SssSettingsUI(HDRenderPipelineAsset renderContext)
{
EditorGUILayout.Space();
EditorGUILayout.PropertyField(m_SubsurfaceScatteringSettings, s_Styles.sssSettings);
}
EditorGUILayout.PropertyField(m_GlobalFrameSettings, s_Styles.globalFrameSettings);
SssSettingsUI(renderContext);
EditorGUILayout.Space();
EditorGUILayout.PropertyField(m_SubsurfaceScatteringSettings, s_Styles.sssSettings);
EditorGUI.indentLevel--;
}

9
ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineMenuItems.cs


class DoCreateNewAssetHDRISkySettings : DoCreateNewAsset<HDRISkySettings> {}
class DoCreateNewAssetProceduralSkySettings : DoCreateNewAsset<ProceduralSkySettings> {}
class DoCreateNewAssetSubsurfaceScatteringSettings : DoCreateNewAsset<SubsurfaceScatteringSettings> {}
class DoCreateNewAssetGlobalFrameSettings : DoCreateNewAsset<GlobalFrameSettings> { }
[MenuItem("Assets/Create/Render Pipeline/High Definition/Global Frame Settings", priority = CoreUtils.assetCreateMenuPriority2)]
static void MenuCreateGlobalFrameSettings()
{
var icon = EditorGUIUtility.FindTexture("ScriptableObject Icon");
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, ScriptableObject.CreateInstance<DoCreateNewAssetGlobalFrameSettings>(), "New Global Frame Settings.asset", icon, null);
}
[MenuItem("Assets/Create/Render Pipeline/High Definition/Common Settings", priority = CoreUtils.assetCreateMenuPriority2)]
static void MenuCreateCommonSettings()

var icon = EditorGUIUtility.FindTexture("ScriptableObject Icon");
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, ScriptableObject.CreateInstance<DoCreateNewAssetProceduralSkySettings>(), "New ProceduralSkySettings.asset", icon, null);
}
}
}

4
ScriptableRenderPipeline/HDRenderPipeline/Editor/Material/Lit/LitUI.cs


protected void ShaderSSSInputGUI(Material material, int layerIndex)
{
var hdPipeline = RenderPipelineManager.currentPipeline as HDRenderPipeline;
var sssSettings = hdPipeline.sssSettings;
var sssSettings = hdPipeline.GetCurrentSssSettings();
if (sssSettings == null)
{

// TODO: Optimize me
var profiles = hdPipeline.sssSettings.profiles;
var profiles = sssSettings.profiles;
var names = new GUIContent[profiles.Length + 1];
names[0] = new GUIContent("None");

2
ScriptableRenderPipeline/HDRenderPipeline/Editor/Material/SubsurfaceScattering/SubsurfaceScatteringSettingsEditor.cs


CheckStyles();
// Display a warning if this settings asset is not currently in use
if (m_HDPipeline == null || m_HDPipeline.sssSettings != m_Target)
if (m_HDPipeline == null || m_HDPipeline.GetCurrentSssSettings() != m_Target)
EditorGUILayout.HelpBox("These profiles aren't currently in use, assign this asset to the HD render pipeline asset to use them.", MessageType.Warning);
serializedObject.Update();

45
ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs


readonly HDRenderPipelineAsset m_Asset;
public SubsurfaceScatteringSettings GetCurrentSssSettings()
{
return m_Asset.sssSettings;
}
readonly RenderPipelineMaterial m_DeferredMaterial;
readonly List<RenderPipelineMaterial> m_MaterialList = new List<RenderPipelineMaterial>();

int m_DebugFullScreenTempRT;
bool m_FullScreenDebugPushed;
SubsurfaceScatteringSettings m_InternalSSSAsset;
public SubsurfaceScatteringSettings sssSettings
{
get
{
// If no SSS asset is set, build / reuse an internal one for simplicity
var asset = m_Asset.sssSettings;
if (asset == null)
{
if (m_InternalSSSAsset == null)
m_InternalSSSAsset = ScriptableObject.CreateInstance<SubsurfaceScatteringSettings>();
asset = m_InternalSSSAsset;
}
return asset;
}
}
CommonSettings.Settings m_CommonSettings = CommonSettings.Settings.s_Defaultsettings;
SkySettings m_SkySettings = null;

m_CameraSssDiffuseLightingBuffer = HDShaderIDs._CameraSssDiffuseLightingBuffer;
m_CameraSssDiffuseLightingBufferRT = new RenderTargetIdentifier(m_CameraSssDiffuseLightingBuffer);
m_SSSBufferManager.Build(asset.renderPipelineResources, asset.sssSettings);
m_SSSBufferManager.Build(asset);
// Initialize various compute shader resources
m_applyDistortionKernel = m_applyDistortionCS.FindKernel("KMain");

m_DeferredShadowBuffer = HDShaderIDs._DeferredShadowTexture;
m_DeferredShadowBufferRT = new RenderTargetIdentifier(m_DeferredShadowBuffer);
m_MaterialList.ForEach(material => material.Build(asset.renderPipelineResources));
m_MaterialList.ForEach(material => material.Build(asset));
m_LightLoop.Build(asset.renderPipelineResources, RenderPipelineSettings.GetGlobalFrameSettings().shadowInitParams, m_ShadowSettings, m_IBLFilterGGX);
m_LightLoop.Build(asset, m_ShadowSettings, m_IBLFilterGGX);
m_SkyManager.Build(asset.renderPipelineResources, m_IBLFilterGGX);
m_SkyManager.Build(asset, m_IBLFilterGGX);
m_SkyManager.skySettings = skySettingsToUse;
m_DebugDisplaySettings.RegisterDebug(m_debugSettings);

public void OnSceneLoad()
{
// Recreate the textures which went NULL
m_MaterialList.ForEach(material => material.Build(m_Asset.renderPipelineResources));
m_MaterialList.ForEach(material => material.Build(m_Asset));
}
public override void Dispose()

CoreUtils.Destroy(m_DebugDisplayLatlong);
CoreUtils.Destroy(m_DebugFullScreen);
CoreUtils.Destroy(m_ErrorMaterial);
CoreUtils.Destroy(m_InternalSSSAsset);
m_SSSBufferManager.Cleanup();
m_SkyManager.Cleanup();

// First, get aggregate of frame settings base on global settings, camera frame settings and debug settings
var additionalCameraData = camera.GetComponent<HDAdditionalCameraData>();
// Note: the scene view camera will never have additionalCameraData
m_FrameSettings = FrameSettings.InitializeFrameSettings( camera, RenderPipelineSettings.GetGlobalFrameSettings(),
m_FrameSettings = FrameSettings.InitializeFrameSettings( camera, m_Asset.globalFrameSettings,
(additionalCameraData && additionalCameraData.renderingPath != HDAdditionalCameraData.RenderingPath.Default) ? additionalCameraData.frameSettings : m_Asset.defaultFrameSettings,
(camera.cameraType != CameraType.Preview && camera.cameraType != CameraType.Preview) ? m_debugSettings : null);

renderContext.SetupCameraProperties(camera);
PushGlobalParams(hdCamera, cmd, sssSettings);
PushGlobalParams(hdCamera, cmd, m_Asset.sssSettings);
// TODO: Find a correct place to bind these material textures
// We have to bind the material specific global parameters in this mode

{
GPUFence startFence = cmd.CreateGPUFence();
renderContext.ExecuteCommandBuffer(cmd);
// TODO: check that 2 line below can be replace by cmd.Clear() (reset the command buffer instead of recreating it)
//CommandBufferPool.Release(cmd);
//cmd = CommandBufferPool.Get("");
cmd.Clear();
buildGPULightListsCompleteFence = m_LightLoop.BuildGPULightListsAsyncBegin(camera, renderContext, m_CameraDepthStencilBufferRT, m_CameraStencilBufferCopyRT, startFence);

RenderForwardError(m_CullResults, camera, renderContext, cmd, ForwardPass.Opaque);
// SSS pass here handle both SSS material from deferred and forward
m_SSSBufferManager.SubsurfaceScatteringPass(hdCamera, cmd, sssSettings, m_FrameSettings,
m_SSSBufferManager.SubsurfaceScatteringPass(hdCamera, cmd, m_Asset.sssSettings, m_FrameSettings,
m_CameraColorBufferRT, m_CameraSssDiffuseLightingBufferRT, m_CameraDepthStencilBufferRT, GetDepthTexture());
RenderSky(hdCamera, cmd);

58
ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipelineAsset.asset


m_EditorClassIdentifier:
m_RenderPipelineResources: {fileID: 11400000, guid: 3ce144cff5783da45aa5d4fdc2da14b7,
type: 2}
globalRenderingSettings:
useForwardRenderingOnly: 0
useDepthPrepassWithDeferredRendering: 0
renderAlphaTestOnlyInDeferredPrepass: 0
globalTextureSettings:
spotCookieSize: 128
pointCookieSize: 512
reflectionCubemapSize: 128
reflectionCacheCompressed: 0
sssSettings: {fileID: 11400000, guid: c4d57f106d34d0046a33b3e66da29a72, type: 2}
lightLoopSettings:
enableTileAndCluster: 1
enableComputeLightEvaluation: 1
enableComputeLightVariants: 1
enableComputeMaterialVariants: 1
enableFptlForForwardOpaque: 1
enableBigTilePrepass: 1
enableAsyncCompute: 0
shadowInitParams:
shadowAtlasWidth: 4096
shadowAtlasHeight: 4096
defaultFrameSettings:
lightingSettings:
enableShadow: 1
enableSSR: 1
enableSSAO: 1
enableSSSAndTransmission: 1
diffuseGlobalDimmer: 1
specularGlobalDimmer: 1
renderSettings:
enableForwardRenderingOnly: 1
enableDepthPrepassWithDeferredRendering: 0
enableAlphaTestOnlyInDeferredPrepass: 0
enableTransparentPrePass: 1
enableMotionVectors: 1
enableDBuffer: 1
enableAtmosphericScattering: 1
enableRoughRefraction: 1
enableTransparentPostPass: 1
enableDistortion: 1
enablePostprocess: 1
enableStereo: 0
enableAsyncCompute: 0
enableOpaqueObjects: 1
enableTransparentObjects: 1
enableMSAA: 0
enableMaterialDisplayDebug: 0
enableShadowMask: 0
lightLoopSettings:
enableTileAndCluster: 1
enableComputeLightEvaluation: 1
enableComputeLightVariants: 1
enableComputeMaterialVariants: 1
enableFptlForForwardOpaque: 1
enableBigTilePrepass: 1
isFptlEnabled: 1
m_globalFrameSettings: {fileID: 0}
m_sssSettings: {fileID: 0}
m_DefaultDiffuseMaterial: {fileID: 2100000, guid: 73c176f402d2c2f4d929aa5da7585d17,
type: 2}
m_DefaultShader: {fileID: 4800000, guid: 6e4ae4064600d784cac1e41a9e6f2e59, type: 3}

29
ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipelineAsset.cs


}
public FrameSettings defaultFrameSettings = new FrameSettings(); // This are the defaultFrameSettings for all the camera and apply to sceneView
public SubsurfaceScatteringSettings sssSettings;
[SerializeField]
GlobalFrameSettings m_globalFrameSettings;
public GlobalFrameSettings globalFrameSettings
{
// TODO: This function must return the current globalFrameSettings for the given platform
// If nothing is define we return a default value
get
{
if (m_globalFrameSettings == null)
{
if (m_defaultGlobalFrameSettings == null)
m_defaultGlobalFrameSettings = ScriptableObject.CreateInstance<GlobalFrameSettings>(); // TODO: where to destroy this ?
m_globalFrameSettings = m_defaultGlobalFrameSettings;
}
return m_globalFrameSettings;
}
set { m_globalFrameSettings = value; }
}
GlobalFrameSettings m_defaultGlobalFrameSettings;
[SerializeField]
SubsurfaceScatteringSettings m_sssSettings;
// Default Material / Shader
[SerializeField]

9
ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightLoop/LightLoop.cs


return (outputSplitLighting) | (lightLoopTilePass << 1) | (shadowMask << 2) | (debugDisplay << 3);
}
public void Build( RenderPipelineResources renderPipelineResources,
ShadowInitParameters shadowInit, ShadowSettings shadowSettings, IBLFilterGGX iblFilterGGX)
public void Build(HDRenderPipelineAsset hdAsset, ShadowSettings shadowSettings, IBLFilterGGX iblFilterGGX)
m_Resources = renderPipelineResources;
m_Resources = hdAsset.renderPipelineResources;
m_lightList = new LightList();
m_lightList.Allocate();

s_EnvLightDatas = new ComputeBuffer(k_MaxEnvLightsOnScreen, System.Runtime.InteropServices.Marshal.SizeOf(typeof(EnvLightData)));
s_shadowDatas = new ComputeBuffer(k_MaxCascadeCount + k_MaxShadowOnScreen, System.Runtime.InteropServices.Marshal.SizeOf(typeof(ShadowData)));
GlobalLightLoopSettings gLightLoopSettings = RenderPipelineSettings.GetGlobalFrameSettings().lightLoopSettings;
GlobalLightLoopSettings gLightLoopSettings = hdAsset.globalFrameSettings.lightLoopSettings;
m_CookieTexArray = new TextureCache2D();
m_CookieTexArray.AllocTextureArray(gLightLoopSettings.cookieTexArraySize, gLightLoopSettings.spotCookieSize, gLightLoopSettings.spotCookieSize, TextureFormat.RGBA32, true);
m_CubeCookieTexArray = new TextureCacheCubemap();

UnityEditor.SceneView.onSceneGUIDelegate += OnSceneGUI;
#endif
InitShadowSystem(shadowInit, shadowSettings);
InitShadowSystem(hdAsset.globalFrameSettings.shadowInitParams, shadowSettings);
}
public void Cleanup()

2
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs


public Lit() {}
public override void Build(RenderPipelineResources renderPipelineResources)
public override void Build(HDRenderPipelineAsset hdAsset)
{
m_InitPreFGD = CoreUtils.CreateEngineMaterial("Hidden/HDRenderPipeline/PreIntegratedFGD");

2
ScriptableRenderPipeline/HDRenderPipeline/Material/RenderPipelineMaterial.cs


}
// Regular interface
public virtual void Build(RenderPipelineResources renderPipelineResources) {}
public virtual void Build(HDRenderPipelineAsset hdAsset) {}
public virtual void Cleanup() {}
// Following function can be use to initialize GPU resource (once or each frame) and bind them

14
ScriptableRenderPipeline/HDRenderPipeline/Material/SubsurfaceScattering/SubsurfaceScatteringManager.cs


return m_RTIDs[index];
}
public void Build(RenderPipelineResources renderPipelineResources, SubsurfaceScatteringSettings sssSettings)
public void Build(HDRenderPipelineAsset hdAsset)
m_sssSettings = sssSettings;
m_sssSettings = hdAsset.sssSettings;
m_SubsurfaceScatteringCS = renderPipelineResources.subsurfaceScatteringCS;
m_SubsurfaceScatteringCS = hdAsset.renderPipelineResources.subsurfaceScatteringCS;
m_CombineLightingPass = CoreUtils.CreateEngineMaterial(renderPipelineResources.combineLighting);
m_CombineLightingPass = CoreUtils.CreateEngineMaterial(hdAsset.renderPipelineResources.combineLighting);
m_SssVerticalFilterPass = CoreUtils.CreateEngineMaterial(renderPipelineResources.subsurfaceScattering);
m_SssVerticalFilterPass = CoreUtils.CreateEngineMaterial(hdAsset.renderPipelineResources.subsurfaceScattering);
m_SssHorizontalFilterAndCombinePass = CoreUtils.CreateEngineMaterial(renderPipelineResources.subsurfaceScattering);
m_SssHorizontalFilterAndCombinePass = CoreUtils.CreateEngineMaterial(hdAsset.renderPipelineResources.subsurfaceScattering);
m_CopyStencilForSplitLighting = CoreUtils.CreateEngineMaterial(renderPipelineResources.copyStencilBuffer);
m_CopyStencilForSplitLighting = CoreUtils.CreateEngineMaterial(hdAsset.renderPipelineResources.copyStencilBuffer);
m_CopyStencilForSplitLighting.SetInt(HDShaderIDs._StencilRef, (int)StencilLightingUsage.SplitLighting);
}

8
ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyManager.cs


RebuildSkyMatrices(nearPlane, farPlane);
}
public void Build(RenderPipelineResources renderPipelineResources, IBLFilterGGX iblFilterGGX)
public void Build(HDRenderPipelineAsset hdAsset, IBLFilterGGX iblFilterGGX)
m_StandardSkyboxMaterial = CoreUtils.CreateEngineMaterial(renderPipelineResources.skyboxCubemap);
m_StandardSkyboxMaterial = CoreUtils.CreateEngineMaterial(hdAsset.renderPipelineResources.skyboxCubemap);
m_BlitCubemapMaterial = CoreUtils.CreateEngineMaterial(renderPipelineResources.blitCubemap);
m_BlitCubemapMaterial = CoreUtils.CreateEngineMaterial(hdAsset.renderPipelineResources.blitCubemap);
m_OpaqueAtmScatteringMaterial = CoreUtils.CreateEngineMaterial(renderPipelineResources.opaqueAtmosphericScattering);
m_OpaqueAtmScatteringMaterial = CoreUtils.CreateEngineMaterial(hdAsset.renderPipelineResources.opaqueAtmosphericScattering);
m_CurrentUpdateTime = 0.0f;
}

21
ScriptableRenderPipeline/HDRenderPipeline/RenderPipeline/RenderPipelineSettings.cs


using System;
using UnityEngine;
namespace UnityEngine.Experimental.Rendering.HDPipeline
{
public class RenderPipelineSettings : Singleton<RenderPipelineSettings>
{
[SerializeField]
GlobalFrameSettings m_globalFrameSettings;
static public GlobalFrameSettings GetGlobalFrameSettings()
{
if (instance.m_globalFrameSettings == null)
{
instance.m_globalFrameSettings = new GlobalFrameSettings();
}
return instance.m_globalFrameSettings;
}
}
}

11
ScriptableRenderPipeline/HDRenderPipeline/RenderPipeline/RenderPipelineSettings.cs.meta


fileFormatVersion: 2
guid: 1f7e249841334a44f809b475ea9ae2cf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存