Peter Bay Bastian
7 年前
当前提交
7e160ce8
共有 204 个文件被更改,包括 1455 次插入 和 1439 次删除
-
40MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Testing/IntegrationTests/SerializationTests.cs
-
1MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Assets/IGraphAsset.cs
-
4MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Implementation/NodeUtils.cs
-
10MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Implementation/SerializableGraph.cs
-
4MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Interfaces/GraphDrawingData.cs
-
4MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Util/PooledObject.cs
-
16MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Util/SerializationHelper.cs
-
68MaterialGraphProject/Assets/NewNodes/ChannelBlendNode.cs
-
16MaterialGraphProject/Assets/NewNodes/CommonMatrixType.cs
-
4MaterialGraphProject/Assets/NewNodes/ConstantType.cs
-
12MaterialGraphProject/Assets/NewNodes/Editor/BlendModeNodePresenter.cs
-
3MaterialGraphProject/Assets/NewNodes/Editor/ConstantsNodePresenter.cs
-
18MaterialGraphProject/Assets/NewNodes/Editor/ToggleNodePresenter.cs
-
11MaterialGraphProject/Assets/NewNodes/Editor/TransformNodePresenter.cs
-
3MaterialGraphProject/Assets/NewNodes/FractalNode.cs
-
108MaterialGraphProject/Assets/NewNodes/FunctionNAddNode.cs
-
306MaterialGraphProject/Assets/NewNodes/FunctionNInNOut.cs
-
3MaterialGraphProject/Assets/NewNodes/Keep/BlendModeNode.cs
-
2MaterialGraphProject/Assets/NewNodes/Keep/BlendModesEnum.cs
-
2MaterialGraphProject/Assets/NewNodes/Keep/ColorBalanceNode.cs
-
3MaterialGraphProject/Assets/NewNodes/Keep/ConstantsNode.cs
-
6MaterialGraphProject/Assets/NewNodes/Keep/GradientField.cs
-
11MaterialGraphProject/Assets/NewNodes/Keep/GradientNode.cs
-
97MaterialGraphProject/Assets/NewNodes/Keep/GradientWrapper.cs
-
2MaterialGraphProject/Assets/NewNodes/Keep/HeightToNormalNode.cs
-
54MaterialGraphProject/Assets/NewNodes/Keep/LightProbeNode.cs
-
11MaterialGraphProject/Assets/NewNodes/Keep/ParallaxNode.cs
-
3MaterialGraphProject/Assets/NewNodes/Keep/RadialShearNode.cs
-
2MaterialGraphProject/Assets/NewNodes/Keep/RandomRangeNode.cs
-
4MaterialGraphProject/Assets/NewNodes/Keep/ReciprocalSqrtNode.cs
-
56MaterialGraphProject/Assets/NewNodes/Keep/ReflectionProbeNode.cs
-
3MaterialGraphProject/Assets/NewNodes/Keep/SamplerStateNode.cs
-
3MaterialGraphProject/Assets/NewNodes/Keep/ScaleOffsetNode.cs
-
9MaterialGraphProject/Assets/NewNodes/Keep/Texture2DNode.cs
-
22MaterialGraphProject/Assets/NewNodes/Keep/TextureSamplerNode.cs
-
363MaterialGraphProject/Assets/NewNodes/Keep/TransformNode.cs
-
377MaterialGraphProject/Assets/NewNodes/Keep/UVTriPlanar.cs
-
3MaterialGraphProject/Assets/NewNodes/Kill/AACheckerBoard3dNode.cs
-
2MaterialGraphProject/Assets/NewNodes/Kill/AACheckerBoardNode.cs
-
9MaterialGraphProject/Assets/NewNodes/Kill/MultiLayerParallaxNode.cs
-
3MaterialGraphProject/Assets/NewNodes/Kill/POMNode.cs
-
262MaterialGraphProject/Assets/NewNodes/Kill/ScatterNode.cs
-
2MaterialGraphProject/Assets/NewNodes/Kill/SphereWarpNode.cs
-
2MaterialGraphProject/Assets/NewNodes/Kill/SphericalIndentationNode.cs
-
22MaterialGraphProject/Assets/NewNodes/Kill/ToggleNode.cs
-
2MaterialGraphProject/Assets/NewNodes/Kill/VertexNormalNode.cs
-
6MaterialGraphProject/Assets/NewNodes/Kill/VertexPositionNode.cs
-
6MaterialGraphProject/Assets/UnityShaderEditor/Editor/AssetCallbacks/CreateRemapGraph.cs
-
6MaterialGraphProject/Assets/UnityShaderEditor/Editor/AssetCallbacks/CreateShaderGraph.cs
-
18MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs
-
10MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Manipulators/Clicker.cs
-
16MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphPreviewGenerator.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeInspectors/AbstractNodeInspector.cs
-
34MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeInspectors/PropertyNodeInspector.cs
-
14MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeInspectors/SurfaceMasterNodeInspector.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/GraphInspectorPresenter.cs
-
48MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs
-
10MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/NodePreviewPresenter.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/ColorNodePresenter.cs
-
20MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/CubemapNodePresenter.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/CustomCodeNodePresenter.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/GradientNodePresenter.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/IfNodePresenter.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/MasterNodePresenter.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/MatrixCommonNodePresenter.cs
-
60MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/RemapInputNodePresenter.cs
-
64MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/RemapMasterNodePresenter.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/SamplerAssetNodePresenter.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/SamplerStateNodePresenter.cs
-
58MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/ScatterNodePresenter.cs
-
16MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/SubgraphIONodePresenter.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/TextureAssetNodePresenter.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/TextureLODNodePresenter.cs
-
74MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/TextureNodePresenter.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/TextureSamplerNodePresenter.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/UVNodePresenter.cs
-
84MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/Vector1NodePresenter.cs
-
38MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/TitleBarPresenter.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphInspectorView.cs
-
29MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialGraphView.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/TitleBarButtonView.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/TitleBarView.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderGraphImporter.cs
-
24MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderSubGraphImporter.cs
-
5MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderSubGraphImporterEditor.cs
-
50MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Shaders/Checkerboard.shader
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/ShaderGenerationTest.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/MaterialGraphTests.cs
-
33MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/PixelShaderNodeTests.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/PropertyChunkTests.cs
-
132MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/PropertyNodeTests.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Util/CopyPasteGraph.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Util/ScriptableObjectFactory.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Util/TypeMapper.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Util/TypeMapping.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/AbstractMaterialGraphAsset.cs
-
1MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/IMaterialGraphAsset.cs
-
1MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/MaterialGraph.cs
-
1MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/MaterialGraphAsset.cs
|
|||
namespace UnityEngine.Graphing |
|||
{ |
|||
|
|||
} |
|
|||
using UnityEngine.Graphing; |
|||
using UnityEngine.Graphing; |
|||
/* [Title("Art/ChannelBlend")] |
|||
public class ChannelBlend : FunctionNInNOut, IGeneratesFunction |
|||
{ |
|||
/* [Title("Art/ChannelBlend")] |
|||
public class ChannelBlend : FunctionNInNOut, IGeneratesFunction |
|||
{ |
|||
public ChannelBlend() |
|||
{ |
|||
name = "ChannelBlend"; |
|||
AddSlot("Mask", "mask", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero); |
|||
AddSlot("RColor", "rCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero); |
|||
AddSlot("GColor", "gCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero); |
|||
AddSlot("BColor", "bCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero); |
|||
AddSlot("AColor", "aCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero); |
|||
AddSlot("BGColor", "bgCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero); |
|||
public ChannelBlend() |
|||
{ |
|||
name = "ChannelBlend"; |
|||
AddSlot("Mask", "mask", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero); |
|||
AddSlot("RColor", "rCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero); |
|||
AddSlot("GColor", "gCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero); |
|||
AddSlot("BColor", "bCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero); |
|||
AddSlot("AColor", "aCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero); |
|||
AddSlot("BGColor", "bgCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero); |
|||
AddSlot("BlendedColor", "blendCol", Graphing.SlotType.Output, SlotValueType.Vector4, Vector4.zero); |
|||
} |
|||
AddSlot("BlendedColor", "blendCol", Graphing.SlotType.Output, SlotValueType.Vector4, Vector4.zero); |
|||
} |
|||
protected override string GetFunctionName() |
|||
{ |
|||
return "unity_ChannelBlend"; |
|||
} |
|||
protected override string GetFunctionName() |
|||
{ |
|||
return "unity_ChannelBlend"; |
|||
} |
|||
public override bool hasPreview |
|||
{ |
|||
get { return true; } |
|||
} |
|||
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.AddShaderChunk("float4 background = step(max(mask.r,max(mask.g,mask.b)), 0.001) * bgCol;", false); |
|||
outputString.AddShaderChunk("blendCol = mask.r * rCol + mask.g * gCol + mask.b * bCol + mask.a * aCol + background;", false); |
|||
outputString.AddShaderChunk("}", false); |
|||
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var outputString = new ShaderGenerator(); |
|||
outputString.AddShaderChunk(GetFunctionPrototype(), false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.AddShaderChunk("float4 background = step(max(mask.r,max(mask.g,mask.b)), 0.001) * bgCol;", false); |
|||
outputString.AddShaderChunk("blendCol = mask.r * rCol + mask.g * gCol + mask.b * bCol + mask.a * aCol + background;", false); |
|||
outputString.AddShaderChunk("}", false); |
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
}*/ |
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
}*/ |
|||
} |
|
|||
using UnityEngine.Graphing; |
|||
using UnityEngine.Graphing; |
|||
/* [Title("Math/Advanced/Adder")] |
|||
public class AddManyNode : FunctionNInNOut, IGeneratesFunction |
|||
{ |
|||
int m_nodeInputCount = 2; |
|||
/* [Title("Math/Advanced/Adder")] |
|||
public class AddManyNode : FunctionNInNOut, IGeneratesFunction |
|||
{ |
|||
int m_nodeInputCount = 2; |
|||
public void AddInputSlot() |
|||
{ |
|||
string inputName = "Input" + GetInputSlots<MaterialSlot>().Count().ToString(); |
|||
AddSlot(inputName, inputName, Graphing.SlotType.Input, SlotValueType.Dynamic, Vector4.zero); |
|||
} |
|||
public void AddInputSlot() |
|||
{ |
|||
string inputName = "Input" + GetInputSlots<MaterialSlot>().Count().ToString(); |
|||
AddSlot(inputName, inputName, Graphing.SlotType.Input, SlotValueType.Dynamic, Vector4.zero); |
|||
} |
|||
public AddManyNode() |
|||
{ |
|||
name = "Adder"; |
|||
for(int i = 0; i < m_nodeInputCount; ++i) |
|||
{ |
|||
AddInputSlot(); |
|||
} |
|||
public AddManyNode() |
|||
{ |
|||
name = "Adder"; |
|||
for(int i = 0; i < m_nodeInputCount; ++i) |
|||
{ |
|||
AddInputSlot(); |
|||
} |
|||
AddSlot("Sum", "finalSum", Graphing.SlotType.Output, SlotValueType.Dynamic, Vector4.zero); |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
AddSlot("Sum", "finalSum", Graphing.SlotType.Output, SlotValueType.Dynamic, Vector4.zero); |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
public void OnModified() |
|||
{ |
|||
if (onModified != null) |
|||
onModified(this, ModificationScope.Node); |
|||
} |
|||
public void OnModified() |
|||
{ |
|||
if (onModified != null) |
|||
onModified(this, ModificationScope.Node); |
|||
} |
|||
protected override string GetFunctionName() |
|||
{ |
|||
return "unity_Adder"; |
|||
} |
|||
protected override string GetFunctionName() |
|||
{ |
|||
return "unity_Adder"; |
|||
} |
|||
string GetSumOfAllInputs() |
|||
{ |
|||
string sumString = ""; |
|||
int inputsLeft = GetInputSlots<ISlot>().Count(); |
|||
string GetSumOfAllInputs() |
|||
{ |
|||
string sumString = ""; |
|||
int inputsLeft = GetInputSlots<ISlot>().Count(); |
|||
foreach (ISlot slot in GetInputSlots<ISlot>()) |
|||
{ |
|||
sumString += GetShaderOutputName(slot.id); |
|||
if (inputsLeft > 1) |
|||
sumString += " + "; |
|||
--inputsLeft; |
|||
} |
|||
foreach (ISlot slot in GetInputSlots<ISlot>()) |
|||
{ |
|||
sumString += GetShaderOutputName(slot.id); |
|||
if (inputsLeft > 1) |
|||
sumString += " + "; |
|||
--inputsLeft; |
|||
} |
|||
return sumString; |
|||
} |
|||
return sumString; |
|||
} |
|||
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var outputString = new ShaderGenerator(); |
|||
outputString.AddShaderChunk(GetFunctionPrototype(), false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
outputString.AddShaderChunk("finalSum = " + GetSumOfAllInputs() + ";", false); |
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var outputString = new ShaderGenerator(); |
|||
outputString.AddShaderChunk(GetFunctionPrototype(), false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
outputString.AddShaderChunk("finalSum = " + GetSumOfAllInputs() + ";", false); |
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
}*/ |
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
}*/ |
|||
} |
|
|||
using UnityEngine.Graphing; |
|||
using UnityEngine.Graphing; |
|||
[Title ("Math/Vector/Transform")] |
|||
public class TransformNode : AbstractMaterialNode, IGeneratesBodyCode, IMayRequireTangent, IMayRequireBitangent, IMayRequireNormal |
|||
{ |
|||
[SerializeField] |
|||
private SimpleMatrixType m_spaceListFrom; |
|||
[SerializeField] |
|||
private SimpleMatrixType m_spaceListTo; |
|||
[Title("Math/Vector/Transform")] |
|||
public class TransformNode : AbstractMaterialNode, IGeneratesBodyCode, IMayRequireTangent, IMayRequireBitangent, IMayRequireNormal |
|||
{ |
|||
[SerializeField] |
|||
private SimpleMatrixType m_spaceListFrom; |
|||
[SerializeField] |
|||
private SimpleMatrixType m_spaceListTo; |
|||
private const int InputSlotId = 0; |
|||
private const int OutputSlotId = 1; |
|||
private const string kInputSlotName = "Input"; |
|||
private const string kOutputSlotName = "Output"; |
|||
private const int InputSlotId = 0; |
|||
private const int OutputSlotId = 1; |
|||
private const string kInputSlotName = "Input"; |
|||
private const string kOutputSlotName = "Output"; |
|||
public SimpleMatrixType spaceFrom |
|||
{ |
|||
get { return m_spaceListFrom; } |
|||
set |
|||
{ |
|||
if (m_spaceListFrom == value) |
|||
return; |
|||
public SimpleMatrixType spaceFrom |
|||
{ |
|||
get { return m_spaceListFrom; } |
|||
set |
|||
{ |
|||
if (m_spaceListFrom == value) |
|||
return; |
|||
m_spaceListFrom = value; |
|||
if (onModified != null) |
|||
{ |
|||
onModified(this, ModificationScope.Graph); |
|||
} |
|||
} |
|||
} |
|||
m_spaceListFrom = value; |
|||
if (onModified != null) |
|||
{ |
|||
onModified(this, ModificationScope.Graph); |
|||
} |
|||
} |
|||
} |
|||
public override bool hasPreview |
|||
{ |
|||
get { return false; } |
|||
} |
|||
public override bool hasPreview |
|||
{ |
|||
get { return false; } |
|||
} |
|||
public SimpleMatrixType spaceTo |
|||
{ |
|||
get { return m_spaceListTo; } |
|||
set |
|||
{ |
|||
if (m_spaceListTo == value) |
|||
return; |
|||
public SimpleMatrixType spaceTo |
|||
{ |
|||
get { return m_spaceListTo; } |
|||
set |
|||
{ |
|||
if (m_spaceListTo == value) |
|||
return; |
|||
m_spaceListTo = value; |
|||
if (onModified != null) |
|||
{ |
|||
onModified(this, ModificationScope.Graph); |
|||
} |
|||
} |
|||
} |
|||
m_spaceListTo = value; |
|||
if (onModified != null) |
|||
{ |
|||
onModified(this, ModificationScope.Graph); |
|||
} |
|||
} |
|||
} |
|||
public TransformNode () |
|||
{ |
|||
name = "Transform"; |
|||
UpdateNodeAfterDeserialization (); |
|||
} |
|||
public TransformNode() |
|||
{ |
|||
name = "Transform"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(GetInputSlot()); |
|||
AddSlot(GetOutputSlot()); |
|||
RemoveSlotsNameNotMatching(validSlots); |
|||
} |
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(GetInputSlot()); |
|||
AddSlot(GetOutputSlot()); |
|||
RemoveSlotsNameNotMatching(validSlots); |
|||
} |
|||
protected int[] validSlots |
|||
{ |
|||
get { return new[] {InputSlotId, OutputSlotId}; } |
|||
} |
|||
protected int[] validSlots |
|||
{ |
|||
get { return new[] {InputSlotId, OutputSlotId}; } |
|||
} |
|||
protected virtual MaterialSlot GetInputSlot() |
|||
{ |
|||
return new MaterialSlot(InputSlotId, GetInputSlotName(), kInputSlotName, SlotType.Input, SlotValueType.Vector3, Vector3.zero); |
|||
} |
|||
protected virtual MaterialSlot GetInputSlot() |
|||
{ |
|||
return new MaterialSlot(InputSlotId, GetInputSlotName(), kInputSlotName, SlotType.Input, SlotValueType.Vector3, Vector3.zero); |
|||
} |
|||
protected virtual MaterialSlot GetOutputSlot() |
|||
{ |
|||
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotName, SlotType.Output, SlotValueType.Vector3, Vector4.zero); |
|||
} |
|||
protected virtual MaterialSlot GetOutputSlot() |
|||
{ |
|||
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotName, SlotType.Output, SlotValueType.Vector3, Vector4.zero); |
|||
} |
|||
protected virtual string GetInputSlotName() |
|||
{ |
|||
return "Input"; |
|||
} |
|||
protected virtual string GetInputSlotName() |
|||
{ |
|||
return "Input"; |
|||
} |
|||
protected virtual string GetOutputSlotName() |
|||
{ |
|||
return "Output"; |
|||
} |
|||
protected virtual string GetOutputSlotName() |
|||
{ |
|||
return "Output"; |
|||
} |
|||
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
NodeUtils.SlotConfigurationExceptionIfBadConfiguration(this, new[] { InputSlotId }, new[] { OutputSlotId }); |
|||
string inputValue = GetSlotValue(InputSlotId, generationMode); |
|||
string transformString = ""; |
|||
bool requiresTangentTransform = false; |
|||
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
NodeUtils.SlotConfigurationExceptionIfBadConfiguration(this, new[] { InputSlotId }, new[] { OutputSlotId }); |
|||
string inputValue = GetSlotValue(InputSlotId, generationMode); |
|||
string transformString = ""; |
|||
bool requiresTangentTransform = false; |
|||
if(spaceFrom == SimpleMatrixType.World){ |
|||
if (spaceTo == SimpleMatrixType.World) { |
|||
transformString = inputValue; |
|||
} else if (spaceTo == SimpleMatrixType.Local) { |
|||
transformString = "mul(unity_WorldToObject, float4(" + inputValue + ", 0)).xyz"; |
|||
} else if (spaceTo == SimpleMatrixType.Tangent) { |
|||
requiresTangentTransform = true; |
|||
transformString = "mul(tangentTransform, " + inputValue + ").xyz"; |
|||
} else if (spaceTo == SimpleMatrixType.View) { |
|||
transformString = "mul( UNITY_MATRIX_V, float4(" + inputValue + ", 0)).xyz"; |
|||
} |
|||
}else if(spaceFrom == SimpleMatrixType.Local){ |
|||
if (spaceTo == SimpleMatrixType.World) { |
|||
transformString = "mul(unity_ObjectToWorld, float4(" + inputValue + ", 0)).xyz"; |
|||
} else if (spaceTo == SimpleMatrixType.Local) { |
|||
transformString = inputValue; |
|||
} else if (spaceTo == SimpleMatrixType.Tangent) { |
|||
requiresTangentTransform = true; |
|||
transformString = "mul( tangentTransform, mul( unity_ObjectToWorld, float4(" + inputValue + ", 0) ).xyz).xyz"; |
|||
} else if (spaceTo == SimpleMatrixType.View) { |
|||
transformString = "mul( UNITY_MATRIX_MV, float4(" + inputValue + ", 0)).xyz"; |
|||
} |
|||
}else if(spaceFrom == SimpleMatrixType.Tangent){ |
|||
requiresTangentTransform = true; |
|||
if (spaceTo == SimpleMatrixType.World) { |
|||
transformString = "mul( " + inputValue + ", tangentTransform ).xyz"; |
|||
} else if (spaceTo == SimpleMatrixType.Local) { |
|||
transformString = "mul( unity_WorldToObject, float4(mul(" + inputValue + ", tangentTransform ),0) ).xyz"; |
|||
} else if (spaceTo == SimpleMatrixType.Tangent) { |
|||
transformString = inputValue; |
|||
} else if (spaceTo == SimpleMatrixType.View) { |
|||
transformString = "mul( UNITY_MATRIX_V, float4(mul(" + inputValue + ", tangentTransform ),0) ).xyz"; |
|||
} |
|||
}else if(spaceFrom == SimpleMatrixType.View){ |
|||
if (spaceTo == SimpleMatrixType.World) { |
|||
transformString = "mul( float4(" + inputValue + ", 0), UNITY_MATRIX_V ).xyz"; |
|||
} else if (spaceTo == SimpleMatrixType.Local) { |
|||
transformString = "mul( float4(" + inputValue + ", 0), UNITY_MATRIX_MV ).xyz"; |
|||
} else if (spaceTo == SimpleMatrixType.Tangent) { |
|||
requiresTangentTransform = true; |
|||
transformString = "mul( tangentTransform, mul( float4(" + inputValue + ", 0), UNITY_MATRIX_V ).xyz ).xyz"; |
|||
} else if (spaceTo == SimpleMatrixType.View) { |
|||
transformString = inputValue; |
|||
} |
|||
} |
|||
if (spaceFrom == SimpleMatrixType.World) |
|||
{ |
|||
if (spaceTo == SimpleMatrixType.World) |
|||
{ |
|||
transformString = inputValue; |
|||
} |
|||
else if (spaceTo == SimpleMatrixType.Local) |
|||
{ |
|||
transformString = "mul(unity_WorldToObject, float4(" + inputValue + ", 0)).xyz"; |
|||
} |
|||
else if (spaceTo == SimpleMatrixType.Tangent) |
|||
{ |
|||
requiresTangentTransform = true; |
|||
transformString = "mul(tangentTransform, " + inputValue + ").xyz"; |
|||
} |
|||
else if (spaceTo == SimpleMatrixType.View) |
|||
{ |
|||
transformString = "mul( UNITY_MATRIX_V, float4(" + inputValue + ", 0)).xyz"; |
|||
} |
|||
} |
|||
else if (spaceFrom == SimpleMatrixType.Local) |
|||
{ |
|||
if (spaceTo == SimpleMatrixType.World) |
|||
{ |
|||
transformString = "mul(unity_ObjectToWorld, float4(" + inputValue + ", 0)).xyz"; |
|||
} |
|||
else if (spaceTo == SimpleMatrixType.Local) |
|||
{ |
|||
transformString = inputValue; |
|||
} |
|||
else if (spaceTo == SimpleMatrixType.Tangent) |
|||
{ |
|||
requiresTangentTransform = true; |
|||
transformString = "mul( tangentTransform, mul( unity_ObjectToWorld, float4(" + inputValue + ", 0) ).xyz).xyz"; |
|||
} |
|||
else if (spaceTo == SimpleMatrixType.View) |
|||
{ |
|||
transformString = "mul( UNITY_MATRIX_MV, float4(" + inputValue + ", 0)).xyz"; |
|||
} |
|||
} |
|||
else if (spaceFrom == SimpleMatrixType.Tangent) |
|||
{ |
|||
requiresTangentTransform = true; |
|||
if (spaceTo == SimpleMatrixType.World) |
|||
{ |
|||
transformString = "mul( " + inputValue + ", tangentTransform ).xyz"; |
|||
} |
|||
else if (spaceTo == SimpleMatrixType.Local) |
|||
{ |
|||
transformString = "mul( unity_WorldToObject, float4(mul(" + inputValue + ", tangentTransform ),0) ).xyz"; |
|||
} |
|||
else if (spaceTo == SimpleMatrixType.Tangent) |
|||
{ |
|||
transformString = inputValue; |
|||
} |
|||
else if (spaceTo == SimpleMatrixType.View) |
|||
{ |
|||
transformString = "mul( UNITY_MATRIX_V, float4(mul(" + inputValue + ", tangentTransform ),0) ).xyz"; |
|||
} |
|||
} |
|||
else if (spaceFrom == SimpleMatrixType.View) |
|||
{ |
|||
if (spaceTo == SimpleMatrixType.World) |
|||
{ |
|||
transformString = "mul( float4(" + inputValue + ", 0), UNITY_MATRIX_V ).xyz"; |
|||
} |
|||
else if (spaceTo == SimpleMatrixType.Local) |
|||
{ |
|||
transformString = "mul( float4(" + inputValue + ", 0), UNITY_MATRIX_MV ).xyz"; |
|||
} |
|||
else if (spaceTo == SimpleMatrixType.Tangent) |
|||
{ |
|||
requiresTangentTransform = true; |
|||
transformString = "mul( tangentTransform, mul( float4(" + inputValue + ", 0), UNITY_MATRIX_V ).xyz ).xyz"; |
|||
} |
|||
else if (spaceTo == SimpleMatrixType.View) |
|||
{ |
|||
transformString = inputValue; |
|||
} |
|||
} |
|||
if(requiresTangentTransform) |
|||
visitor.AddShaderChunk ("float3x3 tangentTransform = float3x3( worldSpaceTangent, worldSpaceBitangent, worldSpaceNormal);", false); |
|||
if (requiresTangentTransform) |
|||
visitor.AddShaderChunk("float3x3 tangentTransform = float3x3( worldSpaceTangent, worldSpaceBitangent, worldSpaceNormal);", false); |
|||
visitor.AddShaderChunk(precision + outputDimension + " " + GetVariableNameForSlot(OutputSlotId) + " = " + transformString + ";", true); |
|||
} |
|||
visitor.AddShaderChunk(precision + outputDimension + " " + GetVariableNameForSlot(OutputSlotId) + " = " + transformString + ";", true); |
|||
} |
|||
//float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);------
|
|||
//float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);------
|
|||
//mul(unity_WorldToObject, float4(i.posWorld.rgb,0) ).xyz - world to local---------
|
|||
//mul( tangentTransform, i.posWorld.rgb ).xyz - world to tangent-----------------
|
|||
//mul( UNITY_MATRIX_V, float4(i.posWorld.rgb,0) ).xyz - world to view-------------
|
|||
//mul(unity_WorldToObject, float4(i.posWorld.rgb,0) ).xyz - world to local---------
|
|||
//mul( tangentTransform, i.posWorld.rgb ).xyz - world to tangent-----------------
|
|||
//mul( UNITY_MATRIX_V, float4(i.posWorld.rgb,0) ).xyz - world to view-------------
|
|||
//mul( unity_ObjectToWorld, float4(i.posWorld.rgb,0) ).xyz - local to world--------
|
|||
//mul( tangentTransform, mul( unity_ObjectToWorld, float4(i.posWorld.rgb,0) ).xyz - local to tangent------------
|
|||
//mul( UNITY_MATRIX_MV, float4(i.posWorld.rgb,0) ).xyz - local to view--------------
|
|||
//mul( unity_ObjectToWorld, float4(i.posWorld.rgb,0) ).xyz - local to world--------
|
|||
//mul( tangentTransform, mul( unity_ObjectToWorld, float4(i.posWorld.rgb,0) ).xyz - local to tangent------------
|
|||
//mul( UNITY_MATRIX_MV, float4(i.posWorld.rgb,0) ).xyz - local to view--------------
|
|||
//mul( i.posWorld.rgb, tangentTransform ).xyz - tangent to world---------
|
|||
//mul( unity_WorldToObject, float4(mul( i.posWorld.rgb, tangentTransform ),0) ).xyz - tangent to local-----
|
|||
//mul( UNITY_MATRIX_V, float4(mul( i.posWorld.rgb, tangentTransform ),0) ).xyz - tangent to view-------
|
|||
//mul( i.posWorld.rgb, tangentTransform ).xyz - tangent to world---------
|
|||
//mul( unity_WorldToObject, float4(mul( i.posWorld.rgb, tangentTransform ),0) ).xyz - tangent to local-----
|
|||
//mul( UNITY_MATRIX_V, float4(mul( i.posWorld.rgb, tangentTransform ),0) ).xyz - tangent to view-------
|
|||
//mul( float4(i.posWorld.rgb,0), UNITY_MATRIX_V ).xyz - view to world
|
|||
//mul( float4(i.posWorld.rgb,0), UNITY_MATRIX_MV ).xyz - view to local
|
|||
//mul( tangentTransform, mul( float4(i.posWorld.rgb,0), UNITY_MATRIX_V ).xyz ).xyz - view to tangent
|
|||
//mul( float4(i.posWorld.rgb,0), UNITY_MATRIX_V ).xyz - view to world
|
|||
//mul( float4(i.posWorld.rgb,0), UNITY_MATRIX_MV ).xyz - view to local
|
|||
//mul( tangentTransform, mul( float4(i.posWorld.rgb,0), UNITY_MATRIX_V ).xyz ).xyz - view to tangent
|
|||
public string outputDimension |
|||
{ |
|||
get { return ConvertConcreteSlotValueTypeToString(FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType); } |
|||
} |
|||
private string inputDimension |
|||
{ |
|||
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(InputSlotId).concreteValueType); } |
|||
} |
|||
public string outputDimension |
|||
{ |
|||
get { return ConvertConcreteSlotValueTypeToString(FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType); } |
|||
} |
|||
private string inputDimension |
|||
{ |
|||
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(InputSlotId).concreteValueType); } |
|||
} |
|||
public bool RequiresTangent() |
|||
{ |
|||
return true; |
|||
} |
|||
public bool RequiresTangent() |
|||
{ |
|||
return true; |
|||
} |
|||
public bool RequiresBitangent() |
|||
{ |
|||
return true; |
|||
} |
|||
public bool RequiresBitangent() |
|||
{ |
|||
return true; |
|||
} |
|||
public bool RequiresNormal(){ |
|||
return true; |
|||
} |
|||
} |
|||
public bool RequiresNormal() |
|||
{ |
|||
return true; |
|||
} |
|||
} |
|||
|
|
|||
using UnityEngine.Graphing; |
|||
using UnityEngine.Graphing; |
|||
/* [Title("UV/Tri-Planar Mapping")] |
|||
public class UVTriPlanar : FunctionNInNOut, IGeneratesFunction, IMayRequireNormal, IMayRequireWorldPosition |
|||
{ |
|||
private int slot0, slot1, slot2, slot3, slot4, slot5, slot6 = 0; |
|||
/* [Title("UV/Tri-Planar Mapping")] |
|||
public class UVTriPlanar : FunctionNInNOut, IGeneratesFunction, IMayRequireNormal, IMayRequireWorldPosition |
|||
{ |
|||
private int slot0, slot1, slot2, slot3, slot4, slot5, slot6 = 0; |
|||
private string slot0Name = "texRef"; |
|||
private string slot1Name = "tileFactor"; |
|||
private string slot2Name = "blendFactor"; |
|||
private string slot4Name = "normalRef"; |
|||
private string slot5Name = "posRef"; |
|||
private string slot6Name = "outputRef"; |
|||
private string slot0Name = "texRef"; |
|||
private string slot1Name = "tileFactor"; |
|||
private string slot2Name = "blendFactor"; |
|||
private string slot4Name = "normalRef"; |
|||
private string slot5Name = "posRef"; |
|||
private string slot6Name = "outputRef"; |
|||
protected override string GetFunctionName() |
|||
{ |
|||
return "unity_triplanar_" + precision; |
|||
} |
|||
protected override string GetFunctionName() |
|||
{ |
|||
return "unity_triplanar_" + precision; |
|||
} |
|||
public UVTriPlanar() |
|||
{ |
|||
name = "UVTriPlanar"; |
|||
public UVTriPlanar() |
|||
{ |
|||
name = "UVTriPlanar"; |
|||
slot0 = AddSlot("Texture", slot0Name, Graphing.SlotType.Input, SlotValueType.Sampler2D, Vector4.zero); |
|||
slot1 = AddSlot("Tile", slot1Name, Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero); |
|||
slot2 = AddSlot("Blend", slot2Name, Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero); |
|||
slot4 = AddSlot("Normals", slot4Name, Graphing.SlotType.Input, SlotValueType.Vector3, Vector3.one); |
|||
slot5 = AddSlot("Position", slot5Name, Graphing.SlotType.Input, SlotValueType.Vector3, Vector3.one); |
|||
slot6 = AddSlot("RGBA ", slot6Name, Graphing.SlotType.Output, SlotValueType.Vector4, Vector4.zero); |
|||
slot0 = AddSlot("Texture", slot0Name, Graphing.SlotType.Input, SlotValueType.Sampler2D, Vector4.zero); |
|||
slot1 = AddSlot("Tile", slot1Name, Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero); |
|||
slot2 = AddSlot("Blend", slot2Name, Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero); |
|||
slot4 = AddSlot("Normals", slot4Name, Graphing.SlotType.Input, SlotValueType.Vector3, Vector3.one); |
|||
slot5 = AddSlot("Position", slot5Name, Graphing.SlotType.Input, SlotValueType.Vector3, Vector3.one); |
|||
slot6 = AddSlot("RGBA ", slot6Name, Graphing.SlotType.Output, SlotValueType.Vector4, Vector4.zero); |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
public override bool hasPreview |
|||
{ |
|||
get { return true; } |
|||
} |
|||
public override bool hasPreview |
|||
{ |
|||
get { return true; } |
|||
} |
|||
public override PreviewMode previewMode |
|||
{ |
|||
get |
|||
{ |
|||
return PreviewMode.Preview3D; |
|||
} |
|||
} |
|||
public override PreviewMode previewMode |
|||
{ |
|||
get |
|||
{ |
|||
return PreviewMode.Preview3D; |
|||
} |
|||
} |
|||
//TODO:Externalize
|
|||
//Reference code from:http://www.chilliant.com/rgb2hsv.html
|
|||
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var outputString = new ShaderGenerator(); |
|||
//TODO:Externalize
|
|||
//Reference code from:http://www.chilliant.com/rgb2hsv.html
|
|||
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var outputString = new ShaderGenerator(); |
|||
// outputString.AddShaderChunk(GetFunctionPrototype("arg1", "arg2", "arg3", samplerName), false);
|
|||
outputString.AddShaderChunk(GetFunctionPrototype(), false); |
|||
outputString.Indent(); |
|||
outputString.AddShaderChunk("{", false); |
|||
// create UVs from position
|
|||
outputString.AddShaderChunk("float3 uvs = " + slot5Name + "*" + slot1Name + ";", false); |
|||
// outputString.AddShaderChunk(GetFunctionPrototype("arg1", "arg2", "arg3", samplerName), false);
|
|||
outputString.AddShaderChunk(GetFunctionPrototype(), false); |
|||
outputString.Indent(); |
|||
outputString.AddShaderChunk("{", false); |
|||
// create UVs from position
|
|||
outputString.AddShaderChunk("float3 uvs = " + slot5Name + "*" + slot1Name + ";", false); |
|||
// use absolute value of normal as texture weights
|
|||
outputString.AddShaderChunk("half3 blend = pow(abs(" + slot4Name + ")," + slot2Name + ");", false); |
|||
// use absolute value of normal as texture weights
|
|||
outputString.AddShaderChunk("half3 blend = pow(abs(" + slot4Name + ")," + slot2Name + ");", false); |
|||
// make sure the weights sum up to 1 (divide by sum of x+y+z)
|
|||
outputString.AddShaderChunk("blend /= dot(blend, 1.0);", false); |
|||
// make sure the weights sum up to 1 (divide by sum of x+y+z)
|
|||
outputString.AddShaderChunk("blend /= dot(blend, 1.0);", false); |
|||
// read the three texture projections, for x,y,z axes
|
|||
outputString.AddShaderChunk("float4 cx = " + "tex2D(" + slot0Name + ", uvs.yz);", false); |
|||
outputString.AddShaderChunk("float4 cy = " + "tex2D(" + slot0Name + ", uvs.xz);", false); |
|||
outputString.AddShaderChunk("float4 cz = " + "tex2D(" + slot0Name + ", uvs.xy);", false); |
|||
// read the three texture projections, for x,y,z axes
|
|||
outputString.AddShaderChunk("float4 cx = " + "tex2D(" + slot0Name + ", uvs.yz);", false); |
|||
outputString.AddShaderChunk("float4 cy = " + "tex2D(" + slot0Name + ", uvs.xz);", false); |
|||
outputString.AddShaderChunk("float4 cz = " + "tex2D(" + slot0Name + ", uvs.xy);", false); |
|||
// blend the textures based on weights
|
|||
outputString.AddShaderChunk(slot6Name + " = cx * blend.x + cy * blend.y + cz * blend.z;", false); |
|||
// blend the textures based on weights
|
|||
outputString.AddShaderChunk(slot6Name + " = cx * blend.x + cy * blend.y + cz * blend.z;", false); |
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
//prevent validation errors when a sampler2D input is missing
|
|||
//use on any input requiring a Texture2DNode
|
|||
public override void ValidateNode() |
|||
{ |
|||
base.ValidateNode(); |
|||
var slot = FindInputSlot<MaterialSlot>(0); |
|||
if (slot == null) |
|||
return; |
|||
//prevent validation errors when a sampler2D input is missing
|
|||
//use on any input requiring a Texture2DNode
|
|||
public override void ValidateNode() |
|||
{ |
|||
base.ValidateNode(); |
|||
var slot = FindInputSlot<MaterialSlot>(0); |
|||
if (slot == null) |
|||
return; |
|||
var edges = owner.GetEdges(slot.slotReference).ToList(); |
|||
hasError |= edges.Count == 0; |
|||
} |
|||
var edges = owner.GetEdges(slot.slotReference).ToList(); |
|||
hasError |= edges.Count == 0; |
|||
} |
|||
public bool RequiresNormal() |
|||
{ |
|||
return true; |
|||
} |
|||
public bool RequiresNormal() |
|||
{ |
|||
return true; |
|||
} |
|||
public bool RequiresWorldPosition() |
|||
{ |
|||
return true; |
|||
} |
|||
} |
|||
} |
|||
public bool RequiresWorldPosition() |
|||
{ |
|||
return true; |
|||
} |
|||
} |
|||
} |
|||
///////////////// TEXTURE2D version below. Works fine, but the master nodes don't jive with it //////////////////////////
|
|||
///////////////// TEXTURE2D version below. Works fine, but the master nodes don't jive with it //////////////////////////
|
|||
/* |
|||
/* |
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("UV/Tri-Planar Mapping")] |
|||
public class UVTriPlanar : FunctionNInNOut, IGeneratesFunction, IMayRequireNormal, IMayRequireWorldPosition |
|||
{ |
|||
private int slot0, slot1, slot2, slot3, slot4, slot5, slot6 = 0; |
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("UV/Tri-Planar Mapping")] |
|||
public class UVTriPlanar : FunctionNInNOut, IGeneratesFunction, IMayRequireNormal, IMayRequireWorldPosition |
|||
{ |
|||
private int slot0, slot1, slot2, slot3, slot4, slot5, slot6 = 0; |
|||
private string slot0Name = "texRef"; |
|||
private string slot1Name = "tileFactor"; |
|||
private string slot2Name = "blendFactor"; |
|||
private string slot3Name = "samplerRef"; |
|||
private string slot4Name = "normalRef"; |
|||
private string slot5Name = "posRef"; |
|||
private string slot6Name = "outputRef"; |
|||
private string slot0Name = "texRef"; |
|||
private string slot1Name = "tileFactor"; |
|||
private string slot2Name = "blendFactor"; |
|||
private string slot3Name = "samplerRef"; |
|||
private string slot4Name = "normalRef"; |
|||
private string slot5Name = "posRef"; |
|||
private string slot6Name = "outputRef"; |
|||
protected override string GetFunctionName() |
|||
{ |
|||
return "unity_triplanar_" + precision; |
|||
} |
|||
protected override string GetFunctionName() |
|||
{ |
|||
return "unity_triplanar_" + precision; |
|||
} |
|||
public UVTriPlanar() |
|||
{ |
|||
name = "UVTriPlanar"; |
|||
public UVTriPlanar() |
|||
{ |
|||
name = "UVTriPlanar"; |
|||
slot0 = AddSlot("Texture", slot0Name, Graphing.SlotType.Input, SlotValueType.Texture2D, Vector4.zero); |
|||
slot1 = AddSlot("Tile", slot1Name, Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero); |
|||
slot2 = AddSlot("Blend", slot2Name, Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero); |
|||
slot3 = AddSlot("Sampler", slot3Name, Graphing.SlotType.Input, SlotValueType.SamplerState, Vector4.zero); |
|||
slot4 = AddSlot("Normals", slot4Name, Graphing.SlotType.Input, SlotValueType.Vector3, Vector3.one); |
|||
slot5 = AddSlot("Position", slot5Name, Graphing.SlotType.Input, SlotValueType.Vector3, Vector3.one); |
|||
slot6 = AddSlot("RGBA ", slot6Name, Graphing.SlotType.Output, SlotValueType.Vector4, Vector4.zero); |
|||
slot0 = AddSlot("Texture", slot0Name, Graphing.SlotType.Input, SlotValueType.Texture2D, Vector4.zero); |
|||
slot1 = AddSlot("Tile", slot1Name, Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero); |
|||
slot2 = AddSlot("Blend", slot2Name, Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero); |
|||
slot3 = AddSlot("Sampler", slot3Name, Graphing.SlotType.Input, SlotValueType.SamplerState, Vector4.zero); |
|||
slot4 = AddSlot("Normals", slot4Name, Graphing.SlotType.Input, SlotValueType.Vector3, Vector3.one); |
|||
slot5 = AddSlot("Position", slot5Name, Graphing.SlotType.Input, SlotValueType.Vector3, Vector3.one); |
|||
slot6 = AddSlot("RGBA ", slot6Name, Graphing.SlotType.Output, SlotValueType.Vector4, Vector4.zero); |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
public override bool hasPreview |
|||
{ |
|||
get { return true; } |
|||
} |
|||
public override bool hasPreview |
|||
{ |
|||
get { return true; } |
|||
} |
|||
public override PreviewMode previewMode |
|||
{ |
|||
get |
|||
{ |
|||
return PreviewMode.Preview3D; |
|||
} |
|||
} |
|||
public override PreviewMode previewMode |
|||
{ |
|||
get |
|||
{ |
|||
return PreviewMode.Preview3D; |
|||
} |
|||
} |
|||
//TODO:Externalize
|
|||
//Reference code from:http://www.chilliant.com/rgb2hsv.html
|
|||
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var outputString = new ShaderGenerator(); |
|||
//Sampler input
|
|||
var samplerName = GetSamplerInput(3); |
|||
outputString.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", false); |
|||
//TODO:Externalize
|
|||
//Reference code from:http://www.chilliant.com/rgb2hsv.html
|
|||
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var outputString = new ShaderGenerator(); |
|||
//Sampler input
|
|||
var samplerName = GetSamplerInput(3); |
|||
outputString.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", false); |
|||
// outputString.AddShaderChunk(GetFunctionPrototype("arg1", "arg2", "arg3", samplerName), false);
|
|||
outputString.AddShaderChunk(GetFunctionPrototype(), false); |
|||
outputString.Indent(); |
|||
outputString.AddShaderChunk("{", false); |
|||
// create UVs from position
|
|||
outputString.AddShaderChunk("float3 uvs = " + slot5Name + "*" + slot1Name + ";", false); |
|||
// outputString.AddShaderChunk(GetFunctionPrototype("arg1", "arg2", "arg3", samplerName), false);
|
|||
outputString.AddShaderChunk(GetFunctionPrototype(), false); |
|||
outputString.Indent(); |
|||
outputString.AddShaderChunk("{", false); |
|||
// create UVs from position
|
|||
outputString.AddShaderChunk("float3 uvs = " + slot5Name + "*" + slot1Name + ";", false); |
|||
// use absolute value of normal as texture weights
|
|||
outputString.AddShaderChunk("half3 blend = pow(abs(" + slot4Name + ")," + slot2Name + ");", false); |
|||
// use absolute value of normal as texture weights
|
|||
outputString.AddShaderChunk("half3 blend = pow(abs(" + slot4Name + ")," + slot2Name + ");", false); |
|||
// make sure the weights sum up to 1 (divide by sum of x+y+z)
|
|||
outputString.AddShaderChunk("blend /= dot(blend, 1.0);", false); |
|||
// make sure the weights sum up to 1 (divide by sum of x+y+z)
|
|||
outputString.AddShaderChunk("blend /= dot(blend, 1.0);", false); |
|||
// read the three texture projections, for x,y,z axes
|
|||
outputString.AddShaderChunk("float4 cx = " + slot0Name + ".Sample(" + slot3Name + ", uvs.yz);", false); |
|||
outputString.AddShaderChunk("float4 cy = " + slot0Name + ".Sample(" + slot3Name + ", uvs.xz);", false); |
|||
outputString.AddShaderChunk("float4 cz = " + slot0Name + ".Sample(" + slot3Name + ", uvs.xy);", false); |
|||
// read the three texture projections, for x,y,z axes
|
|||
outputString.AddShaderChunk("float4 cx = " + slot0Name + ".Sample(" + slot3Name + ", uvs.yz);", false); |
|||
outputString.AddShaderChunk("float4 cy = " + slot0Name + ".Sample(" + slot3Name + ", uvs.xz);", false); |
|||
outputString.AddShaderChunk("float4 cz = " + slot0Name + ".Sample(" + slot3Name + ", uvs.xy);", false); |
|||
// blend the textures based on weights
|
|||
outputString.AddShaderChunk(slot6Name + " = cx * blend.x + cy * blend.y + cz * blend.z;", false); |
|||
// blend the textures based on weights
|
|||
outputString.AddShaderChunk(slot6Name + " = cx * blend.x + cy * blend.y + cz * blend.z;", false); |
|||
//outputString.AddShaderChunk("return " + "c;", false);
|
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
outputString.AddShaderChunk("#endif", true); |
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
//outputString.AddShaderChunk("return " + "c;", false);
|
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
outputString.AddShaderChunk("#endif", true); |
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
//Sampler input slot
|
|||
//Sampler input slot
|
|||
base.GeneratePropertyUsages(visitor, generationMode); |
|||
var samplerSlot = FindInputSlot<MaterialSlot>(slot3); |
|||
base.GeneratePropertyUsages(visitor, generationMode); |
|||
var samplerSlot = FindInputSlot<MaterialSlot>(slot3); |
|||
if (samplerSlot != null) |
|||
{ |
|||
var samplerName = GetSamplerInput(slot3); |
|||
if (samplerSlot != null) |
|||
{ |
|||
var samplerName = GetSamplerInput(slot3); |
|||
visitor.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", false); |
|||
visitor.AddShaderChunk("SamplerState " + samplerName + ";", true); |
|||
visitor.AddShaderChunk("#endif", false); |
|||
} |
|||
} |
|||
visitor.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", false); |
|||
visitor.AddShaderChunk("SamplerState " + samplerName + ";", true); |
|||
visitor.AddShaderChunk("#endif", false); |
|||
} |
|||
} |
|||
//prevent validation errors when a sampler2D input is missing
|
|||
//use on any input requiring a Texture2DNode
|
|||
public override void ValidateNode() |
|||
{ |
|||
base.ValidateNode(); |
|||
var slot = FindInputSlot<MaterialSlot>(0); |
|||
if (slot == null) |
|||
return; |
|||
//prevent validation errors when a sampler2D input is missing
|
|||
//use on any input requiring a Texture2DNode
|
|||
public override void ValidateNode() |
|||
{ |
|||
base.ValidateNode(); |
|||
var slot = FindInputSlot<MaterialSlot>(0); |
|||
if (slot == null) |
|||
return; |
|||
var edges = owner.GetEdges(slot.slotReference).ToList(); |
|||
hasError |= edges.Count == 0; |
|||
} |
|||
var edges = owner.GetEdges(slot.slotReference).ToList(); |
|||
hasError |= edges.Count == 0; |
|||
} |
|||
public bool RequiresNormal() |
|||
{ |
|||
return true; |
|||
} |
|||
public bool RequiresNormal() |
|||
{ |
|||
return true; |
|||
} |
|||
public bool RequiresWorldPosition() |
|||
{ |
|||
return true; |
|||
} |
|||
}*/ |
|||
public bool RequiresWorldPosition() |
|||
{ |
|||
return true; |
|||
} |
|||
}*/ |
|||
|
|
|||
using UnityEngine.Graphing; |
|||
using UnityEngine.Graphing; |
|||
/* [Title("Procedural/Scatter")] |
|||
public class ScatterNode : FunctionNInNOut, IGeneratesFunction |
|||
{ |
|||
/* [Title("Procedural/Scatter")] |
|||
public class ScatterNode : FunctionNInNOut, IGeneratesFunction |
|||
{ |
|||
[SerializeField] |
|||
private int m_num = 1 ; |
|||
[SerializeField] |
|||
private int m_num = 1 ; |
|||
public int num |
|||
{ |
|||
get { return m_num; } |
|||
set |
|||
{ |
|||
public int num |
|||
{ |
|||
get { return m_num; } |
|||
set |
|||
{ |
|||
if (m_num == value) |
|||
{ |
|||
return; |
|||
} |
|||
if (m_num == value) |
|||
{ |
|||
return; |
|||
} |
|||
m_num = value; |
|||
if (onModified != null) |
|||
{ |
|||
onModified(this, ModificationScope.Graph); |
|||
} |
|||
} |
|||
} |
|||
m_num = value; |
|||
if (onModified != null) |
|||
{ |
|||
onModified(this, ModificationScope.Graph); |
|||
} |
|||
} |
|||
} |
|||
public ScatterNode() |
|||
{ |
|||
name = "Scatter"; |
|||
AddSlot("TextureAsset", "inputTex", Graphing.SlotType.Input, SlotValueType.Texture2D, Vector4.zero); |
|||
AddSlot("SamplerState", "inputSampler", Graphing.SlotType.Input, SlotValueType.SamplerState, Vector4.zero); |
|||
AddSlot("UV", "inputUV", Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.one); |
|||
AddSlot("Seed", "seed", Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.one); |
|||
AddSlot("PositionRange", "p_range", Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero); |
|||
AddSlot("RotationRange", "r_range", Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero); |
|||
AddSlot("ScaleRange", "s_range", Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero); |
|||
AddSlot("RGBA", "finalColor", Graphing.SlotType.Output, SlotValueType.Vector4, Vector4.zero); |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
public ScatterNode() |
|||
{ |
|||
name = "Scatter"; |
|||
AddSlot("TextureAsset", "inputTex", Graphing.SlotType.Input, SlotValueType.Texture2D, Vector4.zero); |
|||
AddSlot("SamplerState", "inputSampler", Graphing.SlotType.Input, SlotValueType.SamplerState, Vector4.zero); |
|||
AddSlot("UV", "inputUV", Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.one); |
|||
AddSlot("Seed", "seed", Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.one); |
|||
AddSlot("PositionRange", "p_range", Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero); |
|||
AddSlot("RotationRange", "r_range", Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero); |
|||
AddSlot("ScaleRange", "s_range", Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero); |
|||
AddSlot("RGBA", "finalColor", Graphing.SlotType.Output, SlotValueType.Vector4, Vector4.zero); |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
protected override string GetFunctionName() |
|||
{ |
|||
return "unity_scatter_" + precision; |
|||
} |
|||
protected override string GetFunctionName() |
|||
{ |
|||
return "unity_scatter_" + precision; |
|||
} |
|||
public override bool hasPreview |
|||
{ |
|||
get { return true; } |
|||
} |
|||
public override bool hasPreview |
|||
{ |
|||
get { return true; } |
|||
} |
|||
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
//Sampler input slot
|
|||
//Sampler input slot
|
|||
base.GeneratePropertyUsages(visitor, generationMode); |
|||
var samplerSlot = FindInputSlot<MaterialSlot>(2); |
|||
base.GeneratePropertyUsages(visitor, generationMode); |
|||
var samplerSlot = FindInputSlot<MaterialSlot>(2); |
|||
if (samplerSlot != null) |
|||
{ |
|||
var samplerName = GetSamplerInput(2); |
|||
if (samplerSlot != null) |
|||
{ |
|||
var samplerName = GetSamplerInput(2); |
|||
visitor.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", false); |
|||
visitor.AddShaderChunk("SamplerState " + samplerName + ";", true); |
|||
visitor.AddShaderChunk("#endif", false); |
|||
} |
|||
} |
|||
visitor.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", false); |
|||
visitor.AddShaderChunk("SamplerState " + samplerName + ";", true); |
|||
visitor.AddShaderChunk("#endif", false); |
|||
} |
|||
} |
|||
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var outputString = new ShaderGenerator(); |
|||
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var outputString = new ShaderGenerator(); |
|||
//RotateUVFunction ===================================================================
|
|||
outputString.AddShaderChunk("inline float2 rotateUV( float2 arg1, float arg2 )", false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
//center texture's pivot
|
|||
outputString.AddShaderChunk("arg1.xy -= 0.5;", false); |
|||
//rotation matrix
|
|||
outputString.AddShaderChunk(precision + " s = sin(arg2);", false); |
|||
outputString.AddShaderChunk(precision + " c = cos(arg2);", false); |
|||
outputString.AddShaderChunk(precision + "2x2 rMatrix = float2x2(c, -s, s, c);", false); |
|||
//center rotation matrix
|
|||
outputString.AddShaderChunk("rMatrix *= 0.5;", false); |
|||
outputString.AddShaderChunk("rMatrix += 0.5;", false); |
|||
outputString.AddShaderChunk("rMatrix = rMatrix*2 - 1;", false); |
|||
//multiply the UVs by the rotation matrix
|
|||
outputString.AddShaderChunk("arg1.xy = mul(arg1.xy, rMatrix);", false); |
|||
outputString.AddShaderChunk("arg1.xy += 0.5;", false); |
|||
outputString.AddShaderChunk("return " + "arg1;", false); |
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
//RotateUVFunction ===================================================================
|
|||
outputString.AddShaderChunk("inline float2 rotateUV( float2 arg1, float arg2 )", false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
//center texture's pivot
|
|||
outputString.AddShaderChunk("arg1.xy -= 0.5;", false); |
|||
//rotation matrix
|
|||
outputString.AddShaderChunk(precision + " s = sin(arg2);", false); |
|||
outputString.AddShaderChunk(precision + " c = cos(arg2);", false); |
|||
outputString.AddShaderChunk(precision + "2x2 rMatrix = float2x2(c, -s, s, c);", false); |
|||
//center rotation matrix
|
|||
outputString.AddShaderChunk("rMatrix *= 0.5;", false); |
|||
outputString.AddShaderChunk("rMatrix += 0.5;", false); |
|||
outputString.AddShaderChunk("rMatrix = rMatrix*2 - 1;", false); |
|||
//multiply the UVs by the rotation matrix
|
|||
outputString.AddShaderChunk("arg1.xy = mul(arg1.xy, rMatrix);", false); |
|||
outputString.AddShaderChunk("arg1.xy += 0.5;", false); |
|||
outputString.AddShaderChunk("return " + "arg1;", false); |
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
//RamdomFunction ===================================================================
|
|||
outputString.AddShaderChunk("inline float randomrange(float2 randomseed, float min, float max)", false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
outputString.AddShaderChunk("float randomno = frac(sin(dot(randomseed, float2(12.9898, 78.233)))*43758.5453);", false); |
|||
outputString.AddShaderChunk("return lerp(min,max,abs(frac(randomno)));", false); |
|||
//outputString.AddShaderChunk("return floor(randomno * (max - min + 1)) + min;", false);
|
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
//RamdomFunction ===================================================================
|
|||
outputString.AddShaderChunk("inline float randomrange(float2 randomseed, float min, float max)", false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
outputString.AddShaderChunk("float randomno = frac(sin(dot(randomseed, float2(12.9898, 78.233)))*43758.5453);", false); |
|||
outputString.AddShaderChunk("return lerp(min,max,abs(frac(randomno)));", false); |
|||
//outputString.AddShaderChunk("return floor(randomno * (max - min + 1)) + min;", false);
|
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
//ScatterFunction ===================================================================
|
|||
outputString.AddShaderChunk(GetFunctionPrototype(), false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
//ScatterFunction ===================================================================
|
|||
outputString.AddShaderChunk(GetFunctionPrototype(), false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
outputString.AddShaderChunk("finalColor = float4(0,0,0,0);", false); |
|||
outputString.AddShaderChunk("float2 newuv;", false); |
|||
outputString.AddShaderChunk("float4 tex = finalColor;", false); |
|||
outputString.AddShaderChunk("finalColor = float4(0,0,0,0);", false); |
|||
outputString.AddShaderChunk("float2 newuv;", false); |
|||
outputString.AddShaderChunk("float4 tex = finalColor;", false); |
|||
outputString.AddShaderChunk("float scale;", false); |
|||
outputString.AddShaderChunk("float rotation;", false); |
|||
outputString.AddShaderChunk("float2 position;", false); |
|||
outputString.AddShaderChunk("float j;", false); |
|||
outputString.AddShaderChunk("float scale;", false); |
|||
outputString.AddShaderChunk("float rotation;", false); |
|||
outputString.AddShaderChunk("float2 position;", false); |
|||
outputString.AddShaderChunk("float j;", false); |
|||
for (int i=0; i<m_num; i++) |
|||
{ |
|||
//random UV
|
|||
for (int i=0; i<m_num; i++) |
|||
{ |
|||
//random UV
|
|||
outputString.AddShaderChunk("newuv = inputUV;", false); |
|||
outputString.AddShaderChunk("j = "+i+"+0.001f;", false); |
|||
outputString.AddShaderChunk("newuv = inputUV;", false); |
|||
outputString.AddShaderChunk("j = "+i+"+0.001f;", false); |
|||
outputString.AddShaderChunk("scale = randomrange(seed+j,s_range.x,s_range.y);", false); //Random Scale
|
|||
outputString.AddShaderChunk("newuv *= scale;", false); //Scale
|
|||
outputString.AddShaderChunk("newuv -= (scale-1)*0.5f;", false); //Move to Center After Scale
|
|||
outputString.AddShaderChunk("scale = randomrange(seed+j,s_range.x,s_range.y);", false); //Random Scale
|
|||
outputString.AddShaderChunk("newuv *= scale;", false); //Scale
|
|||
outputString.AddShaderChunk("newuv -= (scale-1)*0.5f;", false); //Move to Center After Scale
|
|||
outputString.AddShaderChunk("rotation = randomrange(seed+j,r_range.x,r_range.y);", false); //Random rotation
|
|||
outputString.AddShaderChunk("newuv = rotateUV(newuv,rotation);", false); //Rotate
|
|||
outputString.AddShaderChunk("rotation = randomrange(seed+j,r_range.x,r_range.y);", false); //Random rotation
|
|||
outputString.AddShaderChunk("newuv = rotateUV(newuv,rotation);", false); //Rotate
|
|||
outputString.AddShaderChunk("position.x = randomrange(seed.x+j,p_range.x,p_range.y);", false); //Random position
|
|||
outputString.AddShaderChunk("position.y = randomrange(seed.y+j,p_range.x,p_range.y);", false); //Random position
|
|||
outputString.AddShaderChunk("newuv += position*scale;", false); //Position
|
|||
outputString.AddShaderChunk("position.x = randomrange(seed.x+j,p_range.x,p_range.y);", false); //Random position
|
|||
outputString.AddShaderChunk("position.y = randomrange(seed.y+j,p_range.x,p_range.y);", false); //Random position
|
|||
outputString.AddShaderChunk("newuv += position*scale;", false); //Position
|
|||
//sample
|
|||
outputString.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", false); |
|||
outputString.AddShaderChunk("tex = inputTex.Sample(inputSampler, newuv);", false); |
|||
outputString.AddShaderChunk("#endif",false); |
|||
//sample
|
|||
outputString.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", false); |
|||
outputString.AddShaderChunk("tex = inputTex.Sample(inputSampler, newuv);", false); |
|||
outputString.AddShaderChunk("#endif",false); |
|||
//blend together
|
|||
outputString.AddShaderChunk("finalColor = lerp(finalColor,tex, tex.a);", false); |
|||
//blend together
|
|||
outputString.AddShaderChunk("finalColor = lerp(finalColor,tex, tex.a);", false); |
|||
//seamless
|
|||
outputString.AddShaderChunk("newuv = 1-newuv;", false); |
|||
outputString.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", false); |
|||
outputString.AddShaderChunk("tex = inputTex.Sample(inputSampler, newuv);", false); |
|||
outputString.AddShaderChunk("#endif", false); |
|||
//blend seamless
|
|||
outputString.AddShaderChunk("finalColor = lerp(finalColor,tex, tex.a);", false); |
|||
//seamless
|
|||
outputString.AddShaderChunk("newuv = 1-newuv;", false); |
|||
outputString.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", false); |
|||
outputString.AddShaderChunk("tex = inputTex.Sample(inputSampler, newuv);", false); |
|||
outputString.AddShaderChunk("#endif", false); |
|||
//blend seamless
|
|||
outputString.AddShaderChunk("finalColor = lerp(finalColor,tex, tex.a);", false); |
|||
} |
|||
} |
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
}*/ |
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
}*/ |
|||
} |
|
|||
using UnityEngine; |
|||
using UnityEngine; |
|||
public class PropertyNodeInspector : BasicNodeInspector |
|||
{ |
|||
public override void OnInspectorGUI() |
|||
{ |
|||
base.OnInspectorGUI(); |
|||
public class PropertyNodeInspector : BasicNodeInspector |
|||
{ |
|||
public override void OnInspectorGUI() |
|||
{ |
|||
base.OnInspectorGUI(); |
|||
var propertyNode = node as PropertyNode; |
|||
if (propertyNode == null) |
|||
return; |
|||
var propertyNode = node as PropertyNode; |
|||
if (propertyNode == null) |
|||
return; |
|||
GUILayout.Label("Settings", EditorStyles.boldLabel); |
|||
GUILayout.Label("Settings", EditorStyles.boldLabel); |
|||
EditorGUI.BeginChangeCheck(); |
|||
EditorGUI.BeginChangeCheck(); |
|||
//propertyNode.name = EditorGUILayout.TextField ("Name", propertyNode.name);
|
|||
propertyNode.description = EditorGUILayout.TextField ("Description", propertyNode.description); |
|||
//propertyNode.name = EditorGUILayout.TextField ("Name", propertyNode.name);
|
|||
propertyNode.description = EditorGUILayout.TextField("Description", propertyNode.description); |
|||
if (EditorGUI.EndChangeCheck()) |
|||
node.onModified(node, ModificationScope.Node); |
|||
} |
|||
} |
|||
if (EditorGUI.EndChangeCheck()) |
|||
node.onModified(node, ModificationScope.Node); |
|||
} |
|||
} |
|||
} |
|
|||
Shader "Hidden/Checkerboard" |
|||
Shader "Hidden/Checkerboard" |
|||
SubShader |
|||
{ |
|||
// No culling or depth |
|||
Cull Off ZWrite Off ZTest Always |
|||
SubShader |
|||
{ |
|||
// No culling or depth |
|||
Cull Off ZWrite Off ZTest Always |
|||
Pass |
|||
{ |
|||
CGPROGRAM |
|||
#pragma vertex vert_img |
|||
#pragma fragment frag |
|||
Pass |
|||
{ |
|||
CGPROGRAM |
|||
#pragma vertex vert_img |
|||
#pragma fragment frag |
|||
#include "UnityCG.cginc" |
|||
#include "UnityCG.cginc" |
|||
uniform float _X; |
|||
uniform float _Y; |
|||
|
|||
static const float4 col1 = float4(0.25, 0.25, 0.25, 1.0); |
|||
static const float4 col2 = float4(0.75, 0.75, 0.75, 1.0); |
|||
uniform float _X; |
|||
uniform float _Y; |
|||
|
|||
static const float4 col1 = float4(0.25, 0.25, 0.25, 1.0); |
|||
static const float4 col2 = float4(0.75, 0.75, 0.75, 1.0); |
|||
float4 frag(v2f_img i) : COLOR |
|||
{ |
|||
float total = floor(i.uv.x * _X) + floor(i.uv.y * _Y); |
|||
bool isEven = total % 2.0 == 0.0; |
|||
return isEven ? col1 : col2; |
|||
} |
|||
ENDCG |
|||
} |
|||
} |
|||
float4 frag(v2f_img i) : COLOR |
|||
{ |
|||
float total = floor(i.uv.x * _X) + floor(i.uv.y * _Y); |
|||
bool isEven = total % 2.0 == 0.0; |
|||
return isEven ? col1 : col2; |
|||
} |
|||
ENDCG |
|||
} |
|||
} |
|||
} |
|
|||
using System.Linq; |
|||
using System.Linq; |
|||
} |
|||
} |
部分文件因为文件数量过多而无法显示
撰写
预览
正在加载...
取消
保存
Reference in new issue