浏览代码

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

/main
Matt Dean 8 年前
当前提交
34f0ba4b
共有 2 个文件被更改,包括 67 次插入0 次删除
  1. 55
      MaterialGraphProject/Assets/_MingWai/ColorBalanceNode.cs
  2. 12
      MaterialGraphProject/Assets/_MingWai/ColorBalanceNode.cs.meta

55
MaterialGraphProject/Assets/_MingWai/ColorBalanceNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("ColorBalance")]
public class ColorBalanceNode : FunctionNInNOut, IGeneratesFunction
{
public ColorBalanceNode()
{
name = "ColorBalance";
AddSlot("Color", "inputColor", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.one);
AddSlot("AdjustRGB", "adjustRGB", Graphing.SlotType.Input, SlotValueType.Vector3, Vector3.zero);
AddSlot("RGBA", "finalColor", Graphing.SlotType.Output, SlotValueType.Vector4, Vector4.zero);
UpdateNodeAfterDeserialization();
}
protected override string GetFunctionName()
{
return "unity_colorbalance_" + precision;
}
public override bool hasPreview
{
get { return true; }
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
outputString.AddShaderChunk(GetFunctionPrototype(), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("float red = 0;", false);
outputString.AddShaderChunk("float green = 0;", false);
outputString.AddShaderChunk("float blue = 0;", false);
outputString.AddShaderChunk("red = 1.00f / (1-adjustRGB.r) * inputColor.r;", false);
outputString.AddShaderChunk("green = 1.00f / (1-adjustRGB.g) * inputColor.g;", false);
outputString.AddShaderChunk("blue = 1.00f / (1-adjustRGB.b) * inputColor.b;", false);
outputString.AddShaderChunk("red = clamp(red,0.00f,1.00f);", false);
outputString.AddShaderChunk("green = clamp(green,0.00f,1.00f);", false);
outputString.AddShaderChunk("blue = clamp(blue,0.00f,1.00f);", false);
outputString.AddShaderChunk("finalColor.r = red;", false);
outputString.AddShaderChunk("finalColor.g = green;", false);
outputString.AddShaderChunk("finalColor.b = blue;", false);
outputString.AddShaderChunk("finalColor.a = inputColor.a;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}
}

12
MaterialGraphProject/Assets/_MingWai/ColorBalanceNode.cs.meta


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