浏览代码

Merge pull request #161 from Unity-Technologies/Branch_SceneSettings

Added Scene Setting manager for better handling of scene settings for users.
/Branch_Batching2
GitHub 8 年前
当前提交
207a9a78
共有 44 个文件被更改,包括 378 次插入312 次删除
  1. 2
      Assets/ScriptableRenderPipeline.meta
  2. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline.meta
  3. 16
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs
  4. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Editor.meta
  5. 106
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineInspector.cs
  6. 7
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineMenuItems.cs
  7. 14
      Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.asset
  8. 91
      Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
  9. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting.meta
  10. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightLoop.cs
  11. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/Resources.meta
  12. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass.meta
  13. 24
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs
  14. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material.meta
  15. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit.meta
  16. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit.meta
  17. 33
      Assets/ScriptableRenderPipeline/HDRenderPipeline/SceneSettings/SceneSettings.cs
  18. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass.meta
  19. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky.meta
  20. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/HDRISky/Editor/HDRISkyEditor.cs
  21. 6
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/HDRISky/HDRISkyRenderer.cs
  22. 26
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkyRenderer.cs
  23. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkySettings.cs
  24. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/Resources.meta
  25. 38
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyManager.cs
  26. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyRenderer.cs
  27. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkySettings.cs
  28. 64
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Editor/SceneSettingsManagementWindow.cs
  29. 81
      Assets/ScriptableRenderPipeline/HDRenderPipeline/SceneSettings/SceneSettingsManager.cs
  30. 12
      Assets/ScriptableRenderPipeline/HDRenderPipeline/SceneSettings/SceneSettingsManager.cs.meta
  31. 15
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/HDRISky/HDRISkySettings.cs
  32. 17
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkySettingsSingleton.cs
  33. 45
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipeWindow.cs
  34. 15
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/HDRISky/HDRISkyParameters.cs
  35. 17
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyParametersSingleton.cs
  36. 20
      Assets/TestScenes/HDTest/CascadedShadowsTest/HDRISkyParameters_Cascaded.asset
  37. 9
      Assets/TestScenes/HDTest/CascadedShadowsTest/HDRISkyParameters_Cascaded.asset.meta
  38. 0
      /Assets/ScriptableRenderPipeline/HDRenderPipeline/Editor/SceneSettingsManagementWindow.cs.meta
  39. 0
      /Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/HDRISky/HDRISkySettings.cs.meta
  40. 0
      /Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkySettings.cs.meta
  41. 0
      /Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkySettings.cs
  42. 0
      /Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkySettingsSingleton.cs.meta
  43. 0
      /Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkySettings.cs.meta
  44. 0
      /Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkySettings.cs

2
Assets/ScriptableRenderPipeline.meta


fileFormatVersion: 2
guid: 7f2fa2efb8ce343069fc5393536094ad
guid: 403e54624681147459c529bbda90360e
folderAsset: yes
timeCreated: 1466769773
licenseType: Pro

2
Assets/ScriptableRenderPipeline/HDRenderPipeline.meta


fileFormatVersion: 2
guid: 4c38eac64d0e8344d85c9f309419d619
guid: a75de3f722a762f4daf65be08cd9c5c6
folderAsset: yes
timeCreated: 1483548930
licenseType: Pro

16
Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs


namespace UnityEngine.Experimental.Rendering.HDPipeline
{
[Serializable]
public class GlobalDebugParameters
public class GlobalDebugSettings
{
public float debugOverlayRatio = 0.33f;
public bool displayMaterialDebug = false;

public MaterialDebugParameters materialDebugParameters = new MaterialDebugParameters();
public LightingDebugParameters lightingDebugParameters = new LightingDebugParameters();
public RenderingDebugParameters renderingDebugParametrs = new RenderingDebugParameters();
public MaterialDebugSettings materialDebugSettings = new MaterialDebugSettings();
public LightingDebugSettings lightingDebugSettings = new LightingDebugSettings();
public RenderingDebugSettings renderingDebugSettings = new RenderingDebugSettings();
lightingDebugParameters.OnValidate();
lightingDebugSettings.OnValidate();
public class MaterialDebugParameters
public class MaterialDebugSettings
public class RenderingDebugParameters
public class RenderingDebugSettings
{
public bool displayOpaqueObjects = true;
public bool displayTransparentObjects = true;

}
[Serializable]
public class LightingDebugParameters
public class LightingDebugSettings
{
public bool enableShadows = true;
public ShadowDebugMode shadowDebugMode = ShadowDebugMode.None;

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Editor.meta


fileFormatVersion: 2
guid: ab51b986e84ae98449eab2308fbe74db
guid: 6170264326b703040b82caf4f14a7567
folderAsset: yes
timeCreated: 1479127051
licenseType: Pro

106
Assets/ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineInspector.cs


// Sky Settings
public readonly GUIContent skyParams = new GUIContent("Sky Settings");
// Global debug parameters
// Global debug Settings
public readonly GUIContent debugging = new GUIContent("Debugging");
public readonly GUIContent debugOverlayRatio = new GUIContent("Overlay Ratio");

public int[] debugViewMaterialValues = null;
// Rendering Debug
public readonly GUIContent renderingDebugParameters = new GUIContent("Rendering Debug");
public readonly GUIContent renderingDebugSettings = new GUIContent("Rendering Debug");
public readonly GUIContent lightingDebugParameters = new GUIContent("Lighting Debug");
public readonly GUIContent lightingDebugSettings = new GUIContent("Lighting Debug");
public readonly GUIContent shadowDebugEnable = new GUIContent("Enable Shadows");
public readonly GUIContent shadowDebugVisualizationMode = new GUIContent("Shadow Debug Mode");
public readonly GUIContent shadowDebugVisualizeShadowIndex = new GUIContent("Visualize Shadow Index");

SerializedProperty m_LightingDebugOverrideSmoothnessValue = null;
SerializedProperty m_LightingDebugAlbedo = null;
// Rendering Parameters
// Rendering Settings
SerializedProperty m_RenderingUseForwardOnly = null;
SerializedProperty m_RenderingUseDepthPrepass = null;

m_DebugOverlayRatio = FindProperty(x => x.globalDebugParameters.debugOverlayRatio);
m_ShowLightingDebug = FindProperty(x => x.globalDebugParameters.displayLightingDebug);
m_ShowRenderingDebug = FindProperty(x => x.globalDebugParameters.displayRenderingDebug);
m_ShowMaterialDebug = FindProperty(x => x.globalDebugParameters.displayMaterialDebug);
m_DebugOverlayRatio = FindProperty(x => x.globalDebugSettings.debugOverlayRatio);
m_ShowLightingDebug = FindProperty(x => x.globalDebugSettings.displayLightingDebug);
m_ShowRenderingDebug = FindProperty(x => x.globalDebugSettings.displayRenderingDebug);
m_ShowMaterialDebug = FindProperty(x => x.globalDebugSettings.displayMaterialDebug);
m_MaterialDebugMode = FindProperty(x => x.globalDebugParameters.materialDebugParameters.debugViewMaterial);
m_MaterialDebugMode = FindProperty(x => x.globalDebugSettings.materialDebugSettings.debugViewMaterial);
m_DisplayOpaqueObjects = FindProperty(x => x.globalDebugParameters.renderingDebugParametrs.displayOpaqueObjects);
m_DisplayTransparentObjects = FindProperty(x => x.globalDebugParameters.renderingDebugParametrs.displayTransparentObjects);
m_EnableDistortion = FindProperty(x => x.globalDebugParameters.renderingDebugParametrs.enableDistortion);
m_DisplayOpaqueObjects = FindProperty(x => x.globalDebugSettings.renderingDebugSettings.displayOpaqueObjects);
m_DisplayTransparentObjects = FindProperty(x => x.globalDebugSettings.renderingDebugSettings.displayTransparentObjects);
m_EnableDistortion = FindProperty(x => x.globalDebugSettings.renderingDebugSettings.enableDistortion);
m_DebugShadowEnabled = FindProperty(x => x.globalDebugParameters.lightingDebugParameters.enableShadows);
m_ShadowDebugMode = FindProperty(x => x.globalDebugParameters.lightingDebugParameters.shadowDebugMode);
m_ShadowDebugShadowMapIndex = FindProperty(x => x.globalDebugParameters.lightingDebugParameters.shadowMapIndex);
m_LightingDebugMode = FindProperty(x => x.globalDebugParameters.lightingDebugParameters.lightingDebugMode);
m_LightingDebugOverrideSmoothness = FindProperty(x => x.globalDebugParameters.lightingDebugParameters.overrideSmoothness);
m_LightingDebugOverrideSmoothnessValue = FindProperty(x => x.globalDebugParameters.lightingDebugParameters.overrideSmoothnessValue);
m_LightingDebugAlbedo = FindProperty(x => x.globalDebugParameters.lightingDebugParameters.debugLightingAlbedo);
m_DebugShadowEnabled = FindProperty(x => x.globalDebugSettings.lightingDebugSettings.enableShadows);
m_ShadowDebugMode = FindProperty(x => x.globalDebugSettings.lightingDebugSettings.shadowDebugMode);
m_ShadowDebugShadowMapIndex = FindProperty(x => x.globalDebugSettings.lightingDebugSettings.shadowMapIndex);
m_LightingDebugMode = FindProperty(x => x.globalDebugSettings.lightingDebugSettings.lightingDebugMode);
m_LightingDebugOverrideSmoothness = FindProperty(x => x.globalDebugSettings.lightingDebugSettings.overrideSmoothness);
m_LightingDebugOverrideSmoothnessValue = FindProperty(x => x.globalDebugSettings.lightingDebugSettings.overrideSmoothnessValue);
m_LightingDebugAlbedo = FindProperty(x => x.globalDebugSettings.lightingDebugSettings.debugLightingAlbedo);
m_RenderingUseForwardOnly = FindProperty(x => x.renderingParameters.useForwardRenderingOnly);
m_RenderingUseDepthPrepass = FindProperty(x => x.renderingParameters.useDepthPrepass);
m_RenderingUseForwardOnly = FindProperty(x => x.renderingSettings.useForwardRenderingOnly);
m_RenderingUseDepthPrepass = FindProperty(x => x.renderingSettings.useDepthPrepass);
}

{
EditorGUILayout.LabelField(styles.debugging);
// Global debug parameters
// Global debug settings
MaterialDebugParametersUI(renderContext);
RenderingDebugParametersUI(renderContext);
LightingDebugParametersUI(renderContext, renderpipelineInstance);
MaterialDebugSettingsUI(renderContext);
RenderingDebugSettingsUI(renderContext);
LightingDebugSettingsUI(renderContext, renderpipelineInstance);
EditorGUILayout.Space();

private void MaterialDebugParametersUI(HDRenderPipeline renderContext)
private void MaterialDebugSettingsUI(HDRenderPipeline renderContext)
{
m_ShowMaterialDebug.boolValue = EditorGUILayout.Foldout(m_ShowMaterialDebug.boolValue, styles.materialDebugLabel);
if (!m_ShowMaterialDebug.boolValue)

EditorGUI.indentLevel--;
}
private void RenderingDebugParametersUI(HDRenderPipeline renderContext)
private void RenderingDebugSettingsUI(HDRenderPipeline renderContext)
m_ShowRenderingDebug.boolValue = EditorGUILayout.Foldout(m_ShowRenderingDebug.boolValue, styles.renderingDebugParameters);
m_ShowRenderingDebug.boolValue = EditorGUILayout.Foldout(m_ShowRenderingDebug.boolValue, styles.renderingDebugSettings);
if (!m_ShowRenderingDebug.boolValue)
return;

}
}
private void LightingDebugParametersUI(HDRenderPipeline renderContext, HDRenderPipelineInstance renderpipelineInstance)
private void LightingDebugSettingsUI(HDRenderPipeline renderContext, HDRenderPipelineInstance renderpipelineInstance)
m_ShowLightingDebug.boolValue = EditorGUILayout.Foldout(m_ShowLightingDebug.boolValue, styles.lightingDebugParameters);
m_ShowLightingDebug.boolValue = EditorGUILayout.Foldout(m_ShowLightingDebug.boolValue, styles.lightingDebugSettings);
if (!m_ShowLightingDebug.boolValue)
return;

HackSetDirty(renderContext); // Repaint
}
SkySettingsUI(renderContext);
ShadowParametersUI(renderContext);
TextureParametersUI(renderContext);
RendereringParametersUI(renderContext);
ShadowSettingsUI(renderContext);
TextureSettingsUI(renderContext);
RendereringSettingsUI(renderContext);
private void SkySettingsUI(HDRenderPipeline pipe)
private void ShadowSettingsUI(HDRenderPipeline renderContext)
EditorGUILayout.LabelField(styles.skyParams);
EditorGUI.BeginChangeCheck();
EditorGUI.indentLevel++;
pipe.skyParameters = (SkyParameters)EditorGUILayout.ObjectField(new GUIContent("Sky Settings"), pipe.skyParameters, typeof(SkyParameters), false);
EditorGUI.indentLevel--;
if (EditorGUI.EndChangeCheck())
{
HackSetDirty(pipe); // Repaint
}
}
private void ShadowParametersUI(HDRenderPipeline renderContext)
{
EditorGUILayout.Space();
var shadowParameters = renderContext.shadowSettings;
var shadowSettings = renderContext.shadowSettings;
shadowParameters.shadowAtlasWidth = Mathf.Max(0, EditorGUILayout.IntField(styles.shadowsAtlasWidth, shadowParameters.shadowAtlasWidth));
shadowParameters.shadowAtlasHeight = Mathf.Max(0, EditorGUILayout.IntField(styles.shadowsAtlasHeight, shadowParameters.shadowAtlasHeight));
shadowSettings.shadowAtlasWidth = Mathf.Max(0, EditorGUILayout.IntField(styles.shadowsAtlasWidth, shadowSettings.shadowAtlasWidth));
shadowSettings.shadowAtlasHeight = Mathf.Max(0, EditorGUILayout.IntField(styles.shadowsAtlasHeight, shadowSettings.shadowAtlasHeight));
if (EditorGUI.EndChangeCheck())
{

}
private void RendereringParametersUI(HDRenderPipeline renderContext)
private void RendereringSettingsUI(HDRenderPipeline renderContext)
{
EditorGUILayout.Space();
EditorGUILayout.LabelField(styles.renderingSettingsLabel);

EditorGUI.indentLevel--;
}
private void TextureParametersUI(HDRenderPipeline renderContext)
private void TextureSettingsUI(HDRenderPipeline renderContext)
var textureParameters = renderContext.textureSettings;
var textureSettings = renderContext.textureSettings;
textureParameters.spotCookieSize = Mathf.NextPowerOfTwo(Mathf.Clamp(EditorGUILayout.IntField(styles.spotCookieSize, textureParameters.spotCookieSize), 16, 1024));
textureParameters.pointCookieSize = Mathf.NextPowerOfTwo(Mathf.Clamp(EditorGUILayout.IntField(styles.pointCookieSize, textureParameters.pointCookieSize), 16, 1024));
textureParameters.reflectionCubemapSize = Mathf.NextPowerOfTwo(Mathf.Clamp(EditorGUILayout.IntField(styles.reflectionCubemapSize, textureParameters.reflectionCubemapSize), 64, 1024));
textureSettings.spotCookieSize = Mathf.NextPowerOfTwo(Mathf.Clamp(EditorGUILayout.IntField(styles.spotCookieSize, textureSettings.spotCookieSize), 16, 1024));
textureSettings.pointCookieSize = Mathf.NextPowerOfTwo(Mathf.Clamp(EditorGUILayout.IntField(styles.pointCookieSize, textureSettings.pointCookieSize), 16, 1024));
textureSettings.reflectionCubemapSize = Mathf.NextPowerOfTwo(Mathf.Clamp(EditorGUILayout.IntField(styles.reflectionCubemapSize, textureSettings.reflectionCubemapSize), 64, 1024));
renderContext.textureSettings = textureParameters;
renderContext.textureSettings = textureSettings;
HackSetDirty(renderContext); // Repaint
}
EditorGUI.indentLevel--;

