浏览代码

Merge remote-tracking branch 'refs/remotes/origin/master' into Update-POM-+-Heightmap-behavior

/Branch_Batching2
sebastienlagarde 8 年前
当前提交
264abb2c
共有 17 个文件被更改,包括 1634 次插入96 次删除
  1. 106
      Assets/ScriptableRenderLoop/HDRenderPipeline/Editor/HDRenderPipelineInspector.cs
  2. 8
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.asset
  3. 177
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs
  4. 38
      Assets/ScriptableRenderLoop/HDRenderPipeline/Utilities.cs
  5. 26
      Assets/ScriptableRenderLoop/RenderPasses/ShadowRenderPass.cs
  6. 26
      ProjectSettings/ProjectSettings.asset
  7. 50
      Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs
  8. 12
      Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs.meta
  9. 82
      Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugDisplayShadowMap.shader
  10. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugDisplayShadowMap.shader.meta
  11. 9
      Assets/TestScenes/HDTest/CascadedShadowsTest.meta
  12. 1001
      Assets/TestScenes/HDTest/CascadedShadowsTest.unity
  13. 8
      Assets/TestScenes/HDTest/CascadedShadowsTest.unity.meta
  14. 160
      Assets/TestScenes/HDTest/CascadedShadowsTest/Lit_Gray.mat
  15. 9
      Assets/TestScenes/HDTest/CascadedShadowsTest/Lit_Gray.mat.meta
  16. 9
      Assets/TestScenes/HDTest/HDRenderLoopTest.meta

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


using System;
using System.Reflection;
using System.Linq.Expressions;
using UnityEditor;
//using EditorGUIUtility=UnityEditor.EditorGUIUtility;

