Skip to content

Fix box light disappearing when range is below 1 and no range attenuation #1989

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 5 commits into from
Sep 30, 2020
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 @@ -113,6 +113,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed issue with MSAA resolve killing the alpha channel.
- Fixed a warning in materialevalulation
- Fixed an error when building the player.
- Fixed issue with box light not visible if range is below one and range attenuation is off.

### Changed
- Preparation pass for RTSSShadows to be supported by render graph.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,22 @@ void GetPunctualLightVectors(float3 positionWS, LightData light, out float3 L, o
{
L = -light.forward;

float dist = -dot(lightToSample, L);
float distSq = dist * dist;
distances.y = distSq;
if (light.rangeAttenuationBias == 1.0) // Light uses range attenuation
{
float dist = -dot(lightToSample, L);
float distSq = dist * dist;
float distRcp = rcp(dist);
distances.xyz = float3(dist, distSq, distRcp);
distances.x = dist;
distances.z = distRcp;
ModifyDistancesForFillLighting(distances, light.size.x);
}
else // Light is directionnal
distances.xyz = 1; // No distance or angle attenuation
{
// 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
}
}
else
{
Expand Down