Skip to content

Hdrp/atlas cube modif #1235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 10, 2020
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 @@ -886,6 +886,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- PBR Sky now doesn't go black when going below sea level, but it instead freezes calculation as if on the horizon.
- Fixed an issue with quality setting foldouts not opening when clicking on them (1253088).
- Shutter speed can now be changed by dragging the mouse over the UI label (case 1245007).
- Remove the 'Point Cube Size' for cookie, use the Cubemap size directly.

## [7.1.1] - 2019-09-05

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ public class GeneralSection

public static readonly GUIContent cookieSizeContent = EditorGUIUtility.TrTextContent("Cookie Size", "Specifies the maximum size for the individual 2D cookies that HDRP uses for Directional and Spot Lights.");
public static readonly GUIContent cookieTextureArraySizeContent = EditorGUIUtility.TrTextContent("Texture Array Size", "Sets the maximum Texture Array size for the 2D cookies HDRP uses for Directional and Spot Lights. Higher values allow HDRP to use more cookies concurrently on screen.");
#if UNITY_2020_1_OR_NEWER
#else
public static readonly GUIContent pointCoockieSizeContent = EditorGUIUtility.TrTextContent("Point Cookie Size", "Specifies the maximum size for the Cube cookies HDRP uses for Point Lights.");
#endif
public static readonly GUIContent pointCookieTextureArraySizeContent = EditorGUIUtility.TrTextContent("Cubemap Array Size", "Sets the maximum Texture Array size for the Cube cookies HDRP uses for Directional and Spot Lights. Higher values allow HDRP to use more cookies concurrently on screen.");
public static readonly GUIContent maxPlanarReflectionOnScreen = EditorGUIUtility.TrTextContent("Max Planar Reflection On Screen", "Sets the maximum number of the Planar Reflection HDRP can handle on screen at once.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,10 @@ static void Drawer_SectionCookies(SerializedHDRenderPipelineAsset serialized, Ed
if (EditorGUI.EndChangeCheck())
serialized.renderPipelineSettings.lightLoopSettings.cookieAtlasLastValidMip.intValue = Mathf.Clamp(serialized.renderPipelineSettings.lightLoopSettings.cookieAtlasLastValidMip.intValue, 0, Texture2DAtlas.maxMipLevelPadding);
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightLoopSettings.cookieFormat, Styles.cookieAtlasFormatContent);
#if UNITY_2020_1_OR_NEWER
#else
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightLoopSettings.pointCookieSize, Styles.pointCoockieSizeContent);
#endif
EditorGUI.BeginChangeCheck();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ class SerializedGlobalLightLoopSettings
public SerializedProperty cookieAtlasSize;
public SerializedProperty cookieFormat;
public SerializedProperty cookieAtlasLastValidMip;
#if UNITY_2020_1_OR_NEWER
#else
public SerializedProperty pointCookieSize;
#endif
public SerializedProperty reflectionProbeCacheSize;
public SerializedProperty reflectionCubemapSize;
public SerializedProperty reflectionCacheCompressed;
Expand All @@ -32,7 +35,10 @@ public SerializedGlobalLightLoopSettings(SerializedProperty root)
cookieAtlasSize = root.Find((GlobalLightLoopSettings s) => s.cookieAtlasSize);
cookieFormat = root.Find((GlobalLightLoopSettings s) => s.cookieFormat);
cookieAtlasLastValidMip = root.Find((GlobalLightLoopSettings s) => s.cookieAtlasLastValidMip);
#if UNITY_2020_1_OR_NEWER
#else
pointCookieSize = root.Find((GlobalLightLoopSettings s) => s.pointCookieSize);
#endif

