浏览代码

HDRenderLoop: Misc fix for making cluster FPTL work, still not working

/main
sebastienlagarde 8 年前
当前提交
898ec83d
共有 10 个文件被更改,包括 157 次插入145 次删除
  1. 12
      Assets/ScriptableRenderLoop/HDRenderLoop/Debug/Resources/DebugViewTiles.shader
  2. 19
      Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs
  3. 12
      Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/SinglePass/SinglePass.cs
  4. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/SinglePass/SinglePassLoop.hlsl
  5. 184
      Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/TilePass.cs
  6. 4
      Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/TilePass.hlsl
  7. 63
      Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/TilePassLoop.hlsl
  8. 2
      Assets/ScriptableRenderLoop/fptl/FptlLighting.cs
  9. 2
      ProjectSettings/GraphicsSettings.asset
  10. 2
      ProjectSettings/ProjectVersion.txt

12
Assets/ScriptableRenderLoop/HDRenderLoop/Debug/Resources/DebugViewTiles.shader


#pragma vertex VertViewTiles
#pragma fragment FragViewTiles
#define LIGHTLOOP_TILE_PASS 1
#define USE_FPTL_LIGHTLIST 1 //TODO: make it also work with clustered
#define LIGHTLOOP_TILE_PASS 1
#pragma multi_compile USE_FPTL_LIGHTLIST USE_CLUSTERED_LIGHTLIST
//-------------------------------------------------------------------------------------
// Include

{
Coordinate coord = GetCoordinate(positionCS.xy, _ScreenSize.zw);
#if USE_FPTL_LIGHTLIST
float linearDepth = 0.0;
#ifdef USE_CLUSTERED_LIGHTLIST
float depth = LOAD_TEXTURE2D(_CameraDepthTexture, coord.unPositionSS).x;
float linearDepth = GetLinearDepth(depth); // View space linear depth
float depth = LOAD_TEXTURE2D(_CameraDepthTexture, coord.unPositionSS).x;
float linearDepth = GetLinearDepth(depth);
float linearDepth = 0.0; // unused
#endif
int n = 0;

19
Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs


return ;
}
using (new Utilities.ProfilingSample("Single Pass - Deferred Lighting Pass", renderLoop))
// Bind material data
m_LitRenderLoop.Bind();
if (debugParameters.useSinglePassLightLoop)
// Bind material data
m_LitRenderLoop.Bind();
if (debugParameters.useSinglePassLightLoop)
{
m_SinglePassLightLoop.RenderDeferredLighting(camera, renderLoop, m_CameraColorBuffer);
}
else
{
tilePassLightLoop.RenderDeferredLighting(camera, renderLoop, m_CameraColorBufferRT);
}
m_SinglePassLightLoop.RenderDeferredLighting(camera, renderLoop, m_CameraColorBuffer);
}
else
{
tilePassLightLoop.RenderDeferredLighting(camera, renderLoop, m_CameraColorBufferRT);
}
}

12
Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/SinglePass/SinglePass.cs


// m_gbufferManager.BindBuffers(m_DeferredMaterial);
// TODO: Bind depth textures
var cmd = new CommandBuffer { name = "" };
cmd.Blit(null, cameraColorBufferRT, m_DeferredMaterial, 0);
renderLoop.ExecuteCommandBuffer(cmd);
cmd.Dispose();
using (new Utilities.ProfilingSample("SinglePass - Deferred Lighting Pass", renderLoop))
{
var cmd = new CommandBuffer { name = "" };
cmd.Blit(null, cameraColorBufferRT, m_DeferredMaterial, 0);
renderLoop.ExecuteCommandBuffer(cmd);
cmd.Dispose();
}
}
}
}

2
Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/SinglePass/SinglePassLoop.hlsl