{
private class Styles
{
// Global debug parameters
public readonly GUIContent debugging = new GUIContent("Debugging");
public readonly GUIContent debugOverlayRatio = new GUIContent("Overlay Ratio");
public readonly GUIContent debugParameters = new GUIContent("Debug Parameters");
public readonly GUIContent debugViewMaterial = new GUIContent("DebugView Material", "Display various properties of Materials.");

public readonly GUIContent useForwardRenderingOnly = new GUIContent("Use Forward Rendering Only");
public readonly GUIContent useDepthPrepass = new GUIContent("Use Depth Prepass");
public readonly GUIContent useDistortion = new GUIContent("Use Distortion");
public readonly GUIContent useDistortion = new GUIContent("Use Distortion");
public bool isDebugViewMaterialInit = false;
public GUIContent[] debugViewMaterialStrings = null;

// Shadow Debug
public readonly GUIContent shadowDebugParameters = new GUIContent("Shadow Debug");
public readonly GUIContent shadowDebugEnable = new GUIContent("Enable Shadows");
public readonly GUIContent shadowDebugVisualizationMode = new GUIContent("Visualize");
public readonly GUIContent shadowDebugVisualizeShadowIndex = new GUIContent("Visualize Shadow Index");
public readonly GUIContent shadowsEnabled = new GUIContent("Enabled");
public readonly string[] tileLightLoopDebugTileFlagStrings = new string[] {"Punctual Light", "Area Light", "Env Light"};
public readonly string[] tileLightLoopDebugTileFlagStrings = new string[] { "Punctual Light", "Area Light", "Env Light"};
public readonly GUIContent splitLightEvaluation = new GUIContent("Split light and reflection evaluation", "Toggle");
public readonly GUIContent bigTilePrepass = new GUIContent("Enable big tile prepass", "Toggle");
public readonly GUIContent clustered = new GUIContent("Enable clustered", "Toggle");

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 reflectionCubemapSize = new GUIContent("Reflection cubemap size");
}
private static Styles s_Styles = null;

}
}
const float k_MaxExposure = 32.0f;
SerializedProperty m_ShowDebug = null;
SerializedProperty m_ShowDebugShadow = null;
SerializedProperty m_DebugOverlayRatio = null;
SerializedProperty m_DebugShadowEnabled = null;
SerializedProperty m_DebugShadowVisualizationMode = null;
SerializedProperty m_DebugShadowVisualizeShadowIndex = null;
private void InitializeProperties()
{
m_DebugOverlayRatio = FindProperty(x => x.globalDebugParameters.debugOverlayRatio);
m_ShowDebugShadow = FindProperty(x => x.globalDebugParameters.displayShadowDebug);
m_ShowDebug = FindProperty(x => x.globalDebugParameters.displayDebug);
m_DebugShadowEnabled = FindProperty(x => x.globalDebugParameters.shadowDebugParameters.enableShadows);
m_DebugShadowVisualizationMode = FindProperty(x => x.globalDebugParameters.shadowDebugParameters.visualizationMode);
m_DebugShadowVisualizeShadowIndex = FindProperty(x => x.globalDebugParameters.shadowDebugParameters.visualizeShadowMapIndex);
}
SerializedProperty FindProperty<TValue>(Expression<Func<HDRenderPipeline, TValue>> expr)
{
var path = Utilities.GetFieldPath(expr);
return serializedObject.FindProperty(path);
}
string GetSubNameSpaceName(Type type)
{

if (!attr.needParamDefines)
{
return;
return ;
}
var fields = type.GetFields();

// Check if the display name have been override by the users
if (Attribute.IsDefined(field, typeof(SurfaceDataAttributes)))
{
var propertyAttr = (SurfaceDataAttributes[]) field.GetCustomAttributes(typeof(SurfaceDataAttributes), false);
var propertyAttr = (SurfaceDataAttributes[])field.GetCustomAttributes(typeof(SurfaceDataAttributes), false);
if (propertyAttr[0].displayName != "")
{
fieldName = propertyAttr[0].displayName;

fieldName = (isBSDFData ? "Engine/" : "") + strSubNameSpace + fieldName;
debugViewMaterialStrings[index] = new GUIContent(fieldName);
debugViewMaterialValues[index] = attr.paramDefinesStart + (int) localIndex;
debugViewMaterialValues[index] = attr.paramDefinesStart + (int)localIndex;
index++;
localIndex++;
}

var valueName = (isBSDFData ? "Engine/" : "" + prefix) + names[localIndex];
debugViewMaterialStrings[index] = new GUIContent(valueName);
debugViewMaterialValues[index] = (int) value;
debugViewMaterialValues[index] = (int)value;
index++;
localIndex++;
}

method.Invoke(asset, new object[0]);
}
private void DebuggingUI(HDRenderPipeline renderContext)
{
EditorGUILayout.LabelField(styles.debugging);
// Global debug parameters
EditorGUI.indentLevel++;
m_DebugOverlayRatio.floatValue = EditorGUILayout.Slider(styles.debugOverlayRatio, m_DebugOverlayRatio.floatValue, 0.1f, 1.0f);
EditorGUILayout.Space();
DebugParametersUI(renderContext);
EditorGUILayout.Space();
ShadowDebugParametersUI(renderContext);
EditorGUI.indentLevel--;
}
m_ShowDebug.boolValue = EditorGUILayout.Foldout(m_ShowDebug.boolValue, styles.debugParameters);
if (!m_ShowDebug.boolValue)
return;
EditorGUILayout.LabelField(styles.debugParameters);
EditorGUI.indentLevel++;
EditorGUI.BeginChangeCheck();

