Skip to content

Fix box light attenuation #3056

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 14, 2021
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ -48,6 +48,7 @@ The version number for this package has increased due to a version update of a r
- Fixed missing BeginCameraRendering call for custom render mode of a Camera.
- Fixed LayerMask editor for volume parameters.
- Fixed the condition on temporal accumulation in the reflection denoiser (case 1303504).
- Fixed box light attenuation.

### Changed
- Removed the material pass probe volumes evaluation mode.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ void ShadowLoopMin(HDShadowContext shadowContext, PositionInputs posInput, float
float3 L;
float4 distances; // {d, d^2, 1/d, d_proj}
GetPunctualLightVectors(posInput.positionWS, s_lightData, L, distances);
float distToLight = (s_lightData.lightType == GPULIGHTTYPE_PROJECTOR_BOX) ? distances.w : distances.x;
float lightRadSqr = s_lightData.size.x;
if (distances.x < s_lightData.range &&
PunctualLightAttenuation(distances, s_lightData.rangeAttenuationScale, s_lightData.rangeAttenuationBias,
Expand Down Expand Up @@ -169,7 +168,6 @@ void ShadowLoopMin(HDShadowContext shadowContext, PositionInputs posInput, float
float3 L;
float4 distances; // {d, d^2, 1/d, d_proj}
GetPunctualLightVectors(posInput.positionWS, lightData, L, distances);
float distToLight = (lightData.lightType == GPULIGHTTYPE_PROJECTOR_BOX) ? distances.w : distances.x;
float lightRadSqr = lightData.size.x;
float shadowP;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,11 @@ void GetPunctualLightVectors(float3 positionWS, LightData light, out float3 L, o

if (light.lightType == GPULIGHTTYPE_PROJECTOR_BOX)
{
L = -light.forward;

float dist = -dot(lightToSample, L);
float dist = distances.w;
float distSq = dist * dist;
distances.y = distSq;
if (light.rangeAttenuationBias == 1.0) // Light uses range attenuation
{
float distRcp = rcp(dist);
distances.x = dist;
distances.z = distRcp;
ModifyDistancesForFillLighting(distances, light.size.x);
}
else // Light is directionnal
{
// Note we maintain distances.y as otherwise the windowing function will give wrong results.
// There won't be attenuation as the light attenuation scale and biases are set such that attenuation is prevented.
distances.xz = 1; // No distance or angle attenuation
}

L = -light.forward;
distances.xyz = float3(1.0f, distSq, 1.0);
}
else
{
Expand Down