浏览代码

Pulling tile pass into it's own asset. :)

/main
Tim Cooper 8 年前
当前提交
72689571
共有 18 个文件被更改,包括 303 次插入209 次删除
  1. 34
      Assets/ScriptableRenderLoop/HDRenderPipeline/Editor/HDRenderPipelineInspector.cs
  2. 15
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.asset
  3. 109
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs
  4. 3
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/LightLoop.cs
  5. 85
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePass.cs
  6. 7
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/LightLoopProducer.cs
  7. 12
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/LightLoopProducer.cs.meta
  8. 78
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TileLightLoopProducer.cs
  9. 12
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TileLightLoopProducer.cs.meta
  10. 24
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePassProducer.asset
  11. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePassProducer.asset.meta
  12. 27
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePassResources.asset
  13. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePassResources.asset.meta
  14. 28
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePassResources.cs
  15. 26
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipelineSetup.cs
  16. 25
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipelineSetup.asset
  17. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipelineSetup.asset.meta
  18. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePassResources.cs.meta

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


public bool isDebugViewMaterialInit = false;
public GUIContent[] debugViewMaterialStrings = null;
public int[] debugViewMaterialValues = null;
public readonly GUIContent commonSettings = new GUIContent("Common Settings");
public readonly GUIContent maxShadowDistance = new GUIContent("Max Shadow Distance");
public readonly GUIContent shadowCascadeCount = new GUIContent("Shadow Cascade Count");
public readonly GUIContent shadowCascadeSplit0 = new GUIContent("Cascade Split 0");
public readonly GUIContent shadowCascadeSplit1 = new GUIContent("Cascade Split 1");
public readonly GUIContent shadowCascadeSplit2 = new GUIContent("Cascade Split 2");
public readonly GUIContent skyParams = new GUIContent("Sky Settings");

EditorGUI.indentLevel--;
}
private void CommonSettingsUI(HDRenderPipeline pipe)
private void SkySettingsUI(HDRenderPipeline pipe)
var commonSettings = pipe.commonSettings;
EditorGUILayout.LabelField(styles.commonSettings);
EditorGUI.indentLevel++;
EditorGUILayout.LabelField(styles.skyParams);
commonSettings.shadowMaxDistance = Mathf.Max(0, EditorGUILayout.FloatField(styles.maxShadowDistance, commonSettings.shadowMaxDistance));
commonSettings.shadowCascadeCount = Mathf.Max(0, EditorGUILayout.IntField(styles.shadowCascadeCount, commonSettings.shadowCascadeCount));
commonSettings.shadowCascadeSplit0 = Mathf.Max(0, EditorGUILayout.FloatField(styles.shadowCascadeSplit0, commonSettings.shadowCascadeSplit0));
commonSettings.shadowCascadeSplit1 = Mathf.Max(0, EditorGUILayout.FloatField(styles.shadowCascadeSplit1, commonSettings.shadowCascadeSplit1));
commonSettings.shadowCascadeSplit2 = Mathf.Max(0, EditorGUILayout.FloatField(styles.shadowCascadeSplit2, commonSettings.shadowCascadeSplit2));
EditorGUI.indentLevel--;
EditorGUILayout.Space();
EditorGUILayout.LabelField(styles.skyParams);
pipe.lightLoopProducer = (LightLoopProducer) EditorGUILayout.ObjectField(new GUIContent("Light Loop"), pipe.lightLoopProducer, typeof(LightLoopProducer), false);
pipe.commonSettings = commonSettings;
EditorUtility.SetDirty(pipe); // Repaint
}
}

EditorGUI.indentLevel--;
}
private void TilePassUI(HDRenderPipeline renderContext)
/* private void TilePassUI(HDRenderPipeline renderContext)
{
EditorGUILayout.Space();

}
EditorGUI.indentLevel--;
}
}
}*/
public override void OnInspectorGUI()
{

return;
DebugParametersUI(renderContext);
CommonSettingsUI(renderContext);
SkySettingsUI(renderContext);
TilePassUI(renderContext);
//TilePassUI(renderContext);
}
}
}

15
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.asset


m_Script: {fileID: 11500000, guid: d440c0deec24a2f478b3e9021cb66c29, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Setup: {fileID: 11400000, guid: c90ada6c2ed7b4e4b85a303678826111, type: 2}
m_CommonSettings:
m_ShadowMaxDistance: 1000
m_ShadowCascadeCount: 4

m_SkyParameters: {fileID: 11400000, guid: 8f69e950dd2c9dc40a8e9bcb0d4faedb, type: 2}
m_SkyParameters: {fileID: 11400000, guid: 12b814c3b2e53c246a0c9f1594c01532, type: 2}
m_LightLoopProducer: {fileID: 11400000, guid: bf8cd9ae03ff7d54c89603e67be0bfc5,
type: 2}
m_ShadowSettings:
enabled: 1
shadowAtlasWidth: 4096

spotCookieSize: 128
pointCookieSize: 512
reflectionCubemapSize: 128
m_TileSettings:
enableDrawLightBoundsDebug: 0
disableTileAndCluster: 0
disableDeferredShadingInCompute: 1
enableSplitLightEvaluation: 1
enableComputeLightEvaluation: 0
debugViewTilesFlags: 0
enableClustered: 1
disableFptlWhenClustered: 0
enableBigTilePrepass: 1

109
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs


{
var instance = CreateInstance<HDRenderPipeline>();
AssetDatabase.CreateAsset(instance, k_HDRenderPipelinePath);
instance.m_Setup = AssetDatabase.LoadAssetAtPath<HDRenderPipelineSetup>("Assets/HDRenderPipelineSetup.asset");
}
[UnityEditor.MenuItem("RenderPipeline/UpdateHDLoop")]

{
string path = AssetDatabase.GUIDToAssetPath(guid);
var loop = AssetDatabase.LoadAssetAtPath<HDRenderPipeline>(path);
loop.m_Setup = AssetDatabase.LoadAssetAtPath<HDRenderPipelineSetup>("Assets/HDRenderPipelineSetup.asset");
// loop.m_Setup = AssetDatabase.LoadAssetAtPath<TilePassSetup>("Assets/HDRenderPipelineSetup.asset");
EditorUtility.SetDirty(loop);
}
}

private HDRenderPipeline()
{}
[SerializeField]
private HDRenderPipelineSetup m_Setup;
public HDRenderPipelineSetup renderPipelineSetup
{
get { return m_Setup; }
}
public CommonSettings.Settings commonSettings
{
get { return m_CommonSettings; }
set { m_CommonSettings = value; }
}
public CommonSettings.Settings commonSettingsToUse
{
get

return m_CommonSettings;
}
}
[SerializeField]
private SkyParameters m_SkyParameters;

}
}
[SerializeField]
private LightLoopProducer m_LightLoopProducer;
public LightLoopProducer lightLoopProducer
{
get { return m_LightLoopProducer; }
set { m_LightLoopProducer = value; }
}
protected override IRenderPipeline InternalCreatePipeline()
{
return new HDRenderPipelineInstance(this);

set { m_TextureSettings = value; }
}
[SerializeField]
TileSettings m_TileSettings = new TileSettings();
public TileSettings tileSettings
{
get { return m_TileSettings; }
}
public void UpdateCommonSettings()
{
var commonSettings = commonSettingsToUse;

}
}
[Serializable]
public class TileSettings
{
public bool enableDrawLightBoundsDebug = false;
public bool disableTileAndCluster = false; // For debug / test
public bool disableDeferredShadingInCompute = true;
public bool enableSplitLightEvaluation = true;
public bool enableComputeLightEvaluation = false;
// clustered light list specific buffers and data begin
public int debugViewTilesFlags = 0;
public bool enableClustered = true;
public bool disableFptlWhenClustered = false; // still useful on opaques. Should be false by default to force tile on opaque.
public bool enableBigTilePrepass = true;
}
public struct HDCamera

int m_CurrentHeight;
ShadowRenderPass m_ShadowPass;
private readonly BaseLightLoop m_LightLoop;
private DebugParameters debugParameters
{

m_LitRenderLoop.Build();
m_lightLoop = new LightLoop(owner);
m_lightLoop.Build(owner.textureSettings);
if (owner.lightLoopProducer)
m_LightLoop = owner.lightLoopProducer.CreateLightLoop();
if(m_LightLoop != null)
m_LightLoop.Build(owner.textureSettings);
m_SkyManager.skyParameters = owner.skyParametersToUse;
}

base.Dispose();
m_lightLoop.Cleanup();
if (m_LightLoop != null)
m_LightLoop.Cleanup();
m_LitRenderLoop.Cleanup();
Utilities.Destroy(m_DebugViewMaterialGBuffer);

