123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628 |
- using UnityEngine;
- using UnityEditorInternal;
- using System.Linq;
- using System.Collections.Generic;
- using UnityEngine.Rendering;
- using UnityEngine.Rendering.Universal;
-
- namespace UnityEditor.Rendering.Universal.ShaderGUI
- {
- /// <summary>
- /// Editor script for the particle material inspector.
- /// </summary>
- public static class ParticleGUI
- {
- /// <summary>
- /// The available color modes.
- /// Controls how the Particle color and the Material color blend together.
- /// </summary>
- public enum ColorMode
- {
- /// <summary>
- /// Use this to select multiply mode.
- /// </summary>
- Multiply,
-
- /// <summary>
- /// Use this to select additive mode.
- /// </summary>
- Additive,
-
- /// <summary>
- /// Use this to select subtractive mode.
- /// </summary>
- Subtractive,
-
- /// <summary>
- /// Use this to select overlay mode.
- /// </summary>
- Overlay,
-
- /// <summary>
- /// Use this to select color mode.
- /// </summary>
- Color,
-
- /// <summary>
- /// Use this to select difference mode.
- /// </summary>
- Difference
- }
-
- /// <summary>
- /// Container for the text and tooltips used to display the shader.
- /// </summary>
- public static class Styles
- {
- /// <summary>
- /// The text and tooltip color mode.
- /// </summary>
- public static GUIContent colorMode = EditorGUIUtility.TrTextContent("Color Mode",
- "Controls how the Particle color and the Material color blend together.");
-
- /// <summary>
- /// The text and tooltip flip-book blending.
- /// </summary>
- public static GUIContent flipbookMode = EditorGUIUtility.TrTextContent("Flip-Book Blending",
- "Blends the frames in a flip-book together in a smooth animation.");
-
- /// <summary>
- /// The text and tooltip soft particles.
- /// </summary>
- public static GUIContent softParticlesEnabled = EditorGUIUtility.TrTextContent("Soft Particles",
- "Makes particles fade out when they get close to intersecting with the surface of other geometry in the depth buffer.");
-
- /// <summary>
- /// The text and tooltip soft particles surface fade.
- /// </summary>
- public static GUIContent softParticlesFadeText = EditorGUIUtility.TrTextContent("Surface Fade");
-
- /// <summary>
- /// The text and tooltip soft particles near fade distance.
- /// </summary>
- public static GUIContent softParticlesNearFadeDistanceText =
- EditorGUIUtility.TrTextContent("Near",
- "The distance from the other surface where the particle is completely transparent.");
-
- /// <summary>
- /// The text and tooltip soft particles far fade distance.
- /// </summary>
- public static GUIContent softParticlesFarFadeDistanceText =
- EditorGUIUtility.TrTextContent("Far",
- "The distance from the other surface where the particle is completely opaque.");
-
- /// <summary>
- /// The text and tooltip camera fading.
- /// </summary>
- public static GUIContent cameraFadingEnabled = EditorGUIUtility.TrTextContent("Camera Fading",
- "Makes particles fade out when they get close to the camera.");
-
- /// <summary>
- /// The text and tooltip camera fading distance.
- /// </summary>
- public static GUIContent cameraFadingDistanceText = EditorGUIUtility.TrTextContent("Distance");
-
- /// <summary>
- /// The text and tooltip camera fading near distance.
- /// </summary>
- public static GUIContent cameraNearFadeDistanceText =
- EditorGUIUtility.TrTextContent("Near",
- "The distance from the camera where the particle is completely transparent.");
-
- /// <summary>
- /// The text and tooltip camera fading far distance.
- /// </summary>
- public static GUIContent cameraFarFadeDistanceText =
- EditorGUIUtility.TrTextContent("Far", "The distance from the camera where the particle is completely opaque.");
-
- /// <summary>
- /// The text and tooltip distortion.
- /// </summary>
- public static GUIContent distortionEnabled = EditorGUIUtility.TrTextContent("Distortion",
- "Creates a distortion effect by making particles perform refraction with the objects drawn before them.");
-
- /// <summary>
- /// The text and tooltip distortion strength.
- /// </summary>
- public static GUIContent distortionStrength = EditorGUIUtility.TrTextContent("Strength",
- "Controls how much the Particle distorts the background. ");
-
- /// <summary>
- /// The text and tooltip distortion blend.
- /// </summary>
- public static GUIContent distortionBlend = EditorGUIUtility.TrTextContent("Blend",
- "Controls how visible the distortion effect is. At 0, there’s no visible distortion. At 1, only the distortion effect is visible, not the background.");
-
- /// <summary>
- /// The text and tooltip for vertex streams.
- /// </summary>
- public static GUIContent VertexStreams = EditorGUIUtility.TrTextContent("Vertex Streams",
- "List detailing the expected layout of data sent to the shader from the particle system.");
-
- /// <summary>
- /// The string for position vertex stream.
- /// </summary>
- public static string streamPositionText = "Position (POSITION.xyz)";
-
- /// <summary>
- /// The string for normal vertex stream.
- /// </summary>
- public static string streamNormalText = "Normal (NORMAL.xyz)";
-
- /// <summary>
- /// The string for color vertex stream.
- /// </summary>
- public static string streamColorText = "Color (COLOR.xyzw)";
-
- /// <summary>
- /// The string for color instanced vertex stream.
- /// </summary>
- public static string streamColorInstancedText = "Color (INSTANCED0.xyzw)";
-
- /// <summary>
- /// The string for UV vertex stream.
- /// </summary>
- public static string streamUVText = "UV (TEXCOORD0.xy)";
-
- /// <summary>
- /// The string for UV2 vertex stream.
- /// </summary>
- public static string streamUV2Text = "UV2 (TEXCOORD0.zw)";
-
- /// <summary>
- /// The string for AnimBlend Texcoord1 vertex stream.
- /// </summary>
- public static string streamAnimBlendText = "AnimBlend (TEXCOORD1.x)";
-
- /// <summary>
- /// The string for AnimBlend Instanced1 vertex stream.
- /// </summary>
- public static string streamAnimFrameText = "AnimFrame (INSTANCED1.x)";
-
- /// <summary>
- /// The string for tangent vertex stream.
- /// </summary>
- public static string streamTangentText = "Tangent (TANGENT.xyzw)";
-
- /// <summary>
- /// The text and tooltip for the vertex stream fix now GUI.
- /// </summary>
- public static GUIContent streamApplyToAllSystemsText = EditorGUIUtility.TrTextContent("Fix Now",
- "Apply the vertex stream layout to all Particle Systems using this material");
-
- /// <summary>
- /// The string for applying custom vertex streams from material.
- /// </summary>
- public static string undoApplyCustomVertexStreams = L10n.Tr("Apply custom vertex streams from material");
-
- /// <summary>
- /// The vertex stream icon.
- /// </summary>
- public static GUIStyle vertexStreamIcon = new GUIStyle();
- }
-
- private static ReorderableList vertexStreamList;
-
- /// <summary>
- /// Container for the properties used in the <c>ParticleGUI</c> editor script.
- /// </summary>
- public struct ParticleProperties
- {
- // Surface Option Props
-
- /// <summary>
- /// The MaterialProperty for color mode.
- /// </summary>
- public MaterialProperty colorMode;
-
-
- // Advanced Props
-
- /// <summary>
- /// The MaterialProperty for flip-book blending.
- /// </summary>
- public MaterialProperty flipbookMode;
-
- /// <summary>
- /// The MaterialProperty for soft particles enabled.
- /// </summary>
- public MaterialProperty softParticlesEnabled;
-
- /// <summary>
- /// The MaterialProperty for camera fading.
- /// </summary>
- public MaterialProperty cameraFadingEnabled;
-
- /// <summary>
- /// The MaterialProperty for distortion enabled.
- /// </summary>
- public MaterialProperty distortionEnabled;
-
- /// <summary>
- /// The MaterialProperty for soft particles near fade distance.
- /// </summary>
- public MaterialProperty softParticlesNearFadeDistance;
-
- /// <summary>
- /// The MaterialProperty for soft particles far fade distance.
- /// </summary>
- public MaterialProperty softParticlesFarFadeDistance;
-
- /// <summary>
- /// The MaterialProperty for camera fading near distance.
- /// </summary>
- public MaterialProperty cameraNearFadeDistance;
-
- /// <summary>
- /// The MaterialProperty for camera fading far distance.
- /// </summary>
- public MaterialProperty cameraFarFadeDistance;
-
- /// <summary>
- /// The MaterialProperty for distortion blend.
- /// </summary>
- public MaterialProperty distortionBlend;
-
- /// <summary>
- /// The MaterialProperty for distortion strength.
- /// </summary>
- public MaterialProperty distortionStrength;
-
- /// <summary>
- /// Constructor for the <c>ParticleProperties</c> container struct.
- /// </summary>
- /// <param name="properties"></param>
- public ParticleProperties(MaterialProperty[] properties)
- {
- // Surface Option Props
- colorMode = BaseShaderGUI.FindProperty("_ColorMode", properties, false);
-
- // Advanced Props
- flipbookMode = BaseShaderGUI.FindProperty("_FlipbookBlending", properties);
- softParticlesEnabled = BaseShaderGUI.FindProperty("_SoftParticlesEnabled", properties);
- cameraFadingEnabled = BaseShaderGUI.FindProperty("_CameraFadingEnabled", properties);
- distortionEnabled = BaseShaderGUI.FindProperty("_DistortionEnabled", properties, false);
- softParticlesNearFadeDistance = BaseShaderGUI.FindProperty("_SoftParticlesNearFadeDistance", properties);
- softParticlesFarFadeDistance = BaseShaderGUI.FindProperty("_SoftParticlesFarFadeDistance", properties);
- cameraNearFadeDistance = BaseShaderGUI.FindProperty("_CameraNearFadeDistance", properties);
- cameraFarFadeDistance = BaseShaderGUI.FindProperty("_CameraFarFadeDistance", properties);
- distortionBlend = BaseShaderGUI.FindProperty("_DistortionBlend", properties, false);
- distortionStrength = BaseShaderGUI.FindProperty("_DistortionStrength", properties, false);
- }
- }
-
- /// <summary>
- /// Sets up the material with correct keywords based on the color mode.
- /// </summary>
- /// <param name="material">The material to use.</param>
- public static void SetupMaterialWithColorMode(Material material)
- {
- var colorMode = (ColorMode)material.GetFloat("_ColorMode");
-
- switch (colorMode)
- {
- case ColorMode.Multiply:
- material.DisableKeyword("_COLOROVERLAY_ON");
- material.DisableKeyword("_COLORCOLOR_ON");
- material.DisableKeyword("_COLORADDSUBDIFF_ON");
- break;
- case ColorMode.Overlay:
- material.DisableKeyword("_COLORCOLOR_ON");
- material.DisableKeyword("_COLORADDSUBDIFF_ON");
- material.EnableKeyword("_COLOROVERLAY_ON");
- break;
- case ColorMode.Color:
- material.DisableKeyword("_COLOROVERLAY_ON");
- material.DisableKeyword("_COLORADDSUBDIFF_ON");
- material.EnableKeyword("_COLORCOLOR_ON");
- break;
- case ColorMode.Difference:
- material.DisableKeyword("_COLOROVERLAY_ON");
- material.DisableKeyword("_COLORCOLOR_ON");
- material.EnableKeyword("_COLORADDSUBDIFF_ON");
- material.SetVector("_BaseColorAddSubDiff", new Vector4(-1.0f, 1.0f, 0.0f, 0.0f));
- break;
- case ColorMode.Additive:
- material.DisableKeyword("_COLOROVERLAY_ON");
- material.DisableKeyword("_COLORCOLOR_ON");
- material.EnableKeyword("_COLORADDSUBDIFF_ON");
- material.SetVector("_BaseColorAddSubDiff", new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
- break;
- case ColorMode.Subtractive:
- material.DisableKeyword("_COLOROVERLAY_ON");
- material.DisableKeyword("_COLORCOLOR_ON");
- material.EnableKeyword("_COLORADDSUBDIFF_ON");
- material.SetVector("_BaseColorAddSubDiff", new Vector4(-1.0f, 0.0f, 0.0f, 0.0f));
- break;
- }
- }
-
- /// <summary>
- /// Draws the fading options GUI.
- /// </summary>
- /// <param name="material">The material to use.</param>
- /// <param name="materialEditor">The material editor to use.</param>
- /// <param name="properties">The particle properties to use.</param>
- public static void FadingOptions(Material material, MaterialEditor materialEditor, ParticleProperties properties)
- {
- // Z write doesn't work with fading
- bool hasZWrite = (material.GetFloat("_ZWrite") > 0.0f);
- if (!hasZWrite)
- {
- // Soft Particles
- {
- materialEditor.ShaderProperty(properties.softParticlesEnabled, Styles.softParticlesEnabled);
- if (properties.softParticlesEnabled.floatValue >= 0.5f)
- {
- UniversalRenderPipelineAsset urpAsset = UniversalRenderPipeline.asset;
- if (urpAsset != null && !urpAsset.supportsCameraDepthTexture)
- {
- GUIStyle warnStyle = new GUIStyle(GUI.skin.label);
- warnStyle.fontStyle = FontStyle.BoldAndItalic;
- warnStyle.wordWrap = true;
- EditorGUILayout.HelpBox("Soft Particles require depth texture. Please enable \"Depth Texture\" in the Universal Render Pipeline settings.", MessageType.Warning);
- }
-
- EditorGUI.indentLevel++;
- BaseShaderGUI.TwoFloatSingleLine(Styles.softParticlesFadeText,
- properties.softParticlesNearFadeDistance,
- Styles.softParticlesNearFadeDistanceText,
- properties.softParticlesFarFadeDistance,
- Styles.softParticlesFarFadeDistanceText,
- materialEditor);
- EditorGUI.indentLevel--;
- }
- }
-
- // Camera Fading
- {
- materialEditor.ShaderProperty(properties.cameraFadingEnabled, Styles.cameraFadingEnabled);
- if (properties.cameraFadingEnabled.floatValue >= 0.5f)
- {
- EditorGUI.indentLevel++;
- BaseShaderGUI.TwoFloatSingleLine(Styles.cameraFadingDistanceText,
- properties.cameraNearFadeDistance,
- Styles.cameraNearFadeDistanceText,
- properties.cameraFarFadeDistance,
- Styles.cameraFarFadeDistanceText,
- materialEditor);
- EditorGUI.indentLevel--;
- }
- }
-
- // Distortion
- if (properties.distortionEnabled != null)
- {
- materialEditor.ShaderProperty(properties.distortionEnabled, Styles.distortionEnabled);
- if (properties.distortionEnabled.floatValue >= 0.5f)
- {
- EditorGUI.indentLevel++;
- materialEditor.ShaderProperty(properties.distortionStrength, Styles.distortionStrength);
- materialEditor.ShaderProperty(properties.distortionBlend, Styles.distortionBlend);
- EditorGUI.indentLevel--;
- }
- }
-
- EditorGUI.showMixedValue = false;
- }
- }
-
- /// <summary>
- /// Draws the vertex streams area.
- /// </summary>
- /// <param name="material">The material to use.</param>
- /// <param name="renderers">List of particle system renderers.</param>
- /// <param name="useLighting">Marks whether the renderers uses lighting or not.</param>
- public static void DoVertexStreamsArea(Material material, List<ParticleSystemRenderer> renderers, bool useLighting = false)
- {
- EditorGUILayout.Space();
- // Display list of streams required to make this shader work
- bool useNormalMap = false;
- bool useFlipbookBlending = (material.GetFloat("_FlipbookBlending") > 0.0f);
- if (material.HasProperty("_BumpMap"))
- useNormalMap = material.GetTexture("_BumpMap");
-
- bool useGPUInstancing = ShaderUtil.HasProceduralInstancing(material.shader);
- if (useGPUInstancing && renderers.Count > 0)
- {
- if (!renderers[0].enableGPUInstancing || renderers[0].renderMode != ParticleSystemRenderMode.Mesh)
- useGPUInstancing = false;
- }
-
- // Build the list of expected vertex streams
- List<ParticleSystemVertexStream> streams = new List<ParticleSystemVertexStream>();
- List<string> streamList = new List<string>();
-
- streams.Add(ParticleSystemVertexStream.Position);
- streamList.Add(Styles.streamPositionText);
-
- if (useLighting || useNormalMap)
- {
- streams.Add(ParticleSystemVertexStream.Normal);
- streamList.Add(Styles.streamNormalText);
- if (useNormalMap)
- {
- streams.Add(ParticleSystemVertexStream.Tangent);
- streamList.Add(Styles.streamTangentText);
- }
- }
-
- streams.Add(ParticleSystemVertexStream.Color);
- streamList.Add(useGPUInstancing ? Styles.streamColorInstancedText : Styles.streamColorText);
- streams.Add(ParticleSystemVertexStream.UV);
- streamList.Add(Styles.streamUVText);
-
- List<ParticleSystemVertexStream> instancedStreams = new List<ParticleSystemVertexStream>(streams);
-
- if (useGPUInstancing)
- {
- instancedStreams.Add(ParticleSystemVertexStream.AnimFrame);
- streamList.Add(Styles.streamAnimFrameText);
- }
- else if (useFlipbookBlending && !useGPUInstancing)
- {
- streams.Add(ParticleSystemVertexStream.UV2);
- streamList.Add(Styles.streamUV2Text);
- streams.Add(ParticleSystemVertexStream.AnimBlend);
- streamList.Add(Styles.streamAnimBlendText);
- }
-
- vertexStreamList = new ReorderableList(streamList, typeof(string), false, true, false, false);
-
- vertexStreamList.drawHeaderCallback = (Rect rect) =>
- {
- EditorGUI.LabelField(rect, Styles.VertexStreams);
- };
-
- vertexStreamList.DoLayoutList();
-
- // Display a warning if any renderers have incorrect vertex streams
- string Warnings = "";
- List<ParticleSystemVertexStream> rendererStreams = new List<ParticleSystemVertexStream>();
- foreach (ParticleSystemRenderer renderer in renderers)
- {
- renderer.GetActiveVertexStreams(rendererStreams);
-
- bool streamsValid;
- if (useGPUInstancing && renderer.renderMode == ParticleSystemRenderMode.Mesh && renderer.supportsMeshInstancing)
- streamsValid = CompareVertexStreams(rendererStreams, instancedStreams);
- else
- streamsValid = CompareVertexStreams(rendererStreams, streams);
-
- if (!streamsValid)
- Warnings += "-" + renderer.name + "\n";
- }
-
- if (!string.IsNullOrEmpty(Warnings))
- {
- EditorGUILayout.HelpBox(
- "The following Particle System Renderers are using this material with incorrect Vertex Streams:\n" +
- Warnings, MessageType.Error, true);
- // Set the streams on all systems using this material
- if (GUILayout.Button(Styles.streamApplyToAllSystemsText, EditorStyles.miniButton, GUILayout.ExpandWidth(true)))
- {
- Undo.RecordObjects(renderers.Where(r => r != null).ToArray(), Styles.undoApplyCustomVertexStreams);
-
- foreach (ParticleSystemRenderer renderer in renderers)
- {
- if (useGPUInstancing && renderer.renderMode == ParticleSystemRenderMode.Mesh && renderer.supportsMeshInstancing)
- renderer.SetActiveVertexStreams(instancedStreams);
- else
- renderer.SetActiveVertexStreams(streams);
- }
- }
- }
- }
-
- private static bool CompareVertexStreams(IEnumerable<ParticleSystemVertexStream> a, IEnumerable<ParticleSystemVertexStream> b)
- {
- var differenceA = a.Except(b);
- var differenceB = b.Except(a);
- var difference = differenceA.Union(differenceB).Distinct();
- if (!difference.Any())
- return true;
- // If normals are the only difference, ignore them, because the default particle streams include normals, to make it easy for users to switch between lit and unlit
- if (difference.Count() == 1)
- {
- if (difference.First() == ParticleSystemVertexStream.Normal)
- return true;
- }
- return false;
- }
-
- /// <summary>
- /// Sets up the keywords for the material and shader.
- /// </summary>
- /// <param name="material">The material to use.</param>
- public static void SetMaterialKeywords(Material material)
- {
- // Setup particle + material color blending
- SetupMaterialWithColorMode(material);
- // Is the material transparent, this is set in BaseShaderGUI
- bool isTransparent = material.GetTag("RenderType", false) == "Transparent";
- // Z write doesn't work with distortion/fading
- bool hasZWrite = (material.GetFloat("_ZWrite") > 0.0f);
-
- // Flipbook blending
- if (material.HasProperty("_FlipbookBlending"))
- {
- var useFlipbookBlending = (material.GetFloat("_FlipbookBlending") > 0.0f);
- CoreUtils.SetKeyword(material, "_FLIPBOOKBLENDING_ON", useFlipbookBlending);
- }
- // Soft particles
- var useSoftParticles = false;
- if (material.HasProperty("_SoftParticlesEnabled"))
- {
- useSoftParticles = (material.GetFloat("_SoftParticlesEnabled") > 0.0f && isTransparent);
- if (useSoftParticles)
- {
- var softParticlesNearFadeDistance = material.GetFloat("_SoftParticlesNearFadeDistance");
- var softParticlesFarFadeDistance = material.GetFloat("_SoftParticlesFarFadeDistance");
- // clamp values
- if (softParticlesNearFadeDistance < 0.0f)
- {
- softParticlesNearFadeDistance = 0.0f;
- material.SetFloat("_SoftParticlesNearFadeDistance", 0.0f);
- }
-
- if (softParticlesFarFadeDistance < 0.0f)
- {
- softParticlesFarFadeDistance = 0.0f;
- material.SetFloat("_SoftParticlesFarFadeDistance", 0.0f);
- }
- // set keywords
- material.SetVector("_SoftParticleFadeParams",
- new Vector4(softParticlesNearFadeDistance,
- 1.0f / (softParticlesFarFadeDistance - softParticlesNearFadeDistance), 0.0f, 0.0f));
- }
- else
- {
- material.SetVector("_SoftParticleFadeParams", new Vector4(0.0f, 0.0f, 0.0f, 0.0f));
- }
- CoreUtils.SetKeyword(material, "_SOFTPARTICLES_ON", useSoftParticles);
- }
- // Camera fading
- var useCameraFading = false;
- if (material.HasProperty("_CameraFadingEnabled") && isTransparent)
- {
- useCameraFading = (material.GetFloat("_CameraFadingEnabled") > 0.0f);
- if (useCameraFading)
- {
- var cameraNearFadeDistance = material.GetFloat("_CameraNearFadeDistance");
- var cameraFarFadeDistance = material.GetFloat("_CameraFarFadeDistance");
- // clamp values
- if (cameraNearFadeDistance < 0.0f)
- {
- cameraNearFadeDistance = 0.0f;
- material.SetFloat("_CameraNearFadeDistance", 0.0f);
- }
-
- if (cameraFarFadeDistance < 0.0f)
- {
- cameraFarFadeDistance = 0.0f;
- material.SetFloat("_CameraFarFadeDistance", 0.0f);
- }
- // set keywords
- material.SetVector("_CameraFadeParams",
- new Vector4(cameraNearFadeDistance, 1.0f / (cameraFarFadeDistance - cameraNearFadeDistance),
- 0.0f, 0.0f));
- }
- else
- {
- material.SetVector("_CameraFadeParams", new Vector4(0.0f, Mathf.Infinity, 0.0f, 0.0f));
- }
- }
- // Distortion
- if (material.HasProperty("_DistortionEnabled"))
- {
- var useDistortion = (material.GetFloat("_DistortionEnabled") > 0.0f) && isTransparent;
- CoreUtils.SetKeyword(material, "_DISTORTION_ON", useDistortion);
- if (useDistortion)
- material.SetFloat("_DistortionStrengthScaled", material.GetFloat("_DistortionStrength") * 0.1f);
- }
-
- var useFading = (useSoftParticles || useCameraFading) && !hasZWrite;
- CoreUtils.SetKeyword(material, "_FADING_ON", useFading);
- }
- }
- } // namespace UnityEditor
|