7
Assets/ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineMenuItems.cs


using UnityEngine;
using UnityEditor;
using UnityEngine.SceneManagement;
using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{

LayeredLitGUI.SynchronizeAllLayers(mat);
EditorUtility.SetDirty(mat);
}
}
}
static void RemoveMaterialKeywords(Material material)
{

material.DisableKeyword(keyword);
}
}
}
// The goal of this script is to help maintenance of data that have already been produced but need to update to the latest shader code change.
// In case the shader code have change and the inspector have been update with new kind of keywords we need to regenerate the set of keywords use by the material.

14
Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.asset


m_EditorClassIdentifier:
m_LightLoopProducer: {fileID: 11400000, guid: bf8cd9ae03ff7d54c89603e67be0bfc5,
type: 2}
globalDebugParameters:
globalDebugSettings:
materialDebugParameters:
materialDebugSettings:
lightingDebugParameters:
lightingDebugSettings:
enableShadows: 1
shadowDebugMode: 0
shadowMapIndex: 0

debugLightingAlbedo: {r: 0.5, g: 0.5, b: 0.5, a: 1}
renderingDebugParametrs:
renderingDebugSettings:
renderingParameters:
renderingSettings:
useForwardRenderingOnly: 0
useDepthPrepass: 0
m_ShadowSettings:

maxShadowDistance: 1000
maxShadowDistance: 400
directionalLightCascadeCount: 4
directionalLightCascades: {x: 0.05, y: 0.2, z: 0.3}
directionalLightNearPlaneOffset: 5

m_ShadowCascadeSplit1: 0.2
m_ShadowCascadeSplit2: 0.3
m_ShadowNearPlaneOffset: 5
m_SkyParameters: {fileID: 0}
m_SkySettings: {fileID: 0}

91
Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs


// NOTE:
// All those properties are public because of how HDRenderPipelineInspector retrieve those properties via serialization/reflection
// Those that are not will be refatored later.
public GlobalDebugParameters globalDebugParameters = new GlobalDebugParameters();
public GlobalDebugSettings globalDebugSettings = new GlobalDebugSettings();
public RenderingParameters renderingParameters = new RenderingParameters();
public RenderingSettings renderingSettings = new RenderingSettings();
[SerializeField] ShadowSettings m_ShadowSettings = ShadowSettings.Default;
public SubsurfaceScatteringParameters localSssParameters;
[SerializeField] TextureSettings m_TextureSettings = TextureSettings.Default;

// Renderer Settings (per "scene")
[SerializeField] private CommonSettings.Settings m_CommonSettings = CommonSettings.Settings.s_Defaultsettings;
[SerializeField] private SkyParameters m_SkyParameters;
[SerializeField] private SkySettings m_SkySettings;
public CommonSettings.Settings commonSettingsToUse
{

}
}
public SkyParameters skyParameters
public SkySettings skySettings
get { return m_SkyParameters; }
set { m_SkyParameters = value; }
get { return m_SkySettings; }
set { m_SkySettings = value; }
public SkyParameters skyParametersToUse
public SkySettings skySettingsToUse
if (SkyParametersSingleton.overrideSettings)
return SkyParametersSingleton.overrideSettings;
if (SkySettingsSingleton.overrideSettings)
return SkySettingsSingleton.overrideSettings;
return m_SkyParameters;
return m_SkySettings;
}
}

return localSssParameters;
}
}
public void ApplyDebugParameters()
public void ApplyDebugSettings()
m_ShadowSettings.enabled = globalDebugParameters.lightingDebugParameters.enableShadows;
m_ShadowSettings.enabled = globalDebugSettings.lightingDebugSettings.enableShadows;
LightingDebugParameters lightDebugParameters = globalDebugParameters.lightingDebugParameters;
Vector4 debugModeAndAlbedo = new Vector4((float)lightDebugParameters.lightingDebugMode, lightDebugParameters.debugLightingAlbedo.r, lightDebugParameters.debugLightingAlbedo.g, lightDebugParameters.debugLightingAlbedo.b);
Vector4 debugSmoothness = new Vector4(lightDebugParameters.overrideSmoothness ? 1.0f : 0.0f, lightDebugParameters.overrideSmoothnessValue, 0.0f, 0.0f);
LightingDebugSettings lightDebugSettings = globalDebugSettings.lightingDebugSettings;
Vector4 debugModeAndAlbedo = new Vector4((float)lightDebugSettings.lightingDebugMode, lightDebugSettings.debugLightingAlbedo.r, lightDebugSettings.debugLightingAlbedo.g, lightDebugSettings.debugLightingAlbedo.b);
Vector4 debugSmoothness = new Vector4(lightDebugSettings.overrideSmoothness ? 1.0f : 0.0f, lightDebugSettings.overrideSmoothnessValue, 0.0f, 0.0f);
Shader.SetGlobalVector("_DebugLightModeAndAlbedo", debugModeAndAlbedo);
Shader.SetGlobalVector("_DebugLightingSmoothness", debugSmoothness);

public void OnValidate()
{
globalDebugParameters.OnValidate();
globalDebugSettings.OnValidate();
public class RenderingParameters
public class RenderingSettings
{
public bool useForwardRenderingOnly = false; // TODO: Currently there is no way to strip the extra forward shaders generated by the shaders compiler, so we can switch dynamically.
public bool useDepthPrepass = false;

readonly SkyManager m_SkyManager = new SkyManager();
private readonly BaseLightLoop m_LightLoop;
private GlobalDebugParameters globalDebugParameters
private GlobalDebugSettings globalDebugSettings
get { return m_Owner.globalDebugParameters; }
get { return m_Owner.globalDebugSettings; }
}
public HDRenderPipelineInstance(HDRenderPipeline owner)

m_LightLoop.Build(owner.textureSettings);
m_SkyManager.Build();
m_SkyManager.skyParameters = owner.skyParametersToUse;
m_SkyManager.skySettings = owner.skySettingsToUse;
}
public override void Dispose()

