浏览代码

Fixing memory allocations

/RenderPassXR_Sandbox
Tim Cooper 7 年前
当前提交
696ae193
共有 11 个文件被更改,包括 112 次插入95 次删除
  1. 4
      Assets/Editor/Tests/RenderloopTests/CullResultsTest.cs
  2. 5
      Assets/Editor/Tests/RenderloopTests/RenderPipelineTestFixture.cs
  3. 7
      Assets/ScriptableRenderPipeline/BasicRenderPipeline/BasicRenderPipeline.cs
  4. 6
      Assets/ScriptableRenderPipeline/Core/Shadow/Shadow.cs
  5. 11
      Assets/ScriptableRenderPipeline/Core/TextureCache.cs
  6. 23
      Assets/ScriptableRenderPipeline/Fptl/FptlLighting.cs
  7. 62
      Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
  8. 38
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs
  9. 4
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkySettingsSingleton.cs
  10. 34
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Utilities.cs
  11. 13
      Assets/ScriptableRenderPipeline/LightweightPipeline/LightweightPipeline.cs

4
Assets/Editor/Tests/RenderloopTests/CullResultsTest.cs


{
void InspectCullResults(Camera camera, CullResults cullResults, ScriptableRenderContext renderContext)
{
VisibleReflectionProbe[] probes = cullResults.visibleReflectionProbes;
VisibleReflectionProbe[] probes = cullResults.visibleReflectionProbes.ToArray();
Assert.AreEqual(1, probes.Length, "Incorrect reflection probe count");

VisibleLight[] lights = cullResults.visibleLights;
VisibleLight[] lights = cullResults.visibleLights.ToArray();
Assert.AreEqual(3, lights.Length, "Incorrect light count");
LightType[] expectedTypes = new LightType[] { LightType.Directional, LightType.Spot, LightType.Point };

5
Assets/Editor/Tests/RenderloopTests/RenderPipelineTestFixture.cs


private static RenderLoopTestFixture m_Instance;
CullResults m_CullResults;
public override void Render(ScriptableRenderContext renderContext, Camera[] cameras)
{
base.Render(renderContext, cameras);

bool gotCullingParams = CullResults.GetCullingParameters(camera, out cullingParams);
Assert.IsTrue(gotCullingParams);
CullResults cullResults = CullResults.Cull(ref cullingParams, renderContext);
CullResults.Cull(ref cullingParams, renderContext, ref m_CullResults);
s_Callback(camera, cullResults, renderContext);
s_Callback(camera, m_CullResults, renderContext);
}
renderContext.Submit();

7
Assets/ScriptableRenderPipeline/BasicRenderPipeline/BasicRenderPipeline.cs


ScriptableCullingParameters cullingParams;
if (!CullResults.GetCullingParameters(camera, out cullingParams))
continue;
CullResults cull = CullResults.Cull(ref cullingParams, context);
CullResults cull = new CullResults();
CullResults.Cull(ref cullingParams, context, ref cull);
// Setup camera for rendering (sets render target, view/projection matrices and other
// per-camera built-in shader variables).

// Setup lighting variables for shader to use
private static void SetupLightShaderVariables(VisibleLight[] lights, ScriptableRenderContext context)
private static void SetupLightShaderVariables(List<VisibleLight> lights, ScriptableRenderContext context)
{
// We only support up to 8 visible lights here. More complex approaches would
// be doing some sort of per-object light setups, but here we go for simplest possible

// to the viewer, so that "most important" lights in the scene are picked, and not the 8
// that happened to be first.
int lightCount = Mathf.Min(lights.Length, kMaxLights);
int lightCount = Mathf.Min(lights.Count, kMaxLights);
// Prepare light data
Vector4[] lightColors = new Vector4[kMaxLights];

6
Assets/ScriptableRenderPipeline/Core/Shadow/Shadow.cs


override public void Update( FrameId frameId, ScriptableRenderContext renderContext, CullResults cullResults, VisibleLight[] lights )
{
var profilingSample = new HDPipeline.Utilities.ProfilingSample("Shadowmap" + m_TexSlot, renderContext);
var profilingSample = new HDPipeline.Utilities.ProfilingSample(string.Format("Shadowmap{0}",m_TexSlot), renderContext);
if (!string.IsNullOrEmpty( m_ShaderKeyword ) )
{

if( entrySlice != curSlice )
{
Debug.Assert( curSlice == uint.MaxValue || entrySlice >= curSlice, "Entries in the entry cache are not ordered in slice order." );
cb.name = "Shadowmap.Update.Slice" + entrySlice;
cb.name = string.Format("Shadowmap.Update.Slice{0}", entrySlice);
if( curSlice != uint.MaxValue )
{

PreUpdate( frameId, cb, curSlice );
}
cb.name = "Shadowmap.Update - slice: " + curSlice + ", vp.x: " + m_EntryCache[i].current.viewport.x + ", vp.y: " + m_EntryCache[i].current.viewport.y + ", vp.w: " + m_EntryCache[i].current.viewport.width + ", vp.h: " + m_EntryCache[i].current.viewport.height;
cb.name = string.Format("Shadowmap.Update - slice: {0}, vp.x: {1}, vp.y: {2}, vp.w: {3}, vp.h: {4}", curSlice, m_EntryCache[i].current.viewport.x, m_EntryCache[i].current.viewport.y, m_EntryCache[i].current.viewport.width, m_EntryCache[i].current.viewport.height);
cb.SetViewport( m_EntryCache[i].current.viewport );
cb.SetViewProjectionMatrices( m_EntryCache[i].current.view, m_EntryCache[i].current.proj );
cb.SetGlobalVector( "g_vLightDirWs", m_EntryCache[i].current.lightDir );

11
Assets/ScriptableRenderPipeline/Core/TextureCache.cs


return sliceIndex;
}
private static List<int> s_TempIntList = new List<int>();
var tmpBuffer = new int[m_NumTextures];
s_TempIntList.Clear();
tmpBuffer[i] = m_SortedIdxArray[i]; // copy buffer
s_TempIntList.Add(m_SortedIdxArray[i]); // copy buffer
if (m_SliceArray[tmpBuffer[i]].countLRU == 0)
if (m_SliceArray[s_TempIntList[i]].countLRU == 0)
m_SortedIdxArray[zerosBase + numNonZeros] = tmpBuffer[i];
m_SortedIdxArray[zerosBase + numNonZeros] = s_TempIntList[i];
m_SortedIdxArray[nonZerosBase] = tmpBuffer[i];
m_SortedIdxArray[nonZerosBase] = s_TempIntList[i];
++nonZerosBase;
}
}

23
Assets/ScriptableRenderPipeline/Fptl/FptlLighting.cs


dirLightCount++;
}
}
s_DirLightList.SetData(lights.ToArray());
s_DirLightList.SetData(lights);
return dirLightCount;
}

