initial commit
This commit is contained in:
parent
6715289efe
commit
788c3389af
37645 changed files with 2526849 additions and 80 deletions
|
@ -0,0 +1,102 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor.Graphing;
|
||||
using UnityEditor.ShaderGraph.Drawing.Slots;
|
||||
using UnityEditor.ShaderGraph.Internal;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[Serializable]
|
||||
class Matrix4MaterialSlot : MaterialSlot, IMaterialSlotHasValue<Matrix4x4>
|
||||
{
|
||||
[SerializeField]
|
||||
private Matrix4x4 m_Value = Matrix4x4.identity;
|
||||
|
||||
[SerializeField]
|
||||
private Matrix4x4 m_DefaultValue = Matrix4x4.identity;
|
||||
|
||||
public Matrix4MaterialSlot()
|
||||
{
|
||||
}
|
||||
|
||||
public Matrix4MaterialSlot(
|
||||
int slotId,
|
||||
string displayName,
|
||||
string shaderOutputName,
|
||||
SlotType slotType,
|
||||
ShaderStageCapability stageCapability = ShaderStageCapability.All,
|
||||
bool hidden = false)
|
||||
: base(slotId, displayName, shaderOutputName, slotType, stageCapability, hidden)
|
||||
{
|
||||
}
|
||||
|
||||
public override VisualElement InstantiateControl()
|
||||
{
|
||||
return new LabelSlotControlView("Identity");
|
||||
}
|
||||
|
||||
public Matrix4x4 defaultValue { get { return m_DefaultValue; } }
|
||||
|
||||
public Matrix4x4 value
|
||||
{
|
||||
get { return m_Value; }
|
||||
set { m_Value = value; }
|
||||
}
|
||||
|
||||
public override bool isDefaultValue => value.Equals(defaultValue);
|
||||
|
||||
protected override string ConcreteSlotValueAsVariable()
|
||||
{
|
||||
return "$precision4x4 (1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)";
|
||||
}
|
||||
|
||||
public override void AddDefaultProperty(PropertyCollector properties, GenerationMode generationMode)
|
||||
{
|
||||
if (!generationMode.IsPreview())
|
||||
return;
|
||||
|
||||
var matOwner = owner as AbstractMaterialNode;
|
||||
if (matOwner == null)
|
||||
throw new Exception(string.Format("Slot {0} either has no owner, or the owner is not a {1}", this, typeof(AbstractMaterialNode)));
|
||||
|
||||
var property = new Matrix4ShaderProperty()
|
||||
{
|
||||
overrideReferenceName = matOwner.GetVariableNameForSlot(id),
|
||||
generatePropertyBlock = false,
|
||||
value = value
|
||||
};
|
||||
properties.AddShaderProperty(property);
|
||||
}
|
||||
|
||||
public override void GetPreviewProperties(List<PreviewProperty> properties, string name)
|
||||
{
|
||||
var pp = new PreviewProperty(PropertyType.Matrix4)
|
||||
{
|
||||
name = name,
|
||||
matrixValue = value
|
||||
};
|
||||
properties.Add(pp);
|
||||
}
|
||||
|
||||
public override SlotValueType valueType { get { return SlotValueType.Matrix4; } }
|
||||
public override ConcreteSlotValueType concreteValueType { get { return ConcreteSlotValueType.Matrix4; } }
|
||||
|
||||
public override void CopyValuesFrom(MaterialSlot foundSlot)
|
||||
{
|
||||
var slot = foundSlot as Matrix4MaterialSlot;
|
||||
if (slot != null)
|
||||
value = slot.value;
|
||||
}
|
||||
|
||||
public override void CopyDefaultValue(MaterialSlot other)
|
||||
{
|
||||
base.CopyDefaultValue(other);
|
||||
if (other is IMaterialSlotHasValue<Matrix4x4> ms)
|
||||
{
|
||||
m_DefaultValue = ms.defaultValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue