浏览代码

[shader graph] add lerp node.

/main
Tim Cooper 9 年前
当前提交
e7365ac3
共有 2 个文件被更改,包括 42 次插入0 次删除
  1. 30
      UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/LerpNode.cs
  2. 12
      UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/LerpNode.cs.meta

30
UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/LerpNode.cs


namespace UnityEditor.Graphs.Material
{
[Title("Math/Lerp Node")]
class LerpNode : Function3Input, IGeneratesFunction
{
public override void Init()
{
name = "LerpNode";
base.Init();
}
protected override string GetFunctionName() {return "unity_lerp_" + precision; }
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
foreach (var precision in m_PrecisionNames)
{
outputString.AddShaderChunk("inline " + precision + "4 unity_lerp_" + precision + " (" + precision + "4 first, " + precision + "4 second, " + precision + "4 s)", false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("return lerp(first, second, s);", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
}
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}
}

12
UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/LerpNode.cs.meta


fileFormatVersion: 2
guid: a5622947be2d8cd48beb2362351ddf12
timeCreated: 1444218016
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存