浏览代码

Minor refactoring in HDRenderLoop: Renamed light types are now referred to as volumes and light models are now referred to as light categories

/main
runes 8 年前
当前提交
36e49e0d
共有 7 个文件被更改,包括 137 次插入144 次删除
  1. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Debug/Resources/DebugViewTiles.shader
  2. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/Resources/lightlistbuild-bigtile.compute
  3. 12
      Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/Resources/lightlistbuild-clustered.compute
  4. 26
      Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/Resources/lightlistbuild.compute
  5. 203
      Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/TilePass.cs
  6. 30
      Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/TilePass.cs.hlsl
  7. 6
      Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/TilePassLoop.hlsl

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


#endif
int n = 0;
for(int category = 0; category < NR_LIGHT_MODELS; category++)
for(int category = 0; category < NR_LIGHT_CATEGORIES; category++)
{
uint mask = 1u << category;
uint start;

2
Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/Resources/lightlistbuild-bigtile.compute


for(int l=0; l<iNrCoarseLights; l++)
{
const uint idxCoarse = lightsListLDS[l];
[branch]if (idxCoarse<(uint)g_iNrVisibLights && _LightShapeData[idxCoarse].lightType != SPHERE_LIGHT) // don't bother doing edge tests for sphere lights since these have camera aligned bboxes.
[branch]if (idxCoarse<(uint)g_iNrVisibLights && _LightShapeData[idxCoarse].lightVolume != SPHERE_VOLUME) // don't bother doing edge tests for sphere lights since these have camera aligned bboxes.
{
SFiniteLightBound lgtDat = g_data[idxCoarse];

12
Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/Resources/lightlistbuild-clustered.compute


InterlockedAdd(g_LayeredSingleIdxBuffer[0], (uint) iSpaceAvail, start); // alloc list memory
}
int modelListCount[NR_LIGHT_MODELS]={0,0,0}; // direct light count and reflection lights
int categoryListCount[NR_LIGHT_CATEGORIES]={0,0,0}; // direct light count and reflection lights
uint offs = start;
for(int ll=0; ll<iNrCoarseLights; ll+=4)
{

if(offs<(start+iSpaceAvail) && i<nrClusters && CheckIntersection(l, i, viTilLL.xy, viTilUR.xy, suggestedBase) )
{
uint lightCategory = _LightShapeData[coarseList[l]].lightCategory;
++modelListCount[lightCategory == REFLECTION_LIGHT ? 1 : 0];
++categoryListCount[lightCategory];
g_vLayeredLightList[offs++] = _LightShapeData[coarseList[l]].lightIndex; // reflection lights will be last since we sorted
}
}

uint localOffs=0;
offs = i*nrTilesX*nrTilesY + tileIDX.y*nrTilesX + tileIDX.x;
for(int m=0; m<NR_LIGHT_MODELS; m++)
for(int category=0; category<NR_LIGHT_CATEGORIES; category++)
int numLights = min(modelListCount[m],31); // only allow 5 bits
int numLights = min(categoryListCount[category],31); // only allow 5 bits
localOffs += modelListCount[m]; // use unclamped count for localOffs
localOffs += categoryListCount[category]; // use unclamped count for localOffs
}
}