reflectionProbeCacheSize = root.Find((GlobalLightLoopSettings s) => s.reflectionProbeCacheSize);
reflectionCubemapSize = root.Find((GlobalLightLoopSettings s) => s.reflectionCubemapSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ class LightCookieManager
// Structure for cookies used by directional and spotlights
PowerOfTwoTextureAtlas m_CookieAtlas;

#if UNITY_2020_1_OR_NEWER
#else
int m_CookieCubeResolution;
#endif

// During the light loop, when reserving space for the cookies (first part of the light loop) the atlas
// can run out of space, in this case, we set to true this flag which will trigger a re-layouting of the
Expand Down Expand Up @@ -64,7 +67,10 @@ public LightCookieManager(HDRenderPipelineAsset hdAsset, int maxCacheSize)

m_CookieAtlas = new PowerOfTwoTextureAtlas(cookieAtlasSize, gLightLoopSettings.cookieAtlasLastValidMip, cookieFormat, name: "Cookie Atlas (Punctual Lights)", useMipMap: true);

#if UNITY_2020_1_OR_NEWER
#else
m_CookieCubeResolution = (int)gLightLoopSettings.pointCookieSize;
#endif
}

public void NewFrame()
Expand Down Expand Up @@ -303,7 +309,11 @@ public Vector4 FetchAreaCookie(CommandBuffer cmd, Texture cookie, Texture ies)
if (width < k_MinCookieSize || height < k_MinCookieSize)
return Vector4.zero;

int projectionSize = 2*(int)Mathf.Max((float)m_CookieCubeResolution, Mathf.Max((float)cookie.width, (float)ies.width));
#if UNITY_2020_1_OR_NEWER
int projectionSize = 2 * (int)Mathf.Max((float)cookie.width, (float)ies.width);
#else
int projectionSize = 2 * (int)Mathf.Max((float)m_CookieCubeResolution, Mathf.Max((float)cookie.width, (float)ies.width));
#endif

if (!m_CookieAtlas.IsCached(out var scaleBias, cookie, ies) && !m_NoMoreSpace)
Debug.LogError($"Area Light cookie texture {cookie} & {ies} can't be fetched without having reserved. You can try to increase the cookie atlas resolution in the HDRP settings.");
Expand Down Expand Up @@ -386,7 +396,11 @@ public Vector4 FetchCubeCookie(CommandBuffer cmd, Texture cookie)
Debug.Assert(cookie != null);
Debug.Assert(cookie.dimension == TextureDimension.Cube);

int projectionSize = 2*(int)Mathf.Max((float)m_CookieCubeResolution, (float)cookie.width);
#if UNITY_2020_1_OR_NEWER
int projectionSize = 2 * cookie.width;
#else
int projectionSize = 2 * (int)Mathf.Max((float)m_CookieCubeResolution, (float)cookie.width);
#endif
if (projectionSize < k_MinCookieSize)
return Vector4.zero;

Expand All @@ -411,7 +425,11 @@ public Vector4 FetchCubeCookie(CommandBuffer cmd, Texture cookie, Texture ies)
Debug.Assert(cookie.dimension == TextureDimension.Cube);
Debug.Assert(ies.dimension == TextureDimension.Cube);

int projectionSize = 2*(int)Mathf.Max((float)m_CookieCubeResolution, (float)cookie.width);
#if UNITY_2020_1_OR_NEWER
int projectionSize = 2 * cookie.width;
#else
int projectionSize = 2 * (int)Mathf.Max((float)m_CookieCubeResolution, (float)cookie.width);
#endif
if (projectionSize < k_MinCookieSize)
return Vector4.zero;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,11 @@ public struct GlobalLightLoopSettings
public CookieAtlasResolution cookieAtlasSize;
/// <summary>Cookie atlas graphics format.</summary>
public CookieAtlasGraphicsFormat cookieFormat;
#if UNITY_2020_1_OR_NEWER
#else
/// <summary>Cookie atlas resolution for point lights.</summary>
public CubeCookieResolution pointCookieSize;
#endif
/// <summary>Last valid mip for cookie atlas.</summary>
public int cookieAtlasLastValidMip;
// We keep this property for the migration code (we need to know how many cookies we could have before).
Expand Down