styles.isDebugViewMaterialInit = true;
}
debugParameters.debugViewMaterial = EditorGUILayout.IntPopup(styles.debugViewMaterial, (int) debugParameters.debugViewMaterial, styles.debugViewMaterialStrings, styles.debugViewMaterialValues);
debugParameters.debugViewMaterial = EditorGUILayout.IntPopup(styles.debugViewMaterial, (int)debugParameters.debugViewMaterial, styles.debugViewMaterialStrings, styles.debugViewMaterialValues);
EditorGUILayout.Space();
debugParameters.displayOpaqueObjects = EditorGUILayout.Toggle(styles.displayOpaqueObjects, debugParameters.displayOpaqueObjects);

}
}
private void ShadowDebugParametersUI(HDRenderPipeline renderContext)
{
m_ShowDebugShadow.boolValue = EditorGUILayout.Foldout(m_ShowDebugShadow.boolValue, styles.shadowDebugParameters);
if (!m_ShowDebugShadow.boolValue)
return;
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_DebugShadowEnabled, styles.shadowDebugEnable);
EditorGUILayout.PropertyField(m_DebugShadowVisualizationMode, styles.shadowDebugVisualizationMode);
if (!m_DebugShadowVisualizationMode.hasMultipleDifferentValues)
{
if ((ShadowDebugMode)m_DebugShadowVisualizationMode.intValue == ShadowDebugMode.VisualizeShadowMap)
{
EditorGUILayout.IntSlider(m_DebugShadowVisualizeShadowIndex, 0, 5/*renderContext.GetCurrentShadowCount() - 1*/, styles.shadowDebugVisualizeShadowIndex);
}
}
EditorGUI.indentLevel--;
}
private void ShadowParametersUI(HDRenderPipeline renderContext)
{
EditorGUILayout.Space();

EditorGUI.indentLevel++;
EditorGUI.BeginChangeCheck();
shadowParameters.enabled = EditorGUILayout.Toggle(styles.shadowsEnabled, shadowParameters.enabled);
shadowParameters.shadowAtlasWidth = Mathf.Max(0, EditorGUILayout.IntField(styles.shadowsAtlasWidth, shadowParameters.shadowAtlasWidth));
shadowParameters.shadowAtlasHeight = Mathf.Max(0, EditorGUILayout.IntField(styles.shadowsAtlasHeight, shadowParameters.shadowAtlasHeight));

}
}*/
public void OnEnable()
{
InitializeProperties();
}
public override void OnInspectorGUI()
{
var renderContext = target as HDRenderPipeline;

DebugParametersUI(renderContext);
serializedObject.Update();
DebuggingUI(renderContext);
serializedObject.ApplyModifiedProperties();
}
}
}

8
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.asset


m_SkyParameters: {fileID: 0}
m_LightLoopProducer: {fileID: 11400000, guid: bf8cd9ae03ff7d54c89603e67be0bfc5,
type: 2}
globalDebugParameters:
debugOverlayRatio: 0.33
displayDebug: 1
displayShadowDebug: 1
shadowDebugParameters:
enableShadows: 1
visualizationMode: 0
visualizeShadowMapIndex: 0
m_ShadowSettings:
enabled: 1
shadowAtlasWidth: 4096

177
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs


return new HDRenderPipelineInstance(this);
}
// Debugging
public GlobalDebugParameters globalDebugParameters = new GlobalDebugParameters();
readonly DebugParameters m_DebugParameters = new DebugParameters();
public DebugParameters debugParameters