m_FrameId.frameCount++;
// get the indices for all lights that want to have shadows
m_ShadowRequests.Clear();
m_ShadowRequests.Capacity = inputs.visibleLights.Length;
int lcnt = inputs.visibleLights.Length;
m_ShadowRequests.Capacity = inputs.visibleLights.Count;
int lcnt = inputs.visibleLights.Count;
for (int i = 0; i < lcnt; ++i)
{
VisibleLight vl = inputs.visibleLights[i];

uint shadowRequestCount = (uint)m_ShadowRequests.Count;
int[] shadowRequests = m_ShadowRequests.ToArray();
int[] shadowDataIndices;
m_ShadowMgr.ProcessShadowRequests(m_FrameId, inputs, camera, inputs.visibleLights,
m_ShadowMgr.ProcessShadowRequests(m_FrameId, inputs, camera, inputs.visibleLights.ToArray(),
ref shadowRequestCount, shadowRequests, out shadowDataIndices);
// update the visibleLights with the shadow information

}
var numLights = inputs.visibleLights.Length;
var numProbes = probes.Length;
var numLights = inputs.visibleLights.Count;
var numProbes = probes.Count;
var numVolumes = numLights + numProbes;

return numLightsOut + numProbesOut;
}
CullResults m_CullResults;
public void Render(ScriptableRenderContext renderContext, IEnumerable<Camera> cameras)
{
foreach (var camera in cameras)

continue;
m_ShadowMgr.UpdateCullingParameters( ref cullingParams );
var cullResults = CullResults.Cull(ref cullingParams, renderContext);
ExecuteRenderLoop(camera, cullResults, renderContext);
CullResults.Cull(ref cullingParams, renderContext, ref m_CullResults);
ExecuteRenderLoop(camera, m_CullResults, renderContext);
}
renderContext.Submit();

