Skip to content

Commit 293c7a3

Browse files
gabrieldelacruzEvergreen
authored andcommitted
[Particles] Add rendering layer support to Particles Lit shader
1 parent 691fa28 commit 293c7a3

5 files changed

Lines changed: 20 additions & 4 deletions

File tree

Packages/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.Drawers.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,21 @@ static void DrawRenderingContent(UniversalRenderPipelineSerializedLight serializ
272272
{
273273
EditorGUI.BeginChangeCheck();
274274
GUI.enabled = UniversalRenderPipeline.asset.useRenderingLayers;
275-
EditorGUILayout.PropertyField(serializedLight.renderingLayers, UniversalRenderPipeline.asset.useRenderingLayers ? Styles.RenderingLayers : Styles.RenderingLayersDisabled);
275+
EditorGUILayout.PropertyField(serializedLight.renderingLayers, Styles.RenderingLayers);
276276
GUI.enabled = true;
277277
if (EditorGUI.EndChangeCheck())
278278
{
279279
if (!serializedLight.customShadowLayers.boolValue)
280280
SyncLightAndShadowLayers(serializedLight, serializedLight.renderingLayers);
281281
}
282+
if (!UniversalRenderPipeline.asset.useRenderingLayers)
283+
{
284+
CoreEditorUtils.DrawFixMeBox(Styles.RenderingLayersHelpBox, () =>
285+
{
286+
UniversalRenderPipeline.asset.useRenderingLayers = true;
287+
EditorUtility.SetDirty(UniversalRenderPipeline.asset);
288+
});
289+
}
282290
}
283291

284292
EditorGUILayout.PropertyField(serializedLight.settings.cullingMask, Styles.CullingMask);

Packages/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.Skin.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ private static class Styles
5959
EditorGUIUtility.TrTextContent("Use settings from Render Pipeline Asset")
6060
};
6161

62-
public static readonly GUIContent customShadowLayers = EditorGUIUtility.TrTextContent("Custom Shadow Layers", "When enabled, you can use the Layer property below to specify the layers for shadows seperately to lighting. When disabled, the Light Layer property in the General section specifies the layers for both lighting and for shadows.");
62+
public static readonly GUIContent customShadowLayers = EditorGUIUtility.TrTextContent("Custom Shadow Layers", "When enabled, you can use the Layer property below to specify the layers for shadows separately to lighting. When disabled, the Light Layer property in the General section specifies the layers for both lighting and for shadows.");
6363
public static readonly GUIContent ShadowLayer = EditorGUIUtility.TrTextContent("Layer", "Specifies the light layer to use for shadows.");
6464

6565
public static readonly GUIContent LightCookieSize = EditorGUIUtility.TrTextContent("Cookie Size", "Controls the size of the cookie mask currently assigned to the light.");
6666
public static readonly GUIContent LightCookieOffset = EditorGUIUtility.TrTextContent("Cookie Offset", "Controls the offset of the cookie mask currently assigned to the light.");
6767
/// <summary>Title with "Rendering Layer"</summary>
6868
public static readonly GUIContent RenderingLayers = EditorGUIUtility.TrTextContent("Rendering Layers", "Select the Rendering Layers that the Light affects. This Light affects objects where at least one Rendering Layer value matches.");
69-
public static readonly GUIContent RenderingLayersDisabled = 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.");
69+
public static readonly GUIContent RenderingLayersHelpBox = EditorGUIUtility.TrTextContentWithIcon($"Rendering Layers are disabled by default because they have a small GPU performance cost. Enable them in the active Universal Render Pipeline Asset, under Lighting -> Use Rendering Layers.", CoreEditorStyles.GetMessageTypeIcon(MessageType.Info));
7070
}
7171
}
7272
}

Packages/com.unity.render-pipelines.universal/Runtime/Data/UniversalRenderPipelineAsset.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1589,7 +1589,11 @@ public bool supportsDynamicBatching
15891589
/// <summary>
15901590
/// Returns true if the Render Pipeline Asset supports rendering layers for lights, false otherwise.
15911591
/// </summary>
1592-
public bool useRenderingLayers => m_SupportsLightLayers;
1592+
public bool useRenderingLayers
1593+
{
1594+
get => m_SupportsLightLayers;
1595+
internal set => m_SupportsLightLayers = value;
1596+
}
15931597

15941598
/// <summary>
15951599
/// Returns the selected update mode for volumes.

Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLit.shader

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ Shader "Universal Render Pipeline/Particles/Lit"
143143
#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
144144
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
145145
#pragma multi_compile_fragment _ _LIGHT_COOKIES
146+
#pragma multi_compile _ _LIGHT_LAYERS
146147
#pragma multi_compile _ _CLUSTER_LIGHT_LOOP
147148
#pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX
148149
#if defined(UNITY_PLATFORM_META_QUEST)
@@ -152,6 +153,7 @@ Shader "Universal Render Pipeline/Particles/Lit"
152153
#include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
153154
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Fog.hlsl"
154155
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl"
156+
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
155157

156158
// -------------------------------------
157159
// Unity defined keywords

Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLit.shader

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ Shader "Universal Render Pipeline/Particles/Simple Lit"
143143
#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
144144
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
145145
#pragma multi_compile_fragment _ _LIGHT_COOKIES
146+
#pragma multi_compile _ _LIGHT_LAYERS
146147
#pragma multi_compile _ _CLUSTER_LIGHT_LOOP
147148
#pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX
148149
#if defined(UNITY_PLATFORM_META_QUEST)
@@ -152,6 +153,7 @@ Shader "Universal Render Pipeline/Particles/Simple Lit"
152153
#include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
153154
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Fog.hlsl"
154155
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl"
156+
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
155157

156158
// -------------------------------------
157159
// Unity defined keywords

0 commit comments

Comments
 (0)