{
reflectionProbe = SupportedRenderingFeatures.ReflectionProbe.Rotation
};
private LightLoop m_lightLoop;
#endif
void Resize(Camera camera)

m_SkyManager.skyParameters = m_Owner.skyParametersToUse;
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 (camera.pixelWidth != m_CurrentWidth || camera.pixelHeight != m_CurrentHeight || m_lightLoop.NeedResize())
if (m_LightLoop == null)
return;
if (camera.pixelWidth != m_CurrentWidth || camera.pixelHeight != m_CurrentHeight || m_LightLoop.NeedResize())
m_lightLoop.ReleaseResolutionDependentBuffers();
m_LightLoop.ReleaseResolutionDependentBuffers();
m_lightLoop.AllocResolutionDependentBuffers(camera.pixelWidth, camera.pixelHeight);
m_LightLoop.AllocResolutionDependentBuffers(camera.pixelWidth, camera.pixelHeight);
// update recorded window resolution
m_CurrentWidth = camera.pixelWidth;

renderContext.ExecuteCommandBuffer(cmd);
cmd.Dispose();
m_lightLoop.PushGlobalParams(hdCamera.camera, renderContext);
if (m_LightLoop != null)
m_LightLoop.PushGlobalParams(hdCamera.camera, renderContext);
}
public override void Render(ScriptableRenderContext renderContext, Camera[] cameras)

m_LitRenderLoop.RenderInit(renderContext);
// Do anything we need to do upon a new frame.
m_lightLoop.NewFrame();
if (m_LightLoop != null)
m_LightLoop.NewFrame();
m_Owner.UpdateCommonSettings();

renderContext.SetupCameraProperties(camera); // Need to recall SetupCameraProperties after m_ShadowPass.Render
using (new Utilities.ProfilingSample("Build Light list", renderContext))
if (m_LightLoop != null)
m_lightLoop.PrepareLightsForGPU(m_Owner.shadowSettings, cullResults, camera, ref shadows);
m_lightLoop.BuildGPULightLists(camera, renderContext, m_CameraDepthBufferRT); // TODO: Use async compute here to run light culling during shadow
using (new Utilities.ProfilingSample("Build Light list", renderContext))
{
m_LightLoop.PrepareLightsForGPU(m_Owner.shadowSettings, cullResults, camera, ref shadows);
m_LightLoop.BuildGPULightLists(camera, renderContext, m_CameraDepthBufferRT); // TODO: Use async compute here to run light culling during shadow
}
}
PushGlobalParams(hdCamera, renderContext);

{
return;
}
m_lightLoop.RenderDeferredLighting(hdCamera, renderContext, m_CameraColorBuffer);
if (m_LightLoop != null)
m_LightLoop.RenderDeferredLighting(hdCamera, renderContext, m_CameraColorBuffer);
m_SkyManager.UpdateEnvironment(hdCamera, m_lightLoop.GetCurrentSunLight(), renderContext);
m_SkyManager.UpdateEnvironment(hdCamera, m_LightLoop == null ? null : m_LightLoop.GetCurrentSunLight(), renderContext);
m_SkyManager.RenderSky(hdCamera, m_lightLoop.GetCurrentSunLight(), m_CameraColorBufferRT, m_CameraDepthBufferRT, renderContext);
m_SkyManager.RenderSky(hdCamera, m_LightLoop == null ? null : m_LightLoop.GetCurrentSunLight(), m_CameraColorBufferRT, m_CameraDepthBufferRT, renderContext);
}
void RenderForward(CullResults cullResults, Camera camera, ScriptableRenderContext renderContext, bool renderOpaque)

