mirror of
https://github.com/maxartz15/VolumetricLighting.git
synced 2024-11-12 18:05:31 +01:00
Fail more gracefully on platforms without compute shaders.
This commit is contained in:
parent
5597b04fcc
commit
d82679ae5d
17
Assets/VolumetricFog/Editor/VolumetricFogEditor.cs
Normal file
17
Assets/VolumetricFog/Editor/VolumetricFogEditor.cs
Normal 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();
|
||||
}
|
||||
}
|
12
Assets/VolumetricFog/Editor/VolumetricFogEditor.cs.meta
Normal file
12
Assets/VolumetricFog/Editor/VolumetricFogEditor.cs.meta
Normal 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:
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
m_EditorVersion: 5.6.0f3
|
||||
m_EditorVersion: 2017.1.2f1
|
||||
|
Loading…
Reference in New Issue
Block a user