iblSpecularLighting = lerp(iblSpecularLighting, localSpecularLighting, weight.y);
}
/*
// Sky Ibl
{
float3 localDiffuseLighting, localSpecularLighting;

iblDiffuseLighting = lerp(iblDiffuseLighting, localDiffuseLighting, weight.x); // Should be remove by the compiler if it is smart as all is constant 0
iblSpecularLighting = lerp(iblSpecularLighting, localSpecularLighting, weight.y);
}
*/
diffuseLighting += iblDiffuseLighting;
specularLighting += iblSpecularLighting;

184
Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/TilePass.cs


public void RenderDeferredLighting(Camera camera, RenderLoop renderLoop, RenderTargetIdentifier cameraColorBufferRT)
{
var bUseClusteredForDeferred = !usingFptl; // doesn't work on reflections yet but will soon
var bUseClusteredForDeferred = !usingFptl;
var invViewProj = Utilities.GetViewProjectionMatrix(camera).inverse;
var screenSize = Utilities.ComputeScreenSize(camera);

m_DebugViewTilesMaterial.SetVector("_ScreenSize", screenSize);
m_DebugViewTilesMaterial.SetInt("_ViewTilesFlags", (int)debugViewTilesFlags);
m_DebugViewTilesMaterial.EnableKeyword(bUseClusteredForDeferred ? "USE_CLUSTERED_LIGHTLIST" : "USE_FPTL_LIGHTLIST");
m_DebugViewTilesMaterial.DisableKeyword(!bUseClusteredForDeferred ? "USE_CLUSTERED_LIGHTLIST" : "USE_FPTL_LIGHTLIST");
var cmd = new CommandBuffer();
cmd.SetGlobalBuffer("g_vLightListGlobal", bUseClusteredForDeferred ? s_PerVoxelLightLists : s_LightList); // opaques list (unless MSAA possibly)
// In case of bUseClusteredForDeferred disable toggle option since we're using m_perVoxelLightLists as opposed to lightList
if (bUseClusteredForDeferred)
using (new Utilities.ProfilingSample("TilePass - Deferred Lighting Pass", renderLoop))
cmd.SetGlobalFloat("g_isOpaquesOnlyEnabled", 0);
}
cmd.name = "DoTiledDeferredLighting";
var cmd = new CommandBuffer();
cmd.SetGlobalBuffer("g_vLightListGlobal", bUseClusteredForDeferred ? s_PerVoxelLightLists : s_LightList); // opaques list (unless MSAA possibly)
/*
if (enableComputeLightEvaluation) //TODO: temporary workaround for "All kernels must use same constant buffer layouts"
{
var w = camera.pixelWidth;
var h = camera.pixelHeight;
var numTilesX = (w + 7) / 8;
var numTilesY = (h + 7) / 8;
// In case of bUseClusteredForDeferred disable toggle option since we're using m_perVoxelLightLists as opposed to lightList
if (bUseClusteredForDeferred)
{
}
string kernelName = "ShadeDeferred" + (bUseClusteredForDeferred ? "_Clustered" : "_Fptl") + (enableDrawTileDebug ? "_Debug" : "");
int kernel = deferredComputeShader.FindKernel(kernelName);
/*
if (enableComputeLightEvaluation) //TODO: temporary workaround for "All kernels must use same constant buffer layouts"
{
var w = camera.pixelWidth;
var h = camera.pixelHeight;
var numTilesX = (w + 7) / 8;
var numTilesY = (h + 7) / 8;
cmd.SetComputeTextureParam(deferredComputeShader, kernel, "_CameraDepthTexture", new RenderTargetIdentifier(s_CameraDepthTexture));
cmd.SetComputeTextureParam(deferredComputeShader, kernel, "_CameraGBufferTexture0", new RenderTargetIdentifier(s_GBufferAlbedo));
cmd.SetComputeTextureParam(deferredComputeShader, kernel, "_CameraGBufferTexture1", new RenderTargetIdentifier(s_GBufferSpecRough));
cmd.SetComputeTextureParam(deferredComputeShader, kernel, "_CameraGBufferTexture2", new RenderTargetIdentifier(s_GBufferNormal));
cmd.SetComputeTextureParam(deferredComputeShader, kernel, "_CameraGBufferTexture3", new RenderTargetIdentifier(s_GBufferEmission));
cmd.SetComputeTextureParam(deferredComputeShader, kernel, "_spotCookieTextures", m_CookieTexArray.GetTexCache());
cmd.SetComputeTextureParam(deferredComputeShader, kernel, "_pointCookieTextures", m_CubeCookieTexArray.GetTexCache());
cmd.SetComputeTextureParam(deferredComputeShader, kernel, "_reflCubeTextures", m_CubeReflTexArray.GetTexCache());
cmd.SetComputeTextureParam(deferredComputeShader, kernel, "_reflRootCubeTexture", ReflectionProbe.GetDefaultTexture());
cmd.SetComputeTextureParam(deferredComputeShader, kernel, "g_tShadowBuffer", new RenderTargetIdentifier(m_shadowBufferID));
cmd.SetComputeTextureParam(deferredComputeShader, kernel, "unity_NHxRoughness", m_NHxRoughnessTexture);
cmd.SetComputeTextureParam(deferredComputeShader, kernel, "_LightTextureB0", m_LightAttentuationTexture);
string kernelName = "ShadeDeferred" + (bUseClusteredForDeferred ? "_Clustered" : "_Fptl") + (enableDrawTileDebug ? "_Debug" : "");
int kernel = deferredComputeShader.FindKernel(kernelName);
cmd.SetComputeBufferParam(deferredComputeShader, kernel, "g_vLightListGlobal", bUseClusteredForDeferred ? s_PerVoxelLightLists : s_LightList);
cmd.SetComputeBufferParam(deferredComputeShader, kernel, "g_vLightData", s_LightDataBuffer);
cmd.SetComputeBufferParam(deferredComputeShader, kernel, "g_dirLightData", s_DirLightList);
cmd.SetComputeTextureParam(deferredComputeShader, kernel, "_CameraDepthTexture", new RenderTargetIdentifier(s_CameraDepthTexture));
cmd.SetComputeTextureParam(deferredComputeShader, kernel, "_CameraGBufferTexture0", new RenderTargetIdentifier(s_GBufferAlbedo));
cmd.SetComputeTextureParam(deferredComputeShader, kernel, "_CameraGBufferTexture1", new RenderTargetIdentifier(s_GBufferSpecRough));
cmd.SetComputeTextureParam(deferredComputeShader, kernel, "_CameraGBufferTexture2", new RenderTargetIdentifier(s_GBufferNormal));
cmd.SetComputeTextureParam(deferredComputeShader, kernel, "_CameraGBufferTexture3", new RenderTargetIdentifier(s_GBufferEmission));
cmd.SetComputeTextureParam(deferredComputeShader, kernel, "_spotCookieTextures", m_CookieTexArray.GetTexCache());
cmd.SetComputeTextureParam(deferredComputeShader, kernel, "_pointCookieTextures", m_CubeCookieTexArray.GetTexCache());
cmd.SetComputeTextureParam(deferredComputeShader, kernel, "_reflCubeTextures", m_CubeReflTexArray.GetTexCache());
cmd.SetComputeTextureParam(deferredComputeShader, kernel, "_reflRootCubeTexture", ReflectionProbe.GetDefaultTexture());
cmd.SetComputeTextureParam(deferredComputeShader, kernel, "g_tShadowBuffer", new RenderTargetIdentifier(m_shadowBufferID));
cmd.SetComputeTextureParam(deferredComputeShader, kernel, "unity_NHxRoughness", m_NHxRoughnessTexture);
cmd.SetComputeTextureParam(deferredComputeShader, kernel, "_LightTextureB0", m_LightAttentuationTexture);
var defdecode = ReflectionProbe.GetDefaultTextureHDRDecodeValues();
cmd.SetComputeFloatParam(deferredComputeShader, "_reflRootHdrDecodeMult", defdecode.x);
cmd.SetComputeFloatParam(deferredComputeShader, "_reflRootHdrDecodeExp", defdecode.y);
cmd.SetComputeBufferParam(deferredComputeShader, kernel, "g_vLightListGlobal", bUseClusteredForDeferred ? s_PerVoxelLightLists : s_LightList);
cmd.SetComputeBufferParam(deferredComputeShader, kernel, "g_vLightData", s_LightDataBuffer);
cmd.SetComputeBufferParam(deferredComputeShader, kernel, "g_dirLightData", s_DirLightList);
cmd.SetComputeFloatParam(deferredComputeShader, "g_fClustScale", m_ClustScale);
cmd.SetComputeFloatParam(deferredComputeShader, "g_fClustBase", k_ClustLogBase);
cmd.SetComputeFloatParam(deferredComputeShader, "g_fNearPlane", camera.nearClipPlane);
cmd.SetComputeFloatParam(deferredComputeShader, "g_fFarPlane", camera.farClipPlane);
cmd.SetComputeIntParam(deferredComputeShader, "g_iLog2NumClusters", k_Log2NumClusters);
cmd.SetComputeIntParam(deferredComputeShader, "g_isLogBaseBufferEnabled", k_UseDepthBuffer ? 1 : 0);
cmd.SetComputeIntParam(deferredComputeShader, "g_isOpaquesOnlyEnabled", 0);
var defdecode = ReflectionProbe.GetDefaultTextureHDRDecodeValues();
cmd.SetComputeFloatParam(deferredComputeShader, "_reflRootHdrDecodeMult", defdecode.x);
cmd.SetComputeFloatParam(deferredComputeShader, "_reflRootHdrDecodeExp", defdecode.y);
cmd.SetComputeFloatParam(deferredComputeShader, "g_fClustScale", m_ClustScale);
cmd.SetComputeFloatParam(deferredComputeShader, "g_fClustBase", k_ClustLogBase);
cmd.SetComputeFloatParam(deferredComputeShader, "g_fNearPlane", camera.nearClipPlane);
cmd.SetComputeFloatParam(deferredComputeShader, "g_fFarPlane", camera.farClipPlane);
cmd.SetComputeIntParam(deferredComputeShader, "g_iLog2NumClusters", k_Log2NumClusters);
cmd.SetComputeIntParam(deferredComputeShader, "g_isLogBaseBufferEnabled", k_UseDepthBuffer ? 1 : 0);
//
var proj = camera.projectionMatrix;
var temp = new Matrix4x4();
temp.SetRow(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
temp.SetRow(1, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));
temp.SetRow(2, new Vector4(0.0f, 0.0f, 0.5f, 0.5f));
temp.SetRow(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
var projh = temp * proj;
var invProjh = projh.inverse;
temp.SetRow(0, new Vector4(0.5f * w, 0.0f, 0.0f, 0.5f * w));
temp.SetRow(1, new Vector4(0.0f, 0.5f * h, 0.0f, 0.5f * h));
temp.SetRow(2, new Vector4(0.0f, 0.0f, 0.5f, 0.5f));
temp.SetRow(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
var projscr = temp * proj;
var invProjscr = projscr.inverse;
//
var proj = camera.projectionMatrix;
var temp = new Matrix4x4();
temp.SetRow(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
temp.SetRow(1, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));
temp.SetRow(2, new Vector4(0.0f, 0.0f, 0.5f, 0.5f));
temp.SetRow(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
var projh = temp * proj;
var invProjh = projh.inverse;
cmd.SetComputeIntParam(deferredComputeShader, "g_iNrVisibLights", numLights);
SetMatrixCS(cmd, deferredComputeShader, "g_mScrProjection", projscr);
SetMatrixCS(cmd, deferredComputeShader, "g_mInvScrProjection", invProjscr);
SetMatrixCS(cmd, deferredComputeShader, "g_mViewToWorld", camera.cameraToWorldMatrix);
temp.SetRow(0, new Vector4(0.5f * w, 0.0f, 0.0f, 0.5f * w));
temp.SetRow(1, new Vector4(0.0f, 0.5f * h, 0.0f, 0.5f * h));
temp.SetRow(2, new Vector4(0.0f, 0.0f, 0.5f, 0.5f));
temp.SetRow(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
var projscr = temp * proj;
var invProjscr = projscr.inverse;
cmd.SetComputeIntParam(deferredComputeShader, "g_iNrVisibLights", numLights);
SetMatrixCS(cmd, deferredComputeShader, "g_mScrProjection", projscr);
SetMatrixCS(cmd, deferredComputeShader, "g_mInvScrProjection", invProjscr);
SetMatrixCS(cmd, deferredComputeShader, "g_mViewToWorld", camera.cameraToWorldMatrix);
if (bUseClusteredForDeferred)
{
cmd.SetComputeBufferParam(deferredComputeShader, kernel, "g_vLayeredOffsetsBuffer", s_PerVoxelOffset);
if (k_UseDepthBuffer)
if (bUseClusteredForDeferred)
cmd.SetComputeBufferParam(deferredComputeShader, kernel, "g_logBaseBuffer", s_PerTileLogBaseTweak);
cmd.SetComputeBufferParam(deferredComputeShader, kernel, "g_vLayeredOffsetsBuffer", s_PerVoxelOffset);
if (k_UseDepthBuffer)
{
cmd.SetComputeBufferParam(deferredComputeShader, kernel, "g_logBaseBuffer", s_PerTileLogBaseTweak);
}
}
cmd.SetComputeIntParam(deferredComputeShader, "g_widthRT", w);
cmd.SetComputeIntParam(deferredComputeShader, "g_heightRT", h);
cmd.SetComputeIntParam(deferredComputeShader, "g_nNumDirLights", numDirLights);
cmd.SetComputeBufferParam(deferredComputeShader, kernel, "g_dirLightData", s_DirLightList);
cmd.SetComputeTextureParam(deferredComputeShader, kernel, "uavOutput", new RenderTargetIdentifier(s_CameraTarget));
cmd.SetComputeIntParam(deferredComputeShader, "g_widthRT", w);
cmd.SetComputeIntParam(deferredComputeShader, "g_heightRT", h);
cmd.SetComputeIntParam(deferredComputeShader, "g_nNumDirLights", numDirLights);
cmd.SetComputeBufferParam(deferredComputeShader, kernel, "g_dirLightData", s_DirLightList);
cmd.SetComputeTextureParam(deferredComputeShader, kernel, "uavOutput", new RenderTargetIdentifier(s_CameraTarget));
SetMatrixArrayCS(cmd, deferredComputeShader, "g_matWorldToShadow", m_MatWorldToShadow);
SetVectorArrayCS(cmd, deferredComputeShader, "g_vDirShadowSplitSpheres", m_DirShadowSplitSpheres);
cmd.SetComputeVectorParam(deferredComputeShader, "g_vShadow3x3PCFTerms0", m_Shadow3X3PCFTerms[0]);
cmd.SetComputeVectorParam(deferredComputeShader, "g_vShadow3x3PCFTerms1", m_Shadow3X3PCFTerms[1]);
cmd.SetComputeVectorParam(deferredComputeShader, "g_vShadow3x3PCFTerms2", m_Shadow3X3PCFTerms[2]);
cmd.SetComputeVectorParam(deferredComputeShader, "g_vShadow3x3PCFTerms3", m_Shadow3X3PCFTerms[3]);
SetMatrixArrayCS(cmd, deferredComputeShader, "g_matWorldToShadow", m_MatWorldToShadow);
SetVectorArrayCS(cmd, deferredComputeShader, "g_vDirShadowSplitSpheres", m_DirShadowSplitSpheres);
cmd.SetComputeVectorParam(deferredComputeShader, "g_vShadow3x3PCFTerms0", m_Shadow3X3PCFTerms[0]);
cmd.SetComputeVectorParam(deferredComputeShader, "g_vShadow3x3PCFTerms1", m_Shadow3X3PCFTerms[1]);
cmd.SetComputeVectorParam(deferredComputeShader, "g_vShadow3x3PCFTerms2", m_Shadow3X3PCFTerms[2]);
cmd.SetComputeVectorParam(deferredComputeShader, "g_vShadow3x3PCFTerms3", m_Shadow3X3PCFTerms[3]);
cmd.DispatchCompute(deferredComputeShader, kernel, numTilesX, numTilesY, 1);
}
else
{*/
cmd.DispatchCompute(deferredComputeShader, kernel, numTilesX, numTilesY, 1);
}
else
{*/
if (enableDirectIndirectSinglePass)
{
cmd.Blit(null, cameraColorBufferRT, m_DeferredAllMaterial, 0);

cmd.Blit(null, cameraColorBufferRT, m_DeferredDirectMaterial, 0);
cmd.Blit(null, cameraColorBufferRT, m_DeferredIndirectMaterial, 0);
}
//}
//}
if (debugViewTilesFlags != 0)
{
cmd.Blit(null, cameraColorBufferRT, m_DebugViewTilesMaterial, 0);
}
if(debugViewTilesFlags != 0)
{
cmd.Blit(null, cameraColorBufferRT, m_DebugViewTilesMaterial, 0);
}
renderLoop.ExecuteCommandBuffer(cmd);
cmd.Dispose();
} // TilePass - Deferred Lighting Pass
renderLoop.ExecuteCommandBuffer(cmd);
cmd.Dispose();
}
}
}

