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 @@ -108,6 +108,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed APV loading data outside of the relevant area containing probes.
- Fixed the roughness value used for screen space reflections and ray traced reflections to match environment lighting (case 1390916).
- Fixed editor issue with the LiftGammaGain and ShadowsMidtonesHighlights volume components.
- Fixed using the wrong directional light data for clouds and the definition of current Sun when the shadow pass is culled (case 1399000).

## [14.0.0] - 2021-11-17

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ enum ClusterDepthSource : int

// Directional light
Light m_CurrentSunLight;
int m_CurrentSunLightDataIndex = -1;
int m_CurrentShadowSortedSunLightIndex = -1;
HDAdditionalLightData m_CurrentSunLightAdditionalLightData;
HDProcessedVisibleLightsBuilder.ShadowMapFlags m_CurrentSunShadowMapFlags = HDProcessedVisibleLightsBuilder.ShadowMapFlags.None;
Expand Down Expand Up @@ -1577,8 +1578,11 @@ void PreprocessVisibleLights(CommandBuffer cmd, HDCamera hdCamera, in CullingRes
{
// Sunlight is the directional casting shadows
// Fallback to the first non shadow casting directional light.
if ((processedLightEntity.shadowMapFlags & HDProcessedVisibleLightsBuilder.ShadowMapFlags.WillRenderShadowMap) != 0 || m_CurrentSunLight == null)
if (additionalLightData.ShadowsEnabled() || m_CurrentSunLight == null)
{
m_CurrentSunLightDataIndex = i;
m_CurrentSunLight = additionalLightData.legacyLight;
}
}

ReserveCookieAtlasTexture(additionalLightData, additionalLightData.legacyLight, processedLightEntity.lightType);
Expand Down Expand Up @@ -1839,6 +1843,7 @@ bool PrepareLightsForGPU(

// We need to properly reset this here otherwise if we go from 1 light to no visible light we would keep the old reference active.
m_CurrentSunLight = null;
m_CurrentSunLightDataIndex = -1;
m_CurrentSunLightAdditionalLightData = null;
m_CurrentShadowSortedSunLightIndex = -1;
m_DebugSelectedLightShadowIndex = -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,5 +524,13 @@ internal static void ConvertLightIntensity(LightUnit oldLightUnit, LightUnit new

hdLight.intensity = intensity;
}

internal static Color EvaluateLightColor(Light light, HDAdditionalLightData hdLight)
{
Color finalColor = light.color.linear * light.intensity;
if (hdLight.useColorTemperature)
finalColor *= Mathf.CorrelatedColorTemperatureToRGB(light.colorTemperature);
return finalColor;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@ void UpdateShaderVariableslClouds(ref ShaderVariablesClouds cb, HDCamera hdCamer

if (!shadowPass)
{
cb._SunLightColor = m_GpuLightsBuilder.directionalLights[0].color * settings.sunLightDimmer.value;
// m_CurrentSunLightDataIndex is supposed to be guaranteed to be non -1 if the current sun is not null
cb._SunLightColor = m_GpuLightsBuilder.directionalLights[m_CurrentSunLightDataIndex].color * settings.sunLightDimmer.value;
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,10 +537,7 @@ void BuildLightData(CommandBuffer cmd, HDCamera hdCamera, HDRayTracingLights ray
processedLightEntity.isBakedShadowMask = HDRenderPipeline.IsBakedShadowMaskLight(lightComponent);

// Build a visible light
Color finalColor = lightComponent.color.linear * lightComponent.intensity;
if (additionalLightData.useColorTemperature)
finalColor *= Mathf.CorrelatedColorTemperatureToRGB(lightComponent.colorTemperature);
visibleLight.finalColor = finalColor;
visibleLight.finalColor = LightUtils.EvaluateLightColor(lightComponent, additionalLightData);
visibleLight.range = lightComponent.range;
// This should be done explicitly, localToWorld matrix doesn't work here
localToWorldMatrix.SetColumn(3, lightComponent.gameObject.transform.position);
Expand Down