Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed decal position when created from context menu. (case 1368987)
- Fixed the clouds not taking properly into account the fog when in distant mode and with a close far plane (case 1367993).
- Fixed overwriting of preview camera background color. [case 1357004](https://issuetracker.unity3d.com/product/unity/issues/guid/1361557/)
- Fixed selection of light types (point, area, directional) for path-traced Unlit shadow mattes.

## [13.0.0] - 2021-09-01

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ bool IsDistantLightActive(DirectionalLightData lightData, float3 normal)
return dot(normal, lightData.forward) <= sin(lightData.angularDiameter * 0.5);
}

LightList CreateLightList(float3 position, float3 normal, uint lightLayers = DEFAULT_LIGHT_LAYERS, bool withLocal = true, bool withDistant = true, float3 lightPosition = FLT_MAX)
LightList CreateLightList(float3 position, float3 normal, uint lightLayers = DEFAULT_LIGHT_LAYERS,
bool withPoint = true, bool withArea = true, bool withDistant = true,
float3 lightPosition = FLT_MAX)
{
LightList list;
uint i;
Expand All @@ -119,7 +121,7 @@ LightList CreateLightList(float3 position, float3 normal, uint lightLayers = DEF
list.localCount = 0;
list.localPointCount = 0;

if (withLocal)
if (withPoint || withArea)
{
uint localPointCount, localCount;

Expand All @@ -144,35 +146,43 @@ LightList CreateLightList(float3 position, float3 normal, uint lightLayers = DEF
bool forceLightPosition = (lightPosition.x != FLT_MAX);

// First point lights (including spot lights)
for (i = 0; i < localPointCount && list.localPointCount < MAX_LOCAL_LIGHT_COUNT; i++)
if (withPoint)
{
#ifdef USE_LIGHT_CLUSTER
const LightData lightData = FetchClusterLightIndex(list.cellIndex, i);
#else
const LightData lightData = _LightDatasRT[i];
#endif
for (i = 0; i < localPointCount && list.localPointCount < MAX_LOCAL_LIGHT_COUNT; i++)
{
#ifdef USE_LIGHT_CLUSTER
const LightData lightData = FetchClusterLightIndex(list.cellIndex, i);
#else
const LightData lightData = _LightDatasRT[i];
#endif

if (forceLightPosition && any(lightPosition - lightData.positionRWS))
continue;

if (forceLightPosition && any(lightPosition - lightData.positionRWS))
continue;
if (IsMatchingLightLayer(lightData.lightLayers, lightLayers) && IsPointLightActive(lightData, position, normal))
list.localIndex[list.localPointCount++] = i;
}

if (IsMatchingLightLayer(lightData.lightLayers, lightLayers) && IsPointLightActive(lightData, position, normal))
list.localIndex[list.localPointCount++] = i;
list.localCount = list.localPointCount;
}

// Then rect area lights
for (list.localCount = list.localPointCount; i < localCount && list.localCount < MAX_LOCAL_LIGHT_COUNT; i++)
if (withArea)
{
#ifdef USE_LIGHT_CLUSTER
const LightData lightData = FetchClusterLightIndex(list.cellIndex, i);
#else
const LightData lightData = _LightDatasRT[i];
#endif
for (i = localPointCount; i < localCount && list.localCount < MAX_LOCAL_LIGHT_COUNT; i++)
{
#ifdef USE_LIGHT_CLUSTER
const LightData lightData = FetchClusterLightIndex(list.cellIndex, i);
#else
const LightData lightData = _LightDatasRT[i];
#endif

if (forceLightPosition && any(lightPosition - lightData.positionRWS))
continue;
if (forceLightPosition && any(lightPosition - lightData.positionRWS))
continue;

if (IsMatchingLightLayer(lightData.lightLayers, lightLayers) && IsRectAreaLightActive(lightData, position, normal))
list.localIndex[list.localCount++] = i;
if (IsMatchingLightLayer(lightData.lightLayers, lightLayers) && IsRectAreaLightActive(lightData, position, normal))
list.localIndex[list.localCount++] = i;
}
}
}

Expand Down Expand Up @@ -837,7 +847,7 @@ float PickLocalLightInterval(float3 rayOrigin, float3 rayDirection, inout float

LightList CreateLightList(float3 position, bool sampleLocalLights, float3 lightPosition = FLT_MAX)
{
return CreateLightList(position, 0.0, DEFAULT_LIGHT_LAYERS, sampleLocalLights, !sampleLocalLights, lightPosition);
return CreateLightList(position, 0.0, DEFAULT_LIGHT_LAYERS, sampleLocalLights, sampleLocalLights, !sampleLocalLights, lightPosition);
}

#endif // UNITY_PATH_TRACING_LIGHT_INCLUDED
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ float3 GetPositionBias(float3 geomNormal, float bias, bool below)
// Compute scalar visibility for shadow mattes, between 0 and 1
float ComputeVisibility(float3 position, float3 normal, float3 inputSample)
{
LightList lightList = CreateLightList(position, normal);
// Select active types of lights
bool withPoint = asuint(_ShadowMatteFilter) & LIGHTFEATUREFLAGS_PUNCTUAL;
bool withArea = asuint(_ShadowMatteFilter) & LIGHTFEATUREFLAGS_AREA;
bool withDistant = asuint(_ShadowMatteFilter) & LIGHTFEATUREFLAGS_DIRECTIONAL;

LightList lightList = CreateLightList(position, normal, DEFAULT_LIGHT_LAYERS, withPoint, withArea, withDistant);

RayDesc rayDescriptor;
rayDescriptor.Origin = position + normal * _RaytracingRayBias;
Expand Down