Skip to content

Commit 19a40bb

Browse files
skhiatsebastienlagarde
authored andcommitted
Enable Light Baking Cookies by default + Warning #79
1 parent 5d5bcb6 commit 19a40bb

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.Skin.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ sealed class Styles
4242
public readonly GUIContent cookieTextureTypeError = new GUIContent("HDRP does not support the Cookie Texture type, only Default is supported.", EditorGUIUtility.IconContent("console.warnicon").image);
4343
public readonly string cookieNonPOT = "HDRP does not support non power of two cookie textures.";
4444
public readonly string cookieTooSmall = "Min texture size for cookies is 2x2 pixels.";
45+
public readonly string cookieBaking = "Light Baking for cookies disabled on the Project Settings.";
4546

4647

4748
// Additional light data

com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ static void DrawShapeContent(SerializedHDLight serialized, Editor owner)
410410
case AreaLightShape.Disc:
411411
//draw the built-in area light control at the moment as everything is handled by built-in
412412
serialized.settings.DrawArea();
413-
serialized.displayAreaLightEmissiveMesh.boolValue = false; //force deactivate emissive mesh for Disc (not supported)
413+
serialized.displayAreaLightEmissiveMesh.boolValue = false; //force deactivate emissive mesh for Disc (not supported)
414414
break;
415415
case (AreaLightShape)(-1): //multiple different values
416416
using (new EditorGUI.DisabledScope(true))
@@ -722,12 +722,12 @@ static void DrawEmissionContent(SerializedHDLight serialized, Editor owner)
722722
EditorGUI.indentLevel--;
723723
}
724724

725-
ShowCookieTextureWarnings(serialized.settings.cookie);
725+
ShowCookieTextureWarnings(serialized.settings.cookie, serialized.settings.isCompletelyBaked || serialized.settings.isBakedOrMixed);
726726
}
727727
else if (serialized.areaLightShape == AreaLightShape.Rectangle || serialized.areaLightShape == AreaLightShape.Disc)
728728
{
729729
EditorGUILayout.ObjectField( serialized.areaLightCookie, s_Styles.areaLightCookie );
730-
ShowCookieTextureWarnings(serialized.areaLightCookie.objectReferenceValue as Texture);
730+
ShowCookieTextureWarnings(serialized.areaLightCookie.objectReferenceValue as Texture, serialized.settings.isCompletelyBaked || serialized.settings.isBakedOrMixed);
731731
}
732732

733733
if (EditorGUI.EndChangeCheck())
@@ -737,7 +737,7 @@ static void DrawEmissionContent(SerializedHDLight serialized, Editor owner)
737737
}
738738
}
739739

740-
static void ShowCookieTextureWarnings(Texture cookie)
740+
static void ShowCookieTextureWarnings(Texture cookie, bool useBaking)
741741
{
742742
if (cookie == null)
743743
return;
@@ -767,12 +767,14 @@ static void ShowCookieTextureWarnings(Texture cookie)
767767
}
768768
}
769769

770+
if (useBaking && UnityEditor.EditorSettings.disableCookiesInLightmapper)
771+
EditorGUILayout.HelpBox(s_Styles.cookieBaking, MessageType.Warning);
770772
if (cookie.width != cookie.height)
771773
EditorGUILayout.HelpBox(s_Styles.cookieNonPOT, MessageType.Warning);
772774
if (cookie.width < LightCookieManager.k_MinCookieSize || cookie.height < LightCookieManager.k_MinCookieSize)
773775
EditorGUILayout.HelpBox(s_Styles.cookieTooSmall, MessageType.Warning);
774776
}
775-
777+
776778
static void DrawEmissionAdvancedContent(SerializedHDLight serialized, Editor owner)
777779
{
778780
HDLightType lightType = serialized.type;
@@ -808,7 +810,7 @@ static void DrawEmissionAdvancedContent(SerializedHDLight serialized, Editor own
808810

809811
bool showSubArea = serialized.displayAreaLightEmissiveMesh.boolValue && !serialized.displayAreaLightEmissiveMesh.hasMultipleDifferentValues;
810812
++EditorGUI.indentLevel;
811-
813+
812814
Rect lineRect = EditorGUILayout.GetControlRect();
813815
ShadowCastingMode newCastShadow;
814816
EditorGUI.showMixedValue = serialized.areaLightEmissiveMeshCastShadow.hasMultipleDifferentValues;

com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ internal static Volume GetOrCreateDefaultVolume()
104104
readonly XRSystem m_XRSystem;
105105

106106
bool m_FrameSettingsHistoryEnabled = false;
107+
bool m_DisableCookieForLightBaking = false;
107108

108109
/// <summary>
109110
/// This functions allows the user to have an approximation of the number of rays that were traced for a given frame.
@@ -663,6 +664,9 @@ void SetRenderingFeatures()
663664
GraphicsSettings.lightsUseLinearIntensity = true;
664665
GraphicsSettings.lightsUseColorTemperature = true;
665666

667+
m_DisableCookieForLightBaking = UnityEditor.EditorSettings.disableCookiesInLightmapper;
668+
UnityEditor.EditorSettings.disableCookiesInLightmapper = false;
669+
666670
GraphicsSettings.useScriptableRenderPipelineBatching = m_Asset.enableSRPBatcher;
667671

668672
SupportedRenderingFeatures.active = new SupportedRenderingFeatures()
@@ -779,6 +783,8 @@ void UnsetRenderingFeatures()
779783
// Reset srp batcher state just in case
780784
GraphicsSettings.useScriptableRenderPipelineBatching = false;
781785

786+
UnityEditor.EditorSettings.disableCookiesInLightmapper = m_DisableCookieForLightBaking;
787+
782788
Lightmapping.ResetDelegate();
783789
}
784790

0 commit comments

Comments
 (0)