您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
50 行
1.7 KiB
50 行
1.7 KiB
using UnityEngine;
|
|
|
|
namespace UnityEditor.Experimental.VFX.Toolbox.ImageSequencer
|
|
{
|
|
[Processor("Color","Premultiply Alpha")]
|
|
class PremultiplyAlphaProcessor : ProcessorBase
|
|
{
|
|
public bool RemoveAlpha;
|
|
public float AlphaValue;
|
|
|
|
public override string shaderPath => "Packages/com.unity.vfx-toolbox/Editor/ImageSequencer/Shaders/PremultiplyAlpha.shader";
|
|
|
|
public override string processorName => "Premultiply Alpha";
|
|
|
|
public override void Default()
|
|
{
|
|
RemoveAlpha = false;
|
|
AlphaValue = 1.0f;
|
|
}
|
|
public override bool Process(int frame)
|
|
{
|
|
Texture inputFrame = RequestInputTexture(frame);
|
|
material.SetTexture("_MainTex", inputFrame);
|
|
material.SetInt("_RemoveAlpha", RemoveAlpha ? 1 : 0);
|
|
material.SetFloat("_AlphaValue", AlphaValue);
|
|
ProcessFrame(frame, inputFrame);
|
|
return true;
|
|
}
|
|
public override bool OnInspectorGUI(bool changed, SerializedObject serializedObject)
|
|
{
|
|
var removeAlpha = serializedObject.FindProperty("RemoveAlpha");
|
|
var alphaValue = serializedObject.FindProperty("AlphaValue");
|
|
|
|
EditorGUI.BeginChangeCheck();
|
|
EditorGUILayout.PropertyField(removeAlpha, VFXToolboxGUIUtility.Get("Remove Alpha"));
|
|
EditorGUI.BeginDisabledGroup(!removeAlpha.boolValue);
|
|
EditorGUILayout.PropertyField(alphaValue, VFXToolboxGUIUtility.Get("Alpha Value"));
|
|
EditorGUI.EndDisabledGroup();
|
|
|
|
if (EditorGUI.EndChangeCheck())
|
|
{
|
|
Invalidate();
|
|
changed = true;
|
|
}
|
|
|
|
return changed;
|
|
}
|
|
|
|
}
|
|
}
|