浏览代码

Fix merge conflicts for PR

/main
Matt Dean 7 年前
当前提交
b4599393
共有 3 个文件被更改,包括 21 次插入62 次删除
  1. 30
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/ConstantNode.cs
  2. 25
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/WorldSpaceTangentNode.cs
  3. 28
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/TransformNode.cs

30
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/ConstantNode.cs


using System.Collections.Generic;
using UnityEditor.MaterialGraph.Drawing.Controls;
using UnityEngine.Graphing;
public enum ConstantType
{
PI,
TAU,
PHI,
E,
SQRT2
};
[Title("Input/Basic/Constant")]
public class ConstantNode : AbstractMaterialNode, IGeneratesBodyCode
[Title("Math/Constants")]
public class ConstantsNode : AbstractMaterialNode, IGeneratesBodyCode
{
static Dictionary<ConstantType, float> m_constantList = new Dictionary<ConstantType, float>
{

private ConstantType m_constant = ConstantType.PI;
private const int kOutputSlotId = 0;
private const string kOutputSlotName = "Out";
private const string kOutputSlotName = "Constant";
[EnumControl("")]
public ConstantType constant

}
}
public ConstantNode()
public ConstantsNode()
name = "Constant";
name = "MathConstant";
UpdateNodeAfterDeserialization();
}

{
visitor.AddShaderChunk(precision + " " + GetVariableNameForNode() + " = " + m_constantList[constant] + ";", true);
}
public override string GetVariableNameForSlot(int slotId)
{
return GetVariableNameForNode();
}
}
}

25
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/WorldSpaceTangentNode.cs


namespace UnityEngine.MaterialGraph
{
public interface IMayRequireTangent
{
NeededCoordinateSpace RequiresTangent();
}
[Title("Input/Geometry/World Tangent")]
public class TangentNode : AbstractMaterialNode, IMayRequireTangent
[Title("Input/Geometry/Tangent")]
public class TangentNode : GeometryNode, IMayRequireTangent
{
public const int kOutputSlotId = 0;
public const string kOutputSlotName = "Tangent";

public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, new Vector4(0, 0, 1, 1)));
AddSlot(new Vector3MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, new Vector4(0, 0, 1, 1)));
public override bool hasPreview
{
get { return true; }
}
public override PreviewMode previewMode
{
get { return PreviewMode.Preview3D; }
}
return ShaderGeneratorNames.ObjectSpaceTangent;
return space.ToVariableName(InterpolatorType.Tangent);
return NeededCoordinateSpace.Object;
return space.ToNeededCoordinateSpace();
}
}
}

28
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/TransformNode.cs


protected int[] validSlots
{
get { return new[] {InputSlotId, OutputSlotId}; }
get { return new[] { InputSlotId, OutputSlotId }; }
return new MaterialSlot(InputSlotId, GetInputSlotName(), kInputSlotName, SlotType.Input, SlotValueType.Vector3, Vector3.zero);
return new Vector3MaterialSlot(InputSlotId, GetInputSlotName(), kInputSlotName, SlotType.Input, Vector3.zero);
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotName, SlotType.Output, SlotValueType.Vector3, Vector4.zero);
return new Vector3MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotName, SlotType.Output, Vector4.zero);
}
protected virtual string GetInputSlotName()

if (requiresTangentTransform)
visitor.AddShaderChunk("float3x3 tangentTransform = float3x3( worldSpaceTangent, worldSpaceBitangent, worldSpaceNormal);", false);
visitor.AddShaderChunk(precision + outputDimension + " " + GetVariableNameForSlot(OutputSlotId) + " = " + transformString + ";", true);
visitor.AddShaderChunk(string.Format("{0} {1} = {2};",
ConvertConcreteSlotValueTypeToString(precision, FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType),
GetVariableNameForSlot(OutputSlotId),
transformString), true);
}
//float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);------

//mul( float4(i.posWorld.rgb,0), UNITY_MATRIX_MV ).xyz - view to local
//mul( tangentTransform, mul( float4(i.posWorld.rgb,0), UNITY_MATRIX_V ).xyz ).xyz - view to tangent
public string outputDimension
{
get { return ConvertConcreteSlotValueTypeToString(FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType); }
}
private string inputDimension
{
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(InputSlotId).concreteValueType); }
}
return NeededCoordinateSpace.Local;
return NeededCoordinateSpace.World;
return NeededCoordinateSpace.Local;
return NeededCoordinateSpace.World;
return NeededCoordinateSpace.Local;
return NeededCoordinateSpace.World;
}
}
}
正在加载...
取消
保存