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 @@ -311,6 +311,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed ghosting issues if the exposure changed too much (RTGI).
- Fixed failures on platforms that do not support ray tracing due to an engine behavior change.
- Fixed infinite propagation of nans for RTGI and SSGI (case 1349738).
- Fixed access to main directional light from script.

### Changed
- Changed Window/Render Pipeline/HD Render Pipeline Wizard to Window/Rendering/HDRP Wizard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,12 @@ enum ClusterDepthSource : int
int m_CurrentShadowSortedSunLightIndex = -1;
HDAdditionalLightData m_CurrentSunLightAdditionalLightData;
DirectionalLightData m_CurrentSunLightDirectionalLightData;
internal Light GetCurrentSunLight() { return m_CurrentSunLight; }

/// <summary>
/// Main directional Light for the HD Render Pipeline.
/// </summary>
/// <returns>The main directional Light.</returns>
public Light GetMainLight() { return m_CurrentSunLight; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guess is weird to expose this Method inside the LightLoop class. Guess it should be in another location, maybe HDRenderPipeline. What are your thought?

Copy link
Contributor Author

@adrien-de-tocqueville adrien-de-tocqueville Jul 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There isn't actually any lightloop class, it's just the name of the file. The function is inside the class HDRenderPipeline, which is partial, so defined in multiple files.

For user it will be accessible this way:

var sunLight = HDRenderPipeline.currentPipeline.GetMainLight();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah right :)


// Screen space shadow data
struct ScreenSpaceShadowData
Expand Down Expand Up @@ -1178,7 +1183,7 @@ internal void GetDirectionalLightData(CommandBuffer cmd, HDCamera hdCamera, Visi
size = new Vector2(additionalLightData.shapeWidth, additionalLightData.shapeHeight),
position = light.GetPosition()
};
if (lightComponent == GetCurrentSunLight())
if (lightComponent == GetMainLight())
{
// If this is the current sun light and volumetric cloud shadows are enabled we need to render the shadows
if (HasVolumetricCloudsShadows_IgnoreSun(hdCamera))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ void UpdateShaderVariableslClouds(ref ShaderVariablesClouds cb, HDCamera hdCamer
// PB Sun/Sky settings
var visualEnvironment = hdCamera.volumeStack.GetComponent<VisualEnvironment>();
cb._PhysicallyBasedSun = visualEnvironment.skyType.value == (int)SkyType.PhysicallyBased ? 1 : 0;
Light currentSun = GetCurrentSunLight();
Light currentSun = GetMainLight();
if (currentSun != null)
{
// Grab the target sun additional data
Expand Down Expand Up @@ -617,7 +617,7 @@ VolumetricCloudsParameters PrepareVolumetricCloudsParameters(HDCamera hdCamera,
parameters.worley32RGB = m_Asset.renderPipelineResources.textures.worleyNoise32RGB;
BlueNoise blueNoise = GetBlueNoiseManager();
parameters.ditheredTextureSet = blueNoise.DitheredTextureSet8SPP();
parameters.sunLight = GetCurrentSunLight();
parameters.sunLight = GetMainLight();
parameters.enableExposureControl = hdCamera.exposureControlFS;

// Update the constant buffer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void ReleaseVolumetricCloudsShadows()
bool HasVolumetricCloudsShadows(HDCamera hdCamera, in VolumetricClouds settings)
{
return (HasVolumetricClouds(hdCamera, in settings)
&& GetCurrentSunLight() != null
&& GetMainLight() != null
&& settings.shadows.value);
}

Expand Down Expand Up @@ -133,7 +133,7 @@ CookieParameters RenderVolumetricCloudsShadows(CommandBuffer cmd, HDCamera hdCam
TraceVolumetricCloudShadow(cmd, parameters, currentHandle);

// Grab the current sun light
Light sunLight = GetCurrentSunLight();
Light sunLight = GetMainLight();

// Compute the shadow size
float groundShadowSize = settings.shadowDistance.value * 2.0f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1383,7 +1383,7 @@ void PreRenderSky(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle colo

using (var builder = renderGraph.AddRenderPass<PreRenderSkyPassData>("Pre Render Sky", out var passData))
{
passData.sunLight = GetCurrentSunLight();
passData.sunLight = GetMainLight();
passData.hdCamera = hdCamera;
passData.colorBuffer = builder.WriteTexture(colorBuffer);
passData.depthStencilBuffer = builder.WriteTexture(depthStencilBuffer);
Expand Down Expand Up @@ -1421,7 +1421,7 @@ void RenderSky(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle colorBu
using (var builder = renderGraph.AddRenderPass<RenderSkyPassData>("Render Sky And Fog", out var passData))
{
passData.visualEnvironment = hdCamera.volumeStack.GetComponent<VisualEnvironment>();
passData.sunLight = GetCurrentSunLight();
passData.sunLight = GetMainLight();
passData.hdCamera = hdCamera;
passData.volumetricLighting = builder.ReadTexture(volumetricLighting);
passData.colorBuffer = builder.WriteTexture(colorBuffer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2520,7 +2520,7 @@ void RenderWireFrame(CullingResults cull, HDCamera hdCamera, RenderTargetIdentif

void UpdateSkyEnvironment(HDCamera hdCamera, ScriptableRenderContext renderContext, CommandBuffer cmd)
{
m_SkyManager.UpdateEnvironment(hdCamera, renderContext, GetCurrentSunLight(), cmd);
m_SkyManager.UpdateEnvironment(hdCamera, renderContext, GetMainLight(), cmd);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ void RenderSky(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle skyBuff
using (var builder = renderGraph.AddRenderPass<RenderSkyPassData>("Render Sky for Path Tracing", out var passData))
{
passData.visualEnvironment = hdCamera.volumeStack.GetComponent<VisualEnvironment>();
passData.sunLight = GetCurrentSunLight();
passData.sunLight = GetMainLight();
passData.hdCamera = hdCamera;
passData.colorBuffer = builder.WriteTexture(skyBuffer);
passData.depthTexture = builder.WriteTexture(CreateDepthBuffer(renderGraph, true, MSAASamples.None));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public override bool GetSunLightCookieParameters(CloudSettings settings, ref Coo
if (cloudLayer.CastShadows)
{
if (m_PrecomputedData == null || m_PrecomputedData.cloudShadowsRT == null)
UpdateCache(cloudLayer, HDRenderPipeline.currentPipeline.GetCurrentSunLight());
UpdateCache(cloudLayer, HDRenderPipeline.currentPipeline.GetMainLight());

cookieParams.texture = m_PrecomputedData.cloudShadowsRT;
cookieParams.size = new Vector2(cloudLayer.shadowSize.value, cloudLayer.shadowSize.value);
Expand Down