set { m_TextureSettings = value; }
}
public void ApplyDebugParameters()
{
m_ShadowSettings.enabled = globalDebugParameters.shadowDebugParameters.enableShadows;
}
public void UpdateCommonSettings()
{
var commonSettings = commonSettingsToUse;

public Matrix4x4 invViewProjectionMatrix;
}
public class DebugParameters
{
// Material Debugging
public int debugViewMaterial = 0;
// Rendering debugging
public bool displayOpaqueObjects = true;
public bool displayTransparentObjects = true;
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;
public bool useDistortion = true;
// we have to fallback to forward-only rendering when scene view is using wireframe rendering mode --
// as rendering everything in wireframe + deferred do not play well together
public bool ShouldUseForwardRenderingOnly()
{
return useForwardRenderingOnly || GL.wireframe;
}
}
public class GBufferManager
{
public const int MaxGbuffer = 8;

// Various set of material use in render loop
readonly Material m_DebugViewMaterialGBuffer;
readonly Material m_CombineSubsurfaceScattering;
readonly Material m_DebugDisplayShadowMap;
// Various buffer
readonly int m_CameraColorBuffer;

int m_CurrentHeight;
ShadowRenderPass m_ShadowPass;
ShadowOutput m_ShadowsResult = new ShadowOutput();
public int GetCurrentShadowCount() { return m_ShadowsResult.shadowLights == null ? 0 : m_ShadowsResult.shadowLights.Length; }
readonly SkyManager m_SkyManager = new SkyManager();
private readonly BaseLightLoop m_LightLoop;

get { return m_Owner.debugParameters; }
}
private GlobalDebugParameters globalDebugParameters
{
get { return m_Owner.globalDebugParameters; }
}
public HDRenderPipelineInstance(HDRenderPipeline owner)
{

m_DebugViewMaterialGBuffer = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/DebugViewMaterialGBuffer");
m_CombineSubsurfaceScattering = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/CombineSubsurfaceScattering");
m_DebugDisplayShadowMap = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/DebugDisplayShadowMap");
m_ShadowPass = new ShadowRenderPass(owner.shadowSettings);

m_LitRenderLoop.Cleanup();
Utilities.Destroy(m_DebugViewMaterialGBuffer);
Utilities.Destroy(m_DebugDisplayShadowMap);
m_SkyManager.Cleanup();
#if UNITY_EDITOR

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

}
else
{
ShadowOutput shadows;
using (new Utilities.ProfilingSample("Shadow Pass", renderContext))
{
m_ShadowPass.Render(renderContext, cullResults, out shadows);
}
using (new Utilities.ProfilingSample("Shadow Pass", renderContext))
{
m_ShadowPass.Render(renderContext, cullResults, out m_ShadowsResult);
}
renderContext.SetupCameraProperties(camera); // Need to recall SetupCameraProperties after m_ShadowPass.Render
renderContext.SetupCameraProperties(camera); // Need to recall SetupCameraProperties after m_ShadowPass.Render
if (m_LightLoop != null)
if (m_LightLoop != null)
{
using (new Utilities.ProfilingSample("Build Light list", renderContext))
using (new Utilities.ProfilingSample("Build Light list", renderContext))
{
m_LightLoop.PrepareLightsForGPU(m_Owner.shadowSettings, cullResults, camera, ref shadows);
m_LightLoop.BuildGPULightLists(camera, renderContext, m_CameraDepthStencilBufferRT); // TODO: Use async compute here to run light culling during shadow
}
m_LightLoop.PrepareLightsForGPU(m_Owner.shadowSettings, cullResults, camera, ref m_ShadowsResult);
m_LightLoop.BuildGPULightLists(camera, renderContext, m_CameraDepthStencilBufferRT); // TODO: Use async compute here to run light culling during shadow
}
PushGlobalParams(hdCamera, renderContext);
PushGlobalParams(hdCamera, renderContext);
// Caution: We require sun light here as some sky use the sun light to render, mean UpdateSkyEnvironment
// must be call after BuildGPULightLists.
// TODO: Try to arrange code so we can trigger this call earlier and use async compute here to run sky convolution during other passes (once we move convolution shader to compute).
UpdateSkyEnvironment(hdCamera, renderContext);
// Caution: We require sun light here as some sky use the sun light to render, mean UpdateSkyEnvironment
// must be call after BuildGPULightLists.
// TODO: Try to arrange code so we can trigger this call earlier and use async compute here to run sky convolution during other passes (once we move convolution shader to compute).
UpdateSkyEnvironment(hdCamera, renderContext);
RenderDeferredLighting(hdCamera, renderContext);
RenderDeferredLighting(hdCamera, renderContext);
// We compute subsurface scattering here. Therefore, no objects rendered afterwards will exhibit SSS.
// Currently, there is no efficient way to switch between SRT and MRT for the forward pass;
// therefore, forward-rendered objects do not output split lighting required for the SSS pass.
CombineSubsurfaceScattering(hdCamera, renderContext, m_Owner.sssParameters);
// We compute subsurface scattering here. Therefore, no objects rendered afterwards will exhibit SSS.
// Currently, there is no efficient way to switch between SRT and MRT for the forward pass;
// therefore, forward-rendered objects do not output split lighting required for the SSS pass.
CombineSubsurfaceScattering(hdCamera, renderContext, m_Owner.sssParameters);
// For opaque forward we have split rendering in two categories
// Material that are always forward and material that can be deferred or forward depends on render pipeline options (like switch to rendering forward only mode)
// Material that are always forward are unlit and complex (Like Hair) and don't require sorting, so it is ok to split them.
RenderForward(cullResults, camera, renderContext, true); // Render deferred or forward opaque
RenderForwardOnlyOpaque(cullResults, camera, renderContext);
// For opaque forward we have split rendering in two categories
// Material that are always forward and material that can be deferred or forward depends on render pipeline options (like switch to rendering forward only mode)
// Material that are always forward are unlit and complex (Like Hair) and don't require sorting, so it is ok to split them.
RenderForward(cullResults, camera, renderContext, true); // Render deferred or forward opaque
RenderForwardOnlyOpaque(cullResults, camera, renderContext);
RenderSky(hdCamera, renderContext);
RenderSky(hdCamera, renderContext);
// Render all type of transparent forward (unlit, lit, complex (hair...)) to keep the sorting between transparent objects.
RenderForward(cullResults, camera, renderContext, false);
// Render all type of transparent forward (unlit, lit, complex (hair...)) to keep the sorting between transparent objects.
RenderForward(cullResults, camera, renderContext, false);
RenderVelocity(cullResults, camera, renderContext); // Note we may have to render velocity earlier if we do temporalAO, temporal volumetric etc... Mean we will not take into account forward opaque in case of deferred rendering ?
RenderVelocity(cullResults, camera, renderContext); // Note we may have to render velocity earlier if we do temporalAO, temporal volumetric etc... Mean we will not take into account forward opaque in case of deferred rendering ?
// TODO: Check with VFX team.
// Rendering distortion here have off course lot of artifact.
// But resolving at each objects that write in distortion is not possible (need to sort transparent, render those that do not distort, then resolve, then etc...)
// Instead we chose to apply distortion at the end after we cumulate distortion vector and desired blurriness. This
RenderDistortion(cullResults, camera, renderContext);
// TODO: Check with VFX team.
// Rendering distortion here have off course lot of artifact.
// But resolving at each objects that write in distortion is not possible (need to sort transparent, render those that do not distort, then resolve, then etc...)
// Instead we chose to apply distortion at the end after we cumulate distortion vector and desired blurriness. This
RenderDistortion(cullResults, camera, renderContext);
FinalPass(camera, renderContext);
FinalPass(camera, renderContext);
RenderDebugOverlay(camera, renderContext);
// bind depth surface for editor grid/gizmo/selection rendering
if (camera.cameraType == CameraType.SceneView)

localPostProcess.Render(camera, renderContext, m_CameraColorBufferRT, BuiltinRenderTextureType.CameraTarget);
}
}
void NextOverlayCoord(ref float x, ref float y, float overlaySize, float width)
{
x += overlaySize;
// Go to next line if it goes outside the screen.
if (x + overlaySize > width)
{
x = 0;
y -= overlaySize;
}
}
void RenderDebugOverlay(Camera camera, ScriptableRenderContext renderContext)
{
CommandBuffer debugCB = new CommandBuffer();
debugCB.name = "Debug Overlay";
float x = 0;
float overlayRatio = globalDebugParameters.debugOverlayRatio;
float overlaySize = Math.Min(camera.pixelHeight, camera.pixelWidth) * overlayRatio;
float y = camera.pixelHeight - overlaySize;
MaterialPropertyBlock propertyBlock = new MaterialPropertyBlock();
ShadowDebugParameters shadowDebug = globalDebugParameters.shadowDebugParameters;
if (shadowDebug.visualizationMode != ShadowDebugMode.None)
{
if (shadowDebug.visualizationMode == ShadowDebugMode.VisualizeShadowMap)
{
uint visualizeShadowIndex = Math.Min(shadowDebug.visualizeShadowMapIndex, (uint)(GetCurrentShadowCount() - 1));
ShadowLight shadowLight = m_ShadowsResult.shadowLights[visualizeShadowIndex];
for (int slice = 0; slice < shadowLight.shadowSliceCount; ++slice)
{
ShadowSliceData sliceData = m_ShadowsResult.shadowSlices[shadowLight.shadowSliceIndex + slice];
Vector4 texcoordScaleBias = new Vector4((float)sliceData.shadowResolution / m_Owner.shadowSettings.shadowAtlasWidth,
(float)sliceData.shadowResolution / m_Owner.shadowSettings.shadowAtlasHeight,
(float)sliceData.atlasX / m_Owner.shadowSettings.shadowAtlasWidth,
(float)sliceData.atlasY / m_Owner.shadowSettings.shadowAtlasHeight);
propertyBlock.SetVector("_TextureScaleBias", texcoordScaleBias);
debugCB.SetViewport(new Rect(x, y, overlaySize, overlaySize));
debugCB.DrawProcedural(Matrix4x4.identity, m_DebugDisplayShadowMap, 0, MeshTopology.Triangles, 6, 1, propertyBlock);
NextOverlayCoord(ref x, ref y, overlaySize, camera.pixelWidth);
}
}
else if (shadowDebug.visualizationMode == ShadowDebugMode.VisualizeAtlas)
{
propertyBlock.SetVector("_TextureScaleBias", new Vector4(1.0f, 1.0f, 0.0f, 0.0f));
debugCB.SetViewport(new Rect(x, y, overlaySize, overlaySize));
debugCB.DrawProcedural(Matrix4x4.identity, m_DebugDisplayShadowMap, 0, MeshTopology.Triangles, 6, 1, propertyBlock);
NextOverlayCoord(ref x, ref y, overlaySize, camera.pixelWidth);
}
}
renderContext.ExecuteCommandBuffer(debugCB);
}
// Function to prepare light structure for GPU lighting

38
Assets/ScriptableRenderLoop/HDRenderPipeline/Utilities.cs


using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityObject = UnityEngine.Object;

#else
UnityObject.Destroy(obj);
#endif
obj = null;
}
}

buffer.Release();
}
public static string GetFieldPath<TType, TValue>(Expression<Func<TType, TValue>> expr)
{
MemberExpression me;
switch (expr.Body.NodeType)
buffer.Release();
buffer = null;
case ExpressionType.Convert:
case ExpressionType.ConvertChecked:
var ue = expr.Body as UnaryExpression;
me = (ue != null ? ue.Operand : null) as MemberExpression;
break;
default:
me = expr.Body as MemberExpression;
break;
var members = new List<string>();
while (me != null)
{
members.Add(me.Member.Name);
me = me.Expression as MemberExpression;
}
var sb = new StringBuilder();
for (int i = members.Count - 1; i >= 0; i--)
{
sb.Append(members[i]);
if (i > 0) sb.Append('.');
}
return sb.ToString();
}
public class ProfilingSample

26
Assets/ScriptableRenderLoop/RenderPasses/ShadowRenderPass.cs


public int directionalLightCascadeCount;
public Vector3 directionalLightCascades;
static ShadowSettings defaultShadowSettings = null;
ShadowSettings settings = new ShadowSettings();
settings.enabled = true;
settings.shadowAtlasHeight = settings.shadowAtlasWidth = 4096;
settings.directionalLightCascadeCount = 1;
settings.directionalLightCascades = new Vector3(0.05F, 0.2F, 0.3F);
settings.directionalLightCascadeCount = 4;
settings.maxShadowDistance = 1000.0F;
return settings;
if (defaultShadowSettings == null)
{
defaultShadowSettings = new ShadowSettings();
defaultShadowSettings.enabled = true;
defaultShadowSettings.shadowAtlasHeight = defaultShadowSettings.shadowAtlasWidth = 4096;
defaultShadowSettings.directionalLightCascadeCount = 1;
defaultShadowSettings.directionalLightCascades = new Vector3(0.05F, 0.2F, 0.3F);
defaultShadowSettings.directionalLightCascadeCount = 4;
defaultShadowSettings.maxShadowDistance = 1000.0F;
}
return defaultShadowSettings;
}
}
}

