Add project files.

This commit is contained in:
2023-10-08 18:51:40 +02:00
commit 51cc9df14f
2249 changed files with 636804 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "ACos", "Trigonometry Operators", "Arccosine of scalars and vectors" )]
public sealed class ACosOpNode : SingleInputOp
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "acos";
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT,
WirePortDataType.FLOAT ,
WirePortDataType.FLOAT2,
WirePortDataType.FLOAT3,
WirePortDataType.FLOAT4,
WirePortDataType.COLOR,
WirePortDataType.INT );
m_previewShaderGUID = "710f3c0bbd7ba0c4aada6d7dfadd49c2";
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 8238f389c28938544b56035531b3f1be
timeCreated: 1481126957
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "ASin", "Trigonometry Operators", "Arcsine of scalars and vectors" )]
public sealed class ASinOpNode : SingleInputOp
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "asin";
m_previewShaderGUID = "2b016c135284add4cb3364d4a0bd0638";
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT,
WirePortDataType.FLOAT,
WirePortDataType.FLOAT2,
WirePortDataType.FLOAT3,
WirePortDataType.FLOAT4,
WirePortDataType.COLOR,
WirePortDataType.INT );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 268ebf76d03c2e84f8c80a375773b46c
timeCreated: 1481126954
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,28 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
namespace AmplifyShaderEditor
{
[System.Serializable]
[NodeAttributes( "ATan2", "Trigonometry Operators", "Arctangent of y/x" )]
public sealed class ATan2OpNode : DynamicTypeNode
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_dynamicOutputType = true;
m_useInternalPortData = true;
m_previewShaderGUID = "02e3ff61784e38840af6313936b6a730";
}
public override string BuildResults( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
{
if ( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
base.BuildResults( outputId, ref dataCollector, ignoreLocalvar );
string result = "atan2( " + m_inputA + " , " + m_inputB + " )";
return CreateOutputLocalVariable( 0, result, ref dataCollector );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f5957d9ac2cc12146bc862cd0c92815a
timeCreated: 1481126960
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "ATan", "Trigonometry Operators", "Arctangent of scalars and vectors" )]
public sealed class ATanOpNode : SingleInputOp
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "atan";
m_previewShaderGUID = "7d7f3331a98831241b017364e80625ea";
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT,
WirePortDataType.FLOAT,
WirePortDataType.FLOAT2,
WirePortDataType.FLOAT3,
WirePortDataType.FLOAT4,
WirePortDataType.COLOR,
WirePortDataType.INT );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d84f7e90e793aaa4891b4c1fe400dc4c
timeCreated: 1481126959
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Abs", "Math Operators", "Absolute value of scalars and vectors" )]
public sealed class AbsOpNode : SingleInputOp
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "abs";
m_previewShaderGUID = "cd6d6dfa3df214a479f68a490e177db6";
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT,
WirePortDataType.FLOAT,
WirePortDataType.FLOAT2,
WirePortDataType.FLOAT3,
WirePortDataType.FLOAT4,
WirePortDataType.COLOR,
WirePortDataType.INT);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 46aea6c13d71ec74da7f23abba3704d6
timeCreated: 1481126955
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Ceil", "Math Operators", "Smallest integer not less than a scalar or each vector component" )]
public sealed class CeilOpNode : SingleInputOp
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "ceil";
m_previewShaderGUID = "ce0588227a766a245a85291977c1f222";
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT,
WirePortDataType.FLOAT ,
WirePortDataType.FLOAT2,
WirePortDataType.FLOAT3,
WirePortDataType.FLOAT4,
WirePortDataType.COLOR ,
WirePortDataType.INT);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 555db3754f84db947846519630ea303b
timeCreated: 1481126955
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,103 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Clamp", "Math Operators", "Value clamped to the range [min,max]" )]
public sealed class ClampOpNode : ParentNode
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
AddInputPort( WirePortDataType.FLOAT, false, Constants.EmptyPortValue );
AddInputPort( WirePortDataType.FLOAT, false, "Min" );
AddInputPort( WirePortDataType.FLOAT, false, "Max" );
m_inputPorts[ m_inputPorts.Count - 1 ].FloatInternalData = 1;
AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue );
m_useInternalPortData = true;
m_textLabelWidth = 55;
m_previewShaderGUID = "ab6163c4b10bfc84da8e3c486520490a";
}
public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true )
{
base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode );
if ( portId == 0 )
{
m_inputPorts[ 0 ].MatchPortToConnection();
m_inputPorts[ 1 ].ChangeType( m_inputPorts[ 0 ].DataType, false );
m_inputPorts[ 2 ].ChangeType( m_inputPorts[ 0 ].DataType, false );
m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false );
}
//else
//{
// _inputPorts[ portId ].MatchPortToConnection();
//}
}
public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type )
{
base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type );
if ( outputPortId == 0 )
{
m_inputPorts[ 0 ].MatchPortToConnection();
m_inputPorts[ 1 ].ChangeType( m_inputPorts[ 0 ].DataType, false );
m_inputPorts[ 2 ].ChangeType( m_inputPorts[ 0 ].DataType, false );
m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false );
}
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
{
if ( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
WirePortDataType valueType = m_inputPorts[ 0 ].ConnectionType();
WirePortDataType minType = m_inputPorts[ 1 ].ConnectionType();
WirePortDataType maxType = m_inputPorts[ 2 ].ConnectionType();
string value = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
string min = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector );
if ( minType != valueType )
{
min = UIUtils.CastPortType( ref dataCollector, CurrentPrecisionType, new NodeCastInfo( UniqueId, outputId ), null, m_inputPorts[ 1 ].DataType, m_inputPorts[ 0 ].DataType, min );
}
string max = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector );
if ( maxType != valueType )
{
max = UIUtils.CastPortType( ref dataCollector, CurrentPrecisionType, new NodeCastInfo( UniqueId, outputId ), null, m_inputPorts[ 2 ].DataType, m_inputPorts[ 0 ].DataType, max );
}
string result = string.Empty;
switch ( valueType )
{
case WirePortDataType.FLOAT:
case WirePortDataType.FLOAT2:
case WirePortDataType.FLOAT3:
case WirePortDataType.FLOAT4:
case WirePortDataType.INT:
case WirePortDataType.COLOR:
case WirePortDataType.OBJECT:
{
result = "clamp( " + value + " , " + min + " , " + max + " )";
}
break;
case WirePortDataType.FLOAT3x3:
case WirePortDataType.FLOAT4x4:
{
return UIUtils.InvalidParameter( this );
}
}
RegisterLocalVariable( 0, result, ref dataCollector, "clampResult" + OutputId );
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5d7101830aa0c524f9519fef95c90dc3
timeCreated: 1481126956
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,123 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Clip", "Miscellaneous", "Conditionally kill a pixel before output" )]
public sealed class ClipNode : ParentNode
{
private const string ClipOpFormat = "clip( {0} );";
private const string ClipSubOpFormat = "clip( {0} - {1});";
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
AddInputPort( WirePortDataType.FLOAT, false, Constants.EmptyPortValue );
AddInputPort( WirePortDataType.FLOAT, false, "Alpha" );
AddInputPort( WirePortDataType.FLOAT, false, "Threshold" );
AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue );
m_useInternalPortData = true;
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT,
WirePortDataType.FLOAT ,
WirePortDataType.FLOAT2,
WirePortDataType.FLOAT3,
WirePortDataType.FLOAT4,
WirePortDataType.COLOR ,
WirePortDataType.INT);
m_previewShaderGUID = "1fca7774f364aee4d8c64e8634ef4be4";
}
public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true )
{
base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode );
m_inputPorts[ portId ].MatchPortToConnection();
UpdatePortConnection( portId );
}
public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type )
{
base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type );
m_inputPorts[ outputPortId ].MatchPortToConnection();
UpdatePortConnection( outputPortId );
}
void UpdatePortConnection( int portId )
{
if( portId == 0 )
{
m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false );
}
else
{
int otherPortId = portId == 1 ? 2 : 1;
if( m_inputPorts[ otherPortId ].IsConnected )
{
WirePortDataType type1 = m_inputPorts[ portId ].DataType;
WirePortDataType type2 = m_inputPorts[ otherPortId ].DataType;
WirePortDataType mainType = UIUtils.GetPriority( type1 ) > UIUtils.GetPriority( type2 ) ? type1 : type2;
m_inputPorts[ portId ].ChangeType( mainType, false );
m_inputPorts[ otherPortId ].ChangeType( mainType , false );
}
else
{
m_inputPorts[ otherPortId ].ChangeType( m_inputPorts[ portId ].DataType,false );
}
}
}
public override void OnInputPortDisconnected( int portId )
{
base.OnInputPortDisconnected( portId );
if( portId == 0 )
return;
int otherPortId = portId == 1 ? 2 : 1;
if( m_inputPorts[ otherPortId ].IsConnected )
{
m_inputPorts[ portId ].ChangeType( m_inputPorts[ otherPortId ].DataType, false );
}
else
{
m_inputPorts[ portId ].ChangeType( WirePortDataType.FLOAT, false );
m_inputPorts[ otherPortId ].ChangeType( WirePortDataType.FLOAT, false );
}
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
{
if( dataCollector.PortCategory == MasterNodePortCategory.Vertex ||
dataCollector.PortCategory == MasterNodePortCategory.Tessellation )
{
UIUtils.ShowMessage( UniqueId, "Clip can only be used in fragment functions", MessageSeverity.Warning );
return GenerateErrorValue();
}
string value = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
string alpha = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector );
if( m_inputPorts[ 2 ].IsConnected )
{
string threshold = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector );
dataCollector.AddLocalVariable( UniqueId, string.Format( ClipSubOpFormat, alpha , threshold) );
}
else
{
if( m_inputPorts[ 2 ].IsZeroInternalData )
{
dataCollector.AddLocalVariable( UniqueId, string.Format( ClipOpFormat, alpha ) );
}
else
{
string threshold = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector );
dataCollector.AddLocalVariable( UniqueId, string.Format( ClipSubOpFormat, alpha, threshold ) );
}
}
return value;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 78e9954f4d587b74fa38ae1dd9922d77
timeCreated: 1481126957
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,382 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using UnityEditor;
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Component Mask", "Vector Operators", "Mask certain channels from vectors/color components", null, KeyCode.K )]
public sealed class ComponentMaskNode : ParentNode
{
private const string OutputLocalVarName = "componentMask";
[SerializeField]
private bool[] m_selection = { true, true, true, true };
[SerializeField]
private int m_outputPortCount = 4;
[SerializeField]
private string[] m_labels;
private int m_cachedOrderId = -1;
private int m_cachedSingularId = -1;
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
AddInputPort( WirePortDataType.FLOAT4, false, Constants.EmptyPortValue );
AddOutputPort( WirePortDataType.FLOAT4, Constants.EmptyPortValue );
m_useInternalPortData = true;
m_autoWrapProperties = true;
m_selectedLocation = PreviewLocation.TopCenter;
m_labels = new string[] { "X", "Y", "Z", "W" };
m_previewShaderGUID = "b78e2b295c265cd439c80d218fb3e88e";
SetAdditonalTitleText( "Value( XYZW )" );
}
public override void SetPreviewInputs()
{
base.SetPreviewInputs();
Vector4 order = new Vector4(-1,-1,-1,-1);
int lastIndex = 0;
int singularId = -1;
var datatype = m_inputPorts[ 0 ].DataType;
if( m_selection[ 0 ] )
{
order.Set( lastIndex, order.y, order.z, order.w );
lastIndex++;
singularId = 0;
}
if( m_selection[ 1 ] && datatype >= WirePortDataType.FLOAT2 )
{
order.Set( order.x, lastIndex, order.z, order.w );
lastIndex++;
singularId = 1;
}
if( m_selection[ 2 ] && datatype >= WirePortDataType.FLOAT3 )
{
order.Set( order.x, order.y, lastIndex, order.w );
lastIndex++;
singularId = 2;
}
if( m_selection[ 3 ] && ( datatype == WirePortDataType.FLOAT4 || datatype == WirePortDataType.COLOR ) )
{
order.Set( order.x, order.y, order.z, lastIndex );
lastIndex++;
singularId = 3;
}
if ( lastIndex != 1 )
singularId = -1;
if ( m_cachedOrderId == -1 )
m_cachedOrderId = Shader.PropertyToID( "_Order" );
if ( m_cachedSingularId == -1 )
m_cachedSingularId = Shader.PropertyToID( "_Singular" );
PreviewMaterial.SetVector( m_cachedOrderId, order );
PreviewMaterial.SetFloat( m_cachedSingularId, singularId );
}
public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true )
{
base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode );
UpdatePorts();
UpdateTitle();
}
public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type )
{
base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type );
UpdatePorts();
UpdateTitle();
}
public override void OnInputPortDisconnected( int portId )
{
base.OnInputPortDisconnected( portId );
UpdateTitle();
}
void UpdatePorts()
{
m_inputPorts[ 0 ].MatchPortToConnection();
int count = 0;
switch ( m_inputPorts[ 0 ].DataType )
{
case WirePortDataType.FLOAT4:
case WirePortDataType.OBJECT:
case WirePortDataType.COLOR:
{
count = 4;
}
break;
case WirePortDataType.FLOAT3:
{
count = 3;
}
break;
case WirePortDataType.FLOAT2:
{
count = 2;
}
break;
case WirePortDataType.FLOAT:
case WirePortDataType.INT:
case WirePortDataType.FLOAT3x3:
case WirePortDataType.FLOAT4x4:
{ }
break;
}
int activeCount = 0;
if ( count > 0 )
{
for ( int i = 0; i < count; i++ )
{
if ( m_selection[ i ] )
activeCount += 1;
}
}
m_outputPortCount = activeCount;
switch ( activeCount )
{
case 0: ChangeOutputType( m_inputPorts[ 0 ].DataType, false ); break;
case 1: ChangeOutputType( WirePortDataType.FLOAT, false ); break;
case 2: ChangeOutputType( WirePortDataType.FLOAT2, false ); break;
case 3: ChangeOutputType( WirePortDataType.FLOAT3, false ); break;
case 4: ChangeOutputType( m_inputPorts[ 0 ].DataType, false ); break;
}
}
private void UpdateTitle()
{
int count = 0;
string additionalText = string.Empty;
switch ( m_inputPorts[ 0 ].DataType )
{
case WirePortDataType.FLOAT4:
case WirePortDataType.OBJECT:
case WirePortDataType.COLOR:
{
count = 4;
}
break;
case WirePortDataType.FLOAT3:
{
count = 3;
}
break;
case WirePortDataType.FLOAT2:
{
count = 2;
}
break;
case WirePortDataType.FLOAT:
case WirePortDataType.INT:
{
count = 0;
}
break;
case WirePortDataType.FLOAT3x3:
case WirePortDataType.FLOAT4x4:
{ }
break;
}
if ( count > 0 )
{
for ( int i = 0; i < count; i++ )
{
if ( m_selection[ i ] )
{
additionalText += UIUtils.GetComponentForPosition( i, m_inputPorts[ 0 ].DataType ).ToUpper();
}
}
}
if ( additionalText.Length > 0 )
SetAdditonalTitleText( "Value( " + additionalText + " )" );
else
SetAdditonalTitleText( string.Empty );
}
public override void DrawProperties()
{
base.DrawProperties();
EditorGUILayout.BeginVertical();
int count = 0;
switch ( m_inputPorts[ 0 ].DataType )
{
case WirePortDataType.FLOAT4:
case WirePortDataType.OBJECT:
case WirePortDataType.COLOR:
{
count = 4;
}
break;
case WirePortDataType.FLOAT3:
{
count = 3;
}
break;
case WirePortDataType.FLOAT2:
{
count = 2;
}
break;
case WirePortDataType.FLOAT:
case WirePortDataType.INT:
case WirePortDataType.FLOAT3x3:
case WirePortDataType.FLOAT4x4:
{ }
break;
}
int activeCount = 0;
if ( count > 0 )
{
for ( int i = 0; i < count; i++ )
{
m_selection[ i ] = EditorGUILayoutToggleLeft( m_labels[i], m_selection[ i ] );
m_labels[ i ] = UIUtils.GetComponentForPosition( i, m_inputPorts[ 0 ].DataType ).ToUpper();
if ( m_selection[ i ] )
{
activeCount += 1;
}
}
}
if ( activeCount != m_outputPortCount )
{
m_outputPortCount = activeCount;
switch ( activeCount )
{
case 0: ChangeOutputType( m_inputPorts[ 0 ].DataType, false ); break;
case 1: ChangeOutputType( WirePortDataType.FLOAT, false ); break;
case 2: ChangeOutputType( WirePortDataType.FLOAT2, false ); break;
case 3: ChangeOutputType( WirePortDataType.FLOAT3, false ); break;
case 4: ChangeOutputType( m_inputPorts[ 0 ].DataType, false ); break;
}
UpdateTitle();
SetSaveIsDirty();
}
EditorGUILayout.EndVertical();
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
{
if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
string value = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
int count = 0;
switch ( m_inputPorts[ 0 ].DataType )
{
case WirePortDataType.FLOAT4:
case WirePortDataType.OBJECT:
case WirePortDataType.COLOR:
{
count = 4;
}
break;
case WirePortDataType.FLOAT3:
{
count = 3;
}
break;
case WirePortDataType.FLOAT2:
{
count = 2;
}
break;
case WirePortDataType.FLOAT:
case WirePortDataType.INT:
{
count = 0;
}
break;
case WirePortDataType.FLOAT3x3:
case WirePortDataType.FLOAT4x4:
{ }
break;
}
if ( count > 0 )
{
bool firstElement = true;
value = string.Format("({0})",value);
for ( int i = 0; i < count; i++ )
{
if ( m_selection[ i ] )
{
if( firstElement )
{
firstElement = false;
value += ".";
}
value += UIUtils.GetComponentForPosition( i, m_inputPorts[ 0 ].DataType );
}
}
}
return CreateOutputLocalVariable( 0, value, ref dataCollector );
}
public string GetComponentForPosition( int i )
{
switch ( i )
{
case 0:
{
return ( ( m_outputPorts[ 0 ].DataType == WirePortDataType.COLOR ) ? "r" : "x" );
}
case 1:
{
return ( ( m_outputPorts[ 0 ].DataType == WirePortDataType.COLOR ) ? "g" : "y" );
}
case 2:
{
return ( ( m_outputPorts[ 0 ].DataType == WirePortDataType.COLOR ) ? "b" : "z" );
}
case 3:
{
return ( ( m_outputPorts[ 0 ].DataType == WirePortDataType.COLOR ) ? "a" : "w" );
}
}
return string.Empty;
}
public override void ReadFromString( ref string[] nodeParams )
{
base.ReadFromString( ref nodeParams );
for ( int i = 0; i < 4; i++ )
{
m_selection[ i ] = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
}
UpdateTitle();
}
public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
{
base.WriteToString( ref nodeInfo, ref connectionsInfo );
for ( int i = 0; i < 4; i++ )
{
IOUtils.AddFieldValueToString( ref nodeInfo, m_selection[ i ] );
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 85082b6932d1c9a4f8b64605534ef118
timeCreated: 1481126957
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Cos", "Trigonometry Operators", "Cosine of scalars and vectors" )]
public sealed class CosOpNode : SingleInputOp
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "cos";
m_previewShaderGUID = "3dde9e80389196f459eb94137268de4a";
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT,
WirePortDataType.FLOAT ,
WirePortDataType.FLOAT2,
WirePortDataType.FLOAT3,
WirePortDataType.FLOAT4,
WirePortDataType.COLOR ,
WirePortDataType.INT);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ee9c446e7e41d524f8b4c93e6a8886c5
timeCreated: 1481126960
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Cosh", "Trigonometry Operators", "Hyperbolic cosine of scalars and vectors" )]
public sealed class CoshOpNode : SingleInputOp
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "cosh";
m_previewShaderGUID = "154a4c85fe88657489a54a02416402c0";
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT,
WirePortDataType.FLOAT,
WirePortDataType.FLOAT2,
WirePortDataType.FLOAT3,
WirePortDataType.FLOAT4,
WirePortDataType.COLOR,
WirePortDataType.INT );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2b50a187f488a004aaa2dabbe558ab3a
timeCreated: 1481126954
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,35 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using UnityEngine;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Cross", "Vector Operators", "Cross product of two three-component vectors ( A x B )", null, KeyCode.X )]
public sealed class CrossProductOpNode : ParentNode
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
AddInputPort( WirePortDataType.FLOAT3, false, "Lhs" );
AddInputPort( WirePortDataType.FLOAT3, false, "Rhs" );
AddOutputPort( WirePortDataType.FLOAT3, "Out" );
m_useInternalPortData = true;
m_previewShaderGUID = "65a9be5cc7037654db8e148d669f03ee";
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
{
if ( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
string lhsStr = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
string rhsStr = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector );
string result = "cross( " + lhsStr + " , " + rhsStr + " )";
return CreateOutputLocalVariable( 0, result, ref dataCollector );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 283bc0645ce925346b33c024ff5a7dad
timeCreated: 1481126954
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,32 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
namespace AmplifyShaderEditor
{
[System.Serializable]
[NodeAttributes( "DDX", "Math Operators", "Approximate partial derivative with respect to window-space X" )]
public sealed class DdxOpNode : SingleInputOp
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "ddx";
m_previewShaderGUID = "b54ea73d5568b3540977557813eb9c3c";
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT,
WirePortDataType.FLOAT,
WirePortDataType.FLOAT2,
WirePortDataType.FLOAT3,
WirePortDataType.FLOAT4,
WirePortDataType.COLOR,
WirePortDataType.INT );
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
{
if( dataCollector.IsFragmentCategory )
return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
else
return m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2e14c4a7c0be9f146ac912130c280b15
timeCreated: 1481126954
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,32 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
namespace AmplifyShaderEditor
{
[System.Serializable]
[NodeAttributes( "DDY", "Math Operators", "Approximate partial derivative with respect to window-space Y" )]
public sealed class DdyOpNode : SingleInputOp
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "ddy";
m_previewShaderGUID = "197dcc7f05339da47b6b0e681c475c5e";
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT,
WirePortDataType.FLOAT,
WirePortDataType.FLOAT2,
WirePortDataType.FLOAT3,
WirePortDataType.FLOAT4,
WirePortDataType.COLOR,
WirePortDataType.INT );
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
{
if( dataCollector.IsFragmentCategory )
return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
else
return m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 722a2ad531fefdc4d8782d5c7cdfd012
timeCreated: 1481126956
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Degrees", "Trigonometry Operators", "Converts values of scalars and vectors from radians to degrees" )]
public sealed class DegreesOpNode : SingleInputOp
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "degrees";
m_previewShaderGUID = "2a8eebb5566830c4a9d7c4b9021bb743";
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT,
WirePortDataType.FLOAT ,
WirePortDataType.FLOAT2,
WirePortDataType.FLOAT3,
WirePortDataType.FLOAT4,
WirePortDataType.COLOR ,
WirePortDataType.INT);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 3d88a21f3ece742408c7748897a21c79
timeCreated: 1481126955
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,25 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Determinant", "Matrix Operators", "Scalar determinant of a square matrix" )]
public sealed class DeterminantOpNode : SingleInputOp
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "determinant";
m_drawPreview = false;
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.FLOAT3x3,
WirePortDataType.FLOAT4x4 );
m_autoUpdateOutputPort = false;
m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4x4, false );
m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT, false );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e5cded78687f09442895bc96cc5b683d
timeCreated: 1481126960
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,32 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Distance", "Vector Operators", "Euclidean distance between two points" )]
public sealed class DistanceOpNode : DynamicTypeNode
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false );
m_inputPorts[ 1 ].ChangeType( WirePortDataType.FLOAT4, false );
m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT, false );
m_dynamicOutputType = false;
m_useInternalPortData = true;
m_previewShaderGUID = "3be9a95031c0cb740ae982e465dfc242";
}
public override string BuildResults( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
{
if ( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
base.BuildResults( outputId, ref dataCollector, ignoreLocalvar );
string result = "distance( " + m_inputA + " , " + m_inputB + " )";
return CreateOutputLocalVariable( 0, result, ref dataCollector );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 4b8bd7fecbc728f4b89d398cef86ada8
timeCreated: 1481126955
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,34 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using UnityEngine;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Dot", "Vector Operators", "Scalar dot product of two vectors ( A . B )", null, KeyCode.Period )]
public sealed class DotProductOpNode : DynamicTypeNode
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false );
m_inputPorts[ 1 ].ChangeType( WirePortDataType.FLOAT4, false );
m_dynamicOutputType = false;
m_useInternalPortData = true;
m_allowMatrixCheck = true;
m_previewShaderGUID = "85f11fd5cb9bb954c8615a45c57a3784";
}
public override string BuildResults( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
{
if ( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
base.BuildResults( outputId, ref dataCollector, ignoreLocalvar );
string result = "dot( " + m_inputA + " , " + m_inputB + " )";
RegisterLocalVariable( 0, result, ref dataCollector, "dotResult" + OutputId );
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c2bf0375fb75ce245b2f30857a111972
timeCreated: 1481126959
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Exp2", "Math Operators", "Base-2 exponential of scalars and vectors" )]
public sealed class Exp2OpNode : SingleInputOp
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "exp2";
m_previewShaderGUID = "ceb70ed5423a36647a504a41de7dbfe6";
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT,
WirePortDataType.FLOAT,
WirePortDataType.FLOAT2,
WirePortDataType.FLOAT3,
WirePortDataType.FLOAT4,
WirePortDataType.COLOR,
WirePortDataType.INT );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a9881734e0217bc45bb422dc83f6ee1a
timeCreated: 1481126958
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Exp", "Math Operators", "Base-e exponential of scalars and vectors" )]
public sealed class ExpOpNode : SingleInputOp
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "exp";
m_previewShaderGUID = "6416ff506137d97479a7ebde790b45e5";
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT,
WirePortDataType.FLOAT ,
WirePortDataType.FLOAT2,
WirePortDataType.FLOAT3,
WirePortDataType.FLOAT4,
WirePortDataType.COLOR ,
WirePortDataType.INT);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 81ef96bc69f897d4e8bc21e2731e065f
timeCreated: 1481126957
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,38 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
namespace AmplifyShaderEditor
{
[System.Serializable]
[NodeAttributes( "FWidth", "Math Operators", "Sum of approximate window-space partial derivatives magnitudes (Only valid on Fragment type ports)" )]
public sealed class FWidthOpNode : SingleInputOp
{
private const string FWidthErrorMsg = "Attempting to connect an FWidth to a {0} type port. It is only valid on Fragment type ports";
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "fwidth";
m_previewShaderGUID = "81ea481faaef9c8459a555479ba64df7";
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT,
WirePortDataType.FLOAT ,
WirePortDataType.FLOAT2,
WirePortDataType.FLOAT3,
WirePortDataType.FLOAT4,
WirePortDataType.COLOR ,
WirePortDataType.INT);
//m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false );
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
{
if( dataCollector.PortCategory == MasterNodePortCategory.Vertex ||
dataCollector.PortCategory == MasterNodePortCategory.Tessellation )
{
UIUtils.ShowMessage( UniqueId, string.Format( FWidthErrorMsg, dataCollector.PortCategory ), MessageSeverity.Error );
return GenerateErrorValue();
}
return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2e17448829221b04bb3185bef727b19f
timeCreated: 1481126954
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,24 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
namespace AmplifyShaderEditor
{
[System.Serializable]
[NodeAttributes( "Floor", "Math Operators", "Largest integer not greater than a scalar or each vector component" )]
public sealed class FloorOpNode : SingleInputOp
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "floor";
m_previewShaderGUID = "46ae4a72a9a38de40a2d8f20cfccc67d";
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT,
WirePortDataType.FLOAT ,
WirePortDataType.FLOAT2,
WirePortDataType.FLOAT3,
WirePortDataType.FLOAT4,
WirePortDataType.COLOR ,
WirePortDataType.INT);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 176154e86c6c3544fab0d67e098c645d
timeCreated: 1481126953
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,36 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Fmod", "Math Operators", "Floating point remainder of x/y with the same sign as x" )]
public sealed class FmodOpNode : DynamicTypeNode
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_previewShaderGUID = "65083930f9d7812479fd6ff203ad2992";
}
public override string BuildResults( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
{
if ( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
base.BuildResults( outputId, ref dataCollector, ignoreLocalvar );
if( m_inputPorts[ 0 ].DataType == WirePortDataType.INT )
m_inputA = "(float)" + m_inputA;
if( m_inputPorts[ 1 ].DataType == WirePortDataType.INT )
m_inputB = "(float)" + m_inputB;
string result = "fmod( " + m_inputA + " , " + m_inputB + " )";
return CreateOutputLocalVariable( 0, result, ref dataCollector );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 599ae67e52ac45f46acc0efd9285b97c
timeCreated: 1481126956
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Fract", "Math Operators", "Fractional portion of a scalar or each vector component" )]
public sealed class FractNode : SingleInputOp
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "frac";
m_previewShaderGUID = "53a335f8f18d4694b8d94e8aee21fdca";
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT,
WirePortDataType.FLOAT,
WirePortDataType.FLOAT2,
WirePortDataType.FLOAT3,
WirePortDataType.FLOAT4,
WirePortDataType.COLOR,
WirePortDataType.INT );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: fd6da00dbcdf3d04cb35a61cda01ae77
timeCreated: 1481126960
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,207 @@
using System;
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Gradient Sample", "Miscellaneous", "Samples a gradient" )]
public sealed class GradientSampleNode : ParentNode
{
private string m_functionHeader = "SampleGradient( {0}, {1} )";
private string m_functionBody = string.Empty;
private GradientNode m_gradientNode = null;
private InputPort m_gradPort;
private Gradient m_blankGrandient = new Gradient();
private int m_cachedTimeId = -1;
private int m_cachedTypeId = -1;
private int m_cachedColorNumId = -1;
private int m_cachedAlphaNumId = -1;
private Vector4 m_auxVec4 = Vector4.zero;
private string m_functionHeaderStruct = "Gradient( {0} )";
private string m_functionBodyStruct = string.Empty;
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
AddInputPort( WirePortDataType.OBJECT, true, Constants.EmptyPortValue );
AddInputPort( WirePortDataType.FLOAT, false, "Time" );
AddOutputColorPorts( "RGBA", true );
m_gradPort = m_inputPorts[ 0 ];
m_useInternalPortData = true;
m_autoDrawInternalPortData = true;
m_drawPreviewExpander = false;
m_drawPreview = true;
m_showPreview = true;
m_selectedLocation = PreviewLocation.TopCenter;
m_previewShaderGUID = "8a09124cd6e4aa54a996e7487ec16b90";
}
public override void SetPreviewInputs()
{
base.SetPreviewInputs();
if( m_cachedTypeId == -1 )
m_cachedTypeId = Shader.PropertyToID( "_GType" );
if( m_cachedTimeId == -1 )
m_cachedTimeId = Shader.PropertyToID( "_GTime" );
if( m_cachedColorNumId == -1 )
m_cachedColorNumId = Shader.PropertyToID( "_GColorNum" );
if( m_cachedAlphaNumId == -1 )
m_cachedAlphaNumId = Shader.PropertyToID( "_GAlphaNum" );
PreviewMaterial.SetTexture( m_cachedTimeId, m_inputPorts[ 1 ].InputPreviewTexture( ContainerGraph ) );
Gradient curGrad = m_blankGrandient;
if( m_gradientNode != null )
curGrad = m_gradientNode.Gradient;
PreviewMaterial.SetInt( m_cachedTypeId, (int)curGrad.mode );
PreviewMaterial.SetInt( m_cachedColorNumId, curGrad.colorKeys.Length );
PreviewMaterial.SetInt( m_cachedAlphaNumId, curGrad.alphaKeys.Length );
for( int i = 0; i < 8; i++ )
{
if( i < curGrad.colorKeys.Length )
{
m_auxVec4.x = curGrad.colorKeys[ i ].color.r;
m_auxVec4.y = curGrad.colorKeys[ i ].color.g;
m_auxVec4.z = curGrad.colorKeys[ i ].color.b;
m_auxVec4.w = curGrad.colorKeys[ i ].time;
PreviewMaterial.SetVector( "_Col" + i, m_auxVec4 );
}
else
{
PreviewMaterial.SetVector( "_Col" + i, Vector4.zero );
}
}
for( int i = 0; i < 8; i++ )
{
if( i < curGrad.alphaKeys.Length )
{
m_auxVec4.x = curGrad.alphaKeys[ i ].alpha;
m_auxVec4.y = curGrad.alphaKeys[ i ].time;
PreviewMaterial.SetVector( "_Alp" + i, m_auxVec4 );
}
else
{
PreviewMaterial.SetVector( "_Alp" + i, Vector4.zero );
}
}
}
public override void OnNodeLogicUpdate( DrawInfo drawInfo )
{
base.OnNodeLogicUpdate( drawInfo );
if( m_gradPort.IsConnected )
{
m_gradientNode = RecursiveBackCheck( m_gradPort.GetOutputNode( 0 ) );
}
else
{
m_gradientNode = null;
}
}
GradientNode RecursiveBackCheck( ParentNode node )
{
if( node is GradientNode )
{
return node as GradientNode;
}
else
{
if( node is RelayNode || node is WireNode || node is RegisterLocalVarNode )
{
return RecursiveBackCheck( node.InputPorts[ 0 ].GetOutputNode( 0 ) );
}
else if( node is GetLocalVarNode)
{
var gnode = node as GetLocalVarNode;
if( gnode.CurrentSelected != null )
return RecursiveBackCheck( gnode.CurrentSelected );
else
return null;
}
else
{
return null;
}
}
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
{
m_functionBodyStruct = string.Empty;
if( !dataCollector.IsSRP )
{
GradientNode.GenerateGradientStruct( ref m_functionBodyStruct );
dataCollector.AddFunctions( m_functionHeaderStruct, m_functionBodyStruct, "0" );
}
else
{
dataCollector.AddToIncludes( UniqueId, "Packages/com.unity.shadergraph/ShaderGraphLibrary/Functions.hlsl" );
}
GenerateGradientSampler( dataCollector.IsSRP );
string gradient = "(Gradient)0";
if( m_inputPorts[ 0 ].IsConnected && m_gradientNode != null )
gradient = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
string time = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector );
string functionResult = dataCollector.AddFunctions( m_functionHeader, m_functionBody, gradient, time );
return GetOutputVectorItem( 0, outputId, functionResult );
}
void GenerateGradientSampler( bool isSrp )
{
m_functionBody = string.Empty;
IOUtils.AddFunctionHeader( ref m_functionBody, "float4 SampleGradient( Gradient gradient, float time )" );
IOUtils.AddFunctionLine( ref m_functionBody, "float3 color = gradient.colors[0].rgb;" );
IOUtils.AddFunctionLine( ref m_functionBody, "UNITY_UNROLL" );
IOUtils.AddFunctionLine( ref m_functionBody, "for (int c = 1; c < 8; c++)" );
IOUtils.AddFunctionLine( ref m_functionBody, "{" );
if( isSrp )
IOUtils.AddFunctionLine( ref m_functionBody, "float colorPos = saturate((time - gradient.colors[c-1].w) / ( 0.00001 + (gradient.colors[c].w - gradient.colors[c-1].w)) * step(c, gradient.colorsLength-1));" );
else
IOUtils.AddFunctionLine( ref m_functionBody, "float colorPos = saturate((time - gradient.colors[c-1].w) / ( 0.00001 + (gradient.colors[c].w - gradient.colors[c-1].w)) * step(c, (float)gradient.colorsLength-1));" );
IOUtils.AddFunctionLine( ref m_functionBody, "color = lerp(color, gradient.colors[c].rgb, lerp(colorPos, step(0.01, colorPos), gradient.type));" );
IOUtils.AddFunctionLine( ref m_functionBody, "}" );
IOUtils.AddFunctionLine( ref m_functionBody, "#ifndef UNITY_COLORSPACE_GAMMA" );
if( isSrp )
IOUtils.AddFunctionLine( ref m_functionBody, "color = SRGBToLinear(color);" );
else
IOUtils.AddFunctionLine( ref m_functionBody, "color = half3(GammaToLinearSpaceExact(color.r), GammaToLinearSpaceExact(color.g), GammaToLinearSpaceExact(color.b));" );
IOUtils.AddFunctionLine( ref m_functionBody, "#endif" );
IOUtils.AddFunctionLine( ref m_functionBody, "float alpha = gradient.alphas[0].x;" );
IOUtils.AddFunctionLine( ref m_functionBody, "UNITY_UNROLL" );
IOUtils.AddFunctionLine( ref m_functionBody, "for (int a = 1; a < 8; a++)" );
IOUtils.AddFunctionLine( ref m_functionBody, "{" );
if( isSrp )
IOUtils.AddFunctionLine( ref m_functionBody, "float alphaPos = saturate((time - gradient.alphas[a-1].y) / ( 0.00001 + (gradient.alphas[a].y - gradient.alphas[a-1].y)) * step(a, gradient.alphasLength-1));" );
else
IOUtils.AddFunctionLine( ref m_functionBody, "float alphaPos = saturate((time - gradient.alphas[a-1].y) / ( 0.00001 + (gradient.alphas[a].y - gradient.alphas[a-1].y)) * step(a, (float)gradient.alphasLength-1));" );
IOUtils.AddFunctionLine( ref m_functionBody, "alpha = lerp(alpha, gradient.alphas[a].x, lerp(alphaPos, step(0.01, alphaPos), gradient.type));" );
IOUtils.AddFunctionLine( ref m_functionBody, "}" );
IOUtils.AddFunctionLine( ref m_functionBody, "return float4(color, alpha);" );
IOUtils.CloseFunctionBody( ref m_functionBody );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b90e416e2fa93a249952fabc78f659c8
timeCreated: 1562847602
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,138 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
// 4x4 Invert by DBN in
// http://answers.unity3d.com/questions/218333/shader-inversefloat4x4-function.html?childToView=641391#answer-641391
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Inverse", "Matrix Operators", "Inverse matrix of a matrix" )]
public sealed class InverseOpNode : SingleInputOp
{
private string Inverse4x4Header = "Inverse4x4( {0} )";
//4x4
private string[] Inverse4x4Function =
{
"{0}4x4 Inverse4x4({0}4x4 input)\n",
"{\n",
"\t#define minor(a,b,c) determinant({0}3x3(input.a, input.b, input.c))\n",
"\t{0}4x4 cofactors = {0}4x4(\n",
"\tminor( _22_23_24, _32_33_34, _42_43_44 ),\n",
"\t-minor( _21_23_24, _31_33_34, _41_43_44 ),\n",
"\tminor( _21_22_24, _31_32_34, _41_42_44 ),\n",
"\t-minor( _21_22_23, _31_32_33, _41_42_43 ),\n",
"\n",
"\t-minor( _12_13_14, _32_33_34, _42_43_44 ),\n",
"\tminor( _11_13_14, _31_33_34, _41_43_44 ),\n",
"\t-minor( _11_12_14, _31_32_34, _41_42_44 ),\n",
"\tminor( _11_12_13, _31_32_33, _41_42_43 ),\n",
"\n",
"\tminor( _12_13_14, _22_23_24, _42_43_44 ),\n",
"\t-minor( _11_13_14, _21_23_24, _41_43_44 ),\n",
"\tminor( _11_12_14, _21_22_24, _41_42_44 ),\n",
"\t-minor( _11_12_13, _21_22_23, _41_42_43 ),\n",
"\n",
"\t-minor( _12_13_14, _22_23_24, _32_33_34 ),\n",
"\tminor( _11_13_14, _21_23_24, _31_33_34 ),\n",
"\t-minor( _11_12_14, _21_22_24, _31_32_34 ),\n",
"\tminor( _11_12_13, _21_22_23, _31_32_33 ));\n",
"\t#undef minor\n",
"\treturn transpose( cofactors ) / determinant( input );\n",
"}\n"
};
private bool[] Inverse4x4FunctionFlags =
{
true,
false,
true,
true,
false,
false,
false,
false,
false,
false,
false,
false,
false,
false,
false,
false,
false,
false,
false,
false,
false,
false,
false,
false,
false,
false,
false
};
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "inverse";
m_drawPreview = false;
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.FLOAT3x3,
WirePortDataType.FLOAT4x4 );
m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4x4, false );
m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4x4, false );
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
{
if ( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
string precisionString = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, WirePortDataType.FLOAT );
string value = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
if ( m_outputPorts[ 0 ].DataType == WirePortDataType.FLOAT3x3 )
{
GeneratorUtils.Add3x3InverseFunction( ref dataCollector, precisionString );
RegisterLocalVariable( 0, string.Format( GeneratorUtils.Inverse3x3Header, value ), ref dataCollector, "invertVal" + OutputId );
}
else
{
if ( !dataCollector.HasFunction( Inverse4x4Header ) )
{
//Hack to be used util indent is properly used
int currIndent = UIUtils.ShaderIndentLevel;
if ( dataCollector.IsTemplate )
{
UIUtils.ShaderIndentLevel = 0;
}
else
{
UIUtils.ShaderIndentLevel = 1;
UIUtils.ShaderIndentLevel++;
}
string finalFunction = string.Empty;
for ( int i = 0; i < Inverse4x4Function.Length; i++ )
{
finalFunction += UIUtils.ShaderIndentTabs + ( Inverse4x4FunctionFlags[ i ] ? string.Format( Inverse4x4Function[ i ], precisionString ) : Inverse4x4Function[ i ] );
}
UIUtils.ShaderIndentLevel = currIndent;
dataCollector.AddFunction( Inverse4x4Header, finalFunction );
}
RegisterLocalVariable( 0, string.Format( Inverse4x4Header, value ), ref dataCollector, "invertVal" + OutputId );
}
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 785830160e033d24280df9c5b4cec368
timeCreated: 1481126957
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,41 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
namespace AmplifyShaderEditor
{
[System.Serializable]
[NodeAttributes( "Length", "Vector Operators", "Scalar Euclidean length of a vector" )]
public sealed class LengthOpNode : SingleInputOp
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "length";
m_previewShaderGUID = "1c1f6d6512b758942a8b9dd1bea12f34";
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT,
WirePortDataType.FLOAT ,
WirePortDataType.FLOAT2,
WirePortDataType.FLOAT3,
WirePortDataType.FLOAT4,
WirePortDataType.COLOR ,
WirePortDataType.INT);
m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false );
m_autoUpdateOutputPort = false;
}
public override void SetPreviewInputs()
{
base.SetPreviewInputs();
switch( m_inputPorts[0].DataType )
{
case WirePortDataType.OBJECT:
case WirePortDataType.INT:
case WirePortDataType.FLOAT:
case WirePortDataType.UINT:m_previewMaterialPassId = 0;break;
case WirePortDataType.FLOAT2:m_previewMaterialPassId = 1;break;
case WirePortDataType.FLOAT3:m_previewMaterialPassId = 2;break;
case WirePortDataType.FLOAT4:
case WirePortDataType.COLOR:m_previewMaterialPassId = 3;break;
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: bb3fd570e41cfa24d93b53e80eac02d5
timeCreated: 1481126958
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,116 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Lerp", "Math Operators", "Linear interpolation of two scalars or vectors based on a weight", null, KeyCode.L )]
public sealed class LerpOp : ParentNode
{
private const string LertOpFormat = "lerp( {0} , {1} , {2})";
[UnityEngine.SerializeField]
private WirePortDataType m_mainDataType = WirePortDataType.FLOAT;
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_textLabelWidth = 55;
AddInputPort( WirePortDataType.FLOAT, false, "A" );
AddInputPort( WirePortDataType.FLOAT, false, "B" );
AddInputPort( WirePortDataType.FLOAT, false, "Alpha" );
AddOutputPort( WirePortDataType.FLOAT,Constants.EmptyPortValue);
m_useInternalPortData = true;
m_previewShaderGUID = "34d9c4cdcf1fadb49af2de3f90bbc57d";
}
public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true )
{
base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode );
UpdateConnection( portId );
}
public override void OnConnectedOutputNodeChanges( int inputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type )
{
base.OnConnectedOutputNodeChanges( inputPortId, otherNodeId, otherPortId, name, type );
UpdateConnection( inputPortId );
}
public override void OnInputPortDisconnected( int portId )
{
base.OnInputPortDisconnected( portId );
UpdateConnection( portId );
}
void UpdateConnection( int portId )
{
WirePortDataType type1 = WirePortDataType.FLOAT;
if( m_inputPorts[ 0 ].IsConnected )
type1 = m_inputPorts[ 0 ].GetOutputConnection( 0 ).DataType;
WirePortDataType type2 = WirePortDataType.FLOAT;
if( m_inputPorts[ 1 ].IsConnected )
type2 = m_inputPorts[ 1 ].GetOutputConnection( 0 ).DataType;
WirePortDataType typealpha = WirePortDataType.FLOAT;
if( m_inputPorts[ 2 ].IsConnected )
typealpha = m_inputPorts[ 2 ].GetOutputConnection( 0 ).DataType;
m_mainDataType = UIUtils.GetPriority( type1 ) > UIUtils.GetPriority( type2 ) ? type1 : type2;
if( !m_inputPorts[ 0 ].IsConnected && !m_inputPorts[ 1 ].IsConnected && m_inputPorts[ 2 ].IsConnected )
m_mainDataType = m_inputPorts[ 2 ].GetOutputConnection( 0 ).DataType;
m_inputPorts[ 0 ].ChangeType( m_mainDataType, false );
m_inputPorts[ 1 ].ChangeType( m_mainDataType, false );
if( m_inputPorts[ 2 ].IsConnected && ( typealpha == WirePortDataType.FLOAT || typealpha == WirePortDataType.INT ) )
m_inputPorts[ 2 ].ChangeType( WirePortDataType.FLOAT, false );
else
m_inputPorts[ 2 ].ChangeType( m_mainDataType, false );
m_outputPorts[ 0 ].ChangeType( m_mainDataType, false );
}
//void UpdateDisconnection( int portId )
//{
// int otherPortId = ( portId + 1 ) % 2;
// if ( m_inputPorts[ otherPortId ].IsConnected )
// {
// m_mainDataType = m_inputPorts[ otherPortId ].DataType;
// m_inputPorts[ portId ].ChangeType( m_mainDataType, false );
// m_outputPorts[ 0 ].ChangeType( m_mainDataType, false );
// }
//}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
{
if ( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
string aValue = m_inputPorts[ 0 ].GenerateShaderForOutput( ref dataCollector, m_mainDataType, ignoreLocalVar, true );
string bValue = m_inputPorts[ 1 ].GenerateShaderForOutput( ref dataCollector, m_mainDataType, ignoreLocalVar, true );
string interp = string.Empty;
if( m_inputPorts[ 2 ].DataType == WirePortDataType.FLOAT )
interp = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector );
else
interp = m_inputPorts[ 2 ].GenerateShaderForOutput( ref dataCollector, m_mainDataType, ignoreLocalVar,true );
string result = string.Format( LertOpFormat, aValue,bValue,interp);
RegisterLocalVariable( 0, result, ref dataCollector, "lerpResult"+OutputId );
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
}
//public override void RefreshExternalReferences()
//{
// if ( m_inputPorts[ 2 ].DataType != WirePortDataType.FLOAT )
// {
// m_inputPorts[ 2 ].ChangeType( WirePortDataType.FLOAT, false );
// }
//}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 1e38abf6e3c7dfa409a5fe40d2ce8a19
timeCreated: 1481126954
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Log10", "Math Operators", "Base-10 logarithm of scalars and vectors" )]
public sealed class Log10OpNode : SingleInputOp
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "log10";
m_previewShaderGUID = "9e7cfa357dd261f499d0ba8637ff2614";
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT,
WirePortDataType.FLOAT ,
WirePortDataType.FLOAT2,
WirePortDataType.FLOAT3,
WirePortDataType.FLOAT4,
WirePortDataType.COLOR ,
WirePortDataType.INT);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: be47a76f1f42fbe47bf2568584c31196
timeCreated: 1481126959
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Log2", "Math Operators", "Base-2 logarithm of scalars and vectors" )]
public sealed class Log2OpNode : SingleInputOp
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "log2";
m_previewShaderGUID = "5975a154432d4c64cacd78d015ed08ba";
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT,
WirePortDataType.FLOAT ,
WirePortDataType.FLOAT2,
WirePortDataType.FLOAT3,
WirePortDataType.FLOAT4,
WirePortDataType.COLOR ,
WirePortDataType.INT);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b9489308aad1f794982afc1faf646013
timeCreated: 1481126958
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Log", "Math Operators", "Natural logarithm of scalars and vectors" )]
public sealed class LogOpNode : SingleInputOp
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "log";
m_previewShaderGUID = "a3293e0a73834b24682775f5d8ee1e7c";
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT,
WirePortDataType.FLOAT,
WirePortDataType.FLOAT2,
WirePortDataType.FLOAT3,
WirePortDataType.FLOAT4,
WirePortDataType.COLOR,
WirePortDataType.INT );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 1ed2c12cea61a8c4fa67eebdc10d2a2a
timeCreated: 1481126954
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,3 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
// Deprecated file

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 8804c7e5888738547b5a704f788fc18b
timeCreated: 1481126957
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,46 @@
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Negate", "Math Operators", "Negate or invert an input value" )]
public sealed class NegateNode : ParentNode
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
AddInputPort( WirePortDataType.FLOAT, false, Constants.EmptyPortValue );
AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue );
m_useInternalPortData = true;
m_previewShaderGUID = "b035bc40da1ac7c4eafad4116382ec79";
}
public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true )
{
base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode );
m_inputPorts[ 0 ].MatchPortToConnection();
m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false );
}
public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type )
{
base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type );
m_inputPorts[ 0 ].MatchPortToConnection();
m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false );
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
{
string result = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
if ( result.StartsWith( "-" ) )
{
return result.Remove( 0, 1 );
}
else
{
return "-" + result;
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 01c91005470f6b94eba168a127cecd6c
timeCreated: 1481126953
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,87 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using UnityEditor;
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Normalize", "Vector Operators", "Normalizes a vector", null, KeyCode.N )]
public sealed class NormalizeNode : SingleInputOp
{
[SerializeField]
private bool m_safeNormalize = false;
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_selectedLocation = PreviewLocation.TopCenter;
m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false );
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.FLOAT, WirePortDataType.FLOAT2, WirePortDataType.FLOAT3, WirePortDataType.FLOAT4, WirePortDataType.COLOR, WirePortDataType.OBJECT, WirePortDataType.INT );
m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4 , false );
m_previewShaderGUID = "a51b11dfb6b32884e930595e5f9defa8";
m_autoWrapProperties = true;
}
public override void DrawProperties()
{
base.DrawProperties();
m_safeNormalize = EditorGUILayoutToggle( "Safe Normalize" , m_safeNormalize );
EditorGUILayout.HelpBox( Constants.SafeNormalizeInfoStr , MessageType.Info );
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
{
if ( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
string result = string.Empty;
switch ( m_inputPorts[ 0 ].DataType )
{
case WirePortDataType.FLOAT:
case WirePortDataType.FLOAT2:
case WirePortDataType.FLOAT3:
case WirePortDataType.FLOAT4:
case WirePortDataType.OBJECT:
case WirePortDataType.COLOR:
{
string value = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
result = GeneratorUtils.NormalizeValue( ref dataCollector , m_safeNormalize , m_inputPorts[ 0 ].DataType, value );
}
break;
case WirePortDataType.INT:
{
return m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
}
case WirePortDataType.FLOAT3x3:
case WirePortDataType.FLOAT4x4:
{
result = UIUtils.InvalidParameter( this );
}
break;
}
RegisterLocalVariable( 0, result, ref dataCollector, "normalizeResult" + OutputId );
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
}
public override void ReadFromString( ref string[] nodeParams )
{
base.ReadFromString( ref nodeParams );
if( UIUtils.CurrentShaderVersion() > 18814 )
{
m_safeNormalize = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
}
}
public override void WriteToString( ref string nodeInfo , ref string connectionsInfo )
{
base.WriteToString( ref nodeInfo , ref connectionsInfo );
IOUtils.AddFieldValueToString( ref nodeInfo , m_safeNormalize );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: fa6682c371754094f88b3c2a7e96ae26
timeCreated: 1481126960
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,45 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using UnityEngine;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "One Minus", "Math Operators", "1 - input value", null, KeyCode.O )]
public sealed class OneMinusNode : ParentNode
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
AddInputPort( WirePortDataType.FLOAT, false, Constants.EmptyPortValue );
AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue );
m_useInternalPortData = true;
m_previewShaderGUID = "bed5300b92e7bb0419d0f4accb853312";
}
public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true )
{
base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode );
m_inputPorts[ 0 ].MatchPortToConnection();
m_outputPorts[ 0 ].ChangeType( InputPorts[ 0 ].DataType, false );
}
public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type )
{
base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type );
m_inputPorts[ 0 ].MatchPortToConnection();
m_outputPorts[ 0 ].ChangeType( InputPorts[ 0 ].DataType, false );
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
{
if ( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
string result = "( 1.0 - " + m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ) + " )";
return CreateOutputLocalVariable( 0, result, ref dataCollector );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 727743b66e17d7b4f9c2fbe7dde98bd9
timeCreated: 1481126956
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,93 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using UnityEngine;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Power", "Math Operators", "Base to the Exp-th power of scalars and vectors", null, KeyCode.E )]
public sealed class PowerNode : ParentNode
{
public const string SafePowerStr = "max( {0} , 0.0001 )";
public const string SafePowerLabel = "Safe Power";
[SerializeField]
private bool m_safePower = false;
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
AddInputPort( WirePortDataType.FLOAT, false, "Base" );
AddInputPort( WirePortDataType.FLOAT, false, "Exp" );
m_inputPorts[ 1 ].FloatInternalData = 1;
AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue );
m_useInternalPortData = true;
m_autoWrapProperties = true;
m_textLabelWidth = 85;
m_previewShaderGUID = "758cc2f8b537b4e4b93d9833075d138c";
}
public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true )
{
base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode );
UpdateConnections( portId );
}
public override void OnConnectedOutputNodeChanges( int inputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type )
{
base.OnConnectedOutputNodeChanges( inputPortId, otherNodeId, otherPortId, name, type );
UpdateConnections( inputPortId );
}
void UpdateConnections( int inputPort )
{
m_inputPorts[ inputPort ].MatchPortToConnection();
if ( inputPort == 0 )
{
m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false );
}
}
public override void DrawProperties()
{
base.DrawProperties();
m_safePower = EditorGUILayoutToggle( SafePowerLabel, m_safePower );
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
{
if ( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
string x = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
if( m_safePower )
{
string safePowerName = "saferPower" + OutputId;
string safePowerValue = string.Format( SafePowerStr, x );
dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, m_inputPorts[ 0 ].DataType, safePowerName, safePowerValue );
x = safePowerName;
}
string y = m_inputPorts[ 1 ].GenerateShaderForOutput( ref dataCollector, m_inputPorts[ 0 ].DataType, ignoreLocalvar, true );
string result = "pow( " + x + " , " + y + " )";
return CreateOutputLocalVariable( 0, result, ref dataCollector );
}
public override void ReadFromString( ref string[] nodeParams )
{
base.ReadFromString( ref nodeParams );
if( UIUtils.CurrentShaderVersion() > 17502 )
m_safePower = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
}
public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
{
base.WriteToString( ref nodeInfo, ref connectionsInfo );
IOUtils.AddFieldValueToString( ref nodeInfo, m_safePower );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 520a55839e863ce47b3558be612f4691
timeCreated: 1481126955
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Rsqrt", "Math Operators", "Reciprocal square root of scalars and vectors" )]
public sealed class RSqrtOpNode : SingleInputOp
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "rsqrt";
m_previewShaderGUID = "c58c17cb1f7f6e6429a2c7a6cdaef87d";
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT,
WirePortDataType.FLOAT ,
WirePortDataType.FLOAT2,
WirePortDataType.FLOAT3,
WirePortDataType.FLOAT4,
WirePortDataType.COLOR ,
WirePortDataType.INT);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 513de50bd4766d0448bb471ca272608f
timeCreated: 1481126955
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Radians", "Trigonometry Operators", "Converts values of scalars and vectors from degrees to radians" )]
public sealed class RadiansOpNode : SingleInputOp
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "radians";
m_previewShaderGUID = "d27d189eaf6eeb04fae9913d9617ece5";
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT,
WirePortDataType.FLOAT,
WirePortDataType.FLOAT2,
WirePortDataType.FLOAT3,
WirePortDataType.FLOAT4,
WirePortDataType.COLOR,
WirePortDataType.INT );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b6ca01d5c16f73c42996318c140eddb7
timeCreated: 1481126958
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Reflect", "Vector Operators", "Reflection vector given an incidence vector and a normal vector" )]
public sealed class ReflectOpNode : DynamicTypeNode
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_inputPorts[ 0 ].ChangeProperties( "Incident", WirePortDataType.FLOAT4, false );
m_inputPorts[ 1 ].ChangeProperties( "Normal", WirePortDataType.FLOAT4, false );
m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false );
m_textLabelWidth = 67;
m_previewShaderGUID = "fb520f2145c0fa0409320a9e6d720758";
}
public override string BuildResults( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
{
if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
base.BuildResults( outputId, ref dataCollector, ignoreLocalvar );
string result = "reflect( " + m_inputA + " , " + m_inputB + " )";
return CreateOutputLocalVariable( 0, result, ref dataCollector );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: bcd77715f8db1564abc96d502312d476
timeCreated: 1481126958
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,92 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Refract", "Vector Operators", "Computes a refraction vector" )]
public sealed class RefractOpVec : ParentNode
{
[UnityEngine.SerializeField]
private WirePortDataType m_mainDataType = WirePortDataType.FLOAT;
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
AddInputPort( WirePortDataType.FLOAT4, false , "Incident" );
AddInputPort( WirePortDataType.FLOAT4, false , "Normal" );
AddInputPort( WirePortDataType.FLOAT, false, "Eta" );
AddOutputPort( WirePortDataType.FLOAT4, Constants.EmptyPortValue );
m_textLabelWidth = 67;
m_previewShaderGUID = "5ab44ca484bed8b4884b03b1c00fdc3d";
}
public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true )
{
base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode );
UpdateConnection( portId );
}
public override void OnConnectedOutputNodeChanges( int inputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type )
{
base.OnConnectedOutputNodeChanges( inputPortId, otherNodeId, otherPortId, name, type );
UpdateConnection( inputPortId );
}
public override void OnInputPortDisconnected( int portId )
{
base.OnInputPortDisconnected( portId );
UpdateConnection( portId );
}
void UpdateConnection( int portId )
{
if( portId == 2 )
return;
bool hasConnection = false;
WirePortDataType type1 = WirePortDataType.FLOAT;
if( m_inputPorts[ 0 ].IsConnected )
{
type1 = m_inputPorts[ 0 ].GetOutputConnection( 0 ).DataType;
hasConnection = true;
}
WirePortDataType type2 = WirePortDataType.FLOAT;
if( m_inputPorts[ 1 ].IsConnected )
{
type2 = m_inputPorts[ 1 ].GetOutputConnection( 0 ).DataType;
hasConnection = true;
}
if( hasConnection )
{
m_mainDataType = UIUtils.GetPriority( type1 ) > UIUtils.GetPriority( type2 ) ? type1 : type2;
}
else
{
m_mainDataType = WirePortDataType.FLOAT4;
}
m_inputPorts[ 0 ].ChangeType( m_mainDataType, false );
m_inputPorts[ 1 ].ChangeType( m_mainDataType, false );
m_outputPorts[ 0 ].ChangeType( m_mainDataType, false );
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
{
if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
string incident = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
string normal = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector );
string interp = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector );
string result = "refract( " + incident + " , " + normal + " , " + interp + " )";
return CreateOutputLocalVariable( 0, result, ref dataCollector );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c5bb608b83cdc894cab572c72baa5f84
timeCreated: 1481126959
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Round", "Math Operators", "Rounded value of scalars or vectors" )]
public sealed class RoundOpNode : SingleInputOp
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "round";
m_previewShaderGUID = "554d561417b207c4bb3cd4a0c86b6907";
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT,
WirePortDataType.FLOAT ,
WirePortDataType.FLOAT2,
WirePortDataType.FLOAT3,
WirePortDataType.FLOAT4,
WirePortDataType.COLOR ,
WirePortDataType.INT);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f7b5f29bc7f6bb844ae4ea698404adc3
timeCreated: 1481126960
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Saturate", "Math Operators", "Saturate clamps the input values into the [0,1] range" )]
public sealed class SaturateNode : SingleInputOp
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "saturate";
m_previewShaderGUID = "d9e53418dc8b9d34fb395e3ea3c75985";
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT,
WirePortDataType.FLOAT ,
WirePortDataType.FLOAT2,
WirePortDataType.FLOAT3,
WirePortDataType.FLOAT4,
WirePortDataType.COLOR ,
WirePortDataType.INT);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 9d56f68d94c889443af651140ef86948
timeCreated: 1481126957
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,78 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Scale And Offset", "Math Operators", "Scales and offsets an input value\n( ( <b>Value</b> * <b>Scale</b> ) + <b>Offset</b> )" )]
public sealed class ScaleAndOffsetNode : ParentNode
{
private const string ScaleOffsetOpStr = "({0}*{1} + {2})";
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
AddInputPort( WirePortDataType.FLOAT, false, Constants.EmptyPortValue );
AddInputPort( WirePortDataType.FLOAT, false, "Scale" );
m_inputPorts[ 1 ].FloatInternalData = 1;
AddInputPort( WirePortDataType.FLOAT, false, "Offset" );
AddOutputPort( WirePortDataType.FLOAT, " " );
m_useInternalPortData = true;
m_previewShaderGUID = "a1f1053d4d9c3be439e0382038b74771";
}
public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true )
{
base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode );
UpdateConnection( portId );
}
public override void OnConnectedOutputNodeChanges( int inputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type )
{
base.OnConnectedOutputNodeChanges( inputPortId, otherNodeId, otherPortId, name, type );
UpdateConnection( inputPortId );
}
public override void OnInputPortDisconnected( int portId )
{
base.OnInputPortDisconnected( portId );
m_inputPorts[ portId ].ChangeType( WirePortDataType.FLOAT, false );
if( portId == 0 )
{
m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT, false );
}
}
void UpdateConnection( int portId )
{
if( portId == 0 )
{
m_inputPorts[ 0 ].MatchPortToConnection();
m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false );
}
else
{
WirePortDataType newDataType = m_inputPorts[ portId ].ConnectionType() == WirePortDataType.FLOAT ? WirePortDataType.FLOAT : m_outputPorts[ 0 ].DataType;
m_inputPorts[ portId ].ChangeType( newDataType, false );
}
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
{
if ( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
string value = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
// If scale or offset ports are floats then there's no need to cast them to any other type since they can be multiplied with everything
WirePortDataType scaleType = ( m_inputPorts[ 1 ].ConnectionType() == WirePortDataType.FLOAT ) ? WirePortDataType.FLOAT : m_outputPorts[ 0 ].DataType;
string scale = m_inputPorts[ 1 ].GenerateShaderForOutput( ref dataCollector, scaleType, ignoreLocalvar , true );
WirePortDataType offsetType = ( m_inputPorts[ 2 ].ConnectionType() == WirePortDataType.FLOAT ) ? WirePortDataType.FLOAT : m_outputPorts[ 0 ].DataType;
string offset = m_inputPorts[ 2 ].GenerateShaderForOutput( ref dataCollector, offsetType, ignoreLocalvar, true );
string result = string.Format( ScaleOffsetOpStr, value, scale, offset );
return CreateOutputLocalVariable( 0, result, ref dataCollector );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b594feaa69ad03449b563f834fe0c18e
timeCreated: 1484582091
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,152 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using UnityEditor;
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Scale", "Math Operators", "Scales input value by a float factor" )]
public sealed class ScaleNode : ParentNode
{
private const string ScaleFactorStr = "Scale";
[SerializeField]
private float m_scaleFactor = 1;
private int m_cachedPropertyId = -1;
private const float LabelWidth = 8;
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
AddInputPort( WirePortDataType.FLOAT, false, " " );
AddOutputPort( WirePortDataType.FLOAT, " " );
m_insideSize.Set( 50, 10 );
m_autoWrapProperties = true;
m_previewShaderGUID = "6d8ec9d9dab62c44aa2dcc0e3987760d";
}
public override void SetPreviewInputs()
{
base.SetPreviewInputs();
if ( m_cachedPropertyId == -1 )
m_cachedPropertyId = Shader.PropertyToID( "_ScaleFloat" );
PreviewMaterial.SetFloat( m_cachedPropertyId, m_scaleFactor );
}
public override void DrawProperties()
{
base.DrawProperties();
m_scaleFactor = EditorGUILayoutFloatField( ScaleFactorStr, m_scaleFactor );
}
public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true )
{
base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode );
m_inputPorts[ 0 ].MatchPortToConnection();
m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false );
}
public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type )
{
base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type );
m_inputPorts[ 0 ].MatchPortToConnection();
m_outputPorts[ 0 ].ChangeType( InputPorts[ 0 ].DataType, false );
}
public override void OnNodeLayout( DrawInfo drawInfo )
{
base.OnNodeLayout( drawInfo );
m_propertyDrawPos.x = m_remainingBox.x + Constants.FLOAT_WIDTH_SPACING * drawInfo.InvertedZoom * 0.5f;
m_propertyDrawPos.y = m_remainingBox.y + Constants.INPUT_PORT_DELTA_Y * drawInfo.InvertedZoom * 0.5f;
m_propertyDrawPos.width = drawInfo.InvertedZoom * Constants.FLOAT_DRAW_WIDTH_FIELD_SIZE;
m_propertyDrawPos.height = drawInfo.InvertedZoom * Constants.FLOAT_DRAW_HEIGHT_FIELD_SIZE;
}
public override void DrawGUIControls( DrawInfo drawInfo )
{
base.DrawGUIControls( drawInfo );
if ( drawInfo.CurrentEventType != EventType.MouseDown )
return;
Rect hitBox = m_remainingBox;
hitBox.xMin -= LabelWidth * drawInfo.InvertedZoom;
bool insideBox = hitBox.Contains( drawInfo.MousePosition );
if ( insideBox )
{
GUI.FocusControl( null );
m_isEditingFields = true;
}
else if ( m_isEditingFields && !insideBox )
{
GUI.FocusControl( null );
m_isEditingFields = false;
}
}
private bool m_isEditingFields;
private float m_previousValue;
private string m_fieldText = "0";
public override void Draw( DrawInfo drawInfo )
{
base.Draw( drawInfo );
if ( !m_isVisible )
return;
if ( m_isEditingFields )
{
UIUtils.DrawFloat( this, ref m_propertyDrawPos, ref m_scaleFactor, LabelWidth );
}
else if ( drawInfo.CurrentEventType == EventType.Repaint )
{
Rect fakeField = m_propertyDrawPos;
fakeField.xMin += LabelWidth * drawInfo.InvertedZoom;
Rect fakeLabel = m_propertyDrawPos;
fakeLabel.xMax = fakeField.xMin;
EditorGUIUtility.AddCursorRect( fakeLabel, MouseCursor.SlideArrow );
EditorGUIUtility.AddCursorRect( fakeField, MouseCursor.Text );
if ( m_previousValue != m_scaleFactor )
{
m_previousValue = m_scaleFactor;
m_fieldText = m_scaleFactor.ToString();
}
GUI.Label( fakeField, m_fieldText, UIUtils.MainSkin.textField );
}
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
{
if ( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
string portResult = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
string result = "( " + portResult + " * " + m_scaleFactor + " )";
return CreateOutputLocalVariable( 0, result, ref dataCollector );
}
public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
{
base.WriteToString( ref nodeInfo, ref connectionsInfo );
IOUtils.AddFieldValueToString( ref nodeInfo, m_scaleFactor );
}
public override void ReadFromString( ref string[] nodeParams )
{
base.ReadFromString( ref nodeParams );
m_scaleFactor = Convert.ToSingle( GetCurrentParam( ref nodeParams ) );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ec926b11f9c698c458f746e4e55fd7df
timeCreated: 1481126960
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Sign", "Math Operators", "Sign of scalar or each vector component" )]
public sealed class SignOpNode : SingleInputOp
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "sign";
m_previewShaderGUID = "3aca80b49aadf5046b7133730818e18f";
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT,
WirePortDataType.FLOAT ,
WirePortDataType.FLOAT2,
WirePortDataType.FLOAT3,
WirePortDataType.FLOAT4,
WirePortDataType.COLOR ,
WirePortDataType.INT);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 429f407c2b590df45b215f0edfa49b97
timeCreated: 1481126955
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,32 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Simplified Fmod", "Math Operators", "Floating point remainder of x/y" )]
public sealed class SimplifiedFModOpNode : DynamicTypeNode
{
private const string FmodCustomOp = "frac({0}/{1})*{1}";
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_previewShaderGUID = "2688236fb4f37ce47b81cc818c53321d";
}
public override string BuildResults( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
{
if ( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
{
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
}
base.BuildResults( outputId, ref dataCollector, ignoreLocalvar );
RegisterLocalVariable( 0, string.Format( FmodCustomOp, m_inputA, m_inputB ), ref dataCollector, ( "fmodResult" + OutputId ) );
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f186e1b03a8ee2b4b9e45918576e8cf6
timeCreated: 1484731588
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Sin", "Trigonometry Operators", "Sine of scalars and vectors" )]
public sealed class SinOpNode : SingleInputOp
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "sin";
m_previewShaderGUID = "bcd9f8749ddd3ac4f94f4c2071c1d0d4";
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT,
WirePortDataType.FLOAT,
WirePortDataType.FLOAT2,
WirePortDataType.FLOAT3,
WirePortDataType.FLOAT4,
WirePortDataType.COLOR,
WirePortDataType.INT );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: be2a11b08ee8cbb458dbcc4c1a61ad1b
timeCreated: 1481126959
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,67 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using System;
namespace AmplifyShaderEditor
{
[Serializable]
public class SingleInputOp : ParentNode
{
[SerializeField]
protected string m_opName;
//[SerializeField]
//protected int m_validTypes;
protected bool m_autoUpdateOutputPort = true;
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
AddInputPort( WirePortDataType.FLOAT, false, Constants.EmptyPortValue );
AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue );
//m_validTypes = 0;
m_useInternalPortData = true;
}
public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true )
{
base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode );
m_inputPorts[ 0 ].MatchPortToConnection();
if ( m_autoUpdateOutputPort )
m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false );
}
public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type )
{
base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type );
m_inputPorts[ 0 ].MatchPortToConnection();
if ( m_autoUpdateOutputPort )
m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false );
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
{
if ( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
string result = "0";
if ( m_inputPorts[ 0 ].IsConnected )
{
ParentNode node = m_inputPorts[ 0 ].GetOutputNode();
int localOutputId = m_inputPorts[ 0 ].ExternalReferences[ 0 ].PortId;
result = m_opName + "( " + node.GenerateShaderForOutput( localOutputId, ref dataCollector, ignoreLocalvar ) + " )";
}
else
{
result = m_opName + "( " + m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ) + " )";
}
return CreateOutputLocalVariable( 0, result, ref dataCollector );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ed03e964ff9aa274cbf392769b61170b
timeCreated: 1481126960
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Sinh", "Trigonometry Operators", "Hyperbolic sine of scalars and vectors" )]
public sealed class SinhOpNode : SingleInputOp
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
m_opName = "sinh";
m_previewShaderGUID = "4e9c00e6dceb4024f80d4e3d7786abad";
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT,
WirePortDataType.FLOAT,
WirePortDataType.FLOAT2,
WirePortDataType.FLOAT3,
WirePortDataType.FLOAT4,
WirePortDataType.COLOR,
WirePortDataType.INT );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 52092e3985c556943895f86c585bcd25
timeCreated: 1481126955
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,122 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Smoothstep", "Math Operators", "Returns a smooth Hermite interpolation between 0 and 1, if input is in the range [min, max]." )]
public sealed class SmoothstepOpNode : ParentNode
{
//[UnityEngine.SerializeField]
//private WirePortDataType m_mainDataType = WirePortDataType.FLOAT;
private int m_alphaPortId = 0;
private int m_minPortId = 0;
private int m_maxPortId = 0;
private const string SmoothstepOpFormat = "smoothstep( {0} , {1} , {2})";//min max alpha
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
AddInputPort( WirePortDataType.FLOAT, false, Constants.EmptyPortValue, -1, MasterNodePortCategory.Fragment, 0 );
m_alphaPortId = m_inputPorts.Count - 1;
AddInputPort( WirePortDataType.FLOAT, false, "Min", -1, MasterNodePortCategory.Fragment, 1 );
m_minPortId = m_inputPorts.Count - 1;
AddInputPort( WirePortDataType.FLOAT, false, "Max", -1, MasterNodePortCategory.Fragment, 2 );
m_maxPortId = m_inputPorts.Count - 1;
GetInputPortByUniqueId( m_maxPortId ).FloatInternalData = 1;
AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue );
m_useInternalPortData = true;
m_textLabelWidth = 55;
m_previewShaderGUID = "954cdd40a7a528344a0a4d3ff1db5176";
}
public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true )
{
base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode );
if( portId == 0 )
{
m_inputPorts[ 0 ].MatchPortToConnection();
m_inputPorts[ 1 ].ChangeType( m_inputPorts[ 0 ].DataType, false );
m_inputPorts[ 2 ].ChangeType( m_inputPorts[ 0 ].DataType, false );
m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false );
}
}
public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type )
{
base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type );
if( outputPortId == 0 )
{
m_inputPorts[ 0 ].MatchPortToConnection();
m_inputPorts[ 1 ].ChangeType( m_inputPorts[ 0 ].DataType, false );
m_inputPorts[ 2 ].ChangeType( m_inputPorts[ 0 ].DataType, false );
m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false );
}
}
//public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true )
//{
// base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode );
// UpdateConnection( portId );
//}
//public override void OnConnectedOutputNodeChanges( int inputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type )
//{
// base.OnConnectedOutputNodeChanges( inputPortId, otherNodeId, otherPortId, name, type );
// UpdateConnection( inputPortId );
//}
//public override void OnInputPortDisconnected( int portId )
//{
// base.OnInputPortDisconnected( portId );
// UpdateConnection( portId );
//}
//void UpdateConnection( int portId )
//{
// WirePortDataType type1 = WirePortDataType.FLOAT;
// if( m_inputPorts[ m_minPortId ].IsConnected )
// type1 = m_inputPorts[ m_minPortId ].GetOutputConnection( 0 ).DataType;
// WirePortDataType type2 = WirePortDataType.FLOAT;
// if( m_inputPorts[ m_maxPortId ].IsConnected )
// type2 = m_inputPorts[ m_maxPortId ].GetOutputConnection( 0 ).DataType;
// m_mainDataType = UIUtils.GetPriority( type1 ) > UIUtils.GetPriority( type2 ) ? type1 : type2;
// if( !m_inputPorts[ m_minPortId ].IsConnected && !m_inputPorts[ m_maxPortId ].IsConnected && m_inputPorts[ m_alphaPortId ].IsConnected )
// m_mainDataType = m_inputPorts[ m_alphaPortId ].GetOutputConnection( 0 ).DataType;
// m_inputPorts[ m_minPortId ].ChangeType( m_mainDataType, false );
// m_inputPorts[ m_maxPortId ].ChangeType( m_mainDataType, false );
// if( m_inputPorts[ m_alphaPortId ].IsConnected && m_inputPorts[ m_alphaPortId ].GetOutputConnection( 0 ).DataType == WirePortDataType.FLOAT )
// m_inputPorts[ m_alphaPortId ].ChangeType( WirePortDataType.FLOAT, false );
// else
// m_inputPorts[ m_alphaPortId ].ChangeType( m_mainDataType, false );
// m_outputPorts[ 0 ].ChangeType( m_mainDataType, false );
//}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
{
if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
string aValue = m_inputPorts[ m_minPortId ].GeneratePortInstructions( ref dataCollector );
string bValue = m_inputPorts[ m_maxPortId ].GeneratePortInstructions( ref dataCollector );
string interp = m_inputPorts[ m_alphaPortId ].GeneratePortInstructions( ref dataCollector );
string result = string.Format( SmoothstepOpFormat, aValue, bValue, interp );
RegisterLocalVariable( 0, result, ref dataCollector, "smoothstepResult" + OutputId );
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 0f64eb769f843a349a0d249beacc6fc3
timeCreated: 1481126953
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files have changed in this diff Show More