BuildPerTileLightLists(camera, loop, numLights, projscr, invProjscr);
m_ShadowMgr.RenderShadows( m_FrameId, loop, cullResults, cullResults.visibleLights );
m_ShadowMgr.RenderShadows( m_FrameId, loop, cullResults, cullResults.visibleLights.ToArray() );
m_ShadowMgr.SyncData();
m_ShadowMgr.BindResources( loop );

if (enableClustered) RenderForward(cullResults, camera, loop, false);
// debug views.
if (enableDrawLightBoundsDebug) DrawLightBoundsDebug(loop, cullResults.visibleLights.Length);
if (enableDrawLightBoundsDebug) DrawLightBoundsDebug(loop, cullResults.visibleLights.Count);
// present frame buffer.
FinalPass(loop);

62
Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs


}
}
private RenderTargetIdentifier[] m_ColorMRTs;
var colorMRTs = new RenderTargetIdentifier[gbufferCount];
if (m_ColorMRTs == null || m_ColorMRTs.Length != gbufferCount)
m_ColorMRTs = new RenderTargetIdentifier[gbufferCount];
colorMRTs[index] = RTIDs[index];
m_ColorMRTs[index] = RTIDs[index];
return colorMRTs;
return m_ColorMRTs;
}
public int gbufferCount { get; set; }

m_ShadowSettings.directionalLightNearPlaneOffset = commonSettings.shadowNearPlaneOffset;
}
CullResults m_CullResults;
public override void Render(ScriptableRenderContext renderContext, Camera[] cameras)
{
base.Render(renderContext, cameras);

// we only want to render one camera for now
// select the most main camera!
Camera camera = cameras.OrderByDescending(x => x.tag == "MainCamera").FirstOrDefault();
Camera camera = null;
foreach (var cam in cameras)
{
if (cam == Camera.main)
{
camera = cam;
break;
}
}
if (camera == null && cameras.Length > 0)
camera = cameras[0];
if (camera == null)
{
renderContext.Submit();

}
m_LightLoop.UpdateCullingParameters( ref cullingParams );
var cullResults = CullResults.Cull(ref cullingParams, renderContext);
CullResults.Cull(ref cullingParams, renderContext,ref m_CullResults);
Resize(camera);

PushGlobalParams(hdCamera, renderContext, m_Asset.sssSettings);
RenderDepthPrepass(cullResults, camera, renderContext);
RenderDepthPrepass(m_CullResults, camera, renderContext);
RenderForwardOnlyOpaqueDepthPrepass(cullResults, camera, renderContext);
RenderGBuffer(cullResults, camera, renderContext);
RenderForwardOnlyOpaqueDepthPrepass(m_CullResults, camera, renderContext);
RenderGBuffer(m_CullResults, camera, renderContext);
// If full forward rendering, we did not do any rendering yet, so don't need to copy the buffer.
// If Deferred then the depth buffer is full (regular GBuffer + ForwardOnly depth prepass are done so we can copy it safely.

if (m_DebugDisplaySettings.IsDebugMaterialDisplayEnabled())
{
RenderDebugViewMaterial(cullResults, hdCamera, renderContext);
RenderDebugViewMaterial(m_CullResults, hdCamera, renderContext);
}
else
{

m_SsaoEffect.Render(ssaoSettingsToUse, this, hdCamera, renderContext, m_Asset.renderingSettings.useForwardRenderingOnly);
m_LightLoop.PrepareLightsForGPU(m_ShadowSettings, cullResults, camera);
m_LightLoop.RenderShadows(renderContext, cullResults);
m_LightLoop.PrepareLightsForGPU(m_ShadowSettings, m_CullResults, camera);
m_LightLoop.RenderShadows(renderContext, m_CullResults);
renderContext.SetupCameraProperties(camera); // Need to recall SetupCameraProperties after m_ShadowPass.Render
m_LightLoop.BuildGPULightLists(camera, renderContext, m_CameraDepthStencilBufferRT);
}

// 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);
RenderForward(m_CullResults, camera, renderContext, true); // Render deferred or forward opaque
RenderForwardOnlyOpaque(m_CullResults, camera, renderContext);
RenderLightingDebug(hdCamera, renderContext, m_CameraColorBufferRT);

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);
RenderForward(m_CullResults, camera, renderContext, false);
// Planar and real time cubemap doesn't need post process and render in FP16
if (camera.cameraType == CameraType.Reflection)

}
else
{
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(m_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 ?
RenderDistortion(cullResults, camera, renderContext);
RenderDistortion(m_CullResults, camera, renderContext);
RenderPostProcesses(camera, renderContext);
}

}
}
MaterialPropertyBlock m_SharedPropertyBlock = new MaterialPropertyBlock();
void RenderDebug(HDCamera camera, ScriptableRenderContext renderContext)
{
// We don't want any overlay for these kind of rendering

float overlayRatio = m_DebugDisplaySettings.debugOverlayRatio;
float overlaySize = Math.Min(camera.camera.pixelHeight, camera.camera.pixelWidth) * overlayRatio;
float y = camera.camera.pixelHeight - overlaySize;
MaterialPropertyBlock propertyBlock = new MaterialPropertyBlock();
propertyBlock.SetTexture("_InputCubemap", skyReflection);
propertyBlock.SetFloat("_Mipmap", lightingDebug.skyReflectionMipmap);
m_SharedPropertyBlock.SetTexture("_InputCubemap", skyReflection);
m_SharedPropertyBlock.SetFloat("_Mipmap", lightingDebug.skyReflectionMipmap);
debugCB.DrawProcedural(Matrix4x4.identity, m_DebugDisplayLatlong, 0, MeshTopology.Triangles, 3, 1, propertyBlock);
debugCB.DrawProcedural(Matrix4x4.identity, m_DebugDisplayLatlong, 0, MeshTopology.Triangles, 3, 1, m_SharedPropertyBlock);
Utilities.NextOverlayCoord(ref x, ref y, overlaySize, overlaySize, camera.camera.pixelWidth);
}

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