{
Utilities.SetRenderTarget(renderContext, m_CameraColorBufferRT, m_CameraDepthBufferRT);
m_lightLoop.RenderForward(camera, renderContext, renderOpaque);
if (m_LightLoop != null)
m_LightLoop.RenderForward(camera, renderContext, renderOpaque);
if (renderOpaque)
{

{
Utilities.SetRenderTarget(renderContext, m_CameraColorBufferRT, m_CameraDepthBufferRT);
m_lightLoop.RenderForward(camera, renderContext, true);
if (m_LightLoop != null)
m_LightLoop.RenderForward(camera, renderContext, true);
RenderOpaqueRenderList(cullResults, camera, renderContext, "ForwardOnlyOpaque", Utilities.kRendererConfigurationBakedLighting);
}
}

void PrepareLightsForGPU(ShadowSettings shadowSettings, CullResults cullResults, Camera camera, ref ShadowOutput shadowOutput)
{
// build per tile light lists
m_lightLoop.PrepareLightsForGPU(shadowSettings, cullResults, camera, ref shadowOutput);
if (m_LightLoop != null)
m_LightLoop.PrepareLightsForGPU(shadowSettings, cullResults, camera, ref shadowOutput);
}
void InitAndClearBuffer(Camera camera, ScriptableRenderContext renderContext)

3
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/LightLoop.cs


using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
using System;
namespace UnityEngine.Experimental.Rendering.HDPipeline
{

85
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePass.cs


int m_areaLightCount = 0;
int m_lightCount = 0;
private ComputeShader buildScreenAABBShader { get { return m_Parent.renderPipelineSetup.buildScreenAABBShader; } }
private ComputeShader buildPerTileLightListShader { get { return m_Parent.renderPipelineSetup.buildPerTileLightListShader; } }
private ComputeShader buildPerBigTileLightListShader { get { return m_Parent.renderPipelineSetup.buildPerBigTileLightListShader; } }
private ComputeShader buildPerVoxelLightListShader { get { return m_Parent.renderPipelineSetup.buildPerVoxelLightListShader; } }
private ComputeShader shadeOpaqueShader { get { return m_Parent.renderPipelineSetup.shadeOpaqueShader; } }
private ComputeShader buildScreenAABBShader { get { return m_PassResources.buildScreenAABBShader; } }
private ComputeShader buildPerTileLightListShader { get { return m_PassResources.buildPerTileLightListShader; } }
private ComputeShader buildPerBigTileLightListShader { get { return m_PassResources.buildPerBigTileLightListShader; } }
private ComputeShader buildPerVoxelLightListShader { get { return m_PassResources.buildPerVoxelLightListShader; } }
private ComputeShader shadeOpaqueShader { get { return m_PassResources.shadeOpaqueShader; } }
static int s_GenAABBKernel;
static int s_GenListPerTileKernel;

get
{
bool isEnabledMSAA = false;
var tileSettings = m_Parent.tileSettings;
Debug.Assert(!isEnabledMSAA || tileSettings.enableClustered);
bool disableFptl = (tileSettings.disableFptlWhenClustered && tileSettings.enableClustered) || isEnabledMSAA;
Debug.Assert(!isEnabledMSAA || m_PassSettings.enableClustered);
bool disableFptl = (m_PassSettings.disableFptlWhenClustered && m_PassSettings.enableClustered) || isEnabledMSAA;
return !disableFptl;
}
}

}
}
Material m_DeferredDirectMaterial = null;
Material m_DeferredIndirectMaterial = null;
Material m_DeferredAllMaterial = null;

const int k_TileSize = 16;
private readonly HDRenderPipeline m_Parent;
int GetNumTileX(Camera camera)

return (camera.pixelHeight + (k_TileSize - 1)) / k_TileSize;
}
public LightLoop(HDRenderPipeline hdRenderPipeline)
TileLightLoopProducer.TileSettings m_PassSettings;
private TilePassResources m_PassResources;
public LightLoop(TileLightLoopProducer producer)
m_Parent = hdRenderPipeline;
m_PassSettings = producer.tileSettings;
m_PassResources = producer.passResources;
}
public override void Build(TextureSettings textureSettings)

var tileSettings = m_Parent.tileSettings;
s_DirectionalLightDatas = new ComputeBuffer(k_MaxDirectionalLightsOnScreen, System.Runtime.InteropServices.Marshal.SizeOf(typeof(DirectionalLightData)));
s_LightDatas = new ComputeBuffer(k_MaxPunctualLightsOnScreen + k_MaxAreaLightsOnSCreen, System.Runtime.InteropServices.Marshal.SizeOf(typeof(LightData)));
s_EnvLightDatas = new ComputeBuffer(k_MaxEnvLightsOnScreen, System.Runtime.InteropServices.Marshal.SizeOf(typeof(EnvLightData)));