GroupMemoryBarrierWithGroupSync();
#endif
const int idxCoarse = coarseList[l];
[branch]if (_LightShapeData[idxCoarse].lightType != SPHERE_LIGHT) // don't bother doing edge tests for sphere lights since these have camera aligned bboxes.
[branch]if (_LightShapeData[idxCoarse].lightVolume != SPHERE_VOLUME) // don't bother doing edge tests for sphere lights since these have camera aligned bboxes.
{
SFiniteLightBound lgtDat = g_data[idxCoarse];

26
Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/Resources/lightlistbuild.compute


#endif
groupshared int ldsNrLightsFinal;
groupshared int ldsModelListCount[NR_LIGHT_MODELS]; // since NR_LIGHT_MODELS is 3
groupshared int ldsCategoryListCount[NR_LIGHT_CATEGORIES]; // since NR_LIGHT_CATEGORIES is 3
#ifdef PERFORM_SPHERICAL_INTERSECTION_TESTS
groupshared uint lightOffsSph;

#endif
//
if(t<NR_LIGHT_MODELS) ldsModelListCount[t]=0;
if(t<NR_LIGHT_CATEGORIES) ldsCategoryListCount[t]=0;
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
GroupMemoryBarrierWithGroupSync();

int nrLightsCombinedList = min(ldsNrLightsFinal,MAX_NR_COARSE_ENTRIES);
for(int i=t; i<nrLightsCombinedList; i+=NR_THREADS)
{
InterlockedAdd(ldsModelListCount[_LightShapeData[prunedList[i]].lightCategory], 1);
InterlockedAdd(ldsCategoryListCount[_LightShapeData[prunedList[i]].lightCategory], 1);
}

int localOffs=0;
int offs = tileIDX.y*nrTilesX + tileIDX.x;
for(int m=0; m<NR_LIGHT_MODELS; m++)
for(int category=0; category<NR_LIGHT_CATEGORIES; category++)
int nrLightsFinal = ldsModelListCount[ m ];
int nrLightsFinal = ldsCategoryListCount[category];
int nrLightsFinalClamped = nrLightsFinal<MAX_NR_PRUNED_ENTRIES ? nrLightsFinal : MAX_NR_PRUNED_ENTRIES;

{
// fetch light
int idxCoarse = l<iNrCoarseLights ? coarseList[l] : 0;
uint uLgtType = l<iNrCoarseLights ? _LightShapeData[idxCoarse].lightType : 0;
uint uLightVolume = l<iNrCoarseLights ? _LightShapeData[idxCoarse].lightVolume : 0;
while(l<iNrCoarseLights && uLgtType==SPOT_LIGHT)
while(l<iNrCoarseLights && uLightVolume==SPOT_VOLUME)
{
LightShapeData lightData = _LightShapeData[idxCoarse];
// TODO: Change by SebL

uLightsFlags[l<32 ? 0 : 1] |= (uVal<<(l&31));
++l; idxCoarse = l<iNrCoarseLights ? coarseList[l] : 0;
uLgtType = l<iNrCoarseLights ? _LightShapeData[idxCoarse].lightType : 0;
uLightVolume = l<iNrCoarseLights ? _LightShapeData[idxCoarse].lightVolume : 0;
while(l<iNrCoarseLights && uLgtType==SPHERE_LIGHT)
while(l<iNrCoarseLights && uLightVolume==SPHERE_VOLUME)
{
LightShapeData lightData = _LightShapeData[idxCoarse];

uLightsFlags[l<32 ? 0 : 1] |= (uVal<<(l&31));
++l; idxCoarse = l<iNrCoarseLights ? coarseList[l] : 0;
uLgtType = l<iNrCoarseLights ? _LightShapeData[idxCoarse].lightType : 0;
uLightVolume = l<iNrCoarseLights ? _LightShapeData[idxCoarse].lightVolume : 0;
while(l<iNrCoarseLights && uLgtType==BOX_LIGHT)
while(l<iNrCoarseLights && uLightVolume==BOX_VOLUME)
{
LightShapeData lightData = _LightShapeData[idxCoarse];

uLightsFlags[l<32 ? 0 : 1] |= (uVal<<(l&31));
++l; idxCoarse = l<iNrCoarseLights ? coarseList[l] : 0;
uLgtType = l<iNrCoarseLights ? _LightShapeData[idxCoarse].lightType : 0;
uLightVolume = l<iNrCoarseLights ? _LightShapeData[idxCoarse].lightVolume : 0;
if(uLgtType>=MAX_TYPES) ++l;
if(uLightVolume >=MAX_VOLUME_TYPES) ++l;
}
InterlockedOr(ldsDoesLightIntersect[0], uLightsFlags[0]);

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


// types
public static int MAX_TYPES = 3;
public static int MAX_VOLUME_TYPES = 3;
public static int SPOT_LIGHT = 0;
public static int SPHERE_LIGHT = 1;
public static int BOX_LIGHT = 2;
public static int DIRECTIONAL_LIGHT = 3;
public static int SPOT_VOLUME = 0;
public static int SPHERE_VOLUME = 1;
public static int BOX_VOLUME = 2;
public static int DIRECTIONAL_VOLUME = 3;
public static int NR_LIGHT_MODELS = 3;
public static int DIRECT_LIGHT = 0;
public static int REFLECTION_LIGHT = 1;
public static int AREA_LIGHT = 2;
public static int NR_LIGHT_CATEGORIES = 3;
public static int DIRECT_LIGHT_CATEGORY = 0;
public static int REFLECTION_LIGHT_CATEGORY = 1;
public static int AREA_LIGHT_CATEGORY = 2;
}
[GenerateHLSL]

public uint lightIndex; // Index in light tabs like LightData / EnvLightData
public Vector3 lightAxisX;
public uint lightType;
public uint lightVolume;
public Vector3 lightAxisY;
public float radiusSq;

const int capacityUShortsPerTile = 32;
const int dwordsPerTile = (capacityUShortsPerTile + 1) >> 1; // room for 31 lights and a nrLights value.
s_LightList = new ComputeBuffer(LightDefinitions.NR_LIGHT_MODELS * dwordsPerTile * nrTiles, sizeof(uint)); // enough list memory for a 4k x 4k display
s_LightList = new ComputeBuffer(LightDefinitions.NR_LIGHT_CATEGORIES * dwordsPerTile * nrTiles, sizeof(uint)); // enough list memory for a 4k x 4k display
s_PerVoxelOffset = new ComputeBuffer(LightDefinitions.NR_LIGHT_MODELS * (1 << k_Log2NumClusters) * nrTiles, sizeof(uint));
s_PerVoxelOffset = new ComputeBuffer(LightDefinitions.NR_LIGHT_CATEGORIES * (1 << k_Log2NumClusters) * nrTiles, sizeof(uint));
s_PerVoxelLightLists = new ComputeBuffer(NumLightIndicesPerClusteredTile() * nrTiles, sizeof(uint));
if (k_UseDepthBuffer)

public void PrepareLightsForGPU(CullResults cullResults, Camera camera, HDRenderLoop.LightList lightList)
{
var numModels = (int)LightDefinitions.NR_LIGHT_MODELS;
var numVolTypes = (int)LightDefinitions.MAX_TYPES;
var numCategories = (int)LightDefinitions.NR_LIGHT_CATEGORIES;
var numVolTypes = (int)LightDefinitions.MAX_VOLUME_TYPES;
var numEntries = new int[numModels, numVolTypes];
var offsets = new int[numModels, numVolTypes];
var numEntries = new int[numCategories, numVolTypes];
var offsets = new int[numCategories, numVolTypes];
var numEntries2nd = new int[numModels, numVolTypes];
var numEntries2nd = new int[numCategories, numVolTypes];
var volType = punctualLight.lightType == GPULightType.Spot ? LightDefinitions.SPOT_LIGHT : (punctualLight.lightType == GPULightType.Point ? LightDefinitions.SPHERE_LIGHT : -1);
var volType = punctualLight.lightType == GPULightType.Spot ? LightDefinitions.SPOT_VOLUME : (punctualLight.lightType == GPULightType.Point ? LightDefinitions.SPHERE_VOLUME : -1);
++numEntries[LightDefinitions.DIRECT_LIGHT, volType];
++numEntries[LightDefinitions.DIRECT_LIGHT_CATEGORY, volType];
var volType = LightDefinitions.BOX_LIGHT; // always a box for now
++numEntries[LightDefinitions.REFLECTION_LIGHT, volType];
}
var volType = LightDefinitions.BOX_VOLUME; // always a box for now
++numEntries[LightDefinitions.REFLECTION_LIGHT_CATEGORY, volType];
}
var volType = LightDefinitions.BOX_LIGHT;
++numEntries[LightDefinitions.AREA_LIGHT, volType];
var volType = LightDefinitions.BOX_VOLUME;
++numEntries[LightDefinitions.AREA_LIGHT_CATEGORY, volType];
}

for (int m = 0; m < numModels; m++)
for (int category = 0; category < numCategories; category++)
offsets[m, 0] = m == 0 ? 0 : (numEntries[m - 1, numVolTypes - 1] + offsets[m - 1, numVolTypes - 1]);
offsets[category, 0] = category == 0 ? 0 : (numEntries[category - 1, numVolTypes - 1] + offsets[category - 1, numVolTypes - 1]);
offsets[m, v] = numEntries[m, v - 1] + offsets[m, v - 1];
offsets[category, v] = numEntries[category, v - 1] + offsets[category, v - 1];
}
}