4
Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/TilePass.hlsl


int g_iLog2NumClusters; // We need to always define these to keep constant buffer layouts compatible
uint g_isLogBaseBufferEnabled;
uint g_isOpaquesOnlyEnabled;
uint _UseTileLightList;
//#endif
#ifdef USE_CLUSTERED_LIGHTLIST

// TODO: Need to correctly define the shadow framework, WIP
#include "../SinglePass/SinglePass.hlsl"
#include "../SinglePass/SinglePass.hlsl"

63
Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/TilePassLoop.hlsl


return (tileIndex.y + lightCategory * _NumTileY) * _NumTileX + tileIndex.x;
}
void GetCountAndStartOpaque(Coordinate coord, uint lightCategory, float linearDepth, out uint start, out uint lightCount)
void GetCountAndStartTile(Coordinate coord, uint lightCategory, float linearDepth, out uint start, out uint lightCount)
{
const int tileOffset = GetTileOffset(coord, lightCategory);

}
uint FetchIndexOpaque(uint tileOffset, uint lightIndex)
uint FetchIndexTile(uint tileOffset, uint lightIndex)
{
const uint lightIndexPlusOne = lightIndex + 1; // Add +1 as first slot is reserved to store number of light
// Light index are store on 16bit

GetCountAndStartOpaque(coord, lightCategory, linearDepth, start, lightCount);
GetCountAndStartTile(coord, lightCategory, linearDepth, start, lightCount);
return FetchIndexOpaque(tileOffset, lightIndex);
return FetchIndexTile(tileOffset, lightIndex);
}
#else

