initial commit
This commit is contained in:
parent
6715289efe
commit
788c3389af
37645 changed files with 2526849 additions and 80 deletions
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 75cc6d701e07fe246ba5377a454f74c4
|
||||
folderAsset: yes
|
||||
timeCreated: 1495532497
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,152 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor.Graphing;
|
||||
using UnityEditor.ShaderGraph.Drawing.Controls;
|
||||
using UnityEditor.ShaderGraph.Internal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[Title("Artistic", "Adjustment", "Channel Mixer")]
|
||||
class ChannelMixerNode : AbstractMaterialNode, IGeneratesBodyCode, IGeneratesFunction
|
||||
{
|
||||
public ChannelMixerNode()
|
||||
{
|
||||
name = "Channel Mixer";
|
||||
UpdateNodeAfterDeserialization();
|
||||
}
|
||||
|
||||
const int InputSlotId = 0;
|
||||
const int OutputSlotId = 1;
|
||||
const string kInputSlotName = "In";
|
||||
const string kOutputSlotName = "Out";
|
||||
|
||||
public override bool hasPreview
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
string GetFunctionName()
|
||||
{
|
||||
return "Unity_ChannelMixer_$precision";
|
||||
}
|
||||
|
||||
public sealed override void UpdateNodeAfterDeserialization()
|
||||
{
|
||||
AddSlot(new Vector3MaterialSlot(InputSlotId, kInputSlotName, kInputSlotName, SlotType.Input, Vector3.zero));
|
||||
AddSlot(new Vector3MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector3.zero));
|
||||
RemoveSlotsNameNotMatching(new[] { InputSlotId, OutputSlotId });
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
ChannelMixer m_ChannelMixer = new ChannelMixer(new Vector3(1, 0, 0), new Vector3(0, 1, 0), new Vector3(0, 0, 1));
|
||||
|
||||
[Serializable]
|
||||
public struct ChannelMixer
|
||||
{
|
||||
public Vector3 outRed;
|
||||
public Vector3 outGreen;
|
||||
public Vector3 outBlue;
|
||||
|
||||
public ChannelMixer(Vector3 red, Vector3 green, Vector3 blue)
|
||||
{
|
||||
outRed = red;
|
||||
outGreen = green;
|
||||
outBlue = blue;
|
||||
}
|
||||
}
|
||||
|
||||
[ChannelMixerControl("")]
|
||||
public ChannelMixer channelMixer
|
||||
{
|
||||
get { return m_ChannelMixer; }
|
||||
set
|
||||
{
|
||||
if ((value.outRed == m_ChannelMixer.outRed) && (value.outGreen == m_ChannelMixer.outGreen) && (value.outBlue == m_ChannelMixer.outBlue))
|
||||
return;
|
||||
m_ChannelMixer = value;
|
||||
Dirty(ModificationScope.Node);
|
||||
}
|
||||
}
|
||||
|
||||
public void GenerateNodeCode(ShaderStringBuilder sb, GenerationMode generationMode)
|
||||
{
|
||||
var inputValue = GetSlotValue(InputSlotId, generationMode);
|
||||
var outputValue = GetSlotValue(OutputSlotId, generationMode);
|
||||
|
||||
sb.AppendLine("{0} {1};", FindInputSlot<MaterialSlot>(InputSlotId).concreteValueType.ToShaderString(), GetVariableNameForSlot(OutputSlotId));
|
||||
if (!generationMode.IsPreview())
|
||||
{
|
||||
sb.AppendLine("$precision3 _{0}_Red = $precision3 ({1}, {2}, {3});", GetVariableNameForNode(), channelMixer.outRed[0], channelMixer.outRed[1], channelMixer.outRed[2]);
|
||||
sb.AppendLine("$precision3 _{0}_Green = $precision3 ({1}, {2}, {3});", GetVariableNameForNode(), channelMixer.outGreen[0], channelMixer.outGreen[1], channelMixer.outGreen[2]);
|
||||
sb.AppendLine("$precision3 _{0}_Blue = $precision3 ({1}, {2}, {3});", GetVariableNameForNode(), channelMixer.outBlue[0], channelMixer.outBlue[1], channelMixer.outBlue[2]);
|
||||
}
|
||||
sb.AppendLine("{0}({1}, _{2}_Red, _{2}_Green, _{2}_Blue, {3});", GetFunctionName(), inputValue, GetVariableNameForNode(), outputValue);
|
||||
}
|
||||
|
||||
public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties)
|
||||
{
|
||||
base.CollectPreviewMaterialProperties(properties);
|
||||
|
||||
properties.Add(new PreviewProperty(PropertyType.Vector3)
|
||||
{
|
||||
name = string.Format("_{0}_Red", GetVariableNameForNode()),
|
||||
vector4Value = channelMixer.outRed
|
||||
});
|
||||
|
||||
properties.Add(new PreviewProperty(PropertyType.Vector3)
|
||||
{
|
||||
name = string.Format("_{0}_Green", GetVariableNameForNode()),
|
||||
vector4Value = channelMixer.outGreen
|
||||
});
|
||||
|
||||
properties.Add(new PreviewProperty(PropertyType.Vector3)
|
||||
{
|
||||
name = string.Format("_{0}_Blue", GetVariableNameForNode()),
|
||||
vector4Value = channelMixer.outBlue
|
||||
});
|
||||
}
|
||||
|
||||
public override void CollectShaderProperties(PropertyCollector properties, GenerationMode generationMode)
|
||||
{
|
||||
if (!generationMode.IsPreview())
|
||||
return;
|
||||
|
||||
base.CollectShaderProperties(properties, generationMode);
|
||||
|
||||
properties.AddShaderProperty(new Vector4ShaderProperty()
|
||||
{
|
||||
overrideReferenceName = string.Format("_{0}_Red", GetVariableNameForNode()),
|
||||
generatePropertyBlock = false
|
||||
});
|
||||
|
||||
properties.AddShaderProperty(new Vector4ShaderProperty()
|
||||
{
|
||||
overrideReferenceName = string.Format("_{0}_Green", GetVariableNameForNode()),
|
||||
generatePropertyBlock = false
|
||||
});
|
||||
|
||||
properties.AddShaderProperty(new Vector4ShaderProperty()
|
||||
{
|
||||
overrideReferenceName = string.Format("_{0}_Blue", GetVariableNameForNode()),
|
||||
generatePropertyBlock = false
|
||||
});
|
||||
}
|
||||
|
||||
public void GenerateNodeFunction(FunctionRegistry registry, GenerationMode generationMode)
|
||||
{
|
||||
registry.ProvideFunction(GetFunctionName(), s =>
|
||||
{
|
||||
s.AppendLine("void {0} ({1} In, $precision3 Red, $precision3 Green, $precision3 Blue, out {2} Out)",
|
||||
GetFunctionName(),
|
||||
FindInputSlot<MaterialSlot>(InputSlotId).concreteValueType.ToShaderString(),
|
||||
FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType.ToShaderString());
|
||||
using (s.BlockScope())
|
||||
{
|
||||
s.AppendLine("Out = {0}(dot(In, Red), dot(In, Green), dot(In, Blue));",
|
||||
FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType.ToShaderString());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d8d3a2d8c96e5994696f30f658efebea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,33 @@
|
|||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[Title("Artistic", "Adjustment", "Contrast")]
|
||||
class ContrastNode : CodeFunctionNode
|
||||
{
|
||||
public ContrastNode()
|
||||
{
|
||||
name = "Contrast";
|
||||
}
|
||||
|
||||
protected override MethodInfo GetFunctionToConvert()
|
||||
{
|
||||
return GetType().GetMethod("Unity_Contrast", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
}
|
||||
|
||||
static string Unity_Contrast(
|
||||
[Slot(0, Binding.None)] Vector3 In,
|
||||
[Slot(1, Binding.None, 1, 1, 1, 1)] Vector1 Contrast,
|
||||
[Slot(2, Binding.None)] out Vector3 Out)
|
||||
{
|
||||
Out = Vector2.zero;
|
||||
return
|
||||
@"
|
||||
{
|
||||
$precision midpoint = pow(0.5, 2.2);
|
||||
Out = (In - midpoint) * Contrast + midpoint;
|
||||
}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 94965bffe51535041a4f0a618263bf7d
|
||||
timeCreated: 1444218016
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,114 @@
|
|||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using UnityEditor.Graphing;
|
||||
using UnityEditor.ShaderGraph.Drawing.Controls;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
enum HueMode
|
||||
{
|
||||
Degrees,
|
||||
Normalized
|
||||
};
|
||||
|
||||
[Title("Artistic", "Adjustment", "Hue")]
|
||||
class HueNode : CodeFunctionNode
|
||||
{
|
||||
public HueNode()
|
||||
{
|
||||
name = "Hue";
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private HueMode m_HueMode = HueMode.Degrees;
|
||||
|
||||
[EnumControl("Range")]
|
||||
public HueMode hueMode
|
||||
{
|
||||
get { return m_HueMode; }
|
||||
set
|
||||
{
|
||||
if (m_HueMode == value)
|
||||
return;
|
||||
|
||||
m_HueMode = value;
|
||||
Dirty(ModificationScope.Graph);
|
||||
}
|
||||
}
|
||||
|
||||
protected override MethodInfo GetFunctionToConvert()
|
||||
{
|
||||
switch (m_HueMode)
|
||||
{
|
||||
case HueMode.Normalized:
|
||||
return GetType().GetMethod("Unity_Hue_Normalized", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
default:
|
||||
return GetType().GetMethod("Unity_Hue_Degrees", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
}
|
||||
}
|
||||
|
||||
static string Unity_Hue_Degrees(
|
||||
[Slot(0, Binding.None)] Vector3 In,
|
||||
[Slot(1, Binding.None)] Vector1 Offset,
|
||||
[Slot(2, Binding.None)] out Vector3 Out)
|
||||
{
|
||||
Out = Vector3.zero;
|
||||
return
|
||||
@"
|
||||
{
|
||||
// RGB to HSV
|
||||
$precision4 K = $precision4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
$precision4 P = lerp($precision4(In.bg, K.wz), $precision4(In.gb, K.xy), step(In.b, In.g));
|
||||
$precision4 Q = lerp($precision4(P.xyw, In.r), $precision4(In.r, P.yzx), step(P.x, In.r));
|
||||
$precision D = Q.x - min(Q.w, Q.y);
|
||||
$precision E = 1e-10;
|
||||
$precision V = (D == 0) ? Q.x : (Q.x + E);
|
||||
$precision3 hsv = $precision3(abs(Q.z + (Q.w - Q.y)/(6.0 * D + E)), D / (Q.x + E), V);
|
||||
|
||||
$precision hue = hsv.x + Offset / 360;
|
||||
hsv.x = (hue < 0)
|
||||
? hue + 1
|
||||
: (hue > 1)
|
||||
? hue - 1
|
||||
: hue;
|
||||
|
||||
// HSV to RGB
|
||||
$precision4 K2 = $precision4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
$precision3 P2 = abs(frac(hsv.xxx + K2.xyz) * 6.0 - K2.www);
|
||||
Out = hsv.z * lerp(K2.xxx, saturate(P2 - K2.xxx), hsv.y);
|
||||
}";
|
||||
}
|
||||
|
||||
static string Unity_Hue_Normalized(
|
||||
[Slot(0, Binding.None)] Vector3 In,
|
||||
[Slot(1, Binding.None, 0.5f, 0.5f, 0.5f, 0.5f)] Vector1 Offset,
|
||||
[Slot(2, Binding.None)] out Vector3 Out)
|
||||
{
|
||||
Out = Vector3.zero;
|
||||
return
|
||||
@"
|
||||
{
|
||||
// RGB to HSV
|
||||
$precision4 K = $precision4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
$precision4 P = lerp($precision4(In.bg, K.wz), $precision4(In.gb, K.xy), step(In.b, In.g));
|
||||
$precision4 Q = lerp($precision4(P.xyw, In.r), $precision4(In.r, P.yzx), step(P.x, In.r));
|
||||
$precision D = Q.x - min(Q.w, Q.y);
|
||||
$precision E = 1e-10;
|
||||
$precision V = (D == 0) ? Q.x : (Q.x + E);
|
||||
$precision3 hsv = $precision3(abs(Q.z + (Q.w - Q.y)/(6.0 * D + E)), D / (Q.x + E), V);
|
||||
|
||||
$precision hue = hsv.x + Offset;
|
||||
hsv.x = (hue < 0)
|
||||
? hue + 1
|
||||
: (hue > 1)
|
||||
? hue - 1
|
||||
: hue;
|
||||
|
||||
// HSV to RGB
|
||||
$precision4 K2 = $precision4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
$precision3 P2 = abs(frac(hsv.xxx + K2.xyz) * 6.0 - K2.www);
|
||||
Out = hsv.z * lerp(K2.xxx, saturate(P2 - K2.xxx), hsv.y);
|
||||
}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 083caf0fe7ff62f438e121e934355461
|
||||
timeCreated: 1490973460
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,174 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor.Graphing;
|
||||
using UnityEditor.ShaderGraph.Drawing.Controls;
|
||||
using UnityEditor.ShaderGraph.Internal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[Title("Artistic", "Adjustment", "Invert Colors")]
|
||||
class InvertColorsNode : AbstractMaterialNode, IGeneratesBodyCode, IGeneratesFunction
|
||||
{
|
||||
public InvertColorsNode()
|
||||
{
|
||||
name = "Invert Colors";
|
||||
UpdateNodeAfterDeserialization();
|
||||
}
|
||||
|
||||
const int InputSlotId = 0;
|
||||
const int OutputSlotId = 1;
|
||||
const string kInputSlotName = "In";
|
||||
const string kOutputSlotName = "Out";
|
||||
|
||||
public override bool hasPreview
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
string GetFunctionName()
|
||||
{
|
||||
return $"Unity_InvertColors_{FindSlot<MaterialSlot>(InputSlotId).concreteValueType.ToShaderString()}";
|
||||
}
|
||||
|
||||
public sealed override void UpdateNodeAfterDeserialization()
|
||||
{
|
||||
AddSlot(new DynamicVectorMaterialSlot(InputSlotId, kInputSlotName, kInputSlotName, SlotType.Input, Vector4.zero));
|
||||
AddSlot(new DynamicVectorMaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.zero));
|
||||
RemoveSlotsNameNotMatching(new[] { InputSlotId, OutputSlotId });
|
||||
}
|
||||
|
||||
int channelCount { get { return SlotValueHelper.GetChannelCount(FindSlot<MaterialSlot>(InputSlotId).concreteValueType); } }
|
||||
|
||||
[SerializeField]
|
||||
private bool m_RedChannel;
|
||||
|
||||
[ToggleControl("Red")]
|
||||
public ToggleData redChannel
|
||||
{
|
||||
get { return new ToggleData(m_RedChannel, channelCount > 0); }
|
||||
set
|
||||
{
|
||||
if (m_RedChannel == value.isOn)
|
||||
return;
|
||||
m_RedChannel = value.isOn;
|
||||
Dirty(ModificationScope.Node);
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private bool m_GreenChannel;
|
||||
|
||||
[ToggleControl("Green")]
|
||||
public ToggleData greenChannel
|
||||
{
|
||||
get { return new ToggleData(m_GreenChannel, channelCount > 1); }
|
||||
set
|
||||
{
|
||||
if (m_GreenChannel == value.isOn)
|
||||
return;
|
||||
m_GreenChannel = value.isOn;
|
||||
Dirty(ModificationScope.Node);
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private bool m_BlueChannel;
|
||||
|
||||
[ToggleControl("Blue")]
|
||||
public ToggleData blueChannel
|
||||
{
|
||||
get { return new ToggleData(m_BlueChannel, channelCount > 2); }
|
||||
set
|
||||
{
|
||||
if (m_BlueChannel == value.isOn)
|
||||
return;
|
||||
m_BlueChannel = value.isOn;
|
||||
Dirty(ModificationScope.Node);
|
||||
}
|
||||
}
|
||||
|
||||
private bool m_AlphaChannel;
|
||||
|
||||
[ToggleControl("Alpha")]
|
||||
public ToggleData alphaChannel
|
||||
{
|
||||
get { return new ToggleData(m_AlphaChannel, channelCount > 3); }
|
||||
set
|
||||
{
|
||||
if (m_AlphaChannel == value.isOn)
|
||||
return;
|
||||
m_AlphaChannel = value.isOn;
|
||||
Dirty(ModificationScope.Node);
|
||||
}
|
||||
}
|
||||
|
||||
public void GenerateNodeCode(ShaderStringBuilder sb, GenerationMode generationMode)
|
||||
{
|
||||
var inputValue = GetSlotValue(InputSlotId, generationMode);
|
||||
var outputValue = GetSlotValue(OutputSlotId, generationMode);
|
||||
sb.AppendLine("{0} {1};", FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType.ToShaderString(), GetVariableNameForSlot(OutputSlotId));
|
||||
|
||||
if (!generationMode.IsPreview())
|
||||
{
|
||||
sb.TryAppendIndentation();
|
||||
sb.Append("{0} _{1}_InvertColors = {0} ({2}",
|
||||
FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType.ToShaderString(),
|
||||
GetVariableNameForNode(),
|
||||
Convert.ToInt32(m_RedChannel));
|
||||
if (channelCount > 1)
|
||||
sb.Append(", {0}", Convert.ToInt32(m_GreenChannel));
|
||||
if (channelCount > 2)
|
||||
sb.Append(", {0}", Convert.ToInt32(m_BlueChannel));
|
||||
if (channelCount > 3)
|
||||
sb.Append(", {0}", Convert.ToInt32(m_AlphaChannel));
|
||||
sb.Append(");");
|
||||
sb.AppendNewLine();
|
||||
}
|
||||
|
||||
sb.AppendLine("{0}({1}, _{2}_InvertColors, {3});", GetFunctionName(), inputValue, GetVariableNameForNode(), outputValue);
|
||||
}
|
||||
|
||||
public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties)
|
||||
{
|
||||
base.CollectPreviewMaterialProperties(properties);
|
||||
|
||||
properties.Add(new PreviewProperty(PropertyType.Vector4)
|
||||
{
|
||||
name = string.Format("_{0}_InvertColors", GetVariableNameForNode()),
|
||||
vector4Value = new Vector4(Convert.ToInt32(m_RedChannel), Convert.ToInt32(m_GreenChannel), Convert.ToInt32(m_BlueChannel), Convert.ToInt32(m_AlphaChannel)),
|
||||
});
|
||||
}
|
||||
|
||||
public override void CollectShaderProperties(PropertyCollector properties, GenerationMode generationMode)
|
||||
{
|
||||
if (!generationMode.IsPreview())
|
||||
return;
|
||||
|
||||
base.CollectShaderProperties(properties, generationMode);
|
||||
|
||||
properties.AddShaderProperty(new Vector4ShaderProperty
|
||||
{
|
||||
overrideReferenceName = string.Format("_{0}_InvertColors", GetVariableNameForNode()),
|
||||
generatePropertyBlock = false
|
||||
});
|
||||
}
|
||||
|
||||
public void GenerateNodeFunction(FunctionRegistry registry, GenerationMode generationMode)
|
||||
{
|
||||
registry.ProvideFunction(GetFunctionName(), s =>
|
||||
{
|
||||
s.AppendLine("void {0}({1} In, {2} InvertColors, out {3} Out)",
|
||||
GetFunctionName(),
|
||||
FindInputSlot<MaterialSlot>(InputSlotId).concreteValueType.ToShaderString(),
|
||||
FindInputSlot<MaterialSlot>(InputSlotId).concreteValueType.ToShaderString(),
|
||||
FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType.ToShaderString());
|
||||
|
||||
using (s.BlockScope())
|
||||
{
|
||||
s.AppendLine("Out = abs(InvertColors - In);");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3e16bd8daac9e4e42861472225b22405
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[Title("Artistic", "Adjustment", "Replace Color")]
|
||||
class ReplaceColorNode : CodeFunctionNode
|
||||
{
|
||||
public ReplaceColorNode()
|
||||
{
|
||||
name = "Replace Color";
|
||||
}
|
||||
|
||||
protected override MethodInfo GetFunctionToConvert()
|
||||
{
|
||||
return GetType().GetMethod("Unity_ReplaceColor", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
}
|
||||
|
||||
static string Unity_ReplaceColor(
|
||||
[Slot(0, Binding.None)] Vector3 In,
|
||||
[Slot(1, Binding.None)] ColorRGB From,
|
||||
[Slot(2, Binding.None)] ColorRGB To,
|
||||
[Slot(3, Binding.None)] Vector1 Range,
|
||||
[Slot(5, Binding.None)] Vector1 Fuzziness,
|
||||
[Slot(4, Binding.None)] out Vector3 Out)
|
||||
{
|
||||
Out = Vector3.zero;
|
||||
return
|
||||
@"
|
||||
{
|
||||
$precision Distance = distance(From, In);
|
||||
Out = lerp(To, In, saturate((Distance - Range) / max(Fuzziness, 1e-5f)));
|
||||
}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a60be5fb80fbbdb449fcc95fa2256cc5
|
||||
timeCreated: 1444218016
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,33 @@
|
|||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[Title("Artistic", "Adjustment", "Saturation")]
|
||||
class SaturationNode : CodeFunctionNode
|
||||
{
|
||||
public SaturationNode()
|
||||
{
|
||||
name = "Saturation";
|
||||
}
|
||||
|
||||
protected override MethodInfo GetFunctionToConvert()
|
||||
{
|
||||
return GetType().GetMethod("Unity_Saturation", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
}
|
||||
|
||||
static string Unity_Saturation(
|
||||
[Slot(0, Binding.None)] Vector3 In,
|
||||
[Slot(1, Binding.None, 1, 1, 1, 1)] Vector1 Saturation,
|
||||
[Slot(2, Binding.None)] out Vector3 Out)
|
||||
{
|
||||
Out = Vector3.zero;
|
||||
return @"
|
||||
{
|
||||
$precision luma = dot(In, $precision3(0.2126729, 0.7151522, 0.0721750));
|
||||
Out = luma.xxx + Saturation.xxx * (In - luma.xxx);
|
||||
}
|
||||
";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8f3854e9ab30c854b93e88a2e560463e
|
||||
timeCreated: 1444218016
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,71 @@
|
|||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[Title("Artistic", "Adjustment", "White Balance")]
|
||||
class WhiteBalanceNode : CodeFunctionNode
|
||||
{
|
||||
public WhiteBalanceNode()
|
||||
{
|
||||
name = "White Balance";
|
||||
}
|
||||
|
||||
protected override MethodInfo GetFunctionToConvert()
|
||||
{
|
||||
return GetType().GetMethod("Unity_WhiteBalance", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
}
|
||||
|
||||
static string Unity_WhiteBalance(
|
||||
[Slot(0, Binding.None)] Vector3 In,
|
||||
[Slot(1, Binding.None)] Vector1 Temperature,
|
||||
[Slot(2, Binding.None)] Vector1 Tint,
|
||||
[Slot(3, Binding.None)] out Vector3 Out)
|
||||
{
|
||||
Out = Vector3.zero;
|
||||
return @"
|
||||
{
|
||||
// Range ~[-1.67;1.67] works best
|
||||
$precision t1 = Temperature * 10 / 6;
|
||||
$precision t2 = Tint * 10 / 6;
|
||||
|
||||
// Get the CIE xy chromaticity of the reference white point.
|
||||
// Note: 0.31271 = x value on the D65 white point
|
||||
$precision x = 0.31271 - t1 * (t1 < 0 ? 0.1 : 0.05);
|
||||
$precision standardIlluminantY = 2.87 * x - 3 * x * x - 0.27509507;
|
||||
$precision y = standardIlluminantY + t2 * 0.05;
|
||||
|
||||
// Calculate the coefficients in the LMS space.
|
||||
$precision3 w1 = $precision3(0.949237, 1.03542, 1.08728); // D65 white point
|
||||
|
||||
// CIExyToLMS
|
||||
$precision Y = 1;
|
||||
$precision X = Y * x / y;
|
||||
$precision Z = Y * (1 - x - y) / y;
|
||||
$precision L = 0.7328 * X + 0.4296 * Y - 0.1624 * Z;
|
||||
$precision M = -0.7036 * X + 1.6975 * Y + 0.0061 * Z;
|
||||
$precision S = 0.0030 * X + 0.0136 * Y + 0.9834 * Z;
|
||||
$precision3 w2 = $precision3(L, M, S);
|
||||
|
||||
$precision3 balance = $precision3(w1.x / w2.x, w1.y / w2.y, w1.z / w2.z);
|
||||
|
||||
$precision3x3 LIN_2_LMS_MAT = {
|
||||
3.90405e-1, 5.49941e-1, 8.92632e-3,
|
||||
7.08416e-2, 9.63172e-1, 1.35775e-3,
|
||||
2.31082e-2, 1.28021e-1, 9.36245e-1
|
||||
};
|
||||
|
||||
$precision3x3 LMS_2_LIN_MAT = {
|
||||
2.85847e+0, -1.62879e+0, -2.48910e-2,
|
||||
-2.10182e-1, 1.15820e+0, 3.24281e-4,
|
||||
-4.18120e-2, -1.18169e-1, 1.06867e+0
|
||||
};
|
||||
|
||||
$precision3 lms = mul(LIN_2_LMS_MAT, In);
|
||||
lms *= balance;
|
||||
Out = mul(LMS_2_LIN_MAT, lms);
|
||||
}
|
||||
";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c09bf9b59c16e0d48b9a346376d28640
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f85e7557d4bb9874882ec3fa3044a53e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,28 @@
|
|||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
enum BlendMode
|
||||
{
|
||||
Burn,
|
||||
Darken,
|
||||
Difference,
|
||||
Dodge,
|
||||
Divide,
|
||||
Exclusion,
|
||||
HardLight,
|
||||
HardMix,
|
||||
Lighten,
|
||||
LinearBurn,
|
||||
LinearDodge,
|
||||
LinearLight,
|
||||
LinearLightAddSub,
|
||||
Multiply,
|
||||
Negation,
|
||||
Overlay,
|
||||
PinLight,
|
||||
Screen,
|
||||
SoftLight,
|
||||
Subtract,
|
||||
VividLight,
|
||||
Overwrite
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e377212826a27da4f9cbf888b0c39bc9
|
||||
timeCreated: 1495455807
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,372 @@
|
|||
using System.Reflection;
|
||||
using UnityEditor.ShaderGraph.Drawing.Controls;
|
||||
using UnityEngine;
|
||||
using UnityEditor.Graphing;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[Title("Artistic", "Blend", "Blend")]
|
||||
class BlendNode : CodeFunctionNode
|
||||
{
|
||||
public BlendNode()
|
||||
{
|
||||
name = "Blend";
|
||||
synonyms = new string[] { "burn", "darken", "difference", "dodge", "divide", "exclusion", "hard light", "hard mix", "linear burn", "linear dodge", "linear light", "multiply", "negate", "overlay", "pin light", "screen", "soft light", "subtract", "vivid light", "overwrite" };
|
||||
}
|
||||
|
||||
string GetCurrentBlendName()
|
||||
{
|
||||
return System.Enum.GetName(typeof(BlendMode), m_BlendMode);
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
BlendMode m_BlendMode = BlendMode.Overlay;
|
||||
|
||||
[EnumControl("Mode")]
|
||||
public BlendMode blendMode
|
||||
{
|
||||
get { return m_BlendMode; }
|
||||
set
|
||||
{
|
||||
if (m_BlendMode == value)
|
||||
return;
|
||||
|
||||
m_BlendMode = value;
|
||||
Dirty(ModificationScope.Graph);
|
||||
}
|
||||
}
|
||||
|
||||
protected override MethodInfo GetFunctionToConvert()
|
||||
{
|
||||
return GetType().GetMethod(string.Format("Unity_Blend_{0}", GetCurrentBlendName()),
|
||||
BindingFlags.Static | BindingFlags.NonPublic);
|
||||
}
|
||||
|
||||
static string Unity_Blend_Burn(
|
||||
[Slot(0, Binding.None)] DynamicDimensionVector Base,
|
||||
[Slot(1, Binding.None)] DynamicDimensionVector Blend,
|
||||
[Slot(3, Binding.None, 1, 1, 1, 1)] Vector1 Opacity,
|
||||
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
Out = 1.0 - (1.0 - Blend)/(Base + 0.000000000001);
|
||||
Out = lerp(Base, Out, Opacity);
|
||||
}";
|
||||
}
|
||||
|
||||
static string Unity_Blend_Darken(
|
||||
[Slot(0, Binding.None)] DynamicDimensionVector Base,
|
||||
[Slot(1, Binding.None)] DynamicDimensionVector Blend,
|
||||
[Slot(3, Binding.None, 1, 1, 1, 1)] Vector1 Opacity,
|
||||
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
Out = min(Blend, Base);
|
||||
Out = lerp(Base, Out, Opacity);
|
||||
}";
|
||||
}
|
||||
|
||||
static string Unity_Blend_Difference(
|
||||
[Slot(0, Binding.None)] DynamicDimensionVector Base,
|
||||
[Slot(1, Binding.None)] DynamicDimensionVector Blend,
|
||||
[Slot(3, Binding.None, 1, 1, 1, 1)] Vector1 Opacity,
|
||||
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
Out = abs(Blend - Base);
|
||||
Out = lerp(Base, Out, Opacity);
|
||||
}";
|
||||
}
|
||||
|
||||
static string Unity_Blend_Dodge(
|
||||
[Slot(0, Binding.None)] DynamicDimensionVector Base,
|
||||
[Slot(1, Binding.None)] DynamicDimensionVector Blend,
|
||||
[Slot(3, Binding.None, 1, 1, 1, 1)] Vector1 Opacity,
|
||||
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
Out = Base / (1.0 - clamp(Blend, 0.000001, 0.999999));
|
||||
Out = lerp(Base, Out, Opacity);
|
||||
}";
|
||||
}
|
||||
|
||||
static string Unity_Blend_Divide(
|
||||
[Slot(0, Binding.None)] DynamicDimensionVector Base,
|
||||
[Slot(1, Binding.None)] DynamicDimensionVector Blend,
|
||||
[Slot(3, Binding.None, 1, 1, 1, 1)] Vector1 Opacity,
|
||||
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
Out = Base / (Blend + 0.000000000001);
|
||||
Out = lerp(Base, Out, Opacity);
|
||||
}";
|
||||
}
|
||||
|
||||
static string Unity_Blend_Exclusion(
|
||||
[Slot(0, Binding.None)] DynamicDimensionVector Base,
|
||||
[Slot(1, Binding.None)] DynamicDimensionVector Blend,
|
||||
[Slot(3, Binding.None, 1, 1, 1, 1)] Vector1 Opacity,
|
||||
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
Out = Blend + Base - (2.0 * Blend * Base);
|
||||
Out = lerp(Base, Out, Opacity);
|
||||
}";
|
||||
}
|
||||
|
||||
static string Unity_Blend_HardLight(
|
||||
[Slot(0, Binding.None)] DynamicDimensionVector Base,
|
||||
[Slot(1, Binding.None)] DynamicDimensionVector Blend,
|
||||
[Slot(3, Binding.None, 1, 1, 1, 1)] Vector1 Opacity,
|
||||
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
$precision{slot2dimension} result1 = 1.0 - 2.0 * (1.0 - Base) * (1.0 - Blend);
|
||||
$precision{slot2dimension} result2 = 2.0 * Base * Blend;
|
||||
$precision{slot2dimension} zeroOrOne = step(Blend, 0.5);
|
||||
Out = result2 * zeroOrOne + (1 - zeroOrOne) * result1;
|
||||
Out = lerp(Base, Out, Opacity);
|
||||
}";
|
||||
}
|
||||
|
||||
static string Unity_Blend_HardMix(
|
||||
[Slot(0, Binding.None)] DynamicDimensionVector Base,
|
||||
[Slot(1, Binding.None)] DynamicDimensionVector Blend,
|
||||
[Slot(3, Binding.None, 1, 1, 1, 1)] Vector1 Opacity,
|
||||
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
Out = step(1 - Base, Blend);
|
||||
Out = lerp(Base, Out, Opacity);
|
||||
}";
|
||||
}
|
||||
|
||||
static string Unity_Blend_Lighten(
|
||||
[Slot(0, Binding.None)] DynamicDimensionVector Base,
|
||||
[Slot(1, Binding.None)] DynamicDimensionVector Blend,
|
||||
[Slot(3, Binding.None, 1, 1, 1, 1)] Vector1 Opacity,
|
||||
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
Out = max(Blend, Base);
|
||||
Out = lerp(Base, Out, Opacity);
|
||||
}";
|
||||
}
|
||||
|
||||
static string Unity_Blend_LinearBurn(
|
||||
[Slot(0, Binding.None)] DynamicDimensionVector Base,
|
||||
[Slot(1, Binding.None)] DynamicDimensionVector Blend,
|
||||
[Slot(3, Binding.None, 1, 1, 1, 1)] Vector1 Opacity,
|
||||
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
Out = Base + Blend - 1.0;
|
||||
Out = lerp(Base, Out, Opacity);
|
||||
}";
|
||||
}
|
||||
|
||||
static string Unity_Blend_LinearDodge(
|
||||
[Slot(0, Binding.None)] DynamicDimensionVector Base,
|
||||
[Slot(1, Binding.None)] DynamicDimensionVector Blend,
|
||||
[Slot(3, Binding.None, 1, 1, 1, 1)] Vector1 Opacity,
|
||||
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
Out = Base + Blend;
|
||||
Out = lerp(Base, Out, Opacity);
|
||||
}";
|
||||
}
|
||||
|
||||
static string Unity_Blend_LinearLight(
|
||||
[Slot(0, Binding.None)] DynamicDimensionVector Base,
|
||||
[Slot(1, Binding.None)] DynamicDimensionVector Blend,
|
||||
[Slot(3, Binding.None, 1, 1, 1, 1)] Vector1 Opacity,
|
||||
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
Out = Blend < 0.5 ? max(Base + (2 * Blend) - 1, 0) : min(Base + 2 * (Blend - 0.5), 1);
|
||||
Out = lerp(Base, Out, Opacity);
|
||||
}";
|
||||
}
|
||||
|
||||
static string Unity_Blend_LinearLightAddSub(
|
||||
[Slot(0, Binding.None)] DynamicDimensionVector Base,
|
||||
[Slot(1, Binding.None)] DynamicDimensionVector Blend,
|
||||
[Slot(3, Binding.None, 1, 1, 1, 1)] Vector1 Opacity,
|
||||
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
Out = Blend + 2.0 * Base - 1.0;
|
||||
Out = lerp(Base, Out, Opacity);
|
||||
}";
|
||||
}
|
||||
|
||||
static string Unity_Blend_Multiply(
|
||||
[Slot(0, Binding.None)] DynamicDimensionVector Base,
|
||||
[Slot(1, Binding.None)] DynamicDimensionVector Blend,
|
||||
[Slot(3, Binding.None, 1, 1, 1, 1)] Vector1 Opacity,
|
||||
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
Out = Base * Blend;
|
||||
Out = lerp(Base, Out, Opacity);
|
||||
}";
|
||||
}
|
||||
|
||||
static string Unity_Blend_Negation(
|
||||
[Slot(0, Binding.None)] DynamicDimensionVector Base,
|
||||
[Slot(1, Binding.None)] DynamicDimensionVector Blend,
|
||||
[Slot(3, Binding.None, 1, 1, 1, 1)] Vector1 Opacity,
|
||||
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
Out = 1.0 - abs(1.0 - Blend - Base);
|
||||
Out = lerp(Base, Out, Opacity);
|
||||
}";
|
||||
}
|
||||
|
||||
static string Unity_Blend_Screen(
|
||||
[Slot(0, Binding.None)] DynamicDimensionVector Base,
|
||||
[Slot(1, Binding.None)] DynamicDimensionVector Blend,
|
||||
[Slot(3, Binding.None, 1, 1, 1, 1)] Vector1 Opacity,
|
||||
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
Out = 1.0 - (1.0 - Blend) * (1.0 - Base);
|
||||
Out = lerp(Base, Out, Opacity);
|
||||
}";
|
||||
}
|
||||
|
||||
static string Unity_Blend_Overlay(
|
||||
[Slot(0, Binding.None)] DynamicDimensionVector Base,
|
||||
[Slot(1, Binding.None)] DynamicDimensionVector Blend,
|
||||
[Slot(3, Binding.None, 1, 1, 1, 1)] Vector1 Opacity,
|
||||
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
$precision{slot2dimension} result1 = 1.0 - 2.0 * (1.0 - Base) * (1.0 - Blend);
|
||||
$precision{slot2dimension} result2 = 2.0 * Base * Blend;
|
||||
$precision{slot2dimension} zeroOrOne = step(Base, 0.5);
|
||||
Out = result2 * zeroOrOne + (1 - zeroOrOne) * result1;
|
||||
Out = lerp(Base, Out, Opacity);
|
||||
}
|
||||
";
|
||||
}
|
||||
|
||||
static string Unity_Blend_PinLight(
|
||||
[Slot(0, Binding.None)] DynamicDimensionVector Base,
|
||||
[Slot(1, Binding.None)] DynamicDimensionVector Blend,
|
||||
[Slot(3, Binding.None, 1, 1, 1, 1)] Vector1 Opacity,
|
||||
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
$precision{slot2dimension} check = step (0.5, Blend);
|
||||
$precision{slot2dimension} result1 = check * max(2.0 * (Base - 0.5), Blend);
|
||||
Out = result1 + (1.0 - check) * min(2.0 * Base, Blend);
|
||||
Out = lerp(Base, Out, Opacity);
|
||||
}
|
||||
";
|
||||
}
|
||||
|
||||
static string Unity_Blend_SoftLight(
|
||||
[Slot(0, Binding.None)] DynamicDimensionVector Base,
|
||||
[Slot(1, Binding.None)] DynamicDimensionVector Blend,
|
||||
[Slot(3, Binding.None, 1, 1, 1, 1)] Vector1 Opacity,
|
||||
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
$precision{slot2dimension} result1 = 2.0 * Base * Blend + Base * Base * (1.0 - 2.0 * Blend);
|
||||
$precision{slot2dimension} result2 = sqrt(Base) * (2.0 * Blend - 1.0) + 2.0 * Base * (1.0 - Blend);
|
||||
$precision{slot2dimension} zeroOrOne = step(0.5, Blend);
|
||||
Out = result2 * zeroOrOne + (1 - zeroOrOne) * result1;
|
||||
Out = lerp(Base, Out, Opacity);
|
||||
}
|
||||
";
|
||||
}
|
||||
|
||||
static string Unity_Blend_VividLight(
|
||||
[Slot(0, Binding.None)] DynamicDimensionVector Base,
|
||||
[Slot(1, Binding.None)] DynamicDimensionVector Blend,
|
||||
[Slot(3, Binding.None, 1, 1, 1, 1)] Vector1 Opacity,
|
||||
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
Base = clamp(Base, 0.000001, 0.999999);
|
||||
$precision{slot2dimension} result1 = 1.0 - (1.0 - Blend) / (2.0 * Base);
|
||||
$precision{slot2dimension} result2 = Blend / (2.0 * (1.0 - Base));
|
||||
$precision{slot2dimension} zeroOrOne = step(0.5, Base);
|
||||
Out = result2 * zeroOrOne + (1 - zeroOrOne) * result1;
|
||||
Out = lerp(Base, Out, Opacity);
|
||||
}
|
||||
";
|
||||
}
|
||||
|
||||
static string Unity_Blend_Subtract(
|
||||
[Slot(0, Binding.None)] DynamicDimensionVector Base,
|
||||
[Slot(1, Binding.None)] DynamicDimensionVector Blend,
|
||||
[Slot(3, Binding.None, 1, 1, 1, 1)] Vector1 Opacity,
|
||||
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
Out = Base - Blend;
|
||||
Out = lerp(Base, Out, Opacity);
|
||||
}
|
||||
";
|
||||
}
|
||||
|
||||
static string Unity_Blend_Overwrite(
|
||||
[Slot(0, Binding.None)] DynamicDimensionVector Base,
|
||||
[Slot(1, Binding.None)] DynamicDimensionVector Blend,
|
||||
[Slot(3, Binding.None, 1, 1, 1, 1)] Vector1 Opacity,
|
||||
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
Out = lerp(Base, Blend, Opacity);
|
||||
}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1aa4fa75c826d8d409b5033a6ef686eb
|
||||
timeCreated: 1495456651
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e005d19f5315e44bc9f50b3f6f8e50b2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,42 @@
|
|||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[Title("Artistic", "Filter", "Dither")]
|
||||
class DitherNode : CodeFunctionNode
|
||||
{
|
||||
public DitherNode()
|
||||
{
|
||||
name = "Dither";
|
||||
synonyms = new string[] { "blue noise", "half tone" };
|
||||
UpdateNodeAfterDeserialization();
|
||||
}
|
||||
|
||||
protected override MethodInfo GetFunctionToConvert()
|
||||
{
|
||||
return GetType().GetMethod("Unity_Dither", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
}
|
||||
|
||||
static string Unity_Dither(
|
||||
[Slot(0, Binding.None)] DynamicDimensionVector In,
|
||||
[Slot(1, Binding.ScreenPosition)] Vector2 ScreenPosition,
|
||||
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
$precision2 uv = ScreenPosition.xy * _ScreenParams.xy;
|
||||
$precision DITHER_THRESHOLDS[16] =
|
||||
{
|
||||
1.0 / 17.0, 9.0 / 17.0, 3.0 / 17.0, 11.0 / 17.0,
|
||||
13.0 / 17.0, 5.0 / 17.0, 15.0 / 17.0, 7.0 / 17.0,
|
||||
4.0 / 17.0, 12.0 / 17.0, 2.0 / 17.0, 10.0 / 17.0,
|
||||
16.0 / 17.0, 8.0 / 17.0, 14.0 / 17.0, 6.0 / 17.0
|
||||
};
|
||||
uint index = (uint(uv.x) % 4) * 4 + uint(uv.y) % 4;
|
||||
Out = In - DITHER_THRESHOLDS[index];
|
||||
}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 40b83fe632985494f96d2211c1963835
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cdb8c403de0823942a95a464c32ad0f0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,153 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEditor.Graphing;
|
||||
using UnityEditor.ShaderGraph.Drawing.Controls;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
enum TextureChannel
|
||||
{
|
||||
Red,
|
||||
Green,
|
||||
Blue,
|
||||
Alpha
|
||||
}
|
||||
|
||||
[Title("Artistic", "Mask", "Channel Mask")]
|
||||
class ChannelMaskNode : AbstractMaterialNode, IGeneratesBodyCode, IGeneratesFunction
|
||||
{
|
||||
public ChannelMaskNode()
|
||||
{
|
||||
name = "Channel Mask";
|
||||
synonyms = new string[] { "component mask" };
|
||||
UpdateNodeAfterDeserialization();
|
||||
}
|
||||
|
||||
const int InputSlotId = 0;
|
||||
const int OutputSlotId = 1;
|
||||
const string kInputSlotName = "In";
|
||||
const string kOutputSlotName = "Out";
|
||||
|
||||
public override bool hasPreview
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
string GetFunctionName()
|
||||
{
|
||||
string channelSum = "None";
|
||||
if (channelMask != 0)
|
||||
{
|
||||
bool red = (channelMask & 1) != 0;
|
||||
bool green = (channelMask & 2) != 0;
|
||||
bool blue = (channelMask & 4) != 0;
|
||||
bool alpha = (channelMask & 8) != 0;
|
||||
channelSum = string.Format("{0}{1}{2}{3}", red ? "Red" : "", green ? "Green" : "", blue ? "Blue" : "", alpha ? "Alpha" : "");
|
||||
}
|
||||
// NOTE: it's important we use the $precision generic form of the slot type in the name here
|
||||
return $"Unity_ChannelMask_{channelSum}_{FindInputSlot<DynamicVectorMaterialSlot>(InputSlotId).concreteValueType.ToShaderString()}";
|
||||
}
|
||||
|
||||
public sealed override void UpdateNodeAfterDeserialization()
|
||||
{
|
||||
AddSlot(new DynamicVectorMaterialSlot(InputSlotId, kInputSlotName, kInputSlotName, SlotType.Input, Vector3.zero));
|
||||
AddSlot(new DynamicVectorMaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector3.zero));
|
||||
RemoveSlotsNameNotMatching(new[] { InputSlotId, OutputSlotId });
|
||||
}
|
||||
|
||||
public TextureChannel channel;
|
||||
|
||||
[SerializeField]
|
||||
private int m_ChannelMask = -1;
|
||||
|
||||
[ChannelEnumMaskControl("Channels")]
|
||||
public int channelMask
|
||||
{
|
||||
get { return m_ChannelMask; }
|
||||
set
|
||||
{
|
||||
if (m_ChannelMask == value)
|
||||
return;
|
||||
|
||||
m_ChannelMask = value;
|
||||
Dirty(ModificationScope.Graph);
|
||||
}
|
||||
}
|
||||
|
||||
void ValidateChannelCount()
|
||||
{
|
||||
int channelCount = SlotValueHelper.GetChannelCount(FindSlot<MaterialSlot>(InputSlotId).concreteValueType);
|
||||
if (channelMask >= 1 << channelCount)
|
||||
channelMask = -1;
|
||||
}
|
||||
|
||||
string GetFunctionPrototype(string argIn, string argOut)
|
||||
{
|
||||
return string.Format("void {0} ({1} {2}, out {3} {4})"
|
||||
, GetFunctionName()
|
||||
, FindInputSlot<DynamicVectorMaterialSlot>(InputSlotId).concreteValueType.ToShaderString()
|
||||
, argIn
|
||||
, FindOutputSlot<DynamicVectorMaterialSlot>(OutputSlotId).concreteValueType.ToShaderString()
|
||||
, argOut);
|
||||
}
|
||||
|
||||
public void GenerateNodeCode(ShaderStringBuilder sb, GenerationMode generationMode)
|
||||
{
|
||||
ValidateChannelCount();
|
||||
string inputValue = GetSlotValue(InputSlotId, generationMode);
|
||||
string outputValue = GetSlotValue(OutputSlotId, generationMode);
|
||||
sb.AppendLine(string.Format("{0} {1};", FindInputSlot<MaterialSlot>(InputSlotId).concreteValueType.ToShaderString(), GetVariableNameForSlot(OutputSlotId)));
|
||||
sb.AppendLine(GetFunctionCallBody(inputValue, outputValue));
|
||||
}
|
||||
|
||||
string GetFunctionCallBody(string inputValue, string outputValue)
|
||||
{
|
||||
return GetFunctionName() + " (" + inputValue + ", " + outputValue + ");";
|
||||
}
|
||||
|
||||
public void GenerateNodeFunction(FunctionRegistry registry, GenerationMode generationMode)
|
||||
{
|
||||
ValidateChannelCount();
|
||||
registry.ProvideFunction(GetFunctionName(), s =>
|
||||
{
|
||||
int channelCount = SlotValueHelper.GetChannelCount(FindSlot<MaterialSlot>(InputSlotId).concreteValueType);
|
||||
s.AppendLine(GetFunctionPrototype("In", "Out"));
|
||||
using (s.BlockScope())
|
||||
{
|
||||
if (channelMask == 0)
|
||||
s.AppendLine("Out = 0;");
|
||||
else if (channelMask == -1)
|
||||
s.AppendLine("Out = In;");
|
||||
else
|
||||
{
|
||||
bool red = (channelMask & 1) != 0;
|
||||
bool green = (channelMask & 2) != 0;
|
||||
bool blue = (channelMask & 4) != 0;
|
||||
bool alpha = (channelMask & 8) != 0;
|
||||
|
||||
switch (channelCount)
|
||||
{
|
||||
case 1:
|
||||
s.AppendLine("Out = In.r;");
|
||||
break;
|
||||
case 2:
|
||||
s.AppendLine(string.Format("Out = $precision2({0}, {1});",
|
||||
red ? "In.r" : "0", green ? "In.g" : "0"));
|
||||
break;
|
||||
case 3:
|
||||
s.AppendLine(string.Format("Out = $precision3({0}, {1}, {2});",
|
||||
red ? "In.r" : "0", green ? "In.g" : "0", blue ? "In.b" : "0"));
|
||||
break;
|
||||
case 4:
|
||||
s.AppendLine(string.Format("Out = $precision4({0}, {1}, {2}, {3});",
|
||||
red ? "In.r" : "0", green ? "In.g" : "0", blue ? "In.b" : "0", alpha ? "In.a" : "0"));
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e3fd76d77a796b641ba3e9149086efc2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,34 @@
|
|||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[Title("Artistic", "Mask", "Color Mask")]
|
||||
class ColorMaskNode : CodeFunctionNode
|
||||
{
|
||||
public ColorMaskNode()
|
||||
{
|
||||
name = "Color Mask";
|
||||
}
|
||||
|
||||
protected override MethodInfo GetFunctionToConvert()
|
||||
{
|
||||
return GetType().GetMethod("Unity_ColorMask", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
}
|
||||
|
||||
static string Unity_ColorMask(
|
||||
[Slot(0, Binding.None)] Vector3 In,
|
||||
[Slot(1, Binding.None)] ColorRGB MaskColor,
|
||||
[Slot(2, Binding.None)] Vector1 Range,
|
||||
[Slot(4, Binding.None)] Vector1 Fuzziness,
|
||||
[Slot(3, Binding.None)] out Vector1 Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
$precision Distance = distance(MaskColor, In);
|
||||
Out = saturate(1 - (Distance - Range) / max(Fuzziness, 1e-5));
|
||||
}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 19255c24842f72c4c94c21b682a3e170
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b7f9e0995756c4a4896912f8873eb63c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,81 @@
|
|||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using UnityEditor.Graphing;
|
||||
using UnityEditor.ShaderGraph.Drawing.Controls;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
enum NormalBlendMode
|
||||
{
|
||||
Default,
|
||||
Reoriented
|
||||
}
|
||||
|
||||
[FormerName("UnityEditor.ShaderGraph.BlendNormalRNM")]
|
||||
[Title("Artistic", "Normal", "Normal Blend")]
|
||||
class NormalBlendNode : CodeFunctionNode
|
||||
{
|
||||
public NormalBlendNode()
|
||||
{
|
||||
name = "Normal Blend";
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private NormalBlendMode m_BlendMode = NormalBlendMode.Default;
|
||||
|
||||
[EnumControl("Mode")]
|
||||
public NormalBlendMode blendMode
|
||||
{
|
||||
get { return m_BlendMode; }
|
||||
set
|
||||
{
|
||||
if (m_BlendMode == value)
|
||||
return;
|
||||
|
||||
m_BlendMode = value;
|
||||
Dirty(ModificationScope.Graph);
|
||||
}
|
||||
}
|
||||
|
||||
protected override MethodInfo GetFunctionToConvert()
|
||||
{
|
||||
switch (m_BlendMode)
|
||||
{
|
||||
case NormalBlendMode.Reoriented:
|
||||
return GetType().GetMethod("Unity_NormalBlend_Reoriented", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
default:
|
||||
return GetType().GetMethod("Unity_NormalBlend", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
}
|
||||
}
|
||||
|
||||
static string Unity_NormalBlend(
|
||||
[Slot(0, Binding.None, 0, 0, 1, 0)] Vector3 A,
|
||||
[Slot(1, Binding.None, 0, 0, 1, 0)] Vector3 B,
|
||||
[Slot(2, Binding.None)] out Vector3 Out)
|
||||
{
|
||||
Out = Vector3.one;
|
||||
|
||||
return @"
|
||||
{
|
||||
Out = SafeNormalize($precision3(A.rg + B.rg, A.b * B.b));
|
||||
}
|
||||
";
|
||||
}
|
||||
|
||||
static string Unity_NormalBlend_Reoriented(
|
||||
[Slot(0, Binding.None, 0, 0, 1, 0)] Vector3 A,
|
||||
[Slot(1, Binding.None, 0, 0, 1, 0)] Vector3 B,
|
||||
[Slot(2, Binding.None)] out Vector3 Out)
|
||||
{
|
||||
Out = Vector3.one;
|
||||
return
|
||||
@"
|
||||
{
|
||||
$precision3 t = A.xyz + $precision3(0.0, 0.0, 1.0);
|
||||
$precision3 u = B.xyz * $precision3(-1.0, -1.0, 1.0);
|
||||
Out = (t / t.z) * dot(t, u) - u;
|
||||
}
|
||||
";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e8d13e9dbb613e04f835b281d7ee9ef1
|
||||
timeCreated: 1490780593
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,131 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor.Graphing;
|
||||
using UnityEditor.ShaderGraph.Drawing.Controls;
|
||||
using UnityEditor.ShaderGraph.Internal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
enum OutputSpace
|
||||
{
|
||||
Tangent,
|
||||
World
|
||||
};
|
||||
|
||||
[Title("Artistic", "Normal", "Normal From Height")]
|
||||
class NormalFromHeightNode : AbstractMaterialNode, IGeneratesBodyCode, IGeneratesFunction, IMayRequireTangent, IMayRequireBitangent, IMayRequireNormal, IMayRequirePosition
|
||||
{
|
||||
public NormalFromHeightNode()
|
||||
{
|
||||
name = "Normal From Height";
|
||||
synonyms = new string[] { "convert to normal", "bump map" };
|
||||
UpdateNodeAfterDeserialization();
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private OutputSpace m_OutputSpace = OutputSpace.Tangent;
|
||||
|
||||
[EnumControl("Output Space")]
|
||||
public OutputSpace outputSpace
|
||||
{
|
||||
get { return m_OutputSpace; }
|
||||
set
|
||||
{
|
||||
if (m_OutputSpace == value)
|
||||
return;
|
||||
|
||||
m_OutputSpace = value;
|
||||
Dirty(ModificationScope.Graph);
|
||||
}
|
||||
}
|
||||
|
||||
const int InputSlotId = 0;
|
||||
const int StrengthSlotId = 2;
|
||||
const int OutputSlotId = 1;
|
||||
const string kInputSlotName = "In";
|
||||
const string kStrengthSlotName = "Strength";
|
||||
const string kOutputSlotName = "Out";
|
||||
|
||||
public override bool hasPreview
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
string GetFunctionName()
|
||||
{
|
||||
return $"Unity_NormalFromHeight_{outputSpace.ToString()}_$precision";
|
||||
}
|
||||
|
||||
public sealed override void UpdateNodeAfterDeserialization()
|
||||
{
|
||||
AddSlot(new Vector1MaterialSlot(InputSlotId, kInputSlotName, kInputSlotName, SlotType.Input, 0));
|
||||
AddSlot(new Vector1MaterialSlot(StrengthSlotId, kStrengthSlotName, kStrengthSlotName, SlotType.Input, 0.01f));
|
||||
AddSlot(new Vector3MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.zero, ShaderStageCapability.Fragment));
|
||||
RemoveSlotsNameNotMatching(new[] { InputSlotId, StrengthSlotId, OutputSlotId });
|
||||
}
|
||||
|
||||
public void GenerateNodeCode(ShaderStringBuilder sb, GenerationMode generationMode)
|
||||
{
|
||||
var inputValue = GetSlotValue(InputSlotId, generationMode);
|
||||
var strengthValue = GetSlotValue(StrengthSlotId, generationMode);
|
||||
var outputValue = GetSlotValue(OutputSlotId, generationMode);
|
||||
sb.AppendLine("{0} {1};", FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType.ToShaderString(), GetVariableNameForSlot(OutputSlotId));
|
||||
sb.AppendLine("$precision3x3 _{0}_TangentMatrix = $precision3x3(IN.{1}SpaceTangent, IN.{1}SpaceBiTangent, IN.{1}SpaceNormal);", GetVariableNameForNode(), NeededCoordinateSpace.World.ToString());
|
||||
sb.AppendLine("$precision3 _{0}_Position = IN.{1}SpacePosition;", GetVariableNameForNode(), NeededCoordinateSpace.World.ToString());
|
||||
sb.AppendLine("{0}({1},{2},_{3}_Position,_{3}_TangentMatrix, {4});", GetFunctionName(), inputValue, strengthValue, GetVariableNameForNode(), outputValue);
|
||||
}
|
||||
|
||||
public void GenerateNodeFunction(FunctionRegistry registry, GenerationMode generationMode)
|
||||
{
|
||||
registry.ProvideFunction(GetFunctionName(), s =>
|
||||
{
|
||||
s.AppendLine("void {0}({1} In, {2} Strength, $precision3 Position, $precision3x3 TangentMatrix, out {3} Out)",
|
||||
GetFunctionName(),
|
||||
FindInputSlot<MaterialSlot>(InputSlotId).concreteValueType.ToShaderString(),
|
||||
FindInputSlot<MaterialSlot>(StrengthSlotId).concreteValueType.ToShaderString(),
|
||||
FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType.ToShaderString());
|
||||
using (s.BlockScope())
|
||||
{
|
||||
s.AppendLine(GetRayTracingError());
|
||||
s.AppendLine("$precision3 worldDerivativeX = ddx(Position);");
|
||||
s.AppendLine("$precision3 worldDerivativeY = ddy(Position);");
|
||||
s.AppendNewLine();
|
||||
s.AppendLine("$precision3 crossX = cross(TangentMatrix[2].xyz, worldDerivativeX);");
|
||||
s.AppendLine("$precision3 crossY = cross(worldDerivativeY, TangentMatrix[2].xyz);");
|
||||
s.AppendLine("$precision d = dot(worldDerivativeX, crossY);");
|
||||
s.AppendLine("$precision sgn = d < 0.0 ? (-1.0f) : 1.0f;");
|
||||
s.AppendLine("$precision surface = sgn / max(0.000000000000001192093f, abs(d));");
|
||||
s.AppendNewLine();
|
||||
s.AppendLine("$precision dHdx = ddx(In);");
|
||||
s.AppendLine("$precision dHdy = ddy(In);");
|
||||
s.AppendLine("$precision3 surfGrad = surface * (dHdx*crossY + dHdy*crossX);");
|
||||
s.AppendLine("Out = SafeNormalize(TangentMatrix[2].xyz - (Strength * surfGrad));");
|
||||
|
||||
if (outputSpace == OutputSpace.Tangent)
|
||||
s.AppendLine("Out = TransformWorldToTangent(Out, TangentMatrix);");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public NeededCoordinateSpace RequiresTangent(ShaderStageCapability stageCapability)
|
||||
{
|
||||
return NeededCoordinateSpace.World;
|
||||
}
|
||||
|
||||
public NeededCoordinateSpace RequiresBitangent(ShaderStageCapability stageCapability)
|
||||
{
|
||||
return NeededCoordinateSpace.World;
|
||||
}
|
||||
|
||||
public NeededCoordinateSpace RequiresNormal(ShaderStageCapability stageCapability)
|
||||
{
|
||||
return NeededCoordinateSpace.World;
|
||||
}
|
||||
|
||||
public NeededCoordinateSpace RequiresPosition(ShaderStageCapability stageCapability)
|
||||
{
|
||||
return NeededCoordinateSpace.World;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3bf617c1fe220684696e5bf3850bc423
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,108 @@
|
|||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEditor.Graphing;
|
||||
using UnityEditor.ShaderGraph.Internal;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[FormerName("UnityEditor.ShaderGraph.NormalCreateNode")]
|
||||
[Title("Artistic", "Normal", "Normal From Texture")]
|
||||
class NormalFromTextureNode : AbstractMaterialNode, IGeneratesBodyCode, IGeneratesFunction, IMayRequireMeshUV
|
||||
{
|
||||
public const int TextureInputId = 0;
|
||||
public const int UVInputId = 1;
|
||||
public const int SamplerInputId = 2;
|
||||
public const int OffsetInputId = 3;
|
||||
public const int StrengthInputId = 4;
|
||||
public const int OutputSlotId = 5;
|
||||
|
||||
const string k_TextureInputName = "Texture";
|
||||
const string k_UVInputName = "UV";
|
||||
const string k_SamplerInputName = "Sampler";
|
||||
const string k_OffsetInputName = "Offset";
|
||||
const string k_StrengthInputName = "Strength";
|
||||
const string k_OutputSlotName = "Out";
|
||||
|
||||
public NormalFromTextureNode()
|
||||
{
|
||||
name = "Normal From Texture";
|
||||
synonyms = new string[] { "convert to normal", "bump map" };
|
||||
UpdateNodeAfterDeserialization();
|
||||
}
|
||||
|
||||
string GetFunctionName()
|
||||
{
|
||||
return "Unity_NormalFromTexture_$precision";
|
||||
}
|
||||
|
||||
public override bool hasPreview { get { return true; } }
|
||||
|
||||
public sealed override void UpdateNodeAfterDeserialization()
|
||||
{
|
||||
AddSlot(new Texture2DInputMaterialSlot(TextureInputId, k_TextureInputName, k_TextureInputName));
|
||||
AddSlot(new UVMaterialSlot(UVInputId, k_UVInputName, k_UVInputName, UVChannel.UV0));
|
||||
AddSlot(new SamplerStateMaterialSlot(SamplerInputId, k_SamplerInputName, k_SamplerInputName, SlotType.Input));
|
||||
AddSlot(new Vector1MaterialSlot(OffsetInputId, k_OffsetInputName, k_OffsetInputName, SlotType.Input, 0.5f));
|
||||
AddSlot(new Vector1MaterialSlot(StrengthInputId, k_StrengthInputName, k_StrengthInputName, SlotType.Input, 8f));
|
||||
AddSlot(new Vector3MaterialSlot(OutputSlotId, k_OutputSlotName, k_OutputSlotName, SlotType.Output, Vector3.zero, ShaderStageCapability.Fragment));
|
||||
RemoveSlotsNameNotMatching(new[] { TextureInputId, UVInputId, SamplerInputId, OffsetInputId, StrengthInputId, OutputSlotId });
|
||||
}
|
||||
|
||||
public void GenerateNodeCode(ShaderStringBuilder sb, GenerationMode generationMode)
|
||||
{
|
||||
var textureValue = GetSlotValue(TextureInputId, generationMode);
|
||||
var uvValue = GetSlotValue(UVInputId, generationMode);
|
||||
var offsetValue = GetSlotValue(OffsetInputId, generationMode);
|
||||
var strengthValue = GetSlotValue(StrengthInputId, generationMode);
|
||||
var outputValue = GetSlotValue(OutputSlotId, generationMode);
|
||||
|
||||
var samplerSlot = FindInputSlot<MaterialSlot>(SamplerInputId);
|
||||
var edgesSampler = owner.GetEdges(samplerSlot.slotReference);
|
||||
string samplerValue;
|
||||
if (edgesSampler.Any())
|
||||
samplerValue = GetSlotValue(SamplerInputId, generationMode);
|
||||
else
|
||||
samplerValue = textureValue;
|
||||
|
||||
sb.AppendLine("{0} {1};", FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType.ToShaderString(), GetVariableNameForSlot(OutputSlotId));
|
||||
sb.AppendLine("{0}(TEXTURE2D_ARGS({1}.tex, {2}.samplerstate), {1}.GetTransformedUV({3}), {4}, {5}, {6});", GetFunctionName(), textureValue, samplerValue, uvValue, offsetValue, strengthValue, outputValue);
|
||||
}
|
||||
|
||||
public void GenerateNodeFunction(FunctionRegistry registry, GenerationMode generationMode)
|
||||
{
|
||||
registry.ProvideFunction(GetFunctionName(), s =>
|
||||
{
|
||||
s.AppendLine("void {0}(TEXTURE2D_PARAM(Texture, Sampler), {1} UV, {2} Offset, {3} Strength, out {4} Out)",
|
||||
GetFunctionName(),
|
||||
FindInputSlot<MaterialSlot>(UVInputId).concreteValueType.ToShaderString(),
|
||||
FindInputSlot<MaterialSlot>(OffsetInputId).concreteValueType.ToShaderString(),
|
||||
FindInputSlot<MaterialSlot>(StrengthInputId).concreteValueType.ToShaderString(),
|
||||
FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType.ToShaderString());
|
||||
using (s.BlockScope())
|
||||
{
|
||||
s.AppendLine("Offset = pow(Offset, 3) * 0.1;");
|
||||
s.AppendLine("$precision2 offsetU = $precision2(UV.x + Offset, UV.y);");
|
||||
s.AppendLine("$precision2 offsetV = $precision2(UV.x, UV.y + Offset);");
|
||||
|
||||
s.AppendLine("$precision normalSample = SAMPLE_TEXTURE2D(Texture, Sampler, UV);");
|
||||
s.AppendLine("$precision uSample = SAMPLE_TEXTURE2D(Texture, Sampler, offsetU);");
|
||||
s.AppendLine("$precision vSample = SAMPLE_TEXTURE2D(Texture, Sampler, offsetV);");
|
||||
|
||||
s.AppendLine("$precision3 va = $precision3(1, 0, (uSample - normalSample) * Strength);");
|
||||
s.AppendLine("$precision3 vb = $precision3(0, 1, (vSample - normalSample) * Strength);");
|
||||
s.AppendLine("Out = normalize(cross(va, vb));");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public bool RequiresMeshUV(UVChannel channel, ShaderStageCapability stageCapability)
|
||||
{
|
||||
foreach (var slot in this.GetInputSlots<MaterialSlot>().OfType<IMayRequireMeshUV>())
|
||||
{
|
||||
if (slot.RequiresMeshUV(channel))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c943843c9c7424a4d9b629c087d93df5
|
||||
timeCreated: 1495565761
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,34 @@
|
|||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[Title("Artistic", "Normal", "Normal Reconstruct Z")]
|
||||
class NormalReconstructZNode : CodeFunctionNode
|
||||
{
|
||||
public NormalReconstructZNode()
|
||||
{
|
||||
name = "Normal Reconstruct Z";
|
||||
synonyms = new string[] { "derive z" };
|
||||
}
|
||||
|
||||
protected override MethodInfo GetFunctionToConvert()
|
||||
{
|
||||
return GetType().GetMethod("NormalReconstructZ", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
}
|
||||
|
||||
static string NormalReconstructZ(
|
||||
[Slot(0, Binding.None)] Vector2 In,
|
||||
[Slot(2, Binding.None)] out Vector3 Out)
|
||||
{
|
||||
Out = Vector3.zero;
|
||||
return
|
||||
@"
|
||||
{
|
||||
$precision reconstructZ = sqrt(1.0 - saturate(dot(In.xy, In.xy)));
|
||||
$precision3 normalVector = $precision3(In.x, In.y, reconstructZ);
|
||||
Out = normalize(normalVector);
|
||||
}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 27615ef3e2e760b45b15895bd39d0954
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,34 @@
|
|||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[Title("Artistic", "Normal", "Normal Strength")]
|
||||
internal class NormalStrengthNode : CodeFunctionNode
|
||||
{
|
||||
public NormalStrengthNode()
|
||||
{
|
||||
name = "Normal Strength";
|
||||
synonyms = new string[] { "intensity" };
|
||||
}
|
||||
|
||||
protected override MethodInfo GetFunctionToConvert()
|
||||
{
|
||||
return GetType().GetMethod("Unity_NormalStrength", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
}
|
||||
|
||||
static string Unity_NormalStrength(
|
||||
[Slot(0, Binding.None, 0, 0, 1, 0)] Vector3 In,
|
||||
[Slot(1, Binding.None, 1, 1, 1, 1)] Vector1 Strength,
|
||||
[Slot(2, Binding.None)] out Vector3 Out)
|
||||
{
|
||||
Out = Vector3.up;
|
||||
return
|
||||
@"
|
||||
{
|
||||
Out = $precision3(In.rg * Strength, lerp(1, In.b, saturate(Strength)));
|
||||
}
|
||||
";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c003a641a03160e478f4ce7ee8ce8da6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,66 @@
|
|||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using UnityEditor.Graphing;
|
||||
using UnityEditor.ShaderGraph.Drawing.Controls;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[Title("Artistic", "Normal", "Normal Unpack")]
|
||||
internal class NormalUnpackNode : CodeFunctionNode
|
||||
{
|
||||
public NormalUnpackNode()
|
||||
{
|
||||
name = "Normal Unpack";
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private NormalMapSpace m_NormalMapSpace = NormalMapSpace.Tangent;
|
||||
|
||||
[EnumControl("Space")]
|
||||
public NormalMapSpace normalMapSpace
|
||||
{
|
||||
get { return m_NormalMapSpace; }
|
||||
set
|
||||
{
|
||||
if (m_NormalMapSpace == value)
|
||||
return;
|
||||
|
||||
m_NormalMapSpace = value;
|
||||
Dirty(ModificationScope.Graph);
|
||||
}
|
||||
}
|
||||
|
||||
protected override MethodInfo GetFunctionToConvert()
|
||||
{
|
||||
return GetType().GetMethod(normalMapSpace == NormalMapSpace.Tangent ? "Unity_NormalUnpack" : "Unity_NormalUnpackRGB", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
}
|
||||
|
||||
static string Unity_NormalUnpack(
|
||||
[Slot(0, Binding.None)] Vector4 In,
|
||||
[Slot(1, Binding.None)] out Vector3 Out)
|
||||
{
|
||||
Out = Vector3.up;
|
||||
|
||||
return
|
||||
@"
|
||||
{
|
||||
Out = UnpackNormal(In);
|
||||
}
|
||||
";
|
||||
}
|
||||
|
||||
static string Unity_NormalUnpackRGB(
|
||||
[Slot(0, Binding.None)] Vector4 In,
|
||||
[Slot(1, Binding.None)] out Vector3 Out)
|
||||
{
|
||||
Out = Vector3.up;
|
||||
|
||||
return
|
||||
@"
|
||||
{
|
||||
Out = UnpackNormalRGB(In);
|
||||
}
|
||||
";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1295ed68a1115a64088fc9298766fde8
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 32bf6e8fcb46ec24a9db465ddec10a34
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,223 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
using UnityEditor.ShaderGraph.Drawing.Controls;
|
||||
using UnityEngine;
|
||||
using UnityEditor.Graphing;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
enum Colorspace
|
||||
{
|
||||
RGB,
|
||||
Linear,
|
||||
HSV
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
struct ColorspaceConversion : IEnumConversion
|
||||
{
|
||||
public Colorspace from;
|
||||
public Colorspace to;
|
||||
|
||||
public ColorspaceConversion(Colorspace from, Colorspace to)
|
||||
{
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
Enum IEnumConversion.from
|
||||
{
|
||||
get { return from; }
|
||||
set { from = (Colorspace)value; }
|
||||
}
|
||||
|
||||
Enum IEnumConversion.to
|
||||
{
|
||||
get { return to; }
|
||||
set { to = (Colorspace)value; }
|
||||
}
|
||||
}
|
||||
|
||||
[Title("Artistic", "Utility", "Colorspace Conversion")]
|
||||
class ColorspaceConversionNode : CodeFunctionNode
|
||||
{
|
||||
public ColorspaceConversionNode()
|
||||
{
|
||||
name = "Colorspace Conversion";
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
ColorspaceConversion m_Conversion = new ColorspaceConversion(Colorspace.RGB, Colorspace.RGB);
|
||||
|
||||
[EnumConversionControl]
|
||||
ColorspaceConversion conversion
|
||||
{
|
||||
get { return m_Conversion; }
|
||||
set
|
||||
{
|
||||
if (m_Conversion.Equals(value))
|
||||
return;
|
||||
m_Conversion = value;
|
||||
Dirty(ModificationScope.Graph);
|
||||
}
|
||||
}
|
||||
|
||||
string GetSpaceFrom()
|
||||
{
|
||||
return Enum.GetName(typeof(Colorspace), conversion.from);
|
||||
}
|
||||
|
||||
string GetSpaceTo()
|
||||
{
|
||||
return Enum.GetName(typeof(Colorspace), conversion.to);
|
||||
}
|
||||
|
||||
protected override MethodInfo GetFunctionToConvert()
|
||||
{
|
||||
return GetType().GetMethod(string.Format("Unity_ColorspaceConversion_{0}_{1}", GetSpaceFrom(), GetSpaceTo()),
|
||||
BindingFlags.Static | BindingFlags.NonPublic);
|
||||
}
|
||||
|
||||
static string Unity_ColorspaceConversion_RGB_RGB(
|
||||
[Slot(0, Binding.None)] Vector3 In,
|
||||
[Slot(1, Binding.None)] out Vector3 Out)
|
||||
{
|
||||
Out = Vector3.zero;
|
||||
return
|
||||
@"
|
||||
{
|
||||
Out = In;
|
||||
}
|
||||
";
|
||||
}
|
||||
|
||||
static string Unity_ColorspaceConversion_RGB_Linear(
|
||||
[Slot(0, Binding.None)] Vector3 In,
|
||||
[Slot(1, Binding.None)] out Vector3 Out)
|
||||
{
|
||||
Out = Vector3.zero;
|
||||
return
|
||||
@"
|
||||
{
|
||||
$precision3 linearRGBLo = In / 12.92;
|
||||
$precision3 linearRGBHi = pow(max(abs((In + 0.055) / 1.055), 1.192092896e-07), $precision3(2.4, 2.4, 2.4));
|
||||
Out = $precision3(In <= 0.04045) ? linearRGBLo : linearRGBHi;
|
||||
}
|
||||
";
|
||||
}
|
||||
|
||||
static string Unity_ColorspaceConversion_RGB_HSV(
|
||||
[Slot(0, Binding.None)] Vector3 In,
|
||||
[Slot(1, Binding.None)] out Vector3 Out)
|
||||
{
|
||||
Out = Vector3.zero;
|
||||
return
|
||||
@"
|
||||
{
|
||||
$precision4 K = $precision4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
$precision4 P = lerp($precision4(In.bg, K.wz), $precision4(In.gb, K.xy), step(In.b, In.g));
|
||||
$precision4 Q = lerp($precision4(P.xyw, In.r), $precision4(In.r, P.yzx), step(P.x, In.r));
|
||||
$precision D = Q.x - min(Q.w, Q.y);
|
||||
$precision E = 1e-10;
|
||||
$precision V = (D == 0) ? Q.x : (Q.x + E);
|
||||
Out = $precision3(abs(Q.z + (Q.w - Q.y)/(6.0 * D + E)), D / (Q.x + E), V);
|
||||
}
|
||||
";
|
||||
}
|
||||
|
||||
static string Unity_ColorspaceConversion_Linear_RGB(
|
||||
[Slot(0, Binding.None)] Vector3 In,
|
||||
[Slot(1, Binding.None)] out Vector3 Out)
|
||||
{
|
||||
Out = Vector3.zero;
|
||||
return
|
||||
@"
|
||||
{
|
||||
$precision3 sRGBLo = In * 12.92;
|
||||
$precision3 sRGBHi = (pow(max(abs(In), 1.192092896e-07), $precision3(1.0 / 2.4, 1.0 / 2.4, 1.0 / 2.4)) * 1.055) - 0.055;
|
||||
Out = $precision3(In <= 0.0031308) ? sRGBLo : sRGBHi;
|
||||
}
|
||||
";
|
||||
}
|
||||
|
||||
static string Unity_ColorspaceConversion_Linear_Linear(
|
||||
[Slot(0, Binding.None)] Vector3 In,
|
||||
[Slot(1, Binding.None)] out Vector3 Out)
|
||||
{
|
||||
Out = Vector3.zero;
|
||||
return
|
||||
@"
|
||||
{
|
||||
Out = In;
|
||||
}
|
||||
";
|
||||
}
|
||||
|
||||
static string Unity_ColorspaceConversion_Linear_HSV(
|
||||
[Slot(0, Binding.None)] Vector3 In,
|
||||
[Slot(1, Binding.None)] out Vector3 Out)
|
||||
{
|
||||
Out = Vector3.zero;
|
||||
return
|
||||
@"
|
||||
{
|
||||
$precision3 sRGBLo = In * 12.92;
|
||||
$precision3 sRGBHi = (pow(max(abs(In), 1.192092896e-07), $precision3(1.0 / 2.4, 1.0 / 2.4, 1.0 / 2.4)) * 1.055) - 0.055;
|
||||
$precision3 Linear = $precision3(In <= 0.0031308) ? sRGBLo : sRGBHi;
|
||||
$precision4 K = $precision4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
$precision4 P = lerp($precision4(Linear.bg, K.wz), $precision4(Linear.gb, K.xy), step(Linear.b, Linear.g));
|
||||
$precision4 Q = lerp($precision4(P.xyw, Linear.r), $precision4(Linear.r, P.yzx), step(P.x, Linear.r));
|
||||
$precision D = Q.x - min(Q.w, Q.y);
|
||||
$precision E = 1e-10;
|
||||
Out = $precision3(abs(Q.z + (Q.w - Q.y)/(6.0 * D + E)), D / (Q.x + E), Q.x);
|
||||
}
|
||||
";
|
||||
}
|
||||
|
||||
static string Unity_ColorspaceConversion_HSV_RGB(
|
||||
[Slot(0, Binding.None)] Vector3 In,
|
||||
[Slot(1, Binding.None)] out Vector3 Out)
|
||||
{
|
||||
Out = Vector3.zero;
|
||||
return
|
||||
@"
|
||||
{
|
||||
$precision4 K = $precision4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
$precision3 P = abs(frac(In.xxx + K.xyz) * 6.0 - K.www);
|
||||
Out = In.z * lerp(K.xxx, saturate(P - K.xxx), In.y);
|
||||
}
|
||||
";
|
||||
}
|
||||
|
||||
static string Unity_ColorspaceConversion_HSV_Linear(
|
||||
[Slot(0, Binding.None)] Vector3 In,
|
||||
[Slot(1, Binding.None)] out Vector3 Out)
|
||||
{
|
||||
Out = Vector3.zero;
|
||||
return
|
||||
@"
|
||||
{
|
||||
$precision4 K = $precision4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
$precision3 P = abs(frac(In.xxx + K.xyz) * 6.0 - K.www);
|
||||
$precision3 RGB = In.z * lerp(K.xxx, saturate(P - K.xxx), In.y);
|
||||
$precision3 linearRGBLo = RGB / 12.92;
|
||||
$precision3 linearRGBHi = pow(max(abs((RGB + 0.055) / 1.055), 1.192092896e-07), $precision3(2.4, 2.4, 2.4));
|
||||
Out = $precision3(RGB <= 0.04045) ? linearRGBLo : linearRGBHi;
|
||||
}
|
||||
";
|
||||
}
|
||||
|
||||
static string Unity_ColorspaceConversion_HSV_HSV(
|
||||
[Slot(0, Binding.None)] Vector3 In,
|
||||
[Slot(1, Binding.None)] out Vector3 Out)
|
||||
{
|
||||
Out = Vector3.zero;
|
||||
return
|
||||
@"
|
||||
{
|
||||
Out = In;
|
||||
}
|
||||
";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 96dd6bbf093ac3d41a5bdaa467b58e6c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue