|
|
|
|
|
|
using UnityEngine.Graphing; |
|
|
|
|
|
|
|
namespace UnityEngine.MaterialGraph |
|
|
|
{ |
|
|
|
[Title("Normal/Blend Normal")] |
|
|
|
public class BlendNormalNode : Function2Input, IGeneratesFunction |
|
|
|
{ |
|
|
|
public BlendNormalNode() |
|
|
|
{ |
|
|
|
name = "BlendNormal"; |
|
|
|
} |
|
|
|
|
|
|
|
protected override string GetFunctionName() |
|
|
|
{ |
|
|
|
return "unity_blendnormal_" + precision; |
|
|
|
} |
|
|
|
|
|
|
|
protected override MaterialSlot GetInputSlot1() |
|
|
|
{ |
|
|
|
return new MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, SlotType.Input, SlotValueType.Vector3, Vector4.zero); |
|
|
|
} |
|
|
|
|
|
|
|
protected override MaterialSlot GetInputSlot2() |
|
|
|
{ |
|
|
|
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, SlotType.Input, SlotValueType.Vector3, Vector4.zero); |
|
|
|
} |
|
|
|
|
|
|
|
protected override MaterialSlot GetOutputSlot() |
|
|
|
{ |
|
|
|
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, SlotValueType.Vector3, Vector4.zero); |
|
|
|
} |
|
|
|
|
|
|
|
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode) |
|
|
|
{ |
|
|
|
var outputString = new ShaderGenerator(); |
|
|
|
outputString.AddShaderChunk(GetFunctionPrototype("arg1", "arg2"), false); |
|
|
|
outputString.AddShaderChunk("{", false); |
|
|
|
outputString.Indent(); |
|
|
|
outputString.AddShaderChunk("return normalize("+precision+"3(arg1.rg + arg2.rg, arg1.b * arg2.b));", false); |
|
|
|
outputString.Deindent(); |
|
|
|
outputString.AddShaderChunk("}", false); |
|
|
|
|
|
|
|
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|