void GetCountAndStart(Coordinate coord, uint lightCategory, float linearDepth, out uint start, out uint lightCount)
void GetCountAndStartCluster(Coordinate coord, uint lightCategory, float linearDepth, out uint start, out uint lightCount)
if(g_isOpaquesOnlyEnabled)
uint2 tileIndex = coord.unPositionSS / TILE_SIZE;
float logBase = g_fClustBase;
if (g_isLogBaseBufferEnabled)
GetCountAndStartOpaque(coord, lightCategory, linearDepth, start, lightCount);
logBase = g_logBaseBuffer[tileIndex.y * _NumTileX + tileIndex.x];
else
{
uint2 tileIndex = coord.unPositionSS / TILE_SIZE;
float logBase = g_fClustBase;
if (g_isLogBaseBufferEnabled)
{
logBase = g_logBaseBuffer[tileIndex.y * _NumTileX + tileIndex.x];
}
int clustIdx = SnapToClusterIdxFlex(linearDepth, logBase, g_isLogBaseBufferEnabled != 0);
int nrClusters = (1 << g_iLog2NumClusters);
const int idx = ((lightCategory * nrClusters + clustIdx) * _NumTileY + tileIndex.y) * _NumTileX + tileIndex.x;
uint dataPair = g_vLayeredOffsetsBuffer[idx];
start = dataPair & 0x7ffffff;
lightCount = (dataPair >> 27) & 31;
}
int clustIdx = SnapToClusterIdxFlex(linearDepth, logBase, g_isLogBaseBufferEnabled != 0);
uint FetchIndexCluster(uint tileOffset, uint lightIndex)
{
return g_vLightListGlobal[tileOffset + lightIndex];
}
int nrClusters = (1 << g_iLog2NumClusters);
const int idx = ((model * nrClusters + clustIdx) * _NumTileY + tileIndex.y) * _NumTileX + tileIndex.x;
uint dataPair = g_vLayeredOffsetsBuffer[idx];
start = dataPair & 0x7ffffff;
lightCount = (dataPair >> 27) & 31;
}
void GetCountAndStart(Coordinate coord, uint lightCategory, float linearDepth, out uint start, out uint lightCount)
{
if (_UseTileLightList)
GetCountAndStartTile(coord, lightCategory, linearDepth, start, lightCount);
else
GetCountAndStartCluster(coord, lightCategory, linearDepth, start, lightCount);
if(g_isOpaquesOnlyEnabled)
return FetchIndexOpaque(tileOffset, lightIndex);
if (_UseTileLightList)
return FetchIndexTile(tileOffset, lightIndex);
return g_vLightListGlobal[tileOffset + lightIndex];
return FetchIndexCluster(tileOffset, lightIndex);
}
float GetLinearDepth(float zDptBufSpace) // 0 is near 1 is far

out float3 diffuseLighting,
out float3 specularLighting)
{
#if USE_CLUSTERED_LIGHTLIST
// TODO: Think more about the design, it is ok to do that ? hope the compiler could optimize it out as we do it before LightLoop call, else need to pass it as argument...
#ifdef USE_CLUSTERED_LIGHTLIST
// TODO: Think more about the design, it is ok to do that ? hope the compiler could optimize it out as we already depth before LightLoop call, else need to pass it as argument...
float linearDepth = 0.0; // unsued
float linearDepth = 0.0; // unused
#endif
LightLoopContext context;

2
Assets/ScriptableRenderLoop/fptl/FptlLighting.cs


void DoTiledDeferredLighting(Camera camera, RenderLoop loop, int numLights, int numDirLights)
{
var bUseClusteredForDeferred = !usingFptl; // doesn't work on reflections yet but will soon
var bUseClusteredForDeferred = !usingFptl;
var cmd = new CommandBuffer();
m_DeferredMaterial.EnableKeyword(bUseClusteredForDeferred ? "USE_CLUSTERED_LIGHTLIST" : "USE_FPTL_LIGHTLIST");

2
ProjectSettings/GraphicsSettings.asset


m_PreloadedShaders: []
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
type: 0}
m_ScriptableRenderLoop: {fileID: 11400000, guid: 9654ae26e66cbee45b8d2a4f8cac0ceb,
m_ScriptableRenderLoop: {fileID: 11400000, guid: 2400b74f5ce370c4481e5dc417d03703,
type: 2}
m_TransparencySortMode: 0
m_TransparencySortAxis: {x: 0, y: 0, z: 1}

2
ProjectSettings/ProjectVersion.txt


m_EditorVersion: 5.6.0a5
m_EditorVersion: 5.6.0a6
正在加载...
取消
保存