{
m_lightList.Clear();
if (cullResults.visibleLights.Length != 0 || cullResults.visibleReflectionProbes.Length != 0)
if (cullResults.visibleLights.Count != 0 || cullResults.visibleReflectionProbes.Count != 0)
{
// 0. deal with shadows
{

m_ShadowRequests.Capacity = cullResults.visibleLights.Length;
int lcnt = cullResults.visibleLights.Length;
m_ShadowRequests.Capacity = cullResults.visibleLights.Count;
int lcnt = cullResults.visibleLights.Count;
for (int i = 0; i < lcnt; ++i)
{
VisibleLight vl = cullResults.visibleLights[i];

}
// pass this list to a routine that assigns shadows based on some heuristic
uint shadowRequestCount = (uint)m_ShadowRequests.Count;
//TODO: Do not call ToArray here to avoid GC, refactor API
m_ShadowMgr.ProcessShadowRequests(m_FrameId, cullResults, camera, cullResults.visibleLights,
m_ShadowMgr.ProcessShadowRequests(m_FrameId, cullResults, camera, cullResults.visibleLights.ToArray(),
ref shadowRequestCount, shadowRequests, out shadowDataIndices);
// update the visibleLights with the shadow information

int areaLightCount = 0;
int projectorLightCount = 0;
int lightCount = Math.Min(cullResults.visibleLights.Length, k_MaxLightsOnScreen);
int lightCount = Math.Min(cullResults.visibleLights.Count, k_MaxLightsOnScreen);
for (int lightIndex = 0, numLights = cullResults.visibleLights.Length; (lightIndex < numLights) && (sortCount < lightCount); ++lightIndex)
for (int lightIndex = 0, numLights = cullResults.visibleLights.Count; (lightIndex < numLights) && (sortCount < lightCount); ++lightIndex)
{
var light = cullResults.visibleLights[lightIndex];

sortKeys[sortCount++] = (uint)lightCategory << 27 | (uint)gpuLightType << 22 | (uint)lightVolumeType << 17 | shadow << 16 | (uint)lightIndex;
}
//TODO: Replace with custom sort, allocates mem and increases GC pressure.
Array.Sort(sortKeys, 0, sortCount);
// TODO: Refactor shadow management

// Redo everything but this time with envLights
int envLightCount = 0;
int probeCount = Math.Min(cullResults.visibleReflectionProbes.Length, k_MaxEnvLightsOnScreen);
int probeCount = Math.Min(cullResults.visibleReflectionProbes.Count, k_MaxEnvLightsOnScreen);
for (int probeIndex = 0, numProbes = cullResults.visibleReflectionProbes.Length; (probeIndex < numProbes) && (sortCount < probeCount); probeIndex++)
for (int probeIndex = 0, numProbes = cullResults.visibleReflectionProbes.Count; (probeIndex < numProbes) && (sortCount < probeCount); probeIndex++)
{
var probe = cullResults.visibleReflectionProbes[probeIndex];

// enable coarse 2D pass on 64x64 tiles (used for both fptl and clustered).
if (m_TileSettings.enableBigTilePrepass)
{
cmd.SetComputeIntParams(buildPerBigTileLightListShader, "g_viDimensions", new int[2] { w, h });
cmd.SetComputeIntParams(buildPerBigTileLightListShader, "g_viDimensions", w, h);
cmd.SetComputeIntParam(buildPerBigTileLightListShader, "_EnvLightIndexShift", m_lightList.lights.Count);
cmd.SetComputeIntParam(buildPerBigTileLightListShader, "g_iNrVisibLights", m_lightCount);
Utilities.SetMatrixCS(cmd, buildPerBigTileLightListShader, "g_mScrProjection", projscr);

if (usingFptl) // optimized for opaques only
{
cmd.SetComputeIntParams(buildPerTileLightListShader, "g_viDimensions", new int[2] { w, h });
cmd.SetComputeIntParams(buildPerTileLightListShader, "g_viDimensions", w, h);
cmd.SetComputeIntParam(buildPerTileLightListShader, "_EnvLightIndexShift", m_lightList.lights.Count);
cmd.SetComputeIntParam(buildPerTileLightListShader, "g_iNrVisibLights", m_lightCount);

}
cmd.SetComputeIntParam(buildMaterialFlagsShader, "g_BaseFeatureFlags", (int)baseFeatureFlags);
cmd.SetComputeIntParams(buildMaterialFlagsShader, "g_viDimensions", new int[2] { w, h });
cmd.SetComputeIntParams(buildMaterialFlagsShader, "g_viDimensions", w, h);
cmd.SetComputeBufferParam(buildMaterialFlagsShader, buildMaterialFlagsKernel, "g_TileFeatureFlags", s_TileFeatureFlags);
cmd.SetComputeTextureParam(buildMaterialFlagsShader, buildMaterialFlagsKernel, "g_depth_tex", cameraDepthBufferRT);

private void UpdateDataBuffers()
{
s_DirectionalLightDatas.SetData(m_lightList.directionalLights.ToArray());
s_LightDatas.SetData(m_lightList.lights.ToArray());
s_EnvLightDatas.SetData(m_lightList.envLights.ToArray());
s_shadowDatas.SetData(m_lightList.shadows.ToArray());
s_DirectionalLightDatas.SetData(m_lightList.directionalLights);
s_LightDatas.SetData(m_lightList.lights);
s_EnvLightDatas.SetData(m_lightList.envLights);
s_shadowDatas.SetData(m_lightList.shadows);
s_ConvexBoundsBuffer.SetData(m_lightList.bounds.ToArray());
s_LightVolumeDataBuffer.SetData(m_lightList.lightVolumes.ToArray());
s_ConvexBoundsBuffer.SetData(m_lightList.bounds);
s_LightVolumeDataBuffer.SetData(m_lightList.lightVolumes);
}
private void BindGlobalParams(CommandBuffer cmd, ComputeShader computeShader, int kernelIndex, Camera camera, ScriptableRenderContext loop)

public void RenderShadows(ScriptableRenderContext renderContext, CullResults cullResults)
{
// kick off the shadow jobs here
m_ShadowMgr.RenderShadows(m_FrameId, renderContext, cullResults, cullResults.visibleLights);
m_ShadowMgr.RenderShadows(m_FrameId, renderContext, cullResults, cullResults.visibleLights.ToArray());
}
private void SetupDebugDisplayMode(bool debugDisplayEnable)

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


#if UNITY_EDITOR
using UnityEditor;
#endif
namespace UnityEngine.Experimental.Rendering.HDPipeline
{
public class SkySettingsSingleton : Singleton<SkySettingsSingleton>

34
Assets/ScriptableRenderPipeline/HDRenderPipeline/Utilities.cs


return sb.ToString();
}
public class ProfilingSample
public struct ProfilingSample
bool disposed = false;
bool disposed;
ScriptableRenderContext renderContext;
string name;

disposed = false;
name = _name;
CommandBuffer cmd = CommandBufferPool.Get();

}
~ProfilingSample()
{
Dispose(false);
}
public void Dispose()
{
Dispose(true);

protected virtual void Dispose(bool disposing)
void Dispose(bool disposing)
{
if (disposed)
return;

}
// TEMP: These functions should be implemented C++ side, for now do it in C#
static List<float> m_FloatListdata = new List<float>();
var data = new float[16];
m_FloatListdata.Clear();
data[4 * c + r] = mat[r, c];
m_FloatListdata.Add(mat[r, c]);
cmd.SetComputeFloatParams(shadercs, name, data);
cmd.SetComputeFloatParams(shadercs, name, m_FloatListdata);
var data = new float[numMatrices * 16];
m_FloatListdata.Clear();
data[16 * n + 4 * c + r] = matArray[n][r, c];
m_FloatListdata.Add(matArray[n][r, c]);
cmd.SetComputeFloatParams(shadercs, name, data);
cmd.SetComputeFloatParams(shadercs, name, m_FloatListdata);
var data = new float[numVectors * 4];
m_FloatListdata.Clear();
data[4 * n + i] = vecArray[n][i];
m_FloatListdata.Add(vecArray[n][i]);
cmd.SetComputeFloatParams(shadercs, name, data);
cmd.SetComputeFloatParams(shadercs, name, m_FloatListdata);
}
public static void SetKeyword(Material m, string keyword, bool state)

13
Assets/ScriptableRenderPipeline/LightweightPipeline/LightweightPipeline.cs


}
}
CullResults m_CullResults;
public override void Render(ScriptableRenderContext context, Camera[] cameras)
{
base.Render(context, cameras);

continue;
cullingParameters.shadowDistance = m_ShadowSettings.maxShadowDistance;
CullResults cullResults = CullResults.Cull(ref cullingParameters, context);
CullResults.Cull(ref cullingParameters, context,ref m_CullResults);
VisibleLight[] visibleLights = cullResults.visibleLights;
VisibleLight[] visibleLights = m_CullResults.visibleLights.ToArray();
LightData lightData;
InitializeLightData(visibleLights, out lightData);

InitializeMainShadowLightIndex(visibleLights);
if (m_ShadowLightIndex > -1)
shadowsRendered = RenderShadows(ref cullResults, ref visibleLights[m_ShadowLightIndex], ref context);
shadowsRendered = RenderShadows(ref m_CullResults, ref visibleLights[m_ShadowLightIndex], ref context);
// Setup camera matrices and RT
context.SetupCameraProperties(camera);

// Setup light and shadow shader constants
SetupLightShaderVariables(visibleLights, ref cullResults, ref context, ref lightData);
SetupLightShaderVariables(visibleLights, ref m_CullResults, ref context, ref lightData);
if (shadowsRendered)
SetupShadowShaderVariables(ref context, m_ShadowCasterCascadesCount);

configuration |= RendererConfiguration.ProvideLightIndices;
// Render Opaques
var litSettings = new DrawRendererSettings(cullResults, camera, m_LitPassName);
var litSettings = new DrawRendererSettings(m_CullResults, camera, m_LitPassName);
var unlitSettings = new DrawRendererSettings(cullResults, camera, m_UnlitPassName);
var unlitSettings = new DrawRendererSettings(m_CullResults, camera, m_UnlitPassName);
unlitSettings.sorting.flags = SortFlags.CommonOpaque;
unlitSettings.inputFilter.SetQueuesOpaque();

正在加载...
取消
保存