m_CubeReflTexArray.AllocTextureArray(32, textureSettings.reflectionCubemapSize, TextureFormat.BC6H, true);
s_GenAABBKernel = buildScreenAABBShader.FindKernel("ScreenBoundsAABB");
s_GenListPerTileKernel = buildPerTileLightListShader.FindKernel(tileSettings.enableBigTilePrepass ? "TileLightListGen_SrcBigTile" : "TileLightListGen");
s_GenListPerTileKernel = buildPerTileLightListShader.FindKernel(m_PassSettings.enableBigTilePrepass ? "TileLightListGen_SrcBigTile" : "TileLightListGen");
s_AABBBoundsBuffer = new ComputeBuffer(2 * k_MaxLightsOnScreen, 3 * sizeof(float));
s_ConvexBoundsBuffer = new ComputeBuffer(k_MaxLightsOnScreen, System.Runtime.InteropServices.Marshal.SizeOf(typeof(SFiniteLightBound)));
s_LightVolumeDataBuffer = new ComputeBuffer(k_MaxLightsOnScreen, System.Runtime.InteropServices.Marshal.SizeOf(typeof(LightVolumeData)));

buildPerTileLightListShader.SetBuffer(s_GenListPerTileKernel, "_LightVolumeData", s_LightVolumeDataBuffer);
buildPerTileLightListShader.SetBuffer(s_GenListPerTileKernel, "g_data", s_ConvexBoundsBuffer);
if (tileSettings.enableClustered)
if (m_PassSettings.enableClustered)
var kernelName = tileSettings.enableBigTilePrepass ? (k_UseDepthBuffer ? "TileLightListGen_DepthRT_SrcBigTile" : "TileLightListGen_NoDepthRT_SrcBigTile") : (k_UseDepthBuffer ? "TileLightListGen_DepthRT" : "TileLightListGen_NoDepthRT");
var kernelName = m_PassSettings.enableBigTilePrepass ? (k_UseDepthBuffer ? "TileLightListGen_DepthRT_SrcBigTile" : "TileLightListGen_NoDepthRT_SrcBigTile") : (k_UseDepthBuffer ? "TileLightListGen_DepthRT" : "TileLightListGen_NoDepthRT");
s_GenListPerVoxelKernel = buildPerVoxelLightListShader.FindKernel(kernelName);
s_ClearVoxelAtomicKernel = buildPerVoxelLightListShader.FindKernel("ClearAtomic");
buildPerVoxelLightListShader.SetBuffer(s_GenListPerVoxelKernel, "g_vBoundsBuffer", s_AABBBoundsBuffer);

