浏览代码

add files

/main
Sebastien Lagarde 7 年前
当前提交
d36f89ad
共有 3 个文件被更改,包括 39 次插入10 次删除
  1. 2
      TestbedPipelines/Fptl/FPTLRenderPipeline.asset
  2. 39
      TestbedPipelines/Fptl/FptlLighting.cs
  3. 8
      TestbedPipelines/Fptl/RegularForwardLightingUtils.hlsl

2
TestbedPipelines/Fptl/FPTLRenderPipeline.asset


type: 3}
buildPerVoxelLightListShader: {fileID: 7200000, guid: 4c2d6eb0553e2514bba3ea9a85d8c53c,
type: 3}
enableClustered: 0
enableClustered: 1
disableFptlWhenClustered: 0
enableBigTilePrepass: 1
enableDrawLightBoundsDebug: 0

39
TestbedPipelines/Fptl/FptlLighting.cs


private static ComputeBuffer s_AABBBoundsBuffer;
private static ComputeBuffer s_LightList;
private static ComputeBuffer s_DirLightList;
private static ComputeBuffer s_LightIndices;
private static ComputeBuffer s_BigTileLightList; // used for pre-pass coarse culling on 64x64 tiles
private static int s_GenListPerBigTileKernel;

s_AABBBoundsBuffer.Release();
s_ConvexBoundsBuffer.Release();
s_LightDataBuffer.Release();
s_LightIndices.Release();
ReleaseResolutionDependentBuffers();
s_DirLightList.Release();

if (s_LightDataBuffer != null)
s_LightDataBuffer.Release();
if (s_LightIndices != null)
s_LightIndices.Release();
ReleaseResolutionDependentBuffers();

s_ConvexBoundsBuffer = new ComputeBuffer(MaxNumLights, System.Runtime.InteropServices.Marshal.SizeOf(typeof(SFiniteLightBound)));
s_LightDataBuffer = new ComputeBuffer(MaxNumLights, System.Runtime.InteropServices.Marshal.SizeOf(typeof(SFiniteLightData)));
s_DirLightList = new ComputeBuffer(MaxNumDirLights, System.Runtime.InteropServices.Marshal.SizeOf(typeof(DirectionalLight)));
s_LightIndices = null; // only used in traditional forward, will be created on demand
buildScreenAABBShader.SetBuffer(s_GenAABBKernel, "g_data", s_ConvexBoundsBuffer);
//m_BuildScreenAABBShader.SetBuffer(kGenAABBKernel, "g_vBoundsBuffer", m_aabbBoundsBuffer);

{
sorting = { flags = SortFlags.CommonOpaque },
//@TODO: need to get light probes + LPPV too?
rendererConfiguration = RendererConfiguration.PerObjectLightmaps | RendererConfiguration.PerObjectLightProbe
rendererConfiguration = RendererConfiguration.PerObjectLightmaps | RendererConfiguration.PerObjectLightProbe | RendererConfiguration.ProvideLightIndices | RendererConfiguration.ProvideReflectionProbeIndices
};
var filterSettings = new FilterRenderersSettings(true){renderQueueRange = RenderQueueRange.opaque};
loop.DrawRenderers(cull.visibleRenderers, ref drawSettings, filterSettings);

bool haveTiledSolution = opaquesOnly || enableClustered;
cmd.EnableShaderKeyword(haveTiledSolution ? "TILED_FORWARD" : "REGULAR_FORWARD");
cmd.SetViewProjectionMatrices(camera.worldToCameraMatrix, camera.projectionMatrix);
cmd.SetGlobalBuffer("g_vLightListMeshInst", s_LightIndices);
loop.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);

var drawSettings = new DrawRendererSettings(camera, new ShaderPassName("ForwardSinglePass"))
{
sorting = { flags = SortFlags.CommonOpaque },
rendererConfiguration = RendererConfiguration.PerObjectLightmaps | RendererConfiguration.PerObjectLightProbe
sorting = { flags = opaquesOnly ? SortFlags.CommonOpaque : SortFlags.CommonTransparent },
rendererConfiguration = RendererConfiguration.PerObjectLightmaps | RendererConfiguration.PerObjectLightProbe | RendererConfiguration.ProvideLightIndices | RendererConfiguration.ProvideReflectionProbeIndices
};
var filterSettings = new FilterRenderersSettings(true) { renderQueueRange = opaquesOnly ? RenderQueueRange.opaque : RenderQueueRange.transparent };

var boundData = new SFiniteLightBound[numVolumes];
var worldToView = WorldToCamera(camera);
var lightIndexMap = inputs.GetLightIndexMap();
for (int i = 0; i < lightIndexMap.Length; i++)
{
lightIndexMap[i] = -1;
}
int lightIndexCount = inputs.GetLightIndicesCount();
if (s_LightIndices == null || lightIndexCount > s_LightIndices.count)
{
// The light indices buffer is too small, resize
if (s_LightIndices != null)
s_LightIndices.Release();
s_LightIndices = new ComputeBuffer(lightIndexCount, System.Runtime.InteropServices.Marshal.SizeOf(typeof(int)));
}
uint lightIndex = 0;
foreach (var cl in inputs.visibleLights)
{
var range = cl.range;

{
boundData[idxOut] = bound;
lightData[idxOut] = light;
lightIndexMap[lightIndex] = idxOut;
lightIndex++;
}
int numLightsOut = 0;
for(int v=0; v<numVolTypes; v++) numLightsOut += numEntries[LightDefinitions.DIRECT_LIGHT, v];

idxOut = numEntries2nd[i, j] + offsets[i, j]; ++numEntries2nd[i, j];
boundData[idxOut] = bndData;
lightData[idxOut] = lgtData;
lightIndexMap[lightIndex] = idxOut;
lightIndex++;
inputs.SetLightIndexMap(lightIndexMap);
int numProbesOut = 0;
for(int v=0; v<numVolTypes; v++) numProbesOut += numEntries[LightDefinitions.REFLECTION_LIGHT, v];

s_ConvexBoundsBuffer.SetData(boundData);
s_LightDataBuffer.SetData(lightData);
inputs.FillLightIndices(s_LightIndices);
return numLightsOut + numProbesOut;
}

{
VoxelLightListGeneration(cmd, camera, numLights, projscr, invProjscr);
}
}
void PushGlobalParams(Camera camera, ScriptableRenderContext loop, Matrix4x4 viewToWorld, Matrix4x4 scrProj, Matrix4x4 incScrProj, int numDirLights)

8
TestbedPipelines/Fptl/RegularForwardLightingUtils.hlsl


StructuredBuffer<SFiniteLightData> g_vLightData;
StructuredBuffer<uint> g_vLightListMeshInst; // build on CPU if in use. direct lights first, then reflection probes. (don't support Buffer yet in unity, so using structured)
uniform int g_numLights;
uniform int g_numReflectionProbes;
uniform uint4 unity_LightIndicesOffsetAndCount;
uniform uint4 unity_ReflectionProbeIndicesOffsetAndCount;
start = model==REFLECTION_LIGHT ? g_numLights : 0; // offset by numLights entries
nrLights = model==REFLECTION_LIGHT ? g_numReflectionProbes : g_numLights;
start = model==REFLECTION_LIGHT ? unity_ReflectionProbeIndicesOffsetAndCount.x : unity_LightIndicesOffsetAndCount.x;
nrLights = model==REFLECTION_LIGHT ? unity_ReflectionProbeIndicesOffsetAndCount.y : unity_LightIndicesOffsetAndCount.y;
}
uint FetchIndex(const uint start, const uint l)

正在加载...
取消
保存