You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our light masking is too complicated at the moment. Users, our own QA folks and our own engineers are confused by it. Here's quite a [highly voted feature request](https://issuetracker-mig.prd.it.unity3d.com/issues/urp-light-culling-mask-does-not-work-when-using-forward-plus-rendering-path) that asks for support in Forward+. The twist: This is already well-supported!
See below the pseudocode of how this actually works. All the complexity goes away when you ignore culling mask, which is more of a legacy concept, and always rely on the rendering layer mask, which is a newer and better feature.
```c
// Rendering the mesh
// ------------------
if (camera.cullingMask & meshRenderer.layer) {
// Draw the mesh renderer in the game view
} else {
// Skip drawing the mesh renderer in the game view
}
// Lighting the mesh
// -----------------
if (pipeline == Forward) {
if (light.cullingMask & meshRenderer.layer) {
if (light.renderingLayers && meshRenderer.renderingLayerMask) {
// Light the mesh renderer with this light
} else {
// Skip lighting the mesh renderer with this light
}
} else {
// Skip lighting the mesh renderer with this light
}
} else {
// pipeline == Deferred or pipeline == ForwardPlus
if (light.renderingLayers && meshRenderer.renderingLayerMask) {
// Light the mesh renderer with this light
} else {
// Skip lighting the mesh renderer with this light
}
}
```
This PR makes the following changes:
1. It moves the Rendering Layers inspector field on top of the Culling Mask field. They used to be under completely different headers.

2. It shows a greyed out Rendering Layers field even when the "Use Rendering Layers" setting is off on the URP asset. In this condition, the field was totally invsible. My change improves visibility of this feature substantially.

3. If the culling mask is set to anything other than the default value of Everything, we now show a warning box advising the use of Rendering Layers instead.

Copy file name to clipboardExpand all lines: Packages/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.Skin.cs
+4-2Lines changed: 4 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -21,8 +21,9 @@ private static class Styles
21
21
publicstaticreadonlyGUIContentBakingWarning=EditorGUIUtility.TrTextContent("Light mode is currently overridden to Realtime mode. Enable Baked Global Illumination to use Mixed or Baked light modes.");
22
22
publicstaticreadonlyGUIContentDisabledLightWarning=EditorGUIUtility.TrTextContent("Lighting has been disabled in at least one Scene view. Any changes applied to lights in the Scene will not be updated in these views until Lighting has been enabled again.");
23
23
publicstaticreadonlyGUIContentSunSourceWarning=EditorGUIUtility.TrTextContent("This light is set as the current Sun Source, which requires a directional light. Go to the Lighting Window's Environment settings to edit the Sun Source.");
24
-
publicstaticreadonlyGUIContentCullingMask=EditorGUIUtility.TrTextContent("Culling Mask","Specifies which layers will be affected or excluded from the light's effect on objects in the scene. This only applies to objects rendered using the Forward rendering path, and transparent objects rendered using the Deferred rendering path. This setting is ignored in the Forward+ rendering path.");
25
-
publicstaticreadonlyGUIContentCullingMaskDisabled=EditorGUIUtility.TrTextContent("Culling Mask","Culling Mask is disabled. This is because all active renderers use the Forward+ rendering path, which doesn't support Culling Mask. To enable this setting, change the rendering path to Forward or Deferred in the active Universal Render Pipeline Asset.");
24
+
publicstaticreadonlyGUIContentCullingMask=EditorGUIUtility.TrTextContent("Culling Mask","Specifies which layers will be affected or excluded from the light's effect on objects in the scene. This only applies to objects rendered using the Forward rendering path, and transparent objects rendered using the Deferred rendering path.\n\nUse Rendering Layers instead, which is supported across all rendering paths.");
25
+
publicstaticreadonlyGUIContentCullingMaskDisabled=EditorGUIUtility.TrTextContent("Culling Mask","Culling Mask is disabled. This is because all active renderers use the Forward+ rendering path, which doesn't support Culling Mask. Use Rendering Layers instead, which is supported across all rendering paths.");
26
+
publicstaticreadonlyGUIContentCullingMaskWarning=EditorGUIUtility.TrTextContent("Culling Mask only works with Forward rendering. Instead, use Rendering Layers on the Light, and Rendering Layer Mask on the Mesh Renderer, which will work across Deferred, Forward, and Forward+ rendering.");
26
27
27
28
publicstaticreadonlyGUIContentShadowRealtimeSettings=EditorGUIUtility.TrTextContent("Realtime Shadows","Settings for realtime direct shadows.");
28
29
publicstaticreadonlyGUIContentShadowStrength=EditorGUIUtility.TrTextContent("Strength","Controls how dark the shadows cast by the light will be.");
@@ -66,6 +67,7 @@ private static class Styles
66
67
publicstaticreadonlyGUIContentLightCookieOffset=EditorGUIUtility.TrTextContent("Cookie Offset","Controls the offset of the cookie mask currently assigned to the light.");
67
68
/// <summary>Title with "Rendering Layer"</summary>
68
69
publicstaticreadonlyGUIContentRenderingLayers=EditorGUIUtility.TrTextContent("Rendering Layers","Select the Rendering Layers that the Light affects. This Light affects objects where at least one Rendering Layer value matches.");
70
+
publicstaticreadonlyGUIContentRenderingLayersDisabled=EditorGUIUtility.TrTextContent("Rendering Layers","Rendering Layers are disabled because they have a small GPU performance cost. To enable this setting, go to the active Universal Render Pipeline Asset, and enable Lighting -> Use Rendering Layers.");
0 commit comments