Matt Dean
8 年前
当前提交
43f98d51
共有 4 个文件被更改,包括 110 次插入 和 0 次删除
-
43MaterialGraphProject/Assets/Matt/LinearToRGB.cs
-
12MaterialGraphProject/Assets/Matt/LinearToRGB.cs.meta
-
43MaterialGraphProject/Assets/Matt/RGBtoLinear.cs
-
12MaterialGraphProject/Assets/Matt/RGBtoLinear.cs.meta
|
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title ("Math/Color/LineartoRGB")] |
|||
public class LineartoRGBNode : Function1Input, IGeneratesFunction |
|||
{ |
|||
public LineartoRGBNode() |
|||
{ |
|||
name = "RGBtoLinear"; |
|||
} |
|||
|
|||
protected override string GetFunctionName () |
|||
{ |
|||
return "unity_lineartorgb_" + precision; |
|||
} |
|||
|
|||
protected override MaterialSlot GetInputSlot () |
|||
{ |
|||
return new MaterialSlot (InputSlotId, GetInputSlotName (), kInputSlotShaderName, 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"), false); |
|||
outputString.AddShaderChunk ("{", false); |
|||
outputString.Indent (); |
|||
outputString.AddShaderChunk (precision + "3 sRGBLo = arg1 * 12.92;", false); |
|||
outputString.AddShaderChunk (precision + "3 sRGBHi = (pow(max(abs(arg1), 1.192092896e-07), "+precision+ "3(1.0 / 2.4, 1.0 / 2.4, 1.0 / 2.4)) * 1.055) - 0.055;", false); |
|||
outputString.AddShaderChunk ("return " + precision + "3(arg1 <= 0.0031308) ? sRGBLo : sRGBHi;", false); |
|||
outputString.Deindent (); |
|||
outputString.AddShaderChunk ("}", false); |
|||
|
|||
visitor.AddShaderChunk (outputString.GetShaderString (0), true); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 667e5671fc459344c889207ff866ab08 |
|||
timeCreated: 1444218016 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title ("Math/Color/RGBtoLinear")] |
|||
public class RGBtoLinearNode : Function1Input, IGeneratesFunction |
|||
{ |
|||
public RGBtoLinearNode() |
|||
{ |
|||
name = "RGBtoLinear"; |
|||
} |
|||
|
|||
protected override string GetFunctionName () |
|||
{ |
|||
return "unity_rgbtolinear_" + precision; |
|||
} |
|||
|
|||
protected override MaterialSlot GetInputSlot () |
|||
{ |
|||
return new MaterialSlot (InputSlotId, GetInputSlotName (), kInputSlotShaderName, 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"), false); |
|||
outputString.AddShaderChunk ("{", false); |
|||
outputString.Indent (); |
|||
outputString.AddShaderChunk (precision + "3 linearRGBLo = arg1 / 12.92;", false); |
|||
outputString.AddShaderChunk (precision + "3 linearRGBHi = pow(max(abs((arg1 + 0.055) / 1.055), 1.192092896e-07), "+precision+"3(2.4, 2.4, 2.4));", false); |
|||
outputString.AddShaderChunk ("return " + precision + "3(arg1 <= 0.04045) ? linearRGBLo : linearRGBHi;", false); |
|||
outputString.Deindent (); |
|||
outputString.AddShaderChunk ("}", false); |
|||
|
|||
visitor.AddShaderChunk (outputString.GetShaderString (0), true); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: e282583a8fbbf2742bd10d617611c8b0 |
|||
timeCreated: 1444218016 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue