Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Commit bd53778

Browse files
committed
Use R11G11B10 as default HDR format on mobiles
1 parent 2baf891 commit bd53778

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

PostProcessing/Runtime/PostProcessLayer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ void OnPreRender()
309309
void BuildCommandBuffers()
310310
{
311311
var context = m_CurrentContext;
312-
var sourceFormat = m_Camera.allowHDR ? RenderTextureFormat.DefaultHDR : RenderTextureFormat.Default;
312+
var sourceFormat = m_Camera.allowHDR ? RuntimeUtilities.defaultHDRRenderTextureFormat : RenderTextureFormat.Default;
313313

314314
context.Reset();
315315
context.camera = m_Camera;

PostProcessing/Runtime/Utils/RuntimeUtilities.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
using System.Text;
77
using UnityEngine.Assertions;
88

9+
#if UNITY_EDITOR
10+
using UnityEditor;
11+
#endif
12+
913
namespace UnityEngine.Rendering.PostProcessing
1014
{
1115
using SceneManagement;
@@ -283,6 +287,24 @@ public static bool isAndroidOpenGL
283287
get { return Application.platform == RuntimePlatform.Android && SystemInfo.graphicsDeviceType != GraphicsDeviceType.Vulkan; }
284288
}
285289

290+
public static RenderTextureFormat defaultHDRRenderTextureFormat
291+
{
292+
get
293+
{
294+
#if UNITY_ANDROID || UNITY_IPHONE || UNITY_TVOS || UNITY_SWITCH || UNITY_EDITOR
295+
RenderTextureFormat format = RenderTextureFormat.RGB111110Float;
296+
# if UNITY_EDITOR
297+
var target = EditorUserBuildSettings.activeBuildTarget;
298+
if (target != BuildTarget.Android && target != BuildTarget.iOS && target != BuildTarget.tvOS && target != BuildTarget.Switch)
299+
return RenderTextureFormat.DefaultHDR;
300+
# endif // UNITY_EDITOR
301+
if (format.IsSupported())
302+
return format;
303+
#endif // UNITY_ANDROID || UNITY_IPHONE || UNITY_TVOS || UNITY_SWITCH || UNITY_EDITOR
304+
return RenderTextureFormat.DefaultHDR;
305+
}
306+
}
307+
286308
public static void Destroy(UnityObject obj)
287309
{
288310
if (obj != null)

0 commit comments

Comments
 (0)