Fail more gracefully on platforms without compute shaders.

This commit is contained in:
Robert Cupisz 2017-10-08 22:53:04 +02:00
parent 5597b04fcc
commit d82679ae5d
4 changed files with 49 additions and 1 deletions

View File

@ -0,0 +1,17 @@
using UnityEditor;
[CustomEditor(typeof(VolumetricFog))]
[CanEditMultipleObjects]
public class VolumetricFogEditor : Editor
{
override public void OnInspectorGUI()
{
if (!VolumetricFog.CheckSupport())
{
EditorGUILayout.HelpBox(VolumetricFog.GetUnsupportedErrorMessage(), MessageType.Error);
return;
}
DrawDefaultInspector();
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 9dc42dc79f60fe8449ca035a77f732ae
timeCreated: 1507493299
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -520,6 +520,14 @@ public class VolumetricFog : MonoBehaviour
[ImageEffectOpaque]
void OnRenderImage(RenderTexture src, RenderTexture dest)
{
if (!CheckSupport())
{
Debug.LogError(GetUnsupportedErrorMessage());
Graphics.Blit(src, dest);
enabled = false;
return;
}
if(m_Debug)
{
DebugDisplay(src, dest);
@ -684,4 +692,15 @@ public class VolumetricFog : MonoBehaviour
Gizmos.matrix = transform.localToWorldMatrix;
Gizmos.DrawFrustum(Vector3.zero, cam.fieldOfView, farClip, nearClip, cam.aspect);
}
public static bool CheckSupport()
{
return SystemInfo.supportsComputeShaders;
}
public static string GetUnsupportedErrorMessage()
{
return "Volumetric Fog requires compute shaders and this platform doesn't support them. Disabling. \nDetected device type: " +
SystemInfo.graphicsDeviceType + ", version: " + SystemInfo.graphicsDeviceVersion;
}
}

View File

@ -1 +1 @@
m_EditorVersion: 5.6.0f3
m_EditorVersion: 2017.1.2f1