int m_ShadowTexName;
const int k_DepthBuffer = 24;
public int shadowTexName
{
get { return m_ShadowTexName; }
}
public ShadowRenderPass(ShadowSettings settings)
{

if (!m_Settings.enabled)
{
ClearPackedShadows(cullResults.visibleLights, out packedShadows);
return;
}
// Pack all shadow quads into the texture

26
ProjectSettings/ProjectSettings.asset


--- !u!129 &1
PlayerSettings:
m_ObjectHideFlags: 0
serializedVersion: 10
serializedVersion: 11
productGUID: 900e9e40d20cd3e44ad40e5b00239dcc
AndroidProfiler: 0
defaultScreenOrientation: 4

16:10: 1
16:9: 1
Others: 1
bundleIdentifier: com.Company.ProductName
bundleVersion: 1.0
preloadedAssets: []
metroInputSource: 0

depthFormat: 1
protectGraphicsMemory: 0
useHDRDisplay: 0
applicationIdentifier:
Android: com.Company.ProductName
Standalone: unity.DefaultCompany.dev
Tizen: com.Company.ProductName
iOS: com.Company.ProductName
tvOS: com.Company.ProductName
buildNumber:
iOS: 0
AndroidBundleVersionCode: 1
AndroidMinSdkVersion: 16
AndroidTargetSdkVersion: 0

iPhoneStrippingLevel: 0
iPhoneScriptCallOptimization: 0
iPhoneBuildNumber: 0
ForceInternetPermission: 0
ForceSDCardPermission: 0
CreateWallpaper: 0

ps4videoRecordingFeaturesUsed: 0
ps4contentSearchFeaturesUsed: 0
ps4attribEyeToEyeDistanceSettingVR: 0
ps4IncludedModules: []
ps4IncludedModules:
- libc.prx
- libSceAudioLatencyEstimation.prx
- libSceFace.prx
- libSceFaceTracker.prx
- libSceFios2.prx
- libSceHand.prx
- libSceHandTracker.prx
- libSceHeadTracker.prx
- libSceJobManager.prx
- libSceNpToolkit.prx
- libSceS3DConversion.prx
- libSceSmart.prx
monoEnv:
psp2Splashimage: {fileID: 0}
psp2NPTrophyPackPath:

50
Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
namespace UnityEngine.Experimental.Rendering.HDPipeline
{
[Serializable]
public class GlobalDebugParameters
{
public float debugOverlayRatio = 0.33f;
public bool displayDebug = false;
public bool displayShadowDebug = false;
public ShadowDebugParameters shadowDebugParameters = new ShadowDebugParameters();
}
public class DebugParameters
{
// Material Debugging
public int debugViewMaterial = 0;
// Rendering debugging
public bool displayOpaqueObjects = true;
public bool displayTransparentObjects = true;
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;
public bool useDistortion = true;
// we have to fallback to forward-only rendering when scene view is using wireframe rendering mode --
// as rendering everything in wireframe + deferred do not play well together
public bool ShouldUseForwardRenderingOnly() { return useForwardRenderingOnly || GL.wireframe; }
}
public enum ShadowDebugMode
{
None,
VisualizeAtlas,
VisualizeShadowMap
}
[Serializable]
public class ShadowDebugParameters
{
public bool enableShadows = true;
public ShadowDebugMode visualizationMode = ShadowDebugMode.None;
public uint visualizeShadowMapIndex = 0;
}
}

12
Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs.meta


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

82
Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugDisplayShadowMap.shader


Shader "Hidden/HDRenderPipeline/DebugDisplayShadowMap"
{
SubShader
{
Pass
{
ZWrite Off
ZTest Off
Blend One Zero
Cull Off
HLSLPROGRAM
#pragma target 4.5
#pragma only_renderers d3d11 ps4 metal // TEMP: unitl we go futher in dev
#pragma vertex Vert
#pragma fragment Frag
#include "Common.hlsl"
TEXTURE2D(g_tShadowBuffer);
TEXTURE2D(_DummyTexture);
SAMPLER2D(sampler_DummyTexture);
float4 _TextureScaleBias;
struct Attributes
{
uint vertexID : SV_VertexID;
};
struct Varyings
{
float4 positionCS : SV_POSITION;
float2 texcoord : TEXCOORD0;
};
Varyings Vert(Attributes input)
{
float4 positions[] =
{
float4(-1.0, -1.0, 0.0f, 1.0),
float4( 1.0, -1.0, 0.0f, 1.0),
float4( 1.0, 1.0, 0.0f, 1.0),
float4( 1.0, 1.0, 0.0f, 1.0),
float4(-1.0, 1.0, 0.0f, 1.0),
float4(-1.0, -1.0, 0.0f, 1.0)
};
float2 texcoords[] =
{
float2(0.0, 1.0),
float2(1.0, 1.0),
float2(1.0, 0.0),
float2(1.0, 0.0),
float2(0.0, 0.0),
float2(0.0, 1.0),
};
Varyings output;
output.positionCS = positions[input.vertexID];
output.texcoord = texcoords[input.vertexID] * _TextureScaleBias.xy + _TextureScaleBias.zw;
return output;
}
float4 Frag(Varyings input) : SV_Target
{
// We need the dummy texture for the sampler, but we also need to sample it in order not to get a compile error.
float4 dummy = SAMPLE_TEXTURE2D(_DummyTexture, sampler_DummyTexture, input.texcoord) * 0.00001;
return SAMPLE_TEXTURE2D(g_tShadowBuffer, sampler_DummyTexture, input.texcoord).xxxx + dummy;
}
ENDHLSL
}
}
Fallback Off
}

9
Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugDisplayShadowMap.shader.meta


fileFormatVersion: 2
guid: ee25e539f5594f44085e0a9000c15d9b
timeCreated: 1476053153
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Assets/TestScenes/HDTest/CascadedShadowsTest.meta


fileFormatVersion: 2
guid: ab939294412b89e49b889738eeeb844a
folderAsset: yes
timeCreated: 1485274537
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

1001
Assets/TestScenes/HDTest/CascadedShadowsTest.unity
文件差异内容过多而无法显示
查看文件

8
Assets/TestScenes/HDTest/CascadedShadowsTest.unity.meta


fileFormatVersion: 2
guid: e30864c7c4266b24cb1c708c206200a6
timeCreated: 1483527925
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

160
Assets/TestScenes/HDTest/CascadedShadowsTest/Lit_Gray.mat


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Lit_Gray
m_Shader: {fileID: 4800000, guid: 6e4ae4064600d784cac1e41a9e6f2e59, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DEPTHOFFSETENABLE_OFF _DETAIL_MAP_WITH_NORMAL
_DISTORTIONDEPTHTEST_OFF _DISTORTIONENABLE_OFF _DISTORTIONONLY_OFF _ENABLEPERPIXELDISPLACEMENT_OFF
_NORMALMAP_TANGENT_SPACE
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:
- DistortionVectors
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _AnisotropyMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DistortionVectorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissiveColorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _HeightMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MaskMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _NormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecularOcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SubSurfaceRadiusMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _TangentMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _Anisotropy: 0
- _BlendMode: 0
- _BumpScale: 1
- _CullMode: 2
- _Cutoff: 0.5
- _DepthOffsetEnable: 0
- _DetailAOScale: 1
- _DetailAlbedoScale: 1
- _DetailHeightScale: 1
- _DetailMapMode: 0
- _DetailNormalMapScale: 1
- _DetailNormalScale: 1
- _DetailSmoothnessScale: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedMode: 0
- _DstBlend: 0
- _EmissiveColorMode: 1
- _EmissiveIntensity: 0
- _EnablePerPixelDisplacement: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _HeightAmplitude: 0.01
- _HeightCenter: 0.5
- _MaterialId: 0
- _Metallic: 0
- _Mode: 0
- _NormalMapSpace: 0
- _NormalScale: 1
- _OcclusionStrength: 1
- _PPDMaxSamples: 15
- _PPDMinSamples: 5
- _Parallax: 0.02
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _SubSurfaceRadius: 0
- _SurfaceType: 0
- _TexWorldScale: 1
- _UVBase: 0
- _UVDetail: 0
- _UVMappingPlanar: 0
- _UVSec: 0
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 0.49803922, g: 0.49803922, b: 0.49803922, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMask: {r: 1, g: 0, b: 0, a: 0}

9
Assets/TestScenes/HDTest/CascadedShadowsTest/Lit_Gray.mat.meta


fileFormatVersion: 2
guid: 906f2e00230e2a34b832d52909cc5906
timeCreated: 1485274548
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

9
Assets/TestScenes/HDTest/HDRenderLoopTest.meta


fileFormatVersion: 2
guid: bb067c1f82e9d8648b8909e905f6607b
folderAsset: yes
timeCreated: 1484331444
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存