s_GlobalLightListAtomic = new ComputeBuffer(1, sizeof(uint));
}
if (tileSettings.enableBigTilePrepass)
if (m_PassSettings.enableBigTilePrepass)
{
s_GenListPerBigTileKernel = buildPerBigTileLightListShader.FindKernel("BigTileLightListGen");
buildPerBigTileLightListShader.SetBuffer(s_GenListPerBigTileKernel, "g_vBoundsBuffer", s_AABBBoundsBuffer);

public override bool NeedResize()
{
var tileSettings = m_Parent.tileSettings;
(s_BigTileLightList == null && tileSettings.enableBigTilePrepass) ||
(s_PerVoxelLightLists == null && tileSettings.enableClustered);
(s_BigTileLightList == null && m_PassSettings.enableBigTilePrepass) ||
(s_PerVoxelLightLists == null && m_PassSettings.enableClustered);
}
public override void ReleaseResolutionDependentBuffers()

const int dwordsPerTile = (capacityUShortsPerTile + 1) >> 1; // room for 31 lights and a nrLights value.
s_LightList = new ComputeBuffer((int)LightCategory.Count * dwordsPerTile * nrTiles, sizeof(uint)); // enough list memory for a 4k x 4k display
var tileSettings = m_Parent.tileSettings;
if (tileSettings.enableClustered)
if (m_PassSettings.enableClustered)
{
s_PerVoxelOffset = new ComputeBuffer((int)LightCategory.Count * (1 << k_Log2NumClusters) * nrTiles, sizeof(uint));
s_PerVoxelLightLists = new ComputeBuffer(NumLightIndicesPerClusteredTile() * nrTiles, sizeof(uint));

}
}
if (tileSettings.enableBigTilePrepass)
if (m_PassSettings.enableBigTilePrepass)
{
var nrBigTilesX = (width + 63) / 64;
var nrBigTilesY = (height + 63) / 64;

cmd.SetComputeBufferParam(buildPerVoxelLightListShader, s_GenListPerVoxelKernel, "g_vLayeredLightList", s_PerVoxelLightLists);
cmd.SetComputeBufferParam(buildPerVoxelLightListShader, s_GenListPerVoxelKernel, "g_LayeredOffset", s_PerVoxelOffset);
cmd.SetComputeBufferParam(buildPerVoxelLightListShader, s_GenListPerVoxelKernel, "g_LayeredSingleIdxBuffer", s_GlobalLightListAtomic);
if (m_Parent.tileSettings.enableBigTilePrepass)
if (m_PassSettings.enableBigTilePrepass)
cmd.SetComputeBufferParam(buildPerVoxelLightListShader, s_GenListPerVoxelKernel, "g_vBigTileLightList", s_BigTileLightList);
if (k_UseDepthBuffer)

cmd.SetComputeBufferParam(buildScreenAABBShader, s_GenAABBKernel, "g_vBoundsBuffer", s_AABBBoundsBuffer);
cmd.DispatchCompute(buildScreenAABBShader, s_GenAABBKernel, (m_lightCount + 7) / 8, 1, 1);
}
var tileSettings = m_Parent.tileSettings;
if (tileSettings.enableBigTilePrepass)
if (m_PassSettings.enableBigTilePrepass)
{
cmd.SetComputeIntParams(buildPerBigTileLightListShader, "g_viDimensions", new int[2] { w, h });
cmd.SetComputeIntParam(buildPerBigTileLightListShader, "_EnvLightIndexShift", m_lightList.lights.Count);

Utilities.SetMatrixCS(cmd, buildPerTileLightListShader, "g_mInvScrProjection", invProjscr);
cmd.SetComputeTextureParam(buildPerTileLightListShader, s_GenListPerTileKernel, "g_depth_tex", cameraDepthBufferRT);
cmd.SetComputeBufferParam(buildPerTileLightListShader, s_GenListPerTileKernel, "g_vLightList", s_LightList);
if (tileSettings.enableBigTilePrepass)
if (m_PassSettings.enableBigTilePrepass)
if (tileSettings.enableClustered) // works for transparencies too.
if (m_PassSettings.enableClustered) // works for transparencies too.
{
VoxelLightListGeneration(cmd, camera, projscr, invProjscr, cameraDepthBufferRT);
}

SetGlobalInt("_NumTileX", GetNumTileX(camera));
SetGlobalInt("_NumTileY", GetNumTileY(camera));
var tileSettings = m_Parent.tileSettings;
if (tileSettings.enableBigTilePrepass)
if (m_PassSettings.enableBigTilePrepass)
if (tileSettings.enableClustered)
if (m_PassSettings.enableClustered)
{
SetGlobalFloat("g_fClustScale", m_ClustScale);
SetGlobalFloat("g_fClustBase", k_ClustLogBase);

mousePixelCoord.y = (hdCamera.screenSize.y - 1.0f) - mousePixelCoord.y;
}
#endif
var tileSettings = m_Parent.tileSettings;
using (new Utilities.ProfilingSample(tileSettings.disableTileAndCluster ? "SinglePass - Deferred Lighting Pass" : "TilePass - Deferred Lighting Pass", renderContext))
using (new Utilities.ProfilingSample(m_PassSettings.disableTileAndCluster ? "SinglePass - Deferred Lighting Pass" : "TilePass - Deferred Lighting Pass", renderContext))
{
var cmd = new CommandBuffer();

SetGlobalFloat("_UseTileLightList", 0);
}
if (tileSettings.disableTileAndCluster)
if (m_PassSettings.disableTileAndCluster)
{
// This is a debug brute force renderer to debug tile/cluster which render all the lights
Utilities.SetupMaterialHDCamera(hdCamera, m_SingleDeferredMaterial);

}
else
{
if (!tileSettings.disableDeferredShadingInCompute)
if (!m_PassSettings.disableDeferredShadingInCompute)
{
// Compute shader evaluation
int kernel = bUseClusteredForDeferred ? s_shadeOpaqueClusteredKernel : s_shadeOpaqueFptlKernel;

else
{
// Pixel shader evaluation
if (tileSettings.enableSplitLightEvaluation)
if (m_PassSettings.enableSplitLightEvaluation)
{
Utilities.SetupMaterialHDCamera(hdCamera, m_DeferredDirectMaterial);
m_DeferredDirectMaterial.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);

}
// Draw tile debugging
if (tileSettings.debugViewTilesFlags != 0)
if (m_PassSettings.debugViewTilesFlags != 0)
m_DebugViewTilesMaterial.SetInt("_ViewTilesFlags", tileSettings.debugViewTilesFlags);
m_DebugViewTilesMaterial.SetInt("_ViewTilesFlags", m_PassSettings.debugViewTilesFlags);
m_DebugViewTilesMaterial.SetVector("_MousePixelCoord", mousePixelCoord);
m_DebugViewTilesMaterial.EnableKeyword(bUseClusteredForDeferred ? "USE_CLUSTERED_LIGHTLIST" : "USE_FPTL_LIGHTLIST");
m_DebugViewTilesMaterial.DisableKeyword(!bUseClusteredForDeferred ? "USE_CLUSTERED_LIGHTLIST" : "USE_FPTL_LIGHTLIST");

var cmd = new CommandBuffer();
if (m_Parent.tileSettings.disableTileAndCluster)
if (m_PassSettings.disableTileAndCluster)
{
cmd.name = "Forward pass";
cmd.EnableShaderKeyword("LIGHTLOOP_SINGLE_PASS");

7
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/LightLoopProducer.cs


namespace UnityEngine.Experimental.Rendering.HDPipeline
{
public abstract class LightLoopProducer : ScriptableObject
{
public abstract BaseLightLoop CreateLightLoop();
}
}

12
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/LightLoopProducer.cs.meta


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

78
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TileLightLoopProducer.cs


using System;
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine.Experimental.Rendering.HDPipeline.TilePass;
namespace UnityEngine.Experimental.Rendering.HDPipeline
{
public class TileLightLoopProducer : LightLoopProducer
{
#if UNITY_EDITOR
public const string TilePassProducer = "Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePassProducer.asset";
[UnityEditor.MenuItem("RenderPipeline/Create TileLightLoopProducer")]
static void CreateTileLightLoopProducer()
{
var instance = CreateInstance<TileLightLoopProducer>();
UnityEditor.AssetDatabase.CreateAsset(instance, TilePassProducer);
instance.m_PassResources = AssetDatabase.LoadAssetAtPath<TilePassResources>(TilePassResources.tilePassResources);
}
#endif
[Serializable]
public struct TileSettings
{
public bool enableDrawLightBoundsDebug;
public bool disableTileAndCluster; // For debug / test
public bool disableDeferredShadingInCompute;
public bool enableSplitLightEvaluation;
public bool enableComputeLightEvaluation;
// clustered light list specific buffers and data begin
public int debugViewTilesFlags;
public bool enableClustered;
public bool disableFptlWhenClustered; // still useful on opaques. Should be false by default to force tile on opaque.
public bool enableBigTilePrepass;
public static TileSettings defaultSettings = new TileSettings
{
enableDrawLightBoundsDebug = false,
disableTileAndCluster = false,
disableDeferredShadingInCompute = true,
enableSplitLightEvaluation = true,
enableComputeLightEvaluation = false,
debugViewTilesFlags = 0,
enableClustered = true,
disableFptlWhenClustered = false,
enableBigTilePrepass = true,
};
}
[SerializeField]
private TileSettings m_TileSettings = TileSettings.defaultSettings;
public TileSettings tileSettings
{
get { return m_TileSettings; }
set { m_TileSettings = value; }
}
[SerializeField]
private TilePassResources m_PassResources;
public TilePassResources passResources
{
get { return m_PassResources; }
set { m_PassResources = value; }
}
public override BaseLightLoop CreateLightLoop()
{
return new LightLoop(this);
}
}
}

12
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TileLightLoopProducer.cs.meta


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

24
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePassProducer.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: 31c50a63970c0c843ab7cbf7d67d5b33, type: 3}
m_Name: TilePassProducer
m_EditorClassIdentifier:
m_TileSettings:
enableDrawLightBoundsDebug: 0
disableTileAndCluster: 0
disableDeferredShadingInCompute: 1
enableSplitLightEvaluation: 1
enableComputeLightEvaluation: 0
debugViewTilesFlags: 0
enableClustered: 1
disableFptlWhenClustered: 0
enableBigTilePrepass: 1
m_PassResources: {fileID: 11400000, guid: 7f2998544b2ac3848822b80ec3e6c446, type: 2}

9
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePassProducer.asset.meta


fileFormatVersion: 2
guid: bf8cd9ae03ff7d54c89603e67be0bfc5
timeCreated: 1485447725
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

27
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePassResources.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: 8b6f86e1523e69a4282e92d393be89a4, type: 3}
m_Name: TilePassResources
m_EditorClassIdentifier:
buildScreenAABBShader: {fileID: 7200000, guid: 728dce960f8a9c44bbc3abb3b851d8f6,
type: 3}
buildPerTileLightListShader: {fileID: 7200000, guid: 65af3444cbf4b3747a4dead7ee00cfee,
type: 3}
buildPerBigTileLightListShader: {fileID: 7200000, guid: 5ee1f9d6e09abe045b2f5e0b784b9072,
type: 3}
buildPerVoxelLightListShader: {fileID: 7200000, guid: 0bb1b7e0ddcd5c44baf3ddc7456eb196,
type: 3}
shadeOpaqueShader: {fileID: 7200000, guid: 0b64f79746d2daf4198eaf6eab9af259, type: 3}
m_DebugViewMaterialGBuffer: {fileID: 4800000, guid: 439949ea1bfa91b4ba0d04269fcde33d,
type: 3}
m_InitPreFGD: {fileID: 4800000, guid: 123f13d52852ef547b2962de4bd9eaad, type: 3}

9
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePassResources.asset.meta


fileFormatVersion: 2
guid: 7f2998544b2ac3848822b80ec3e6c446
timeCreated: 1485447672
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

28
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePassResources.cs


namespace UnityEngine.Experimental.Rendering.HDPipeline
{
public class TilePassResources : ScriptableObject
{
#if UNITY_EDITOR
public const string tilePassResources = "Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePassResources.asset";
[UnityEditor.MenuItem("RenderPipeline/CreateTilePassResources")]
static void CreateTilePassSetup()
{
var instance = CreateInstance<TilePassResources>();
UnityEditor.AssetDatabase.CreateAsset(instance, tilePassResources);
}
#endif
public ComputeShader buildScreenAABBShader = null;
public ComputeShader buildPerTileLightListShader = null; // FPTL
public ComputeShader buildPerBigTileLightListShader = null;
public ComputeShader buildPerVoxelLightListShader = null; // clustered
public ComputeShader shadeOpaqueShader = null;
// Various set of material use in render loop
public Shader m_DebugViewMaterialGBuffer;
// For image based lighting
public Shader m_InitPreFGD;
}
}

26
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipelineSetup.cs


namespace UnityEngine.Experimental.Rendering.HDPipeline
{
public class HDRenderPipelineSetup : ScriptableObject
{
#if UNITY_EDITOR
[UnityEditor.MenuItem("RenderPipeline/CreateHDPipelineSetup")]
static void CreateHDRenderPipelineSetup()
{
var instance = ScriptableObject.CreateInstance<HDRenderPipelineSetup>();
UnityEditor.AssetDatabase.CreateAsset(instance, "Assets/HDRenderPipelineSetup.asset");
}
#endif
public ComputeShader buildScreenAABBShader = null;
public ComputeShader buildPerTileLightListShader = null; // FPTL
public ComputeShader buildPerBigTileLightListShader = null;
public ComputeShader buildPerVoxelLightListShader = null; // clustered
public ComputeShader shadeOpaqueShader = null;
// Various set of material use in render loop
public Shader m_DebugViewMaterialGBuffer;
// For image based lighting
public Shader m_InitPreFGD;
}
}

25
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipelineSetup.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: 8b6f86e1523e69a4282e92d393be89a4, type: 3}
m_Name: HDRenderPipelineSetup
m_EditorClassIdentifier:
buildScreenAABBShader: {fileID: 7200000, guid: 728dce960f8a9c44bbc3abb3b851d8f6,
type: 3}
buildPerTileLightListShader: {fileID: 7200000, guid: 65af3444cbf4b3747a4dead7ee00cfee,
type: 3}
buildPerBigTileLightListShader: {fileID: 7200000, guid: 5ee1f9d6e09abe045b2f5e0b784b9072,
type: 3}
buildPerVoxelLightListShader: {fileID: 7200000, guid: 4c2d6eb0553e2514bba3ea9a85d8c53c,
type: 3}
shadeOpaqueShader: {fileID: 7200000, guid: 0b64f79746d2daf4198eaf6eab9af259, type: 3}
m_DebugViewMaterialGBuffer: {fileID: 4800000, guid: 439949ea1bfa91b4ba0d04269fcde33d,
type: 3}
m_InitPreFGD: {fileID: 4800000, guid: 123f13d52852ef547b2962de4bd9eaad, type: 3}

9
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipelineSetup.asset.meta


fileFormatVersion: 2
guid: c90ada6c2ed7b4e4b85a303678826111
timeCreated: 1484737584
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

/Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipelineSetup.cs.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePassResources.cs.meta

正在加载...
取消
保存