Skip to content

Commit

Permalink
[PPV2] PPB-6 Disabled compute effects on WebGL and Android OpenGL (#7936
Browse files Browse the repository at this point in the history
)

* Disabled compute based effects not supported on WebGL and Android OpenGL
* Improved editor warning messages.
* Fix editor warning messages.
  • Loading branch information
BenGraterUnity authored Aug 9, 2023
1 parent 9df55b7 commit 8885e24
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 4 deletions.
1 change: 1 addition & 0 deletions com.unity.postprocessing/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Fixed
- Fixed obsolete FormatUsage bug
- Disabled compute based effects not supported on WebGL and Android OpenGL

## [3.3.0] - 2023-05-11

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ public override void OnInspectorGUI()
}
else if (aoMode == (int)AmbientOcclusionMode.MultiScaleVolumetricObscurance)
{
if (!SystemInfo.supportsComputeShaders)
EditorGUILayout.HelpBox("Multi-scale volumetric obscurance requires compute shader support.", MessageType.Warning);
if (!SystemInfo.supportsComputeShaders || EditorUtilities.isTargetingWebGL)
{
EditorGUILayout.HelpBox("Multi-scale volumetric obscurance requires compute shader support which is not available on this platform.", MessageType.Error);
}
else if(EditorUtilities.isTargetingAndroid)
{
EditorGUILayout.HelpBox("Multi-scale volumetric obscurance requires compute shader support (Vulkan) when running on Android.", MessageType.Warning);
}

PropertyField(m_ThicknessModifier);
PropertyField(m_ZBias);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,14 @@ public override void OnEnable()

public override void OnInspectorGUI()
{
if (!SystemInfo.supportsComputeShaders)
EditorGUILayout.HelpBox("Auto exposure requires compute shader support.", MessageType.Warning);
if (!SystemInfo.supportsComputeShaders || EditorUtilities.isTargetingWebGL)
{
EditorGUILayout.HelpBox("Auto exposure requires compute shader support which is not available on this platform.", MessageType.Error);
}
else if (EditorUtilities.isTargetingAndroid)
{
EditorGUILayout.HelpBox("Auto exposure requires compute shader support (Vulkan) when running on Android.", MessageType.Warning);
}

EditorUtilities.DrawHeaderLabel("Exposure");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,30 @@ public static bool isTargetingMobiles
}
}

/// <summary>
/// Returns <c>true</c> if the current target is Android, <c>false</c> otherwise.
/// </summary>
public static bool isTargetingAndroid
{
get
{
var t = EditorUserBuildSettings.activeBuildTarget;
return t == BuildTarget.Android;
}
}

/// <summary>
/// Returns <c>true</c> if the current target is WebGL, <c>false</c> otherwise.
/// </summary>
public static bool isTargetingWebGL
{
get
{
var t = EditorUserBuildSettings.activeBuildTarget;
return t == BuildTarget.WebGL;
}
}

/// <summary>
/// Returns <c>true</c> if the current target is a console or a mobile, <c>false</c>
/// otherwise.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ public override bool IsEnabledAndSupported(PostProcessRenderContext context)

state &= SystemInfo.supportsComputeShaders
&& !RuntimeUtilities.isAndroidOpenGL
&& !RuntimeUtilities.isWebGL
#if UNITY_2023_2_OR_NEWER
&& SystemInfo.IsFormatSupported(GraphicsFormat.R32_SFloat, GraphicsFormatUsage.Render)
&& SystemInfo.IsFormatSupported(GraphicsFormat.R16_SFloat, GraphicsFormatUsage.Render)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public override bool IsEnabledAndSupported(PostProcessRenderContext context)
return enabled.value
&& SystemInfo.supportsComputeShaders
&& !RuntimeUtilities.isAndroidOpenGL
&& !RuntimeUtilities.isWebGL
&& RenderTextureFormat.RFloat.IsSupported()
&& context.resources.computeShaders.autoExposure
&& context.resources.computeShaders.exposureHistogram;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public bool IsRequestedAndSupported(PostProcessRenderContext context)
return requested
&& SystemInfo.supportsComputeShaders
&& !RuntimeUtilities.isAndroidOpenGL
&& !RuntimeUtilities.isWebGL
&& ShaderResourcesAvailable(context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,21 @@ public static bool isAndroidOpenGL
get { return Application.platform == RuntimePlatform.Android && SystemInfo.graphicsDeviceType != GraphicsDeviceType.Vulkan; }
}

/// <summary>
/// Returns <c>true</c> if the target platform is WebGL,
/// <c>false</c> otherwise.
/// </summary>
public static bool isWebGL
{
get {
#if UNITY_WEBGL
return true;
#else
return false;
#endif
}
}

/// <summary>
/// Gets the default HDR render texture format for the current target platform.
/// </summary>
Expand Down

0 comments on commit 8885e24

Please sign in to comment.