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
788 changes: 749 additions & 39 deletions TestProjects/HDRP_DXR_Tests/Assets/Scenes/601_LightCluster.unity

Large diffs are not rendered by default.

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 @@ -20,6 +20,7 @@ The version number for this package has increased due to a version update of a r
- Added the status check of default camera frame settings in the DXR wizard.
- Added frame setting for Virtual Texturing.
- Added a fade distance for light influencing volumetric lighting.
- Adding an "Include For Ray Tracing" toggle on lights to allow the user to exclude them when ray tracing is enabled in the frame settings of a camera.

### Fixed
- Fixed an issue where the Exposure Shader Graph node had clipped text. (case 1265057)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ sealed class Styles
public readonly string cookieNonPOT = "HDRP does not support non power of two cookie textures.";
public readonly string cookieTooSmall = "Min texture size for cookies is 2x2 pixels.";
public readonly string cookieBaking = "Light Baking for cookies disabled on the Project Settings.";
public readonly GUIContent includeLightForRayTracing = new GUIContent("Include For RayTracing", "When enabled, the light affects the scene for cameras with the Ray-Tracing frame setting enabled.");

// Additional light data
public readonly GUIContent directionalIntensity = new GUIContent("Intensity (Lux)", "Illuminance of the Directional Light, at ground level, in lux.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,8 @@ static void DrawEmissionAdvancedContent(SerializedHDLight serialized, Editor own
--EditorGUI.indentLevel;
}

EditorGUILayout.PropertyField(serialized.includeForRayTracing, s_Styles.includeLightForRayTracing);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should show this field only when Raytracing is enabled. What do you think?


if (EditorGUI.EndChangeCheck())
{
serialized.needUpdateAreaLightEmissiveMeshComponents = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ internal class SerializedHDLight
public SerializedProperty areaLightCookie; // We can't use default light cookies because the cookie gets reset by some safety measure on C++ side... :/
public SerializedProperty iesPoint;
public SerializedProperty iesSpot;
public SerializedProperty includeForRayTracing;
public SerializedProperty areaLightShadowCone;
public SerializedProperty useCustomSpotLightShadowCone;
public SerializedProperty customSpotLightShadowCone;
Expand Down Expand Up @@ -361,6 +362,7 @@ public SerializedHDLight(HDAdditionalLightData[] lightDatas, LightEditor.Setting
areaLightCookie = o.Find("m_AreaLightCookie");
iesPoint = o.Find("m_IESPoint");
iesSpot = o.Find("m_IESSpot");
includeForRayTracing = o.Find("m_IncludeForRayTracing");
areaLightShadowCone = o.Find("m_AreaLightShadowCone");
useCustomSpotLightShadowCone = o.Find("m_UseCustomSpotLightShadowCone");
customSpotLightShadowCone = o.Find("m_CustomSpotLightShadowCone");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,23 @@ internal Texture IESSpot
}
}

[SerializeField]
bool m_IncludeForRayTracing = true;
/// <summary>
/// Controls if the light is enabled when the camera has the RayTracing frame setting enabled.
/// </summary>
public bool includeForRayTracing
{
get => m_IncludeForRayTracing;
set
{
if (m_IncludeForRayTracing == value)
return;

UpdateAllLightValues();
}
}

[Range(k_MinAreaLightShadowCone, k_MaxAreaLightShadowCone)]
[SerializeField, FormerlySerializedAs("areaLightShadowCone")]
float m_AreaLightShadowCone = 120.0f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2321,8 +2321,12 @@ int PreprocessVisibleLights(HDCamera hdCamera, CullingResults cullResults, Debug

// Then we can reject lights based on processed data.
var additionalData = processedData.additionalLightData;
var lightType = processedData.lightType;

// If the camera is in ray tracing mode and the light is disabled in ray tracing mode, we skip this light.
if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.RayTracing) && !additionalData.includeForRayTracing)
continue;

var lightType = processedData.lightType;
if (ShaderConfig.s_AreaLights == 0 && (lightType == HDLightType.Area && (additionalData.areaLightShape == AreaLightShape.Rectangle || additionalData.areaLightShape == AreaLightShape.Tube)))
continue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ void BuildGPULightVolumes(HDCamera hdCamera, HDRayTracingLights rayTracingLights
Light light = currentLight.gameObject.GetComponent<Light>();
if (light == null || !light.enabled) continue;

if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.RayTracing) && !currentLight.includeForRayTracing)
continue;

// Reserve space in the cookie atlas
m_RenderPipeline.ReserveCookieAtlasTexture(currentLight, light, currentLight.type);

Expand Down