浏览代码

Merge branch 'hackweek2017' of https://github.com/stramit/MaterialGraph into hackweek2017

/main
bfogerty 8 年前
当前提交
d92a2269
共有 2 个文件被更改,包括 29 次插入8 次删除
  1. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector2Node.cs
  2. 35
      MaterialGraphProject/Assets/Vlad/TextureAssetNode.cs

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector2Node.cs


if (exposedState == ExposedState.Exposed || generationMode.IsPreview())
return;
visitor.AddShaderChunk(precision + "2x2 " + propertyName + " = " + precision + "2 " + propertyName + " = " + precision + "2 (" + m_Value.x + ", " + m_Value.y + ");", true);
visitor.AddShaderChunk(precision + "2 " + propertyName + " = " + precision + "2 (" + m_Value.x + ", " + m_Value.y + ");", true);
}
public override PreviewProperty GetPreviewProperty()

35
MaterialGraphProject/Assets/Vlad/TextureAssetNode.cs


[Title("Input/Texture/Texture Asset")]
public class TextureAssetNode : PropertyNode
{
protected const string kOutputSlotRGBAName = "Texture";
protected const string outputTexture2D_name = "Texture2D";
protected const string outputSampler2D_name = "Sampler2D";
public const int OutputSlotRgbaId = 0;
public const int outputTexture2D_id = 0;
public const int outputSampler2D_id = 1;
[SerializeField]
private string m_SerializedTexture;

public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(OutputSlotRgbaId, kOutputSlotRGBAName, kOutputSlotRGBAName, SlotType.Output, SlotValueType.Texture2D, Vector4.zero, false));
AddSlot(new MaterialSlot(outputTexture2D_id, outputTexture2D_name, outputTexture2D_name, SlotType.Output, SlotValueType.Texture2D, Vector4.zero, false));
AddSlot(new MaterialSlot(outputSampler2D_id, outputSampler2D_name, outputSampler2D_name, SlotType.Output, SlotValueType.Sampler2D, Vector4.zero, false));
get { return new[] { OutputSlotRgbaId }; }
get { return new[] { outputTexture2D_id, outputSampler2D_id }; }
}
public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties)

public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode)
{
visitor.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", true);
visitor.AddShaderChunk("Texture2D " + propertyName + ";", true);
visitor.AddShaderChunk("#endif", true);
var slotTexture2D = FindInputSlot<MaterialSlot>(0);
if (slotTexture2D != null)
{
var edgesTexture2D = owner.GetEdges(slotTexture2D.slotReference).ToList();
if (edgesTexture2D.Count > 0)
{
visitor.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", true);
visitor.AddShaderChunk("Texture2D " + propertyName + "_T2D;", true);
visitor.AddShaderChunk("#endif", true);
}
}
var slotSampler2D = FindInputSlot<MaterialSlot>(0);
if (slotSampler2D != null)
{
var edgesSampler2D = owner.GetEdges(slotTexture2D.slotReference).ToList();
if (edgesSampler2D.Count > 0)
{
visitor.AddShaderChunk("Sampler2D " + propertyName + "_S2D;", true);
}
}
}

正在加载...
取消
保存