浏览代码

Implement tile & cluster support for orthographic projector lights

/fptl_cleanup
Evgenii Golubev 8 年前
当前提交
6c81aaea
共有 3 个文件被更改,包括 32 次插入11 次删除
  1. 20
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs
  2. 1
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.hlsl
  3. 22
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePassLoop.hlsl

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


Vector3 xAxisVS = worldToView.MultiplyVector(lightData.right);
Vector3 yAxisVS = worldToView.MultiplyVector(lightData.up);
Vector3 zAxisVS = worldToView.MultiplyVector(lightData.forward);
float radius = 1.0f / Mathf.Sqrt(lightData.invSqrAttenuationRadius);
Vector3 boxDims = new Vector3(lightData.size.x, lightData.size.y, radius);
Vector3 boxCenterVS = posVS + zAxisVS * (0.5f * radius);
Vector3 boxDims = new Vector3(lightData.size.x, lightData.size.y, 1000000.0f);
bound.center = boxCenterVS;
bound.boxAxisX = 0.5f * boxDims.x * xAxisVS; // Should this be halved or not?
bound.boxAxisY = 0.5f * boxDims.y * yAxisVS;
bound.boxAxisZ = 0.5f * boxDims.z * zAxisVS;
bound.radius = 0.5f * boxDims.magnitude; // Radius of a circumscribed sphere?
bound.center = posVS;
bound.boxAxisX = boxDims.x * xAxisVS; // Should this be halved or not?
bound.boxAxisY = boxDims.y * yAxisVS; // Should this be halved or not?
bound.boxAxisZ = boxDims.z * zAxisVS; // Should this be halved or not?
bound.radius = 0.5f * boxDims.magnitude; // Radius of a circumscribed sphere?
lightVolumeData.lightPos = boxCenterVS; // Is it the center of the volume?
lightVolumeData.lightPos = posVS; // Is this the center of the volume?
lightVolumeData.boxInnerDist = boxDims * 0.5f; // No idea what this is. Document your code
lightVolumeData.boxInvRange.Set(1.0f / radius, 1.0f / radius, 1.0f / radius); // No idea what this is. Document your code
lightVolumeData.boxInnerDist = boxDims * 0.5f; // No idea what this is. Document your code
lightVolumeData.boxInvRange.Set(1.0f / boxDims.x, 1.0f / boxDims.y, 1.0f / boxDims.z); // No idea what this is. Document your code
lightVolumeData.featureFlags = LightFeatureFlags.FEATURE_FLAG_LIGHT_PROJECTOR;
}
else

1
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.hlsl


#define PROCESS_DIRECTIONAL_LIGHT
#define PROCESS_PUNCTUAL_LIGHT
#define PROCESS_AREA_LIGHT
#define PROCESS_PROJECTOR_LIGHT
#endif
#if defined (LIGHTLOOP_TILE_INDIRECT) || defined(LIGHTLOOP_TILE_ALL)

22
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePassLoop.hlsl


}
#endif
#ifdef PROCESS_PROJECTOR_LIGHT
if(featureFlags & FEATURE_FLAG_LIGHT_PROJECTOR)
{
// TODO: Convert the for loop below to a while on each type as we know we are sorted!
uint projectorLightStart;
uint projectorLightCount;
GetCountAndStart(posInput, LIGHTCATEGORY_PROJECTOR, projectorLightStart, projectorLightCount);
for(i = 0; i < projectorLightCount; ++i)
{
float3 localDiffuseLighting, localSpecularLighting;
uint projectorIndex = FetchIndex(projectorLightStart, i);
EvaluateBSDF_Projector(context, V, posInput, prelightData, _LightDatas[projectorIndex], bsdfData,
localDiffuseLighting, localSpecularLighting);
diffuseLighting += localDiffuseLighting;
specularLighting += localSpecularLighting;
}
}
#endif
#ifdef PROCESS_ENV_LIGHT
float3 iblDiffuseLighting = float3(0.0, 0.0, 0.0);
float3 iblSpecularLighting = float3(0.0, 0.0, 0.0);

正在加载...
取消
保存