var lightShapeData = new LightShapeData();
int index = -1;
lightShapeData.lightCategory = (uint)LightDefinitions.DIRECT_LIGHT;
lightShapeData.lightCategory = (uint)LightDefinitions.DIRECT_LIGHT_CATEGORY;
lightShapeData.lightIndex = (uint)lightIndex;
if (punctualLightData.lightType == GPULightType.Spot || punctualLightData.lightType == GPULightType.ProjectorPyramid)

lightShapeData.lightAxisX = vx;
lightShapeData.lightAxisY = vy;
lightShapeData.lightAxisZ = vz;
lightShapeData.lightType = (uint)LightDefinitions.SPOT_LIGHT;
lightShapeData.lightVolume = (uint)LightDefinitions.SPOT_VOLUME;
int i = LightDefinitions.DIRECT_LIGHT, j = LightDefinitions.SPOT_LIGHT;
int i = LightDefinitions.DIRECT_LIGHT_CATEGORY, j = LightDefinitions.SPOT_VOLUME;
index = numEntries2nd[i, j] + offsets[i, j]; ++numEntries2nd[i, j];
}
else // if (punctualLightData.lightType == GPULightType.Point)

lightShapeData.lightAxisX = vx;
lightShapeData.lightAxisY = vy;
lightShapeData.lightAxisZ = vz;
lightShapeData.lightType = (uint)LightDefinitions.SPHERE_LIGHT;
lightShapeData.lightVolume = (uint)LightDefinitions.SPHERE_VOLUME;
int i = LightDefinitions.DIRECT_LIGHT, j = LightDefinitions.SPHERE_LIGHT;
int i = LightDefinitions.DIRECT_LIGHT_CATEGORY, j = LightDefinitions.SPHERE_VOLUME;
index = numEntries2nd[i, j] + offsets[i, j]; ++numEntries2nd[i, j];
}

bound.radius = combinedExtent.magnitude;
var lightShapeData = new LightShapeData();
lightShapeData.lightType = (uint)LightDefinitions.BOX_LIGHT;
lightShapeData.lightCategory = (uint)LightDefinitions.REFLECTION_LIGHT;
lightShapeData.lightVolume = (uint)LightDefinitions.BOX_VOLUME;
lightShapeData.lightCategory = (uint)LightDefinitions.REFLECTION_LIGHT_CATEGORY;
lightShapeData.lightIndex = (uint)envIndex;
lightShapeData.lightPos = Cw;

lightShapeData.boxInnerDist = e;
lightShapeData.boxInvRange.Set(1.0f / delta.x, 1.0f / delta.y, 1.0f / delta.z);
int i = LightDefinitions.REFLECTION_LIGHT, j = LightDefinitions.BOX_LIGHT;
int i = LightDefinitions.REFLECTION_LIGHT_CATEGORY, j = LightDefinitions.BOX_VOLUME;
int index = numEntries2nd[i, j] + offsets[i, j]; ++numEntries2nd[i, j];
m_boundData[index] = bound;
m_lightShapeData[index] = lightShapeData;

{
LightData areaLightData = lightList.areaLights[areaLightIndex];
VisibleLight light = cullResults.visibleLights[lightList.areaCullIndices[areaLightIndex]];
lightShapeData.lightType = (uint)LightDefinitions.BOX_LIGHT;
lightShapeData.lightCategory = (uint)LightDefinitions.AREA_LIGHT;
lightShapeData.lightIndex = (uint)areaLightIndex;
lightShapeData.lightVolume = (uint)LightDefinitions.BOX_VOLUME;
lightShapeData.lightCategory = (uint)LightDefinitions.AREA_LIGHT_CATEGORY;
lightShapeData.lightIndex = (uint)areaLightIndex;
if (areaLightData.lightType == GPULightType.Rectangle)
{
Vector3 centerVS = worldToView.MultiplyPoint(areaLightData.positionWS);
Vector3 xAxisVS = worldToView.MultiplyVector(areaLightData.right);
Vector3 yAxisVS = worldToView.MultiplyVector(areaLightData.up);
Vector3 zAxisVS = worldToView.MultiplyVector(areaLightData.forward);
float radius = 1.0f / Mathf.Sqrt(areaLightData.invSqrAttenuationRadius);
Vector3 dimensions = new Vector3(areaLightData.size.x * 0.5f + radius, areaLightData.size.y * 0.5f + radius, radius);
if (areaLightData.lightType == GPULightType.Rectangle)
{
Vector3 centerVS = worldToView.MultiplyPoint(areaLightData.positionWS);
Vector3 xAxisVS = worldToView.MultiplyVector(areaLightData.right);
Vector3 yAxisVS = worldToView.MultiplyVector(areaLightData.up);
Vector3 zAxisVS = worldToView.MultiplyVector(areaLightData.forward);
float radius = 1.0f / Mathf.Sqrt(areaLightData.invSqrAttenuationRadius);
Vector3 dimensions = new Vector3(areaLightData.size.x * 0.5f + radius, areaLightData.size.y * 0.5f + radius, radius);
if(!areaLightData.twoSided)
{
centerVS -= zAxisVS * radius * 0.5f;
dimensions.z *= 0.5f;
}
bound.center = centerVS;
bound.boxAxisX = dimensions.x * xAxisVS;
bound.boxAxisY = dimensions.y * yAxisVS;
bound.boxAxisZ = dimensions.z * zAxisVS;
bound.scaleXY.Set(1.0f, 1.0f);
bound.radius = dimensions.magnitude;
lightShapeData.lightPos = centerVS;
lightShapeData.lightAxisX = xAxisVS;
lightShapeData.lightAxisY = yAxisVS;
lightShapeData.lightAxisZ = zAxisVS;
lightShapeData.boxInnerDist = dimensions;
lightShapeData.boxInvRange.Set(1e5f, 1e5f, 1e5f);
if(!areaLightData.twoSided)
{
centerVS -= zAxisVS * radius * 0.5f;
dimensions.z *= 0.5f;
}
bound.center = centerVS;
bound.boxAxisX = dimensions.x * xAxisVS;
bound.boxAxisY = dimensions.y * yAxisVS;
bound.boxAxisZ = dimensions.z * zAxisVS;
bound.scaleXY.Set(1.0f, 1.0f);
bound.radius = dimensions.magnitude;
lightShapeData.lightPos = centerVS;
lightShapeData.lightAxisX = xAxisVS;
lightShapeData.lightAxisY = yAxisVS;
lightShapeData.lightAxisZ = zAxisVS;
lightShapeData.boxInnerDist = dimensions;
lightShapeData.boxInvRange.Set(1e5f, 1e5f, 1e5f);
else if (areaLightData.lightType == GPULightType.Line)
{
Vector3 centerVS = worldToView.MultiplyPoint(areaLightData.positionWS);
Vector3 xAxisVS = worldToView.MultiplyVector(areaLightData.right);
Vector3 yAxisVS = worldToView.MultiplyVector(areaLightData.up);
Vector3 zAxisVS = worldToView.MultiplyVector(areaLightData.forward);
float radius = 1.0f / Mathf.Sqrt(areaLightData.invSqrAttenuationRadius);
Vector3 dimensions = new Vector3(areaLightData.size.x * 0.5f + radius, radius, radius);
bound.center = centerVS;
bound.boxAxisX = dimensions.x * xAxisVS;
bound.boxAxisY = dimensions.y * yAxisVS;
bound.boxAxisZ = dimensions.z * zAxisVS;
bound.scaleXY.Set(1.0f, 1.0f);
bound.radius = dimensions.magnitude;
lightShapeData.lightPos = centerVS;
lightShapeData.lightAxisX = xAxisVS;
lightShapeData.lightAxisY = yAxisVS;
lightShapeData.lightAxisZ = zAxisVS;
lightShapeData.boxInnerDist = new Vector3(areaLightData.size.x * 0.5f, 0.01f, 0.01f);
lightShapeData.boxInvRange.Set(1.0f / radius, 1.0f / radius, 1.0f / radius);
else if (areaLightData.lightType == GPULightType.Line)
{
Vector3 centerVS = worldToView.MultiplyPoint(areaLightData.positionWS);
Vector3 xAxisVS = worldToView.MultiplyVector(areaLightData.right);
Vector3 yAxisVS = worldToView.MultiplyVector(areaLightData.up);
Vector3 zAxisVS = worldToView.MultiplyVector(areaLightData.forward);
float radius = 1.0f / Mathf.Sqrt(areaLightData.invSqrAttenuationRadius);
Vector3 dimensions = new Vector3(areaLightData.size.x * 0.5f + radius, radius, radius);
bound.center = centerVS;
bound.boxAxisX = dimensions.x * xAxisVS;
bound.boxAxisY = dimensions.y * yAxisVS;
bound.boxAxisZ = dimensions.z * zAxisVS;
bound.scaleXY.Set(1.0f, 1.0f);
bound.radius = dimensions.magnitude;
lightShapeData.lightPos = centerVS;
lightShapeData.lightAxisX = xAxisVS;
lightShapeData.lightAxisY = yAxisVS;
lightShapeData.lightAxisZ = zAxisVS;
lightShapeData.boxInnerDist = new Vector3(areaLightData.size.x * 0.5f, 0.01f, 0.01f);
lightShapeData.boxInvRange.Set(1.0f / radius, 1.0f / radius, 1.0f / radius);
{
Debug.Assert(false);
}
int i = LightDefinitions.AREA_LIGHT, j = LightDefinitions.BOX_LIGHT;
int index = numEntries2nd[i, j] + offsets[i, j]; ++numEntries2nd[i, j];
{
Debug.Assert(false);
}
int i = LightDefinitions.AREA_LIGHT_CATEGORY, j = LightDefinitions.BOX_VOLUME;
int index = numEntries2nd[i, j] + offsets[i, j]; ++numEntries2nd[i, j];
m_lightShapeData[index] = lightShapeData;
m_lightShapeData[index] = lightShapeData;
for (var m = 0; m < numModels; m++)
for (var category = 0; category < numCategories; category++)
Debug.Assert(numEntries[m, v] == numEntries2nd[m, v], "count mismatch on second pass!");
Debug.Assert(numEntries[category, v] == numEntries2nd[category, v], "count mismatch on second pass!");
}
}

30
Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/TilePass.cs.hlsl


#define HAS_COOKIE_TEXTURE (2)
#define IS_BOX_PROJECTED (4)
#define HAS_SHADOW (8)
#define MAX_TYPES (3)
#define SPOT_LIGHT (0)
#define SPHERE_LIGHT (1)
#define BOX_LIGHT (2)
#define DIRECTIONAL_LIGHT (3)
#define NR_LIGHT_MODELS (3)
#define DIRECT_LIGHT (0)
#define REFLECTION_LIGHT (1)
#define AREA_LIGHT (2)
//
// UnityEngine.Experimental.ScriptableRenderLoop.TilePass.DebugViewTilesFlags: static fields
//
#define DEBUGVIEWTILESFLAGS_DIRECT_LIGHTING (1)
#define DEBUGVIEWTILESFLAGS_REFLECTION (2)
#define MAX_VOLUME_TYPES (3)
#define SPOT_VOLUME (0)
#define SPHERE_VOLUME (1)
#define BOX_VOLUME (2)
#define DIRECTIONAL_VOLUME (3)
#define NR_LIGHT_CATEGORIES (3)
#define DIRECT_LIGHT_CATEGORY (0)
#define REFLECTION_LIGHT_CATEGORY (1)
#define AREA_LIGHT_CATEGORY (2)
// Generated from UnityEngine.Experimental.ScriptableRenderLoop.TilePass.SFiniteLightBound
// PackingRules = Exact

float3 lightPos;
uint lightIndex;
float3 lightAxisX;
uint lightType;
uint lightVolume;
float3 lightAxisY;
float radiusSq;
float3 lightAxisZ;

{
return value.lightAxisX;
}
uint GetLightType(LightShapeData value)
uint GetLightVolume(LightShapeData value)
return value.lightType;
return value.lightVolume;
}
float3 GetLightAxisY(LightShapeData value)
{

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


#ifdef PROCESS_PUNCTUAL_LIGHT
uint punctualLightStart;
uint punctualLightCount;
GetCountAndStart(coord, DIRECT_LIGHT, linearDepth, punctualLightStart, punctualLightCount);
GetCountAndStart(coord, DIRECT_LIGHT_CATEGORY, linearDepth, punctualLightStart, punctualLightCount);
for (i = 0; i < punctualLightCount; ++i)
{
float3 localDiffuseLighting, localSpecularLighting;

// TODO: Area lights are where the sorting is important (Morten approach with while loop)
uint areaLightStart;
uint areaLightCount;
GetCountAndStart(coord, AREA_LIGHT, linearDepth, areaLightStart, areaLightCount);
GetCountAndStart(coord, AREA_LIGHT_CATEGORY, linearDepth, areaLightStart, areaLightCount);
for (i = 0; i < areaLightCount; ++i)
{
float3 localDiffuseLighting, localSpecularLighting;

#ifdef PROCESS_ENV_LIGHT
uint envLightStart;
uint envLightCount;
GetCountAndStart(coord, REFLECTION_LIGHT, linearDepth, envLightStart, envLightCount);
GetCountAndStart(coord, REFLECTION_LIGHT_CATEGORY, linearDepth, envLightStart, envLightCount);
float3 iblDiffuseLighting = float3(0.0, 0.0, 0.0);
float3 iblSpecularLighting = float3(0.0, 0.0, 0.0);

正在加载...
取消
保存