// TODO: This is the wrong way to handle resize/allocation. We can have several different camera here, mean that the loop on camera will allocate and deallocate
// the below buffer which is bad. Best is to have a set of buffer for each camera that is persistent and reallocate resource if need
// For now consider we have only one camera that go to this code, the main one.
m_SkyManager.skyParameters = m_Owner.skyParametersToUse;
m_SkyManager.skySettings = m_Owner.skySettingsToUse;
m_SkyManager.Resize(camera.nearClipPlane, camera.farClipPlane); // TODO: Also a bad naming, here we just want to realloc texture if skyparameters change (usefull for lookdev)
if (m_LightLoop == null)

if (m_LightLoop != null)
m_LightLoop.NewFrame();
m_Owner.ApplyDebugParameters();
m_Owner.ApplyDebugSettings();
m_Owner.UpdateCommonSettings();
// Set Frame constant buffer

cmd.Dispose();
}
if (globalDebugParameters.materialDebugParameters.debugViewMaterial != 0)
if (globalDebugSettings.materialDebugSettings.debugViewMaterial != 0)
{
RenderDebugViewMaterial(cullResults, hdCamera, renderContext);
}

void RenderOpaqueRenderList(CullResults cull, Camera camera, ScriptableRenderContext renderContext, string passName, RendererConfiguration rendererConfiguration = 0)
{
if (!globalDebugParameters.renderingDebugParametrs.displayOpaqueObjects)
if (!globalDebugSettings.renderingDebugSettings.displayOpaqueObjects)
return;
var settings = new DrawRendererSettings(cull, camera, new ShaderPassName(passName))

void RenderTransparentRenderList(CullResults cull, Camera camera, ScriptableRenderContext renderContext, string passName, RendererConfiguration rendererConfiguration = 0)
{
if (!globalDebugParameters.renderingDebugParametrs.displayTransparentObjects)
if (!globalDebugSettings.renderingDebugSettings.displayTransparentObjects)
return;
var settings = new DrawRendererSettings(cull, camera, new ShaderPassName(passName))

{
// If we are forward only we will do a depth prepass
// TODO: Depth prepass should be enabled based on light loop settings. LightLoop define if they need a depth prepass + forward only...
if (!m_Owner.renderingParameters.useDepthPrepass)
if (!m_Owner.renderingSettings.useDepthPrepass)
return;
using (new Utilities.ProfilingSample("Depth Prepass", renderContext))

void RenderGBuffer(CullResults cull, Camera camera, ScriptableRenderContext renderContext)
{
if (m_Owner.renderingParameters.ShouldUseForwardRenderingOnly())
if (m_Owner.renderingSettings.ShouldUseForwardRenderingOnly())
{
return ;
}

bool debugLighting = globalDebugParameters.lightingDebugParameters.lightingDebugMode != LightingDebugMode.None;
bool debugLighting = globalDebugSettings.lightingDebugSettings.lightingDebugMode != LightingDebugMode.None;
// setup GBuffer for rendering
Utilities.SetRenderTarget(renderContext, m_gbufferManager.GetGBuffers(), m_CameraDepthStencilBufferRT);

{
// If we are forward only we don't need to render ForwardOnlyOpaqueDepthOnly object
// But in case we request a prepass we render it
if (m_Owner.renderingParameters.ShouldUseForwardRenderingOnly() && !m_Owner.renderingParameters.useDepthPrepass)
if (m_Owner.renderingSettings.ShouldUseForwardRenderingOnly() && !m_Owner.renderingSettings.useDepthPrepass)
return;
using (new Utilities.ProfilingSample("Forward opaque depth", renderContext))

{
Utilities.SetRenderTarget(renderContext, m_CameraColorBufferRT, m_CameraDepthStencilBufferRT, Utilities.kClearAll, Color.black);
Shader.SetGlobalInt("_DebugViewMaterial", (int)globalDebugParameters.materialDebugParameters.debugViewMaterial);
Shader.SetGlobalInt("_DebugViewMaterial", (int)globalDebugSettings.materialDebugSettings.debugViewMaterial);
if (!m_Owner.renderingParameters.ShouldUseForwardRenderingOnly())
if (!m_Owner.renderingSettings.ShouldUseForwardRenderingOnly())
m_DebugViewMaterialGBuffer.SetFloat("_DebugViewMaterial", (float)globalDebugParameters.materialDebugParameters.debugViewMaterial);
m_DebugViewMaterialGBuffer.SetFloat("_DebugViewMaterial", (float)globalDebugSettings.materialDebugSettings.debugViewMaterial);
// m_gbufferManager.BindBuffers(m_DebugViewMaterialGBuffer);
// TODO: Bind depth textures

void RenderDeferredLighting(HDCamera hdCamera, ScriptableRenderContext renderContext)
{
if (m_Owner.renderingParameters.ShouldUseForwardRenderingOnly() || m_LightLoop == null)
if (m_Owner.renderingSettings.ShouldUseForwardRenderingOnly() || m_LightLoop == null)
{
return ;
}

// Output split lighting for materials tagged with the SSS stencil bit.
m_LightLoop.RenderDeferredLighting(hdCamera, renderContext, globalDebugParameters.lightingDebugParameters, colorRTs, m_CameraStencilBufferRT, true);
m_LightLoop.RenderDeferredLighting(hdCamera, renderContext, globalDebugSettings.lightingDebugSettings, colorRTs, m_CameraStencilBufferRT, true);
m_LightLoop.RenderDeferredLighting(hdCamera, renderContext, globalDebugParameters.lightingDebugParameters, colorRTs, m_CameraStencilBufferRT, false);
m_LightLoop.RenderDeferredLighting(hdCamera, renderContext, globalDebugSettings.lightingDebugSettings, colorRTs, m_CameraStencilBufferRT, false);
}
// Combines specular lighting and diffuse lighting with subsurface scattering.

if (m_Owner.renderingParameters.ShouldUseForwardRenderingOnly()) return;
if (m_Owner.renderingSettings.ShouldUseForwardRenderingOnly()) return;
var cmd = new CommandBuffer() { name = "Subsurface Scattering Pass" };

{
// TODO: Currently we can't render opaque object forward when deferred is enabled
// miss option
if (!m_Owner.renderingParameters.ShouldUseForwardRenderingOnly() && renderOpaque)
if (!m_Owner.renderingSettings.ShouldUseForwardRenderingOnly() && renderOpaque)
return;
using (new Utilities.ProfilingSample("Forward Pass", renderContext))

if (m_LightLoop != null)
m_LightLoop.RenderForward(camera, renderContext, renderOpaque);
bool debugLighting = globalDebugParameters.lightingDebugParameters.lightingDebugMode != LightingDebugMode.None;
bool debugLighting = globalDebugSettings.lightingDebugSettings.lightingDebugMode != LightingDebugMode.None;
string forwardPassName = debugLighting ? "ForwardDebugLighting" : "Forward";
if (renderOpaque)

if (m_LightLoop != null)
m_LightLoop.RenderForward(camera, renderContext, true);
bool debugLighting = globalDebugParameters.lightingDebugParameters.lightingDebugMode != LightingDebugMode.None;
bool debugLighting = globalDebugSettings.lightingDebugSettings.lightingDebugMode != LightingDebugMode.None;
RenderOpaqueRenderList(cullResults, camera, renderContext, debugLighting ? "ForwardOnlyOpaqueDebugLighting" : "ForwardOnlyOpaque", Utilities.kRendererConfigurationBakedLighting);
}
}

using (new Utilities.ProfilingSample("Velocity Pass", renderContext))
{
// If opaque velocity have been render during GBuffer no need to render it here
if ((ShaderConfig.s_VelocityInGbuffer == 1) || m_Owner.renderingParameters.ShouldUseForwardRenderingOnly())
if ((ShaderConfig.s_VelocityInGbuffer == 1) || m_Owner.renderingSettings.ShouldUseForwardRenderingOnly())
return ;
int w = camera.pixelWidth;

void RenderDistortion(CullResults cullResults, Camera camera, ScriptableRenderContext renderContext)
{
if (!globalDebugParameters.renderingDebugParametrs.enableDistortion)
if (!globalDebugSettings.renderingDebugSettings.enableDistortion)
return ;
using (new Utilities.ProfilingSample("Distortion Pass", renderContext))

debugCB.name = "Debug Overlay";
float x = 0;
float overlayRatio = globalDebugParameters.debugOverlayRatio;
float overlayRatio = globalDebugSettings.debugOverlayRatio;
LightingDebugParameters shadowDebug = globalDebugParameters.lightingDebugParameters;
LightingDebugSettings shadowDebug = globalDebugSettings.lightingDebugSettings;
if (shadowDebug.shadowDebugMode != ShadowDebugMode.None)
{

cmd.GetTemporaryRT(m_CameraDepthStencilBufferCopy, w, h, 24, FilterMode.Point, RenderTextureFormat.Depth);
cmd.GetTemporaryRT(m_CameraStencilBuffer, w, h, 24, FilterMode.Point, RenderTextureFormat.Depth);
if (!m_Owner.renderingParameters.ShouldUseForwardRenderingOnly())
if (!m_Owner.renderingSettings.ShouldUseForwardRenderingOnly())
{
m_gbufferManager.InitGBuffers(w, h, cmd);
}

}
// Clear GBuffers
if (!m_Owner.renderingParameters.ShouldUseForwardRenderingOnly())
if (!m_Owner.renderingSettings.ShouldUseForwardRenderingOnly())
{
using (new Utilities.ProfilingSample("Clear GBuffer", renderContext))
{

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting.meta


fileFormatVersion: 2
guid: 1c14e71d397fce047b1675fc26d0bb48
guid: 3002976b0b09954499dd1f6e00169b06
folderAsset: yes
timeCreated: 1474297943
licenseType: Pro

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightLoop.cs


public virtual void PushGlobalParams(Camera camera, ScriptableRenderContext loop) {}
public virtual void RenderDeferredLighting(HDCamera hdCamera, ScriptableRenderContext renderContext,
LightingDebugParameters lightDebugParameters,
LightingDebugSettings lightDebugParameters,
RenderTargetIdentifier[] colorBuffers, RenderTargetIdentifier stencilBuffer,
bool outputSplitLighting) {}

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/Resources.meta


fileFormatVersion: 2
guid: 8d7b73e3debb13b46a544563ce8f4a64
guid: 0823a45531ce4ee45ab39bcbe1ea52a6
folderAsset: yes
timeCreated: 1479129942
licenseType: Pro

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass.meta


fileFormatVersion: 2
guid: 8a355c056864a5d4cb26d9c3168ae0bb
guid: 8d0d2ae5d51ae6e42a81b92e8693272f
folderAsset: yes
timeCreated: 1479218330
licenseType: Pro

24
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs


}
#endif
private void SetupRenderingForDebug(LightingDebugParameters lightDebugParameters)
private void SetupRenderingForDebug(LightingDebugSettings lightDebugSettings)
Utilities.SetKeyword(m_DeferredDirectMaterialSRT, "LIGHTING_DEBUG", lightDebugParameters.lightingDebugMode != LightingDebugMode.None);
Utilities.SetKeyword(m_DeferredDirectMaterialMRT, "LIGHTING_DEBUG", lightDebugParameters.lightingDebugMode != LightingDebugMode.None);
Utilities.SetKeyword(m_DeferredIndirectMaterialSRT, "LIGHTING_DEBUG", lightDebugParameters.lightingDebugMode != LightingDebugMode.None);
Utilities.SetKeyword(m_DeferredIndirectMaterialMRT, "LIGHTING_DEBUG", lightDebugParameters.lightingDebugMode != LightingDebugMode.None);
Utilities.SetKeyword(m_DeferredAllMaterialSRT, "LIGHTING_DEBUG", lightDebugParameters.lightingDebugMode != LightingDebugMode.None);
Utilities.SetKeyword(m_DeferredAllMaterialMRT, "LIGHTING_DEBUG", lightDebugParameters.lightingDebugMode != LightingDebugMode.None);
Utilities.SetKeyword(m_SingleDeferredMaterialSRT, "LIGHTING_DEBUG", lightDebugParameters.lightingDebugMode != LightingDebugMode.None);
Utilities.SetKeyword(m_SingleDeferredMaterialMRT, "LIGHTING_DEBUG", lightDebugParameters.lightingDebugMode != LightingDebugMode.None);
Utilities.SetKeyword(m_DeferredDirectMaterialSRT, "LIGHTING_DEBUG", lightDebugSettings.lightingDebugMode != LightingDebugMode.None);
Utilities.SetKeyword(m_DeferredDirectMaterialMRT, "LIGHTING_DEBUG", lightDebugSettings.lightingDebugMode != LightingDebugMode.None);
Utilities.SetKeyword(m_DeferredIndirectMaterialSRT, "LIGHTING_DEBUG", lightDebugSettings.lightingDebugMode != LightingDebugMode.None);
Utilities.SetKeyword(m_DeferredIndirectMaterialMRT, "LIGHTING_DEBUG", lightDebugSettings.lightingDebugMode != LightingDebugMode.None);
Utilities.SetKeyword(m_DeferredAllMaterialSRT, "LIGHTING_DEBUG", lightDebugSettings.lightingDebugMode != LightingDebugMode.None);
Utilities.SetKeyword(m_DeferredAllMaterialMRT, "LIGHTING_DEBUG", lightDebugSettings.lightingDebugMode != LightingDebugMode.None);
Utilities.SetKeyword(m_SingleDeferredMaterialSRT, "LIGHTING_DEBUG", lightDebugSettings.lightingDebugMode != LightingDebugMode.None);
Utilities.SetKeyword(m_SingleDeferredMaterialMRT, "LIGHTING_DEBUG", lightDebugSettings.lightingDebugMode != LightingDebugMode.None);
LightingDebugParameters lightDebugParameters,
LightingDebugSettings lightDebugSettings,
RenderTargetIdentifier[] colorBuffers, RenderTargetIdentifier stencilBuffer,
bool outputSplitLighting)
{

SetGlobalBuffer("g_vLightListGlobal", bUseClusteredForDeferred ? s_PerVoxelLightLists : s_LightList); // opaques list (unless MSAA possibly)
if (lightDebugParameters.lightingDebugMode == LightingDebugMode.None)
if (lightDebugSettings.lightingDebugMode == LightingDebugMode.None)
SetGlobalPropertyRedirect(shadeOpaqueShader, usingFptl ? s_shadeOpaqueFptlKernel : s_shadeOpaqueClusteredKernel, cmd);
else
SetGlobalPropertyRedirect(shadeOpaqueShader, usingFptl ? s_shadeOpaqueFptlDebugLightingKernel : s_shadeOpaqueClusteredDebugLightingKernel, cmd);

}
// Must be done after setting up the compute shader above.
SetupRenderingForDebug(lightDebugParameters);
SetupRenderingForDebug(lightDebugSettings);
if (m_PassSettings.disableTileAndCluster)
{

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material.meta


fileFormatVersion: 2
guid: 96af336cb096f854ea18990a1c0a4e19
guid: 49844bc6823848a4087668ebd3367436
folderAsset: yes
timeCreated: 1474297943
licenseType: Pro

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit.meta


fileFormatVersion: 2
guid: e173dfe6cd75d954b95306237244f6de
guid: c526d3e6d7f3ce1408308bb431089d2d
folderAsset: yes
timeCreated: 1476653183
licenseType: Pro

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit.meta


fileFormatVersion: 2
guid: d6cadd3aaf3ad6641b86e85a0929b245
guid: 0d05f89ce69203543914d745c388e6bb
folderAsset: yes
timeCreated: 1476653183
licenseType: Pro

33
Assets/ScriptableRenderPipeline/HDRenderPipeline/SceneSettings/SceneSettings.cs


[ExecuteInEditMode]
public class SceneSettings : MonoBehaviour
{
public CommonSettings SceneCommonSettings
public CommonSettings commonSettings
set { m_CommonSettings = value; ApplySettings(); }
public SkyParameters SceneSkyParameters
public SkySettings skySettings
get { return m_SkyParameters; }
set { m_SkyParameters = value; ApplySettings(); }
get { return m_SkySettings; }
[SerializeField]
private CommonSettings m_CommonSettings;
[SerializeField]
private SkyParameters m_SkyParameters;
[SerializeField] private CommonSettings m_CommonSettings;
[SerializeField] private SkySettings m_SkySettings;
ApplySettings();
SceneSettingsManager.instance.AddSceneSettings(this);
void OnValidate()
void OnDisable()
ApplySettings();
SceneSettingsManager.instance.RemoveSceneSettings(this);
private void ApplySettings()
void OnValidate()
if (m_CommonSettings != null)
CommonSettingsSingleton.overrideSettings = m_CommonSettings;
if (m_SkyParameters != null)
SkyParametersSingleton.overrideSettings = m_SkyParameters;
// If the setting is already the one currently used we need to tell the manager to reapply it.
if(SceneSettingsManager.instance.GetCurrentSceneSetting())
{
SceneSettingsManager.instance.UpdateCurrentSceneSetting();
}
}
}

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass.meta


fileFormatVersion: 2
guid: e3b3ad4462341ec4b86566ec1fd82c7c
guid: 057d8506536500045b3047320a4d6122
folderAsset: yes
timeCreated: 1476885561
licenseType: Pro

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky.meta


fileFormatVersion: 2
guid: 066ab4d03bd03384f81c9d82b479f8dd
guid: 99e8d5bd81663624399d10e3fc27571c
folderAsset: yes
timeCreated: 1479239906
licenseType: Pro

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/HDRISky/Editor/HDRISkyEditor.cs


namespace UnityEngine.Experimental.Rendering.HDPipeline
{
[CanEditMultipleObjects]
[CustomEditor(typeof(HDRISkyParameters))]
[CustomEditor(typeof(HDRISkySettings))]
public class HDRISkyParametersEditor
: Editor
{

6
Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/HDRISky/HDRISkyRenderer.cs


public class HDRISkyRenderer : SkyRenderer
{
Material m_SkyHDRIMaterial; // Renders a cubemap into a render texture (can be cube or 2D)
private HDRISkyParameters m_HdriSkyParams;
private HDRISkySettings m_HdriSkyParams;
public HDRISkyRenderer(HDRISkyParameters hdriSkyParams)
public HDRISkyRenderer(HDRISkySettings hdriSkyParams)
{
m_HdriSkyParams = hdriSkyParams;
}

}
}
public override void RenderSky(BuiltinSkyParameters builtinParams, SkyParameters skyParameters, bool renderForCubemap)
public override void RenderSky(BuiltinSkyParameters builtinParams, SkySettings skyParameters, bool renderForCubemap)
{
m_SkyHDRIMaterial.SetTexture("_Cubemap", m_HdriSkyParams.skyHDRI);
m_SkyHDRIMaterial.SetVector("_SkyParam", new Vector4(m_HdriSkyParams.exposure, m_HdriSkyParams.multiplier, m_HdriSkyParams.rotation, 0.0f));

26
Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkyRenderer.cs


public class ProceduralSkyRenderer : SkyRenderer
{
Material m_ProceduralSkyMaterial = null; // Renders a cubemap into a render texture (can be cube or 2D)
private ProceduralSkyParameters m_ProceduralSkyParameters;
private ProceduralSkySettings m_ProceduralSkySettings;
public ProceduralSkyRenderer(ProceduralSkyParameters proceduralSkyParameters)
public ProceduralSkyRenderer(ProceduralSkySettings proceduralSkySettings)
m_ProceduralSkyParameters = proceduralSkyParameters;
m_ProceduralSkySettings = proceduralSkySettings;
}
public override void Build()

public override bool IsSkyValid()
{
if (m_ProceduralSkyMaterial == null || m_ProceduralSkyParameters == null)
if (m_ProceduralSkyMaterial == null || m_ProceduralSkySettings == null)
return m_ProceduralSkyParameters.skyHDRI != null &&
m_ProceduralSkyParameters.worldMieColorRamp != null &&
m_ProceduralSkyParameters.worldRayleighColorRamp != null;
return m_ProceduralSkySettings.skyHDRI != null &&
m_ProceduralSkySettings.worldMieColorRamp != null &&
m_ProceduralSkySettings.worldRayleighColorRamp != null;
}
public override void SetRenderTargets(BuiltinSkyParameters builtinParams)

Utilities.SetRenderTarget(builtinParams.renderContext, builtinParams.colorBuffer);
}
void SetKeywords(BuiltinSkyParameters builtinParams, ProceduralSkyParameters param, bool renderForCubemap)
void SetKeywords(BuiltinSkyParameters builtinParams, ProceduralSkySettings param, bool renderForCubemap)
{
// Ensure that all preprocessor symbols are initially undefined.
m_ProceduralSkyMaterial.DisableKeyword("ATMOSPHERICS");

m_ProceduralSkyMaterial.EnableKeyword("PERFORM_SKY_OCCLUSION_TEST");
}
if (param.debugMode != ProceduralSkyParameters.ScatterDebugMode.None)
if (param.debugMode != ProceduralSkySettings.ScatterDebugMode.None)
void SetUniforms(BuiltinSkyParameters builtinParams, ProceduralSkyParameters param, bool renderForCubemap, ref MaterialPropertyBlock properties)
void SetUniforms(BuiltinSkyParameters builtinParams, ProceduralSkySettings param, bool renderForCubemap, ref MaterialPropertyBlock properties)
{
properties.SetTexture("_Cubemap", param.skyHDRI);
properties.SetVector("_SkyParam", new Vector4(param.exposure, param.multiplier, param.rotation, 0.0f));

properties.SetFloat("_HeightMieDensity", renderForCubemap ? -0.0f : -param.heightMieDensity / 100000f);
}
override public void RenderSky(BuiltinSkyParameters builtinParams, SkyParameters skyParameters, bool renderForCubemap)
override public void RenderSky(BuiltinSkyParameters builtinParams, SkySettings skyParameters, bool renderForCubemap)
SetKeywords(builtinParams, m_ProceduralSkyParameters, renderForCubemap);
SetKeywords(builtinParams, m_ProceduralSkySettings, renderForCubemap);
SetUniforms(builtinParams, m_ProceduralSkyParameters, renderForCubemap, ref properties);
SetUniforms(builtinParams, m_ProceduralSkySettings, renderForCubemap, ref properties);
var cmd = new CommandBuffer { name = "" };

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkySettings.cs


{
[ExecuteInEditMode]
[DisallowMultipleComponent]
public class ProceduralSkyParameters : SkyParameters
public class ProceduralSkySettings : SkySettings
{
public enum OcclusionDownscale { x1 = 1, x2 = 2, x4 = 4 }
public enum OcclusionSamples { x64 = 0, x164 = 1, x244 = 2 }

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/Resources.meta


fileFormatVersion: 2
guid: 4cdc45a9a65126a42aca158413a5b089
guid: 920208451db81a846ae1c2d55f7b50b4
folderAsset: yes
timeCreated: 1479239906
licenseType: Pro

38
Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyManager.cs


bool m_useMIS = false;
private SkyParameters m_SkyParameters;
public SkyParameters skyParameters
private SkySettings m_SkySettings;
public SkySettings skySettings
if (m_SkyParameters == value)
if (m_SkySettings == value)
return;
if (m_Renderer != null)

}
m_SkyParametersHash = 0;
m_SkyParameters = value;
m_SkySettings = value;
m_UpdateRequired = true;
if (value != null)

}
}
get { return m_SkyParameters; }
get { return m_SkySettings; }
}
protected Mesh BuildSkyMesh(Vector3 cameraPosition, Matrix4x4 cameraInvViewProjectionMatrix, bool forceUVBottom)

};
}
void RebuildTextures(SkyParameters skyParameters)
void RebuildTextures(SkySettings skySettings)
if (skyParameters != null)
resolution = (int)skyParameters.resolution;
if (skySettings != null)
resolution = (int)skySettings.resolution;
if ((m_SkyboxCubemapRT != null) && (m_SkyboxCubemapRT.width != resolution))
{

public void Resize(float nearPlane, float farPlane)
{
// When loading RenderDoc, RenderTextures will go null
RebuildTextures(skyParameters);
RebuildTextures(skySettings);
RebuildSkyMeshes(nearPlane, farPlane);
}

return m_Renderer != null && m_Renderer.IsSkyValid();
}
private void RenderSkyToCubemap(BuiltinSkyParameters builtinParams, SkyParameters skyParameters, RenderTexture target)
private void RenderSkyToCubemap(BuiltinSkyParameters builtinParams, SkySettings skySettings, RenderTexture target)
{
for (int i = 0; i < 6; ++i)
{

builtinParams.depthBuffer = BuiltinSkyParameters.nullRT;
Utilities.SetRenderTarget(builtinParams.renderContext, target, ClearFlag.ClearNone, 0, (CubemapFace)i);
m_Renderer.RenderSky(builtinParams, skyParameters, true);
m_Renderer.RenderSky(builtinParams, skySettings, true);
private void RenderCubemapGGXConvolution(ScriptableRenderContext renderContext, BuiltinSkyParameters builtinParams, SkyParameters skyParams, Texture input, RenderTexture target)
private void RenderCubemapGGXConvolution(ScriptableRenderContext renderContext, BuiltinSkyParameters builtinParams, SkySettings skyParams, Texture input, RenderTexture target)
{
using (new Utilities.ProfilingSample("Sky Pass: GGX Convolution", renderContext))
{

}
if (
(skyParameters.updateMode == EnvironementUpdateMode.OnDemand && m_UpdateRequired) ||
(skyParameters.updateMode == EnvironementUpdateMode.OnChanged && skyParameters.GetHash() != m_SkyParametersHash) ||
(skyParameters.updateMode == EnvironementUpdateMode.Realtime && m_CurrentUpdateTime > skyParameters.updatePeriod)
(skySettings.updateMode == EnvironementUpdateMode.OnDemand && m_UpdateRequired) ||
(skySettings.updateMode == EnvironementUpdateMode.OnChanged && skySettings.GetHash() != m_SkyParametersHash) ||
(skySettings.updateMode == EnvironementUpdateMode.Realtime && m_CurrentUpdateTime > skySettings.updatePeriod)
RenderSkyToCubemap(m_BuiltinParameters, skyParameters, m_SkyboxCubemapRT);
RenderSkyToCubemap(m_BuiltinParameters, skySettings, m_SkyboxCubemapRT);
RenderCubemapGGXConvolution(renderContext, m_BuiltinParameters, skyParameters, m_SkyboxCubemapRT, m_SkyboxGGXCubemapRT);
RenderCubemapGGXConvolution(renderContext, m_BuiltinParameters, skySettings, m_SkyboxCubemapRT, m_SkyboxGGXCubemapRT);
m_SkyParametersHash = skyParameters.GetHash();
m_SkyParametersHash = skySettings.GetHash();
m_CurrentUpdateTime = 0.0f;
}
}

m_BuiltinParameters.depthBuffer = depthBuffer;
m_Renderer.SetRenderTargets(m_BuiltinParameters);
m_Renderer.RenderSky(m_BuiltinParameters, skyParameters, false);
m_Renderer.RenderSky(m_BuiltinParameters, skySettings, false);
}
}
}

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyRenderer.cs


public abstract void Cleanup();
public abstract void SetRenderTargets(BuiltinSkyParameters builtinParams);
// renderForCubemap: When rendering into a cube map, no depth buffer is available so user has to make sure not to use depth testing or the depth texture.
public abstract void RenderSky(BuiltinSkyParameters builtinParams, SkyParameters skyParameters, bool renderForCubemap);
public abstract void RenderSky(BuiltinSkyParameters builtinParams, SkySettings skyParameters, bool renderForCubemap);
public abstract bool IsSkyValid();
}
}

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkySettings.cs


namespace UnityEngine.Experimental.Rendering.HDPipeline
{
[ExecuteInEditMode]
public abstract class SkyParameters : ScriptableObject
public abstract class SkySettings : ScriptableObject
{
protected class Unhashed : System.Attribute {}

64
Assets/ScriptableRenderPipeline/HDRenderPipeline/Editor/SceneSettingsManagementWindow.cs


using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
public class SceneSettingsManagementWindow : EditorWindow
{
[MenuItem("HDRenderPipeline/Scene Settings Management")]
static void SceneSettingsManagement()
{
GetWindow<SceneSettingsManagementWindow>().Show();
}
static private string m_LastCreationPath = "Assets";
void CreateAsset<AssetType>(string assetName) where AssetType : ScriptableObject
{
string assetPath = EditorUtility.SaveFilePanel("Create new Asset", m_LastCreationPath, assetName, "asset");
if (!string.IsNullOrEmpty(assetPath))
{
assetPath = assetPath.Substring(assetPath.LastIndexOf("Assets"));
m_LastCreationPath = System.IO.Path.GetDirectoryName(assetPath);
var instance = CreateInstance<AssetType>();
AssetDatabase.CreateAsset(instance, assetPath);
}
}
void OnGUI()
{
// Keep it there temporarily until it's back to an "engine" setting in the HDRenderPipeline asset.
SubsurfaceScatteringSettings.overrideSettings = (SubsurfaceScatteringParameters)EditorGUILayout.ObjectField(new GUIContent("SSS Settings"), SubsurfaceScatteringSettings.overrideSettings, typeof(SubsurfaceScatteringParameters), false);
EditorGUILayout.Space();
if (GUILayout.Button("Create new Common Settings"))
{
CreateAsset<CommonSettings>("NewCommonSettings");
}
if (GUILayout.Button("Create new HDRI sky params"))
{
CreateAsset<HDRISkySettings>("NewHDRISkySettings");
}
if (GUILayout.Button("Create new Procedural sky params"))
{
CreateAsset<ProceduralSkySettings>("NewProceduralSkyParameters");
}
if (GUILayout.Button("Create new SSS params"))
{
CreateAsset<SubsurfaceScatteringParameters>("NewSssParameters");
}
EditorGUILayout.Space();
if (GUILayout.Button("Create Scene Settings"))
{
var manager = new GameObject();
manager.name = "Scene Settings";
manager.AddComponent<SceneSettings>();
}
}
}
}

81
Assets/ScriptableRenderPipeline/HDRenderPipeline/SceneSettings/SceneSettingsManager.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace UnityEngine.Experimental.Rendering.HDPipeline
{
public class SceneSettingsManager
{
static private SceneSettingsManager s_Instance = null;
static public SceneSettingsManager instance
{
get
{
if(s_Instance == null)
s_Instance = new SceneSettingsManager();
return s_Instance;
}
}
private List<SceneSettings> m_SceneSettingsList = new List<SceneSettings>();
void OnEnable()
{
}
void OnDisable()
{
}
public SceneSettings GetCurrentSceneSetting()
{
if (m_SceneSettingsList.Count == 0)
return null;
else
return m_SceneSettingsList[m_SceneSettingsList.Count - 1];
}
// This can be needed in the editor in case the current setting is being changed. In this case we need to reapply it.
public void UpdateCurrentSceneSetting()
{
if (m_SceneSettingsList.Count != 0)
ApplySettings(GetCurrentSceneSetting());
}
public void AddSceneSettings(SceneSettings settings)
{
m_SceneSettingsList.Add(settings);
ApplySettings(settings);
}
public void RemoveSceneSettings(SceneSettings settings)
{
m_SceneSettingsList.Remove(settings);
// Always reapply the settings at the top of the list
// (this way if the setting being removed was the active one we switch to the next one)
ApplySettings(GetCurrentSceneSetting());
}
private void ApplySettings(SceneSettings settings)
{
if(settings)
{
if (settings.commonSettings != null)
CommonSettingsSingleton.overrideSettings = settings.commonSettings;
if (settings.skySettings != null)
SkySettingsSingleton.overrideSettings = settings.skySettings;
}
else
{
CommonSettingsSingleton.overrideSettings = null;
SkySettingsSingleton.overrideSettings = null;
}
}
}
}

12
Assets/ScriptableRenderPipeline/HDRenderPipeline/SceneSettings/SceneSettingsManager.cs.meta


fileFormatVersion: 2
guid: f31f023dee834de44993536e71ee27ac
timeCreated: 1487241314
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

15
Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/HDRISky/HDRISkySettings.cs


namespace UnityEngine.Experimental.Rendering.HDPipeline
{
[DisallowMultipleComponent]
public class HDRISkySettings
: SkySettings
{
public Cubemap skyHDRI;
public override SkyRenderer GetRenderer()
{
return new HDRISkyRenderer(this);
}
}
}

17
Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkySettingsSingleton.cs


#if UNITY_EDITOR
using UnityEditor;
#endif
namespace UnityEngine.Experimental.Rendering.HDPipeline
{
public class SkySettingsSingleton : Singleton<SkySettingsSingleton>
{
private SkySettings settings { get; set; }
public static SkySettings overrideSettings
{
get { return instance.settings; }
set { instance.settings = value; }
}
}
}

45
Assets/ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipeWindow.cs


using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
public class HDRenderPipeWindow : EditorWindow
{
[MenuItem("HDRenderPipeline/Configure Overrides")]
static void ConfigureOverrides()
{
GetWindow<HDRenderPipeWindow>().Show();
}
void OnGUI()
{
CommonSettingsSingleton.overrideSettings = (CommonSettings)EditorGUILayout.ObjectField(new GUIContent("Common Settings"), CommonSettingsSingleton.overrideSettings, typeof(CommonSettings), false);
SkyParametersSingleton.overrideSettings = (SkyParameters)EditorGUILayout.ObjectField(new GUIContent("Sky Settings"), SkyParametersSingleton.overrideSettings, typeof(SkyParameters), false);
SubsurfaceScatteringSettings.overrideSettings = (SubsurfaceScatteringParameters)EditorGUILayout.ObjectField(new GUIContent("Subsurface Scattering Settings"), SubsurfaceScatteringSettings.overrideSettings, typeof(SubsurfaceScatteringParameters), false);
if (GUILayout.Button("Create new common settings"))
{
var instance = CreateInstance<CommonSettings>();
AssetDatabase.CreateAsset(instance, "Assets/NewCommonSettings.asset");
}
if (GUILayout.Button("Create new HDRI sky params"))
{
var instance = CreateInstance<HDRISkyParameters>();
AssetDatabase.CreateAsset(instance, "Assets/NewHDRISkyParameters.asset");
}
if (GUILayout.Button("Create new Procedural sky params"))
{
var instance = CreateInstance<ProceduralSkyParameters>();
AssetDatabase.CreateAsset(instance, "Assets/NewProceduralSkyParameters.asset");
}
if (GUILayout.Button("Create new SSS params"))
{
var instance = CreateInstance<SubsurfaceScatteringParameters>();
AssetDatabase.CreateAsset(instance, "Assets/NewSssParameters.asset");
}
}
}
}

15
Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/HDRISky/HDRISkyParameters.cs


namespace UnityEngine.Experimental.Rendering.HDPipeline
{
[DisallowMultipleComponent]
public class HDRISkyParameters
: SkyParameters
{
public Cubemap skyHDRI;
public override SkyRenderer GetRenderer()
{
return new HDRISkyRenderer(this);
}
}
}

17
Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyParametersSingleton.cs


#if UNITY_EDITOR
using UnityEditor;
#endif
namespace UnityEngine.Experimental.Rendering.HDPipeline
{
public class SkyParametersSingleton : Singleton<SkyParametersSingleton>
{
private SkyParameters settings { get; set; }
public static SkyParameters overrideSettings
{
get { return instance.settings; }
set { instance.settings = value; }
}
}
}

20
Assets/TestScenes/HDTest/CascadedShadowsTest/HDRISkyParameters_Cascaded.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 59b6606ef2548734bb6d11b9d160bc7e, type: 3}
m_Name: HDRISkyParameters_Cascaded
m_EditorClassIdentifier:
rotation: 0
exposure: 0
multiplier: 1
resolution: 256
updateMode: 0
updatePeriod: 0
skyHDRI: {fileID: 8900000, guid: 9b513842339ef704ca63ef696691bc34, type: 3}

9
Assets/TestScenes/HDTest/CascadedShadowsTest/HDRISkyParameters_Cascaded.asset.meta


fileFormatVersion: 2
guid: e87251404948e274ab006302af9b80f8
timeCreated: 1486126252
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

/Assets/ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipeWindow.cs.meta → /Assets/ScriptableRenderPipeline/HDRenderPipeline/Editor/SceneSettingsManagementWindow.cs.meta

/Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/HDRISky/HDRISkyParameters.cs.meta → /Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/HDRISky/HDRISkySettings.cs.meta

/Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkyParameters.cs.meta → /Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkySettings.cs.meta

/Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkyParameters.cs → /Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkySettings.cs

/Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyParametersSingleton.cs.meta → /Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkySettingsSingleton.cs.meta

/Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyParameters.cs.meta → /Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkySettings.cs.meta

/Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyParameters.cs → /Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkySettings.cs

正在加载...
取消
保存