Init
This commit is contained in:
@ -0,0 +1,551 @@
|
||||
// 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( "Color", "Constants And Properties", "Color property", null, KeyCode.Alpha5 )]
|
||||
public sealed class ColorNode : PropertyNode
|
||||
{
|
||||
private const string ColorSpaceStr = "Color Space";
|
||||
|
||||
[SerializeField]
|
||||
[ColorUsage( true, true )]
|
||||
private Color m_defaultValue = new Color( 0, 0, 0, 0 );
|
||||
|
||||
[SerializeField]
|
||||
[ColorUsage( true, true )]
|
||||
private Color m_materialValue = new Color( 0, 0, 0, 0 );
|
||||
|
||||
[SerializeField]
|
||||
private bool m_isHDR = false;
|
||||
|
||||
//[SerializeField]
|
||||
//private ASEColorSpace m_colorSpace = ASEColorSpace.Auto;
|
||||
private GUIContent m_dummyContent;
|
||||
|
||||
private int m_cachedPropertyId = -1;
|
||||
|
||||
private bool m_isEditingFields;
|
||||
|
||||
[SerializeField]
|
||||
private bool m_autoGammaToLinearConversion = true;
|
||||
|
||||
[SerializeField]
|
||||
private bool m_useAlpha = true;
|
||||
|
||||
private const string AutoGammaToLinearConversion = "IsGammaSpace() ? {0} : {1}";
|
||||
private const string AutoGammaToLinearStr = "Auto Gamma To Linear";
|
||||
private const string ShowAlphaStr = "Use Alpha";
|
||||
|
||||
private Rect m_frameDrawPos0;
|
||||
private Rect m_frameDrawPos1;
|
||||
|
||||
public ColorNode() : base() { }
|
||||
public ColorNode( int uniqueId, float x, float y, float width, float height ) : base( uniqueId, x, y, width, height ) { }
|
||||
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
GlobalTypeWarningText = string.Format( GlobalTypeWarningText, "Color" );
|
||||
m_insideSize.Set( 100, 50 );
|
||||
m_dummyContent = new GUIContent();
|
||||
AddOutputColorPorts( m_useAlpha ? "RGBA" : "RGB", m_useAlpha, m_useAlpha );
|
||||
m_sortOutputPorts = true;
|
||||
m_drawPreview = false;
|
||||
m_drawPreviewExpander = false;
|
||||
m_canExpand = false;
|
||||
m_showHybridInstancedUI = true;
|
||||
m_selectedLocation = PreviewLocation.BottomCenter;
|
||||
m_previewShaderGUID = "6cf365ccc7ae776488ae8960d6d134c3";
|
||||
m_srpBatcherCompatible = true;
|
||||
}
|
||||
|
||||
void UpdateOutputPorts()
|
||||
{
|
||||
ChangeOutputProperties( 0, m_useAlpha ? "RGBA" : "RGB", m_useAlpha ? WirePortDataType.COLOR : WirePortDataType.FLOAT3, false );
|
||||
m_outputPorts[ 4 ].Visible = m_useAlpha;
|
||||
m_outputPorts[ 5 ].Visible = m_useAlpha;
|
||||
m_sizeIsDirty = true;
|
||||
m_propertyNameIsDirty = true;
|
||||
}
|
||||
|
||||
public override void SetPreviewInputs()
|
||||
{
|
||||
base.SetPreviewInputs();
|
||||
|
||||
if( m_cachedPropertyId == -1 )
|
||||
m_cachedPropertyId = Shader.PropertyToID( "_InputColor" );
|
||||
|
||||
if( m_materialMode && m_currentParameterType != PropertyType.Constant )
|
||||
PreviewMaterial.SetColor( m_cachedPropertyId, m_materialValue );
|
||||
else
|
||||
PreviewMaterial.SetColor( m_cachedPropertyId, m_defaultValue );
|
||||
}
|
||||
|
||||
public override void CopyDefaultsToMaterial()
|
||||
{
|
||||
m_materialValue = m_defaultValue;
|
||||
}
|
||||
|
||||
public override void DrawSubProperties()
|
||||
{
|
||||
m_textLabelWidth = ( m_currentParameterType == PropertyType.Constant ) ? 152 : 105;
|
||||
|
||||
m_defaultValue = EditorGUILayoutColorField( Constants.DefaultValueLabelContent, m_defaultValue, false, m_useAlpha, m_isHDR, GUILayout.Height( 20 ) );
|
||||
|
||||
if ( m_currentParameterType == PropertyType.Constant )
|
||||
{
|
||||
m_autoGammaToLinearConversion = EditorGUILayoutToggle( AutoGammaToLinearStr, m_autoGammaToLinearConversion );
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
bool wasUsingAlpha = m_useAlpha;
|
||||
m_useAlpha = EditorGUILayoutToggle( ShowAlphaStr, m_useAlpha );
|
||||
if ( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
if ( wasUsingAlpha && m_outputPorts[ 5 ].IsConnected )
|
||||
{
|
||||
WireReference connection = m_outputPorts[ 5 ].GetConnection();
|
||||
m_containerGraph.CreateConnection( connection.NodeId, connection.PortId, UniqueId, 0 );
|
||||
}
|
||||
else if ( !wasUsingAlpha && m_outputPorts[ 0 ].IsConnected )
|
||||
{
|
||||
WireReference connection = m_outputPorts[ 0 ].GetConnection();
|
||||
m_containerGraph.CreateConnection( connection.NodeId, connection.PortId, UniqueId, 5 );
|
||||
m_containerGraph.DeleteConnection( false, UniqueId, 0, true, false );
|
||||
}
|
||||
|
||||
UpdateOutputPorts();
|
||||
}
|
||||
}
|
||||
|
||||
//public override void DrawMainPropertyBlock()
|
||||
//{
|
||||
// EditorGUILayout.BeginVertical();
|
||||
// {
|
||||
|
||||
// PropertyType parameterType = (PropertyType)EditorGUILayoutEnumPopup( ParameterTypeStr, m_currentParameterType );
|
||||
// if( parameterType != m_currentParameterType )
|
||||
// {
|
||||
// ChangeParameterType( parameterType );
|
||||
// BeginPropertyFromInspectorCheck();
|
||||
// }
|
||||
|
||||
// switch( m_currentParameterType )
|
||||
// {
|
||||
// case PropertyType.Property:
|
||||
// case PropertyType.InstancedProperty:
|
||||
// {
|
||||
// ShowPropertyInspectorNameGUI();
|
||||
// ShowPropertyNameGUI( true );
|
||||
// ShowVariableMode();
|
||||
// ShowPrecision();
|
||||
// ShowToolbar();
|
||||
// }
|
||||
// break;
|
||||
// case PropertyType.Global:
|
||||
// {
|
||||
// ShowPropertyInspectorNameGUI();
|
||||
// ShowPropertyNameGUI( false );
|
||||
// ShowVariableMode();
|
||||
// ShowPrecision();
|
||||
// ShowDefaults();
|
||||
// }
|
||||
// break;
|
||||
// case PropertyType.Constant:
|
||||
// {
|
||||
// ShowPropertyInspectorNameGUI();
|
||||
// ShowPrecision();
|
||||
// m_colorSpace = (ASEColorSpace)EditorGUILayoutEnumPopup( ColorSpaceStr, m_colorSpace );
|
||||
// ShowDefaults();
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// EditorGUILayout.EndVertical();
|
||||
//}
|
||||
|
||||
public override void DrawMaterialProperties()
|
||||
{
|
||||
if( m_materialMode )
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_materialValue = EditorGUILayoutColorField( Constants.MaterialValueLabelContent, m_materialValue, false, m_useAlpha, m_isHDR );
|
||||
if( m_materialMode && EditorGUI.EndChangeCheck() )
|
||||
m_requireMaterialUpdate = true;
|
||||
}
|
||||
|
||||
public override void OnNodeLayout( DrawInfo drawInfo )
|
||||
{
|
||||
base.OnNodeLayout( drawInfo );
|
||||
|
||||
int maxWidth = 80;
|
||||
|
||||
m_propertyDrawPos = m_globalPosition;
|
||||
m_propertyDrawPos.x = m_remainingBox.x;
|
||||
m_propertyDrawPos.y = m_remainingBox.y;
|
||||
m_propertyDrawPos.width = maxWidth * drawInfo.InvertedZoom;
|
||||
m_propertyDrawPos.height = Mathf.Min( m_remainingBox.height, ( ( maxWidth + ( m_useAlpha ? 20 : 0 ) ) * drawInfo.InvertedZoom ) );
|
||||
|
||||
m_frameDrawPos0 = new Rect( m_propertyDrawPos.x, m_propertyDrawPos.y - 1, m_propertyDrawPos.width + 1, m_propertyDrawPos.height + 1 );
|
||||
m_frameDrawPos1 = new Rect( m_propertyDrawPos.x, m_propertyDrawPos.y + m_propertyDrawPos.height - 1, m_propertyDrawPos.width, 1 );
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
m_isEditingFields = true;
|
||||
}
|
||||
else if( m_isEditingFields && !insideBox )
|
||||
{
|
||||
GUI.FocusControl( null );
|
||||
m_isEditingFields = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Draw( DrawInfo drawInfo )
|
||||
{
|
||||
base.Draw( drawInfo );
|
||||
|
||||
if( !m_isVisible )
|
||||
return;
|
||||
|
||||
if ( m_isEditingFields && m_currentParameterType != PropertyType.Global )
|
||||
{
|
||||
if( m_materialMode && m_currentParameterType != PropertyType.Constant )
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_materialValue = EditorGUIColorField( m_propertyDrawPos, m_dummyContent, m_materialValue, false, m_useAlpha, m_isHDR );
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
PreviewIsDirty = true;
|
||||
m_requireMaterialUpdate = true;
|
||||
if( m_currentParameterType != PropertyType.Constant )
|
||||
{
|
||||
BeginDelayedDirtyProperty();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_defaultValue = EditorGUIColorField( m_propertyDrawPos, m_dummyContent, m_defaultValue, false, m_useAlpha, m_isHDR );
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
PreviewIsDirty = true;
|
||||
BeginDelayedDirtyProperty();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( drawInfo.CurrentEventType == EventType.Repaint )
|
||||
{
|
||||
var value = ( m_materialMode && m_currentParameterType != PropertyType.Constant ) ? m_materialValue : m_defaultValue;
|
||||
UIUtils.DrawColorSwatch( m_propertyDrawPos, value, m_useAlpha, m_isHDR );
|
||||
}
|
||||
|
||||
GUI.Label( m_frameDrawPos0, string.Empty, UIUtils.GetCustomStyle( CustomStyle.SamplerFrame ) );
|
||||
// @diogo: to prevent gaps in frame; thanks, Unity!...
|
||||
EditorGUI.DrawRect( m_frameDrawPos1, Color.black );
|
||||
}
|
||||
|
||||
public override void ConfigureLocalVariable( ref MasterNodeDataCollector dataCollector )
|
||||
{
|
||||
Color color = m_defaultValue;
|
||||
//switch( m_colorSpace )
|
||||
//{
|
||||
// default:
|
||||
// case ASEColorSpace.Auto: color = m_defaultValue; break;
|
||||
// case ASEColorSpace.Gamma: color = m_defaultValue.gamma; break;
|
||||
// case ASEColorSpace.Linear: color = m_defaultValue.linear; break;
|
||||
//}
|
||||
|
||||
dataCollector.AddLocalVariable( UniqueId, CreateLocalVarDec( color.r + "," + color.g + "," + color.b + ( m_useAlpha ? "," + color.a : string.Empty ) ) );
|
||||
|
||||
m_outputPorts[ 0 ].SetLocalValue( m_propertyName , dataCollector.PortCategory);
|
||||
m_outputPorts[ 1 ].SetLocalValue( m_propertyName + ".r", dataCollector.PortCategory );
|
||||
m_outputPorts[ 2 ].SetLocalValue( m_propertyName + ".g", dataCollector.PortCategory );
|
||||
m_outputPorts[ 3 ].SetLocalValue( m_propertyName + ".b", dataCollector.PortCategory );
|
||||
if ( m_useAlpha )
|
||||
{
|
||||
m_outputPorts[ 4 ].SetLocalValue( m_propertyName + ".a", dataCollector.PortCategory );
|
||||
}
|
||||
}
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
|
||||
m_precisionString = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_outputPorts[ 0 ].DataType );
|
||||
|
||||
if( m_currentParameterType != PropertyType.Constant )
|
||||
return GetOutputVectorItem( 0, outputId, PropertyData( dataCollector.PortCategory ) );
|
||||
|
||||
// Constant Only Code
|
||||
|
||||
if( m_outputPorts[ outputId ].IsLocalValue(dataCollector.PortCategory) )
|
||||
{
|
||||
return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory );
|
||||
}
|
||||
if( m_autoGammaToLinearConversion )
|
||||
{
|
||||
if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
|
||||
return GetOutputColorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue(dataCollector.PortCategory) );
|
||||
|
||||
Color linear = m_defaultValue.linear;
|
||||
|
||||
string colorGamma = m_precisionString + "(" + m_defaultValue.r + "," + m_defaultValue.g + "," + m_defaultValue.b +
|
||||
( m_useAlpha ? "," + m_defaultValue.a : string.Empty ) + ")";
|
||||
|
||||
string colorLinear = m_precisionString + "(" + linear.r + "," + linear.g + "," + linear.b +
|
||||
( m_useAlpha ? "," + m_defaultValue.a : string.Empty ) + ")";
|
||||
|
||||
string result = string.Format( AutoGammaToLinearConversion, colorGamma, colorLinear );
|
||||
RegisterLocalVariable( 0, result, ref dataCollector, "color" + OutputId );
|
||||
return GetOutputColorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( CheckLocalVariable( ref dataCollector ) )
|
||||
{
|
||||
return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory );
|
||||
}
|
||||
|
||||
Color color = m_defaultValue;
|
||||
//switch( m_colorSpace )
|
||||
//{
|
||||
// default:
|
||||
// case ASEColorSpace.Auto: color = m_defaultValue; break;
|
||||
// case ASEColorSpace.Gamma: color = m_defaultValue.gamma; break;
|
||||
// case ASEColorSpace.Linear: color = m_defaultValue.linear; break;
|
||||
//}
|
||||
string result = string.Empty;
|
||||
|
||||
switch( outputId )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
result = m_precisionString + "(" + color.r + "," + color.g + "," + color.b + ( m_useAlpha ? "," + color.a : string.Empty ) + ")";
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
{
|
||||
result = color.r.ToString();
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
result = color.g.ToString();
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
result = color.b.ToString();
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
result = color.a.ToString();
|
||||
}
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnAtrributesChanged()
|
||||
{
|
||||
CheckIfHDR();
|
||||
CheckHeaderAttribute();
|
||||
}
|
||||
|
||||
public override void RefreshExternalReferences()
|
||||
{
|
||||
base.RefreshExternalReferences();
|
||||
CheckIfHDR();
|
||||
}
|
||||
|
||||
void CheckIfHDR()
|
||||
{
|
||||
int count = m_selectedAttribs.Count;
|
||||
bool hdrBuffer = m_isHDR;
|
||||
m_isHDR = false;
|
||||
for( int i = 0; i < count; i++ )
|
||||
{
|
||||
if( m_selectedAttribs[ i ] == 1 /*HDR Property ID*/)
|
||||
{
|
||||
m_isHDR = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( hdrBuffer && !m_isHDR )
|
||||
{
|
||||
bool fireDirtyProperty = false;
|
||||
|
||||
if( m_defaultValue.r > 1 || m_defaultValue.g > 1 || m_defaultValue.b > 1 )
|
||||
{
|
||||
float defaultColorLength = Mathf.Sqrt( m_defaultValue.r * m_defaultValue.r + m_defaultValue.g * m_defaultValue.g + m_defaultValue.b * m_defaultValue.b );
|
||||
m_defaultValue.r /= defaultColorLength;
|
||||
m_defaultValue.g /= defaultColorLength;
|
||||
m_defaultValue.b /= defaultColorLength;
|
||||
fireDirtyProperty = true;
|
||||
}
|
||||
|
||||
if( m_materialValue.r > 1 || m_materialValue.g > 1 || m_materialValue.b > 1 )
|
||||
{
|
||||
float materialColorLength = Mathf.Sqrt( m_materialValue.r * m_materialValue.r + m_materialValue.g * m_materialValue.g + m_materialValue.b * m_materialValue.b );
|
||||
m_materialValue.r /= materialColorLength;
|
||||
m_materialValue.g /= materialColorLength;
|
||||
m_materialValue.b /= materialColorLength;
|
||||
fireDirtyProperty = true;
|
||||
}
|
||||
|
||||
if( fireDirtyProperty )
|
||||
BeginDelayedDirtyProperty();
|
||||
}
|
||||
}
|
||||
|
||||
public override string GetPropertyValue()
|
||||
{
|
||||
string r = UIUtils.PropertyFloatToString( m_defaultValue.r );
|
||||
string g = UIUtils.PropertyFloatToString( m_defaultValue.g );
|
||||
string b = UIUtils.PropertyFloatToString( m_defaultValue.b );
|
||||
string a = UIUtils.PropertyFloatToString( m_defaultValue.a );
|
||||
return PropertyAttributes + m_propertyName + "(\"" + m_propertyInspectorName + "\", Color) = (" + r + "," + g + "," + b +
|
||||
( m_useAlpha ? "," + a : string.Empty ) + ")";
|
||||
}
|
||||
|
||||
public override void UpdateMaterial( Material mat )
|
||||
{
|
||||
base.UpdateMaterial( mat );
|
||||
|
||||
if( UIUtils.IsProperty( m_currentParameterType ) && !InsideShaderFunction )
|
||||
{
|
||||
mat.SetColor( m_propertyName, m_materialValue );
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetMaterialMode( Material mat, bool fetchMaterialValues )
|
||||
{
|
||||
base.SetMaterialMode( mat, fetchMaterialValues );
|
||||
if( m_materialMode && fetchMaterialValues )
|
||||
{
|
||||
if( UIUtils.IsProperty( m_currentParameterType ) && mat.HasProperty( m_propertyName ) )
|
||||
MaterialValue = mat.GetColor( m_propertyName );
|
||||
}
|
||||
}
|
||||
|
||||
public override void ForceUpdateFromMaterial( Material material )
|
||||
{
|
||||
if( UIUtils.IsProperty( m_currentParameterType ) && material.HasProperty( m_propertyName ) )
|
||||
{
|
||||
MaterialValue = material.GetColor( m_propertyName );
|
||||
PreviewIsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void ReadFromString( ref string[] nodeParams )
|
||||
{
|
||||
base.ReadFromString( ref nodeParams );
|
||||
m_defaultValue = IOUtils.StringToColor( GetCurrentParam( ref nodeParams ) );
|
||||
if( UIUtils.CurrentShaderVersion() > 14101 )
|
||||
{
|
||||
m_materialValue = IOUtils.StringToColor( GetCurrentParam( ref nodeParams ) );
|
||||
}
|
||||
|
||||
if( UIUtils.CurrentShaderVersion() > 15900 )
|
||||
{
|
||||
m_autoGammaToLinearConversion = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_autoGammaToLinearConversion = false;
|
||||
}
|
||||
|
||||
if ( UIUtils.CurrentShaderVersion() >= 19500 )
|
||||
{
|
||||
m_useAlpha = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_useAlpha = true;
|
||||
}
|
||||
UpdateOutputPorts();
|
||||
|
||||
//if( UIUtils.CurrentShaderVersion() > 14202 )
|
||||
//{
|
||||
// m_colorSpace = (ASEColorSpace)Enum.Parse( typeof( ASEColorSpace ), GetCurrentParam( ref nodeParams ) );
|
||||
//}
|
||||
}
|
||||
|
||||
public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
|
||||
{
|
||||
base.WriteToString( ref nodeInfo, ref connectionsInfo );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, IOUtils.ColorToString( m_defaultValue ) );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, IOUtils.ColorToString( m_materialValue ) );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, m_autoGammaToLinearConversion );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, m_useAlpha );
|
||||
//IOUtils.AddFieldValueToString( ref nodeInfo, m_colorSpace );
|
||||
}
|
||||
|
||||
public override void SetGlobalValue() { Shader.SetGlobalColor( m_propertyName, m_defaultValue ); }
|
||||
public override void FetchGlobalValue() { m_materialValue = Shader.GetGlobalColor( m_propertyName ); }
|
||||
|
||||
public override string GetPropertyValStr()
|
||||
{
|
||||
if ( m_materialMode && m_currentParameterType != PropertyType.Constant )
|
||||
{
|
||||
return m_materialValue.r.ToString( Constants.PropertyVectorFormatLabel ) + IOUtils.VECTOR_SEPARATOR +
|
||||
m_materialValue.g.ToString( Constants.PropertyVectorFormatLabel ) + IOUtils.VECTOR_SEPARATOR +
|
||||
m_materialValue.b.ToString( Constants.PropertyVectorFormatLabel ) +
|
||||
( m_useAlpha ? IOUtils.VECTOR_SEPARATOR + m_materialValue.a.ToString( Constants.PropertyVectorFormatLabel ) : string.Empty );
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_defaultValue.r.ToString( Constants.PropertyVectorFormatLabel ) + IOUtils.VECTOR_SEPARATOR +
|
||||
m_defaultValue.g.ToString( Constants.PropertyVectorFormatLabel ) + IOUtils.VECTOR_SEPARATOR +
|
||||
m_defaultValue.b.ToString( Constants.PropertyVectorFormatLabel ) +
|
||||
( m_useAlpha ? IOUtils.VECTOR_SEPARATOR + m_defaultValue.a.ToString( Constants.PropertyVectorFormatLabel ) : string.Empty );
|
||||
}
|
||||
}
|
||||
|
||||
private Color MaterialValue
|
||||
{
|
||||
set
|
||||
{
|
||||
if( !m_isHDR && ( value.r > 1 || value.g > 1 || value.r > 1 ) )
|
||||
{
|
||||
float materialColorLength = Mathf.Sqrt( value.r * value.r + value.g * value.g + value.b * value.b );
|
||||
m_materialValue.r = value.r / materialColorLength;
|
||||
m_materialValue.g = value.g / materialColorLength;
|
||||
m_materialValue.b = value.b / materialColorLength;
|
||||
m_materialValue.a = value.a;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_materialValue = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Color Value
|
||||
{
|
||||
get { return m_defaultValue; }
|
||||
set { m_defaultValue = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ColorNode.cs.meta
generated
Normal file
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ColorNode.cs.meta
generated
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b99bcf4cd965c648bbbc1de0d1b152a
|
||||
timeCreated: 1481126955
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,489 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
//
|
||||
// Custom Node Global Array
|
||||
// Donated by Johann van Berkel
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[Serializable]
|
||||
[NodeAttributes( "Global Array" , "Constants And Properties" , "The node returns a value from a global array, which you can configure by entering the name of the array in the node's settings." , null , KeyCode.None , true , false , null , null , "Johann van Berkel" )]
|
||||
public sealed class GlobalArrayNode : ParentNode
|
||||
{
|
||||
private const string DefaultArrayName = "MyGlobalArray";
|
||||
private const string TypeStr = "Type";
|
||||
private const string AutoRangeCheckStr = "Range Check";
|
||||
private const string ArrayFormatStr = "{0}[{1}]";
|
||||
private const string JaggedArrayFormatStr = "{0}[{1}][{2}]";
|
||||
private const string IsJaggedStr = "Is Jagged";
|
||||
private const string AutoRegisterStr = "Auto-Register";
|
||||
|
||||
private readonly string[] AvailableTypesLabel = { "Float" , "Color" , "Vector4" , "Matrix4x4" };
|
||||
private readonly WirePortDataType[] AvailableTypesValues = { WirePortDataType.FLOAT , WirePortDataType.COLOR , WirePortDataType.FLOAT4 , WirePortDataType.FLOAT4x4 };
|
||||
|
||||
[SerializeField]
|
||||
private string m_name = DefaultArrayName;
|
||||
|
||||
[SerializeField]
|
||||
private int m_indexX = 0;
|
||||
|
||||
[SerializeField]
|
||||
private int m_indexY = 0;
|
||||
|
||||
[SerializeField]
|
||||
private int m_arrayLengthX = 1;
|
||||
|
||||
[SerializeField]
|
||||
private int m_arrayLengthY = 1;
|
||||
|
||||
[SerializeField]
|
||||
private int m_type = 0;
|
||||
|
||||
[SerializeField]
|
||||
private bool m_autoRangeCheck = false;
|
||||
|
||||
[SerializeField]
|
||||
private bool m_isJagged = false;
|
||||
|
||||
[SerializeField]
|
||||
private bool m_autoRegister = false;
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
private readonly Color ReferenceHeaderColor = new Color( 0.6f , 3.0f , 1.25f , 1.0f );
|
||||
|
||||
[SerializeField]
|
||||
private TexReferenceType m_referenceType = TexReferenceType.Object;
|
||||
|
||||
[SerializeField]
|
||||
private int m_referenceArrayId = -1;
|
||||
|
||||
[SerializeField]
|
||||
private int m_referenceNodeId = -1;
|
||||
|
||||
private GlobalArrayNode m_referenceNode = null;
|
||||
|
||||
private bool m_updated = false;
|
||||
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
|
||||
AddInputPort( WirePortDataType.INT , false , "Index" , -1 , MasterNodePortCategory.Fragment , 0 );
|
||||
AddInputPort( WirePortDataType.INT , false , "Index Y" , -1 , MasterNodePortCategory.Fragment , 2 );
|
||||
AddInputPort( WirePortDataType.INT , false , "Array Length" , -1 , MasterNodePortCategory.Fragment , 1 );
|
||||
AddInputPort( WirePortDataType.INT , false , "Array Length Y" , -1 , MasterNodePortCategory.Fragment , 3 );
|
||||
|
||||
AddOutputPort( WirePortDataType.FLOAT , "Out" );
|
||||
|
||||
m_textLabelWidth = 95;
|
||||
m_autoWrapProperties = true;
|
||||
SetAdditonalTitleText( string.Format( Constants.SubTitleValueFormatStr , m_name ) );
|
||||
UpdatePorts();
|
||||
}
|
||||
|
||||
protected override void OnUniqueIDAssigned()
|
||||
{
|
||||
base.OnUniqueIDAssigned();
|
||||
UIUtils.CurrentWindow.OutsideGraph.GlobalArrayNodes.AddNode( this );
|
||||
}
|
||||
|
||||
public override void Destroy()
|
||||
{
|
||||
base.Destroy();
|
||||
UIUtils.CurrentWindow.OutsideGraph.GlobalArrayNodes.RemoveNode( this );
|
||||
}
|
||||
|
||||
void UpdatePorts()
|
||||
{
|
||||
InputPort indexXPort = GetInputPortByUniqueId( 0 );
|
||||
InputPort arrayLengthPortX = GetInputPortByUniqueId( 1 );
|
||||
InputPort indexYPort = GetInputPortByUniqueId( 2 );
|
||||
InputPort arrayLengthPortY = GetInputPortByUniqueId( 3 );
|
||||
if( m_referenceType == TexReferenceType.Object )
|
||||
{
|
||||
m_headerColorModifier = Color.white;
|
||||
SetAdditonalTitleText( string.Format( Constants.SubTitleValueFormatStr , m_name ) );
|
||||
arrayLengthPortX.Visible = true;
|
||||
if( m_isJagged )
|
||||
{
|
||||
indexXPort.Name = "Index X";
|
||||
arrayLengthPortX.Name = "Array Length X";
|
||||
indexYPort.Visible = true;
|
||||
arrayLengthPortY.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
indexXPort.Name = "Index";
|
||||
arrayLengthPortX.Name = "Array Length";
|
||||
indexYPort.Visible = false;
|
||||
arrayLengthPortY.Visible = false;
|
||||
}
|
||||
}
|
||||
else if( m_referenceNodeId > -1 )
|
||||
{
|
||||
m_headerColorModifier = ReferenceHeaderColor;
|
||||
if( m_referenceNode == null )
|
||||
m_referenceNode = UIUtils.GetNode( m_referenceNodeId ) as GlobalArrayNode;
|
||||
|
||||
if( m_referenceNode != null )
|
||||
{
|
||||
SetAdditonalTitleText( string.Format( Constants.SubTitleValueFormatStr , m_referenceNode.DataToArray ) );
|
||||
arrayLengthPortX.Visible = false;
|
||||
arrayLengthPortY.Visible = false;
|
||||
if( m_referenceNode.IsJagged )
|
||||
{
|
||||
indexXPort.Name = "Index X";
|
||||
indexYPort.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
indexXPort.Name = "Index";
|
||||
indexYPort.Visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_sizeIsDirty = true;
|
||||
}
|
||||
|
||||
void DrawObjectProperties()
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_name = EditorGUILayoutStringField( "Name" , m_name );
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
m_updated = true;
|
||||
m_name = UIUtils.RemoveInvalidCharacters( m_name );
|
||||
if( string.IsNullOrEmpty( m_name ) )
|
||||
m_name = DefaultArrayName;
|
||||
UIUtils.UpdateGlobalArrayDataNode( UniqueId , m_name );
|
||||
SetAdditonalTitleText( string.Format( Constants.SubTitleValueFormatStr , m_name ) );
|
||||
}
|
||||
|
||||
|
||||
m_autoRegister = EditorGUILayoutToggle( AutoRegisterStr , m_autoRegister );
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_isJagged = EditorGUILayoutToggle( IsJaggedStr , m_isJagged );
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
m_updated = true;
|
||||
UpdatePorts();
|
||||
}
|
||||
|
||||
InputPort indexXPort = GetInputPortByUniqueId( 0 );
|
||||
if( !indexXPort.IsConnected )
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_indexX = EditorGUILayoutIntField( indexXPort.Name , m_indexX );
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
m_indexX = Mathf.Clamp( m_indexX , 0 , ( ArrayLengthX - 1 ) );
|
||||
}
|
||||
}
|
||||
|
||||
if( m_isJagged )
|
||||
{
|
||||
InputPort indexYPort = GetInputPortByUniqueId( 2 );
|
||||
if( !indexYPort.IsConnected )
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_indexY = EditorGUILayoutIntField( indexYPort.Name , m_indexY );
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
m_indexY = Mathf.Clamp( m_indexY , 0 , ( ArrayLengthY - 1 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
InputPort arrayLengthXPort = GetInputPortByUniqueId( 1 );
|
||||
if( !arrayLengthXPort.IsConnected )
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_arrayLengthX = EditorGUILayoutIntField( arrayLengthXPort.Name , m_arrayLengthX );
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
m_arrayLengthX = Mathf.Max( 1 , m_arrayLengthX );
|
||||
}
|
||||
}
|
||||
|
||||
if( m_isJagged )
|
||||
{
|
||||
InputPort arrayLengthYPort = GetInputPortByUniqueId( 3 );
|
||||
if( !arrayLengthYPort.IsConnected )
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_arrayLengthY = EditorGUILayoutIntField( arrayLengthYPort.Name , m_arrayLengthY );
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
m_arrayLengthY = Mathf.Max( 1 , m_arrayLengthY );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_type = EditorGUILayoutPopup( TypeStr , m_type , AvailableTypesLabel );
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
m_outputPorts[ 0 ].ChangeType( (WirePortDataType)AvailableTypesValues[ m_type ] , false );
|
||||
}
|
||||
|
||||
m_autoRangeCheck = EditorGUILayoutToggle( AutoRangeCheckStr , m_autoRangeCheck );
|
||||
}
|
||||
|
||||
public override void OnNodeLayout( DrawInfo drawInfo )
|
||||
{
|
||||
base.OnNodeLayout( drawInfo );
|
||||
m_updated = false;
|
||||
if( m_referenceType == TexReferenceType.Instance )
|
||||
{
|
||||
if( m_referenceNodeId > -1 && m_referenceNode == null )
|
||||
{
|
||||
m_referenceNode = UIUtils.GetNode( m_referenceNodeId ) as GlobalArrayNode;
|
||||
if( m_referenceNode == null )
|
||||
{
|
||||
m_referenceNodeId = -1;
|
||||
}
|
||||
}
|
||||
if( m_referenceNode != null && m_referenceNode.Updated )
|
||||
{
|
||||
UpdatePorts();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawInstancedProperties()
|
||||
{
|
||||
string[] arr = UIUtils.GlobalArrayNodeArr();
|
||||
bool guiEnabledBuffer = GUI.enabled;
|
||||
if( arr != null && arr.Length > 0 )
|
||||
{
|
||||
GUI.enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_referenceArrayId = -1;
|
||||
m_referenceNodeId = -1;
|
||||
m_referenceNode = null;
|
||||
GUI.enabled = false;
|
||||
}
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_referenceArrayId = EditorGUILayoutPopup( Constants.AvailableReferenceStr , m_referenceArrayId , arr );
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
m_referenceNode = UIUtils.GetGlobalArrayNode( m_referenceArrayId );
|
||||
if( m_referenceNode != null )
|
||||
{
|
||||
m_referenceNodeId = m_referenceNode.UniqueId;
|
||||
}
|
||||
UpdatePorts();
|
||||
}
|
||||
|
||||
GUI.enabled = guiEnabledBuffer;
|
||||
|
||||
InputPort indexXPort = GetInputPortByUniqueId( 0 );
|
||||
if( !indexXPort.IsConnected )
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_indexX = EditorGUILayoutIntField( indexXPort.Name , m_indexX );
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
m_indexX = Mathf.Clamp( m_indexX , 0 , ( ArrayLengthX - 1 ) );
|
||||
}
|
||||
}
|
||||
|
||||
if( m_isJagged )
|
||||
{
|
||||
InputPort indexYPort = GetInputPortByUniqueId( 2 );
|
||||
if( !indexYPort.IsConnected )
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_indexY = EditorGUILayoutIntField( indexYPort.Name , m_indexY );
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
m_indexY = Mathf.Clamp( m_indexY , 0 , ( ArrayLengthY - 1 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawProperties()
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_referenceType = (TexReferenceType)EditorGUILayoutPopup( Constants.ReferenceTypeStr , (int)m_referenceType , Constants.ReferenceArrayLabels );
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
UpdatePorts();
|
||||
}
|
||||
|
||||
if( m_referenceType == TexReferenceType.Object )
|
||||
DrawObjectProperties();
|
||||
else
|
||||
DrawInstancedProperties();
|
||||
}
|
||||
|
||||
public string GetArrayValue( string indexX , string indexY = null )
|
||||
{
|
||||
if( m_isJagged )
|
||||
return string.Format( JaggedArrayFormatStr , m_name , indexX , indexY );
|
||||
|
||||
return string.Format( ArrayFormatStr , m_name , indexX );
|
||||
}
|
||||
|
||||
public string GenerateInstancedShaderForOutput( int outputId , ref MasterNodeDataCollector dataCollector , bool ignoreLocalvar )
|
||||
{
|
||||
string result = string.Empty;
|
||||
if( m_referenceNode != null )
|
||||
{
|
||||
InputPort indexXPort = GetInputPortByUniqueId( 0 );
|
||||
if( m_referenceNode.IsJagged )
|
||||
{
|
||||
InputPort indexYPort = GetInputPortByUniqueId( 2 );
|
||||
string arrayIndexX = indexXPort.IsConnected ? indexXPort.GeneratePortInstructions( ref dataCollector ) : m_indexX.ToString();
|
||||
string arrayIndexY = indexYPort.IsConnected ? indexYPort.GeneratePortInstructions( ref dataCollector ) : m_indexY.ToString();
|
||||
result = m_referenceNode.GetArrayValue( arrayIndexX , arrayIndexY );
|
||||
}
|
||||
else
|
||||
{
|
||||
string arrayIndexX = indexXPort.IsConnected ? indexXPort.GeneratePortInstructions( ref dataCollector ) : m_indexX.ToString();
|
||||
result = m_referenceNode.GetArrayValue( arrayIndexX );
|
||||
}
|
||||
}
|
||||
m_outputPorts[ 0 ].SetLocalValue( result , dataCollector.PortCategory );
|
||||
return result;
|
||||
}
|
||||
|
||||
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 );
|
||||
|
||||
if( m_referenceType == TexReferenceType.Instance )
|
||||
return GenerateInstancedShaderForOutput( outputId , ref dataCollector , ignoreLocalvar );
|
||||
|
||||
string dataType = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType , AvailableTypesValues[ m_type ] );
|
||||
|
||||
InputPort indexXPort = GetInputPortByUniqueId( 0 );
|
||||
InputPort arrayLengthXPort = GetInputPortByUniqueId( 1 );
|
||||
string result = string.Empty;
|
||||
|
||||
if( m_isJagged )
|
||||
{
|
||||
InputPort indexYPort = GetInputPortByUniqueId( 2 );
|
||||
InputPort arrayLengthYPort = GetInputPortByUniqueId( 3 );
|
||||
|
||||
string arrayIndexX = indexXPort.IsConnected ? indexXPort.GeneratePortInstructions( ref dataCollector ) : m_indexX.ToString();
|
||||
string arrayLengthX = arrayLengthXPort.IsConnected ? arrayLengthXPort.GeneratePortInstructions( ref dataCollector ) : ArrayLengthX.ToString();
|
||||
|
||||
string arrayIndexY = indexYPort.IsConnected ? indexYPort.GeneratePortInstructions( ref dataCollector ) : m_indexY.ToString();
|
||||
string arrayLengthY = arrayLengthYPort.IsConnected ? arrayLengthYPort.GeneratePortInstructions( ref dataCollector ) : ArrayLengthY.ToString();
|
||||
|
||||
dataCollector.AddToUniforms( UniqueId , dataType , string.Format( JaggedArrayFormatStr , m_name , arrayLengthX , arrayLengthY ) );
|
||||
if( m_autoRangeCheck )
|
||||
{
|
||||
arrayIndexX = string.Format( "clamp({0},0,({1} - 1))" , arrayIndexX , arrayLengthX );
|
||||
arrayIndexY = string.Format( "clamp({0},0,({1} - 1))" , arrayIndexY , arrayLengthY );
|
||||
}
|
||||
result = string.Format( JaggedArrayFormatStr , m_name , arrayIndexX , arrayIndexY );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
string arrayIndex = indexXPort.IsConnected ? indexXPort.GeneratePortInstructions( ref dataCollector ) : m_indexX.ToString();
|
||||
string arrayLength = arrayLengthXPort.IsConnected ? arrayLengthXPort.GeneratePortInstructions( ref dataCollector ) : ArrayLengthX.ToString();
|
||||
|
||||
|
||||
dataCollector.AddToUniforms( UniqueId , dataType , string.Format( ArrayFormatStr , m_name , arrayLength ) );
|
||||
|
||||
if( m_autoRangeCheck )
|
||||
arrayIndex = string.Format( "clamp({0},0,({1} - 1))" , arrayIndex , arrayLength );
|
||||
|
||||
result = string.Format( ArrayFormatStr , m_name , arrayIndex );
|
||||
}
|
||||
|
||||
m_outputPorts[ 0 ].SetLocalValue( result , dataCollector.PortCategory );
|
||||
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
|
||||
}
|
||||
|
||||
public void CheckIfAutoRegister( ref MasterNodeDataCollector dataCollector )
|
||||
{
|
||||
if( m_referenceType == TexReferenceType.Object && m_autoRegister && m_connStatus != NodeConnectionStatus.Connected )
|
||||
{
|
||||
string dataType = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType , AvailableTypesValues[ m_type ] );
|
||||
if( m_isJagged )
|
||||
{
|
||||
dataCollector.AddToUniforms( UniqueId , dataType , string.Format( JaggedArrayFormatStr , m_name , ArrayLengthX , ArrayLengthY ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
dataCollector.AddToUniforms( UniqueId , dataType , string.Format( ArrayFormatStr , m_name , ArrayLengthX ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void WriteToString( ref string nodeInfo , ref string connectionsInfo )
|
||||
{
|
||||
base.WriteToString( ref nodeInfo , ref connectionsInfo );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo , m_name );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo , m_indexX );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo , m_arrayLengthX );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo , m_type );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo , m_autoRangeCheck );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo , m_isJagged );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo , m_indexY );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo , m_arrayLengthY );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo , m_autoRegister );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo , m_referenceType );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo , m_referenceNodeId );
|
||||
}
|
||||
|
||||
public override void ReadFromString( ref string[] nodeParams )
|
||||
{
|
||||
base.ReadFromString( ref nodeParams );
|
||||
m_name = GetCurrentParam( ref nodeParams );
|
||||
m_indexX = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
|
||||
m_arrayLengthX = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
|
||||
m_type = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
|
||||
m_autoRangeCheck = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
|
||||
if( UIUtils.CurrentShaderVersion() > 15801 )
|
||||
{
|
||||
m_isJagged = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
|
||||
m_indexY = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
|
||||
m_arrayLengthY = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
|
||||
m_autoRegister = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
|
||||
m_referenceType = (TexReferenceType)Enum.Parse( typeof( TexReferenceType ) , GetCurrentParam( ref nodeParams ) );
|
||||
m_referenceNodeId = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
|
||||
}
|
||||
SetAdditonalTitleText( string.Format( Constants.SubTitleValueFormatStr , m_name ) );
|
||||
UpdatePorts();
|
||||
}
|
||||
|
||||
public override void RefreshExternalReferences()
|
||||
{
|
||||
base.RefreshExternalReferences();
|
||||
if( m_referenceType == TexReferenceType.Instance && m_referenceNodeId > -1 )
|
||||
{
|
||||
m_referenceNode = UIUtils.GetNode( m_referenceNodeId ) as GlobalArrayNode;
|
||||
if( m_referenceNode != null )
|
||||
{
|
||||
m_referenceArrayId = UIUtils.GetGlobalArrayNodeRegisterId( m_referenceNodeId );
|
||||
UpdatePorts();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_referenceNodeId = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
public int ArrayLengthX { get { return ( m_referenceNode != null ) ? m_referenceNode.ArrayLengthX : m_arrayLengthX; } }
|
||||
public int ArrayLengthY { get { return ( m_referenceNode != null ) ? m_referenceNode.ArrayLengthY : m_arrayLengthY; } }
|
||||
|
||||
public bool AutoRegister { get { return m_autoRegister; } }
|
||||
public bool IsJagged { get { return m_isJagged; } }
|
||||
public bool Updated { get { return m_updated; } }
|
||||
public override string DataToArray { get { return m_name; } }
|
||||
}
|
||||
}
|
||||
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/GlobalArrayNode.cs.meta
generated
Normal file
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/GlobalArrayNode.cs.meta
generated
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 833b18e1479dbd24c80c5b990e16e2bb
|
||||
timeCreated: 1499769855
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,206 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[Serializable]
|
||||
[NodeAttributes( "Gradient", "Constants And Properties", "Gradient property" )]
|
||||
public sealed class GradientNode : ParentNode
|
||||
{
|
||||
[SerializeField]
|
||||
private Gradient m_gradient = new Gradient();
|
||||
|
||||
private string m_functionHeader = "NewGradient( {0}, {1}, {2}," +
|
||||
" {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}," +
|
||||
" {11}, {12}, {13}, {14}, {15}, {16}, {17}, {18} )";
|
||||
private string m_functionBody = string.Empty;
|
||||
|
||||
private string m_functionHeaderStruct = "Gradient( {0} )";
|
||||
private string m_functionBodyStruct = string.Empty;
|
||||
|
||||
public Gradient Gradient { get { return m_gradient; } }
|
||||
|
||||
public GradientNode() : base() { }
|
||||
public GradientNode( int uniqueId, float x, float y, float width, float height ) : base( uniqueId, x, y, width, height ) { }
|
||||
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
m_insideSize.Set( 128, m_insideSize.y );
|
||||
AddOutputPort( WirePortDataType.OBJECT, Constants.EmptyPortValue );
|
||||
m_autoWrapProperties = true;
|
||||
m_textLabelWidth = 100;
|
||||
}
|
||||
|
||||
public override void DrawProperties()
|
||||
{
|
||||
base.DrawProperties();
|
||||
EditorGUI.BeginChangeCheck();
|
||||
{
|
||||
m_gradient = EditorGUILayoutEx.GradientField( "Gradient" , m_gradient );
|
||||
}
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
PreviewIsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Draw( DrawInfo drawInfo )
|
||||
{
|
||||
base.Draw( drawInfo );
|
||||
|
||||
if( !m_isVisible )
|
||||
return;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
{
|
||||
m_gradient = EditorGUIEx.GradientField( m_remainingBox , m_gradient );
|
||||
}
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
PreviewIsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
m_functionBodyStruct = string.Empty;
|
||||
m_functionBody = string.Empty;
|
||||
if( !dataCollector.IsSRP )
|
||||
{
|
||||
GenerateGradientStruct( ref m_functionBodyStruct );
|
||||
dataCollector.AddFunctions( m_functionHeaderStruct, m_functionBodyStruct, "0" );
|
||||
GenerateGradient( ref m_functionBody );
|
||||
}
|
||||
else
|
||||
{
|
||||
dataCollector.AddToIncludes( UniqueId, "Packages/com.unity.shadergraph/ShaderGraphLibrary/Functions.hlsl" );
|
||||
}
|
||||
|
||||
string[] colors = new string[ 8 ];
|
||||
for( int i = 0; i < 8; i++ )
|
||||
{
|
||||
if( i < m_gradient.colorKeys.Length )
|
||||
{
|
||||
colors[ i ] = "float4( " + m_gradient.colorKeys[ i ].color.r + ", " + m_gradient.colorKeys[ i ].color.g + ", " + m_gradient.colorKeys[ i ].color.b + ", " + m_gradient.colorKeys[ i ].time + " )";
|
||||
}
|
||||
else
|
||||
{
|
||||
colors[ i ] = "0";
|
||||
}
|
||||
}
|
||||
|
||||
string[] alphas = new string[ 8 ];
|
||||
for( int i = 0; i < 8; i++ )
|
||||
{
|
||||
if( i < m_gradient.alphaKeys.Length )
|
||||
{
|
||||
alphas[ i ] = "float2( " + m_gradient.alphaKeys[ i ].alpha + ", " + m_gradient.alphaKeys[ i ].time + " )";
|
||||
}
|
||||
else
|
||||
{
|
||||
alphas[ i ] = "0";
|
||||
}
|
||||
}
|
||||
|
||||
string functionResult = dataCollector.AddFunctions( m_functionHeader, m_functionBody, (int)m_gradient.mode, m_gradient.colorKeys.Length, m_gradient.alphaKeys.Length
|
||||
, colors[ 0 ], colors[ 1 ], colors[ 2 ], colors[ 3 ], colors[ 4 ], colors[ 5 ], colors[ 6 ], colors[ 7 ]
|
||||
, alphas[ 0 ], alphas[ 1 ], alphas[ 2 ], alphas[ 3 ], alphas[ 4 ], alphas[ 5 ], alphas[ 6 ], alphas[ 7 ] );
|
||||
|
||||
dataCollector.AddLocalVariable( UniqueId, "Gradient gradient" + OutputId + " = " + functionResult + ";" );
|
||||
|
||||
return "gradient" + OutputId;
|
||||
}
|
||||
|
||||
public static void GenerateGradientStruct( ref string body )
|
||||
{
|
||||
body = string.Empty;
|
||||
IOUtils.AddFunctionHeader( ref body, "struct Gradient" );
|
||||
IOUtils.AddFunctionLine( ref body, "int type;" );
|
||||
IOUtils.AddFunctionLine( ref body, "int colorsLength;" );
|
||||
IOUtils.AddFunctionLine( ref body, "int alphasLength;" );
|
||||
IOUtils.AddFunctionLine( ref body, "float4 colors[8];" );
|
||||
IOUtils.AddFunctionLine( ref body, "float2 alphas[8];" );
|
||||
IOUtils.AddSingleLineFunction( ref body, "};\n" );
|
||||
}
|
||||
|
||||
public static void GenerateGradient( ref string body )
|
||||
{
|
||||
body = string.Empty;
|
||||
IOUtils.AddFunctionHeader( ref body, "Gradient NewGradient(int type, int colorsLength, int alphasLength, \n\t\tfloat4 colors0, float4 colors1, float4 colors2, float4 colors3, float4 colors4, float4 colors5, float4 colors6, float4 colors7,\n\t\tfloat2 alphas0, float2 alphas1, float2 alphas2, float2 alphas3, float2 alphas4, float2 alphas5, float2 alphas6, float2 alphas7)" );
|
||||
IOUtils.AddFunctionLine( ref body, "Gradient g;" );
|
||||
IOUtils.AddFunctionLine( ref body, "g.type = type;" );
|
||||
IOUtils.AddFunctionLine( ref body, "g.colorsLength = colorsLength;" );
|
||||
IOUtils.AddFunctionLine( ref body, "g.alphasLength = alphasLength;" );
|
||||
IOUtils.AddFunctionLine( ref body, "g.colors[ 0 ] = colors0;" );
|
||||
IOUtils.AddFunctionLine( ref body, "g.colors[ 1 ] = colors1;" );
|
||||
IOUtils.AddFunctionLine( ref body, "g.colors[ 2 ] = colors2;" );
|
||||
IOUtils.AddFunctionLine( ref body, "g.colors[ 3 ] = colors3;" );
|
||||
IOUtils.AddFunctionLine( ref body, "g.colors[ 4 ] = colors4;" );
|
||||
IOUtils.AddFunctionLine( ref body, "g.colors[ 5 ] = colors5;" );
|
||||
IOUtils.AddFunctionLine( ref body, "g.colors[ 6 ] = colors6;" );
|
||||
IOUtils.AddFunctionLine( ref body, "g.colors[ 7 ] = colors7;" );
|
||||
IOUtils.AddFunctionLine( ref body, "g.alphas[ 0 ] = alphas0;" );
|
||||
IOUtils.AddFunctionLine( ref body, "g.alphas[ 1 ] = alphas1;" );
|
||||
IOUtils.AddFunctionLine( ref body, "g.alphas[ 2 ] = alphas2;" );
|
||||
IOUtils.AddFunctionLine( ref body, "g.alphas[ 3 ] = alphas3;" );
|
||||
IOUtils.AddFunctionLine( ref body, "g.alphas[ 4 ] = alphas4;" );
|
||||
IOUtils.AddFunctionLine( ref body, "g.alphas[ 5 ] = alphas5;" );
|
||||
IOUtils.AddFunctionLine( ref body, "g.alphas[ 6 ] = alphas6;" );
|
||||
IOUtils.AddFunctionLine( ref body, "g.alphas[ 7 ] = alphas7;" );
|
||||
IOUtils.AddFunctionLine( ref body, "return g;" );
|
||||
IOUtils.CloseFunctionBody( ref body );
|
||||
}
|
||||
|
||||
public override void ReadFromString( ref string[] nodeParams )
|
||||
{
|
||||
base.ReadFromString( ref nodeParams );
|
||||
m_gradient.mode = (GradientMode)Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
|
||||
int colorCount = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
|
||||
int alphaCount = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
|
||||
|
||||
var colorKeys = new GradientColorKey[ colorCount ];
|
||||
for( int i = 0; i < colorCount; i++ )
|
||||
{
|
||||
Vector4 colorKey = IOUtils.StringToVector4( GetCurrentParam( ref nodeParams ) );
|
||||
colorKeys[ i ].color = colorKey;
|
||||
colorKeys[ i ].time = colorKey.w;
|
||||
}
|
||||
m_gradient.colorKeys = colorKeys;
|
||||
|
||||
var alphaKeys = new GradientAlphaKey[ alphaCount ];
|
||||
for( int i = 0; i < alphaCount; i++ )
|
||||
{
|
||||
Vector2 alphaKey = IOUtils.StringToVector2( GetCurrentParam( ref nodeParams ) );
|
||||
alphaKeys[ i ].alpha = alphaKey.x;
|
||||
alphaKeys[ i ].time = alphaKey.y;
|
||||
}
|
||||
m_gradient.alphaKeys = alphaKeys;
|
||||
}
|
||||
|
||||
public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
|
||||
{
|
||||
base.WriteToString( ref nodeInfo, ref connectionsInfo );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, (int)m_gradient.mode );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, m_gradient.colorKeys.Length );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, m_gradient.alphaKeys.Length );
|
||||
|
||||
for( int i = 0; i < m_gradient.colorKeys.Length; i++ )
|
||||
{
|
||||
Vector4 colorKey = new Vector4( m_gradient.colorKeys[ i ].color.r, m_gradient.colorKeys[ i ].color.g, m_gradient.colorKeys[ i ].color.b, m_gradient.colorKeys[ i ].time );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, IOUtils.Vector4ToString( colorKey ) );
|
||||
}
|
||||
|
||||
for( int i = 0; i < m_gradient.alphaKeys.Length; i++ )
|
||||
{
|
||||
Vector2 alphaKey = new Vector4( m_gradient.alphaKeys[ i ].alpha, m_gradient.alphaKeys[ i ].time );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, IOUtils.Vector2ToString( alphaKey ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/GradientNode.cs.meta
generated
Normal file
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/GradientNode.cs.meta
generated
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 98100a8a545b8ce42bc5657fd40a24a5
|
||||
timeCreated: 1481126955
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,300 @@
|
||||
// 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( "Int", "Constants And Properties", "Int property", null, KeyCode.Alpha0 )]
|
||||
public sealed class IntNode : PropertyNode
|
||||
{
|
||||
[SerializeField]
|
||||
private int m_defaultValue;
|
||||
|
||||
[SerializeField]
|
||||
private int m_materialValue;
|
||||
|
||||
[SerializeField]
|
||||
private bool m_setAsUINT = false;
|
||||
|
||||
private const float LabelWidth = 8;
|
||||
|
||||
private int m_cachedPropertyId = -1;
|
||||
|
||||
private bool m_isEditingFields;
|
||||
private int m_previousValue;
|
||||
private string m_fieldText = "0";
|
||||
|
||||
public IntNode() : base() { }
|
||||
public IntNode( int uniqueId, float x, float y, float width, float height ) : base( uniqueId, x, y, width, height ) { }
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
GlobalTypeWarningText = string.Format( GlobalTypeWarningText, "Int" );
|
||||
AddOutputPort( WirePortDataType.INT, Constants.EmptyPortValue );
|
||||
m_insideSize.Set( 50, 10 );
|
||||
m_selectedLocation = PreviewLocation.BottomCenter;
|
||||
m_drawPrecisionUI = false;
|
||||
m_showHybridInstancedUI = true;
|
||||
m_availableAttribs.Add( new PropertyAttributes( "Enum", "[Enum]" ) );
|
||||
m_previewShaderGUID = "0f64d695b6ffacc469f2dd31432a232a";
|
||||
m_srpBatcherCompatible = true;
|
||||
}
|
||||
|
||||
protected override void OnUniqueIDAssigned()
|
||||
{
|
||||
base.OnUniqueIDAssigned();
|
||||
UIUtils.RegisterFloatIntNode( this );
|
||||
}
|
||||
|
||||
public override void Destroy()
|
||||
{
|
||||
base.Destroy();
|
||||
UIUtils.UnregisterFloatIntNode( this );
|
||||
}
|
||||
|
||||
public override void OnDirtyProperty()
|
||||
{
|
||||
UIUtils.UpdateFloatIntDataNode( UniqueId, PropertyInspectorName );
|
||||
}
|
||||
|
||||
public override void RefreshExternalReferences()
|
||||
{
|
||||
base.RefreshExternalReferences();
|
||||
OnPropertyNameChanged();
|
||||
OnDirtyProperty();
|
||||
}
|
||||
|
||||
public override void SetPreviewInputs()
|
||||
{
|
||||
base.SetPreviewInputs();
|
||||
|
||||
if( m_cachedPropertyId == -1 )
|
||||
m_cachedPropertyId = Shader.PropertyToID( "_InputInt" );
|
||||
|
||||
if( m_materialMode && m_currentParameterType != PropertyType.Constant )
|
||||
PreviewMaterial.SetInt( m_cachedPropertyId, m_materialValue );
|
||||
else
|
||||
PreviewMaterial.SetInt( m_cachedPropertyId, m_defaultValue );
|
||||
}
|
||||
|
||||
|
||||
public override void CopyDefaultsToMaterial()
|
||||
{
|
||||
m_materialValue = m_defaultValue;
|
||||
DrawSetAsUINT();
|
||||
}
|
||||
|
||||
public override void DrawSubProperties()
|
||||
{
|
||||
m_defaultValue = EditorGUILayoutIntField( Constants.DefaultValueLabel, m_defaultValue );
|
||||
DrawSetAsUINT();
|
||||
}
|
||||
|
||||
private void DrawSetAsUINT()
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_setAsUINT = EditorGUILayoutToggle( "Set as UINT", m_setAsUINT );
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
WirePortDataType portType = m_setAsUINT ? WirePortDataType.UINT : WirePortDataType.INT;
|
||||
m_outputPorts[ 0 ].ChangeType( portType, false );
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawMaterialProperties()
|
||||
{
|
||||
if( m_materialMode )
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
m_materialValue = EditorGUILayoutIntField( Constants.MaterialValueLabel, m_materialValue );
|
||||
|
||||
if( m_materialMode && EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
m_requireMaterialUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnNodeLayout( DrawInfo drawInfo )
|
||||
{
|
||||
base.OnNodeLayout( drawInfo );
|
||||
|
||||
m_propertyDrawPos = m_remainingBox;
|
||||
m_propertyDrawPos.x = m_remainingBox.x - LabelWidth * drawInfo.InvertedZoom;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Draw( DrawInfo drawInfo )
|
||||
{
|
||||
base.Draw( drawInfo );
|
||||
|
||||
if( !m_isVisible )
|
||||
return;
|
||||
|
||||
if( m_isEditingFields && m_currentParameterType != PropertyType.Global )
|
||||
{
|
||||
float labelWidth = EditorGUIUtility.labelWidth;
|
||||
EditorGUIUtility.labelWidth = LabelWidth * drawInfo.InvertedZoom;
|
||||
|
||||
if( m_materialMode && m_currentParameterType != PropertyType.Constant )
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_materialValue = EditorGUIIntField( m_propertyDrawPos, " ", m_materialValue, UIUtils.MainSkin.textField );
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
PreviewIsDirty = true;
|
||||
m_requireMaterialUpdate = true;
|
||||
if( m_currentParameterType != PropertyType.Constant )
|
||||
BeginDelayedDirtyProperty();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
m_defaultValue = EditorGUIIntField( m_propertyDrawPos, " ", m_defaultValue, UIUtils.MainSkin.textField );
|
||||
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
PreviewIsDirty = true;
|
||||
BeginDelayedDirtyProperty();
|
||||
}
|
||||
}
|
||||
EditorGUIUtility.labelWidth = labelWidth;
|
||||
}
|
||||
else if( drawInfo.CurrentEventType == EventType.Repaint )
|
||||
{
|
||||
bool guiEnabled = GUI.enabled;
|
||||
GUI.enabled = m_currentParameterType != PropertyType.Global;
|
||||
Rect fakeField = m_propertyDrawPos;
|
||||
fakeField.xMin += LabelWidth * drawInfo.InvertedZoom;
|
||||
if( GUI.enabled )
|
||||
{
|
||||
Rect fakeLabel = m_propertyDrawPos;
|
||||
fakeLabel.xMax = fakeField.xMin;
|
||||
EditorGUIUtility.AddCursorRect( fakeLabel, MouseCursor.SlideArrow );
|
||||
EditorGUIUtility.AddCursorRect( fakeField, MouseCursor.Text );
|
||||
}
|
||||
bool currMode = m_materialMode && m_currentParameterType != PropertyType.Constant;
|
||||
int value = currMode ? m_materialValue : m_defaultValue;
|
||||
|
||||
if( m_previousValue != value )
|
||||
{
|
||||
m_previousValue = value;
|
||||
m_fieldText = value.ToString();
|
||||
}
|
||||
|
||||
GUI.Label( fakeField, m_fieldText, UIUtils.MainSkin.textField );
|
||||
GUI.enabled = guiEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
|
||||
|
||||
if( m_currentParameterType != PropertyType.Constant )
|
||||
return PropertyData( dataCollector.PortCategory );
|
||||
|
||||
return m_defaultValue.ToString();
|
||||
}
|
||||
|
||||
public override string GetPropertyValue()
|
||||
{
|
||||
return PropertyAttributes + m_propertyName + "(\"" + m_propertyInspectorName + "\", Int) = " + m_defaultValue;
|
||||
}
|
||||
|
||||
public override void UpdateMaterial( Material mat )
|
||||
{
|
||||
base.UpdateMaterial( mat );
|
||||
if( UIUtils.IsProperty( m_currentParameterType ) && !InsideShaderFunction )
|
||||
{
|
||||
mat.SetInt( m_propertyName, m_materialValue );
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetMaterialMode( Material mat, bool fetchMaterialValues )
|
||||
{
|
||||
base.SetMaterialMode( mat, fetchMaterialValues );
|
||||
if( fetchMaterialValues && m_materialMode && UIUtils.IsProperty( m_currentParameterType ) && mat.HasProperty( m_propertyName ) )
|
||||
{
|
||||
m_materialValue = mat.GetInt( m_propertyName );
|
||||
}
|
||||
}
|
||||
|
||||
public override void ForceUpdateFromMaterial( Material material )
|
||||
{
|
||||
if( UIUtils.IsProperty( m_currentParameterType ) && material.HasProperty( m_propertyName ) )
|
||||
{
|
||||
m_materialValue = material.GetInt( m_propertyName );
|
||||
PreviewIsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void ReadFromString( ref string[] nodeParams )
|
||||
{
|
||||
base.ReadFromString( ref nodeParams );
|
||||
m_defaultValue = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
|
||||
if( UIUtils.CurrentShaderVersion() > 14101 )
|
||||
m_materialValue = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
|
||||
if( UIUtils.CurrentShaderVersion() > 18500 )
|
||||
m_setAsUINT = 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_defaultValue );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, m_materialValue );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, m_setAsUINT );
|
||||
}
|
||||
|
||||
public override string GetPropertyValStr()
|
||||
{
|
||||
return ( m_materialMode && m_currentParameterType != PropertyType.Constant ) ?
|
||||
m_materialValue.ToString( Mathf.Abs( m_materialValue ) > 1000 ? Constants.PropertyBigIntFormatLabel : Constants.PropertyIntFormatLabel ) :
|
||||
m_defaultValue.ToString( Mathf.Abs( m_defaultValue ) > 1000 ? Constants.PropertyBigIntFormatLabel : Constants.PropertyIntFormatLabel );
|
||||
}
|
||||
|
||||
public override void SetGlobalValue() { Shader.SetGlobalInt( m_propertyName, m_defaultValue ); }
|
||||
public override void FetchGlobalValue() { m_materialValue = Shader.GetGlobalInt( m_propertyName ); }
|
||||
public int Value
|
||||
{
|
||||
get { return m_defaultValue; }
|
||||
set { m_defaultValue = value; }
|
||||
}
|
||||
|
||||
public void SetMaterialValueFromInline( int val )
|
||||
{
|
||||
m_materialValue = val;
|
||||
m_requireMaterialUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/IntNode.cs.meta
generated
Normal file
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/IntNode.cs.meta
generated
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 86df2da3da3b1eb4493b968b47030b17
|
||||
timeCreated: 1481126957
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,262 @@
|
||||
// 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( "Matrix3X3", "Constants And Properties", "Matrix3X3 property" )]
|
||||
public sealed class Matrix3X3Node : MatrixParentNode
|
||||
{
|
||||
private string[,] m_fieldText = new string[ 3, 3 ] { { "0", "0", "0" }, { "0", "0", "0" }, { "0", "0", "0" } };
|
||||
public Matrix3X3Node() : base() { }
|
||||
public Matrix3X3Node( int uniqueId, float x, float y, float width, float height ) : base( uniqueId, x, y, width, height ) { }
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
GlobalTypeWarningText = string.Format( GlobalTypeWarningText, "Matrix" );
|
||||
AddOutputPort( WirePortDataType.FLOAT3x3, Constants.EmptyPortValue );
|
||||
m_insideSize.Set( Constants.FLOAT_DRAW_WIDTH_FIELD_SIZE * 3 + Constants.FLOAT_WIDTH_SPACING * 2, Constants.FLOAT_DRAW_HEIGHT_FIELD_SIZE * 3 + Constants.FLOAT_WIDTH_SPACING * 2 + Constants.OUTSIDE_WIRE_MARGIN );
|
||||
//m_defaultValue = new Matrix4x4();
|
||||
//m_materialValue = new Matrix4x4();
|
||||
m_drawPreview = false;
|
||||
}
|
||||
|
||||
public override void CopyDefaultsToMaterial()
|
||||
{
|
||||
m_materialValue = m_defaultValue;
|
||||
}
|
||||
|
||||
public override void DrawSubProperties()
|
||||
{
|
||||
EditorGUILayout.LabelField( Constants.DefaultValueLabel );
|
||||
for( int row = 0; row < 3; row++ )
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
for( int column = 0; column < 3; column++ )
|
||||
{
|
||||
m_defaultValue[ row, column ] = EditorGUILayoutFloatField( string.Empty, m_defaultValue[ row, column ], GUILayout.MaxWidth( 76 ) );
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawMaterialProperties()
|
||||
{
|
||||
if( m_materialMode )
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
EditorGUILayout.LabelField( Constants.MaterialValueLabel );
|
||||
for( int row = 0; row < 3; row++ )
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
for( int column = 0; column < 3; column++ )
|
||||
{
|
||||
m_materialValue[ row, column ] = EditorGUILayoutFloatField( string.Empty, m_materialValue[ row, column ], GUILayout.MaxWidth( 76 ) );
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
if( m_materialMode && EditorGUI.EndChangeCheck() )
|
||||
m_requireMaterialUpdate = true;
|
||||
}
|
||||
|
||||
public override void OnNodeLayout( DrawInfo drawInfo )
|
||||
{
|
||||
base.OnNodeLayout( drawInfo );
|
||||
|
||||
m_propertyDrawPos.position = m_remainingBox.position;
|
||||
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.height = m_insideSize.y * 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void Draw( DrawInfo drawInfo )
|
||||
{
|
||||
base.Draw( drawInfo );
|
||||
|
||||
if( !m_isVisible )
|
||||
return;
|
||||
|
||||
if( m_isEditingFields && m_currentParameterType != PropertyType.Global )
|
||||
{
|
||||
bool currMode = m_materialMode && m_currentParameterType != PropertyType.Constant;
|
||||
Matrix4x4 value = currMode ? m_materialValue : m_defaultValue;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
for( int row = 0; row < 3; row++ )
|
||||
{
|
||||
for( int column = 0; column < 3; column++ )
|
||||
{
|
||||
m_propertyDrawPos.position = m_remainingBox.position + Vector2.Scale( m_propertyDrawPos.size, new Vector2( column, row ) ) + new Vector2( Constants.FLOAT_WIDTH_SPACING * drawInfo.InvertedZoom * column, Constants.FLOAT_WIDTH_SPACING * drawInfo.InvertedZoom * row );
|
||||
value[ row, column ] = EditorGUIFloatField( m_propertyDrawPos, string.Empty, value[ row, column ], UIUtils.MainSkin.textField );
|
||||
}
|
||||
}
|
||||
|
||||
if( currMode )
|
||||
{
|
||||
m_materialValue = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_defaultValue = value;
|
||||
}
|
||||
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
m_requireMaterialUpdate = m_materialMode;
|
||||
BeginDelayedDirtyProperty();
|
||||
}
|
||||
}
|
||||
else if( drawInfo.CurrentEventType == EventType.Repaint )
|
||||
{
|
||||
bool guiEnabled = GUI.enabled;
|
||||
//redundant ternary conditional but this makes easier to read that only when m_showCuffer is on that we need to take PropertyType.Property into account
|
||||
GUI.enabled = ( m_showCBuffer )? m_currentParameterType != PropertyType.Global&& m_currentParameterType != PropertyType.Property : m_currentParameterType != PropertyType.Global;
|
||||
|
||||
bool currMode = m_materialMode && m_currentParameterType != PropertyType.Constant;
|
||||
Matrix4x4 value = currMode ? m_materialValue : m_defaultValue;
|
||||
for( int row = 0; row < 3; row++ )
|
||||
{
|
||||
for( int column = 0; column < 3; column++ )
|
||||
{
|
||||
Rect fakeField = m_propertyDrawPos;
|
||||
fakeField.position = m_remainingBox.position + Vector2.Scale( m_propertyDrawPos.size, new Vector2( column, row ) ) + new Vector2( Constants.FLOAT_WIDTH_SPACING * drawInfo.InvertedZoom * column, Constants.FLOAT_WIDTH_SPACING * drawInfo.InvertedZoom * row );
|
||||
if( GUI.enabled )
|
||||
EditorGUIUtility.AddCursorRect( fakeField, MouseCursor.Text );
|
||||
|
||||
if( m_previousValue[ row, column ] != value[ row, column ] )
|
||||
{
|
||||
m_previousValue[ row, column ] = value[ row, column ];
|
||||
m_fieldText[ row, column ] = value[ row, column ].ToString();
|
||||
}
|
||||
|
||||
GUI.Label( fakeField, m_fieldText[ row, column ], UIUtils.MainSkin.textField );
|
||||
}
|
||||
}
|
||||
GUI.enabled = guiEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
|
||||
m_precisionString = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_outputPorts[ 0 ].DataType );
|
||||
if( m_currentParameterType != PropertyType.Constant )
|
||||
{
|
||||
if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
|
||||
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
|
||||
string localVarName = PropertyData( dataCollector.PortCategory ) + "Local3x3";
|
||||
string localVarValue = string.Format( "float3x3({0}._m00,{0}._m01,{0}._m02,{0}._m10,{0}._m11,{0}._m12,{0}._m20,{0}._m21,{0}._m22 )", PropertyData( dataCollector.PortCategory ) );
|
||||
RegisterLocalVariable( 0, localVarValue, ref dataCollector, localVarName );
|
||||
return localVarName;
|
||||
}
|
||||
|
||||
Matrix4x4 value = m_defaultValue;
|
||||
|
||||
return m_precisionString + "(" + value[ 0, 0 ] + "," + value[ 0, 1 ] + "," + value[ 0, 2 ] + "," +
|
||||
+value[ 1, 0 ] + "," + value[ 1, 1 ] + "," + value[ 1, 2 ] + "," +
|
||||
+value[ 2, 0 ] + "," + value[ 2, 1 ] + "," + value[ 2, 2 ] + ")";
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override void UpdateMaterial( Material mat )
|
||||
{
|
||||
base.UpdateMaterial( mat );
|
||||
if( UIUtils.IsProperty( m_currentParameterType ) && !InsideShaderFunction )
|
||||
{
|
||||
Shader.SetGlobalMatrix( m_propertyName, m_materialValue );
|
||||
//mat.SetMatrix( m_propertyName, m_materialValue );
|
||||
}
|
||||
}
|
||||
|
||||
public override bool GetUniformData( out string dataType, out string dataName, ref bool fullValue )
|
||||
{
|
||||
dataType = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, WirePortDataType.FLOAT4x4 );
|
||||
dataName = m_propertyName;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void SetMaterialMode( Material mat, bool fetchMaterialValues )
|
||||
{
|
||||
base.SetMaterialMode( mat, fetchMaterialValues );
|
||||
if( fetchMaterialValues && m_materialMode && UIUtils.IsProperty( m_currentParameterType ) && mat.HasProperty( m_propertyName ) )
|
||||
{
|
||||
m_materialValue = mat.GetMatrix( m_propertyName );
|
||||
}
|
||||
}
|
||||
|
||||
public override void ForceUpdateFromMaterial( Material material )
|
||||
{
|
||||
if( UIUtils.IsProperty( m_currentParameterType ) && material.HasProperty( m_propertyName ) )
|
||||
{
|
||||
m_materialValue = material.GetMatrix( m_propertyName );
|
||||
PreviewIsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void ReadFromString( ref string[] nodeParams )
|
||||
{
|
||||
base.ReadFromString( ref nodeParams );
|
||||
m_defaultValue = IOUtils.StringToMatrix3x3( GetCurrentParam( ref nodeParams ) );
|
||||
}
|
||||
|
||||
public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
|
||||
{
|
||||
base.WriteToString( ref nodeInfo, ref connectionsInfo );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, IOUtils.Matrix3x3ToString( m_defaultValue ) );
|
||||
}
|
||||
|
||||
public override void ReadAdditionalClipboardData( ref string[] nodeParams )
|
||||
{
|
||||
base.ReadAdditionalClipboardData( ref nodeParams );
|
||||
m_materialValue = IOUtils.StringToMatrix3x3( GetCurrentParam( ref nodeParams ) );
|
||||
}
|
||||
|
||||
public override void WriteAdditionalClipboardData( ref string nodeInfo )
|
||||
{
|
||||
base.WriteAdditionalClipboardData( ref nodeInfo );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, IOUtils.Matrix3x3ToString( m_materialValue ) );
|
||||
}
|
||||
|
||||
public override string GetPropertyValStr()
|
||||
{
|
||||
return ( m_materialMode && m_currentParameterType != PropertyType.Constant ) ? m_materialValue[ 0, 0 ].ToString( Mathf.Abs( m_materialValue[ 0, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 0, 1 ].ToString( Mathf.Abs( m_materialValue[ 0, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 0, 2 ].ToString( Mathf.Abs( m_materialValue[ 0, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.MATRIX_DATA_SEPARATOR +
|
||||
m_materialValue[ 1, 0 ].ToString( Mathf.Abs( m_materialValue[ 1, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 1, 1 ].ToString( Mathf.Abs( m_materialValue[ 1, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 1, 2 ].ToString( Mathf.Abs( m_materialValue[ 1, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.MATRIX_DATA_SEPARATOR +
|
||||
m_materialValue[ 2, 0 ].ToString( Mathf.Abs( m_materialValue[ 2, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 2, 1 ].ToString( Mathf.Abs( m_materialValue[ 2, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 2, 2 ].ToString( Mathf.Abs( m_materialValue[ 2, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) :
|
||||
|
||||
m_defaultValue[ 0, 0 ].ToString( Mathf.Abs( m_defaultValue[ 0, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 0, 1 ].ToString( Mathf.Abs( m_defaultValue[ 0, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 0, 2 ].ToString( Mathf.Abs( m_defaultValue[ 0, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.MATRIX_DATA_SEPARATOR +
|
||||
m_defaultValue[ 1, 0 ].ToString( Mathf.Abs( m_defaultValue[ 1, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 1, 1 ].ToString( Mathf.Abs( m_defaultValue[ 1, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 1, 2 ].ToString( Mathf.Abs( m_defaultValue[ 1, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.MATRIX_DATA_SEPARATOR +
|
||||
m_defaultValue[ 2, 0 ].ToString( Mathf.Abs( m_defaultValue[ 2, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 2, 1 ].ToString( Mathf.Abs( m_defaultValue[ 2, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 2, 2 ].ToString( Mathf.Abs( m_defaultValue[ 2, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Matrix3X3Node.cs.meta
generated
Normal file
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Matrix3X3Node.cs.meta
generated
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01e5a5829caac674fa819ed229de31b6
|
||||
timeCreated: 1481126953
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,249 @@
|
||||
// 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( "Matrix4X4", "Constants And Properties", "Matrix4X4 property" )]
|
||||
public sealed class Matrix4X4Node : MatrixParentNode
|
||||
{
|
||||
private string[,] m_fieldText = new string[ 4, 4 ] { { "0", "0", "0", "0" }, { "0", "0", "0", "0" }, { "0", "0", "0", "0" }, { "0", "0", "0", "0" } };
|
||||
public Matrix4X4Node() : base() { }
|
||||
public Matrix4X4Node( int uniqueId, float x, float y, float width, float height ) : base( uniqueId, x, y, width, height ) { }
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
GlobalTypeWarningText = string.Format( GlobalTypeWarningText, "Matrix" );
|
||||
AddOutputPort( WirePortDataType.FLOAT4x4, Constants.EmptyPortValue );
|
||||
m_insideSize.Set( Constants.FLOAT_DRAW_WIDTH_FIELD_SIZE * 4 + Constants.FLOAT_WIDTH_SPACING * 3, Constants.FLOAT_DRAW_HEIGHT_FIELD_SIZE * 4 + Constants.FLOAT_WIDTH_SPACING * 3 + Constants.OUTSIDE_WIRE_MARGIN );
|
||||
//m_defaultValue = new Matrix4x4();
|
||||
//m_materialValue = new Matrix4x4();
|
||||
m_drawPreview = false;
|
||||
}
|
||||
|
||||
public override void CopyDefaultsToMaterial()
|
||||
{
|
||||
m_materialValue = m_defaultValue;
|
||||
}
|
||||
|
||||
public override void DrawSubProperties()
|
||||
{
|
||||
EditorGUILayout.LabelField( Constants.DefaultValueLabel );
|
||||
for ( int row = 0; row < 4; row++ )
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
for ( int column = 0; column < 4; column++ )
|
||||
{
|
||||
m_defaultValue[ row, column ] = EditorGUILayoutFloatField( string.Empty, m_defaultValue[ row, column ], GUILayout.MaxWidth( 55 ) );
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawMaterialProperties()
|
||||
{
|
||||
if ( m_materialMode )
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
EditorGUILayout.LabelField( Constants.MaterialValueLabel );
|
||||
for ( int row = 0; row < 4; row++ )
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
for ( int column = 0; column < 4; column++ )
|
||||
{
|
||||
m_materialValue[ row, column ] = EditorGUILayoutFloatField( string.Empty, m_materialValue[ row, column ], GUILayout.MaxWidth( 55 ) );
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
if ( m_materialMode && EditorGUI.EndChangeCheck() )
|
||||
m_requireMaterialUpdate = true;
|
||||
}
|
||||
|
||||
public override void OnNodeLayout( DrawInfo drawInfo )
|
||||
{
|
||||
base.OnNodeLayout( drawInfo );
|
||||
|
||||
m_propertyDrawPos.position = m_remainingBox.position;
|
||||
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.height = m_insideSize.y * 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;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Draw( DrawInfo drawInfo )
|
||||
{
|
||||
base.Draw( drawInfo );
|
||||
|
||||
if ( !m_isVisible )
|
||||
return;
|
||||
|
||||
if ( m_isEditingFields && m_currentParameterType != PropertyType.Global )
|
||||
{
|
||||
bool currMode = m_materialMode && m_currentParameterType != PropertyType.Constant;
|
||||
Matrix4x4 value = currMode ? m_materialValue : m_defaultValue;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
for ( int row = 0; row < 4; row++ )
|
||||
{
|
||||
for ( int column = 0; column < 4; column++ )
|
||||
{
|
||||
m_propertyDrawPos.position = m_remainingBox.position + Vector2.Scale( m_propertyDrawPos.size, new Vector2( column, row ) ) + new Vector2( Constants.FLOAT_WIDTH_SPACING * drawInfo.InvertedZoom * column, Constants.FLOAT_WIDTH_SPACING * drawInfo.InvertedZoom * row );
|
||||
value[ row, column ] = EditorGUIFloatField( m_propertyDrawPos, string.Empty, value[ row, column ], UIUtils.MainSkin.textField );
|
||||
}
|
||||
}
|
||||
|
||||
if ( currMode )
|
||||
{
|
||||
m_materialValue = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_defaultValue = value;
|
||||
}
|
||||
|
||||
if ( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
m_requireMaterialUpdate = m_materialMode;
|
||||
BeginDelayedDirtyProperty();
|
||||
}
|
||||
}
|
||||
else if ( drawInfo.CurrentEventType == EventType.Repaint )
|
||||
{
|
||||
bool guiEnabled = GUI.enabled;
|
||||
//redundant ternary conditional but this makes easier to read that only when m_showCuffer is on that we need to take PropertyType.Property into account
|
||||
GUI.enabled = ( m_showCBuffer ) ? m_currentParameterType != PropertyType.Global && m_currentParameterType != PropertyType.Property : m_currentParameterType != PropertyType.Global;
|
||||
|
||||
bool currMode = m_materialMode && m_currentParameterType != PropertyType.Constant;
|
||||
Matrix4x4 value = currMode ? m_materialValue : m_defaultValue;
|
||||
for ( int row = 0; row < 4; row++ )
|
||||
{
|
||||
for ( int column = 0; column < 4; column++ )
|
||||
{
|
||||
Rect fakeField = m_propertyDrawPos;
|
||||
fakeField.position = m_remainingBox.position + Vector2.Scale( m_propertyDrawPos.size, new Vector2( column, row ) ) + new Vector2( Constants.FLOAT_WIDTH_SPACING * drawInfo.InvertedZoom * column, Constants.FLOAT_WIDTH_SPACING * drawInfo.InvertedZoom * row );
|
||||
if( GUI.enabled )
|
||||
EditorGUIUtility.AddCursorRect( fakeField, MouseCursor.Text );
|
||||
|
||||
if ( m_previousValue[ row, column ] != value[ row, column ] )
|
||||
{
|
||||
m_previousValue[ row, column ] = value[ row, column ];
|
||||
m_fieldText[ row, column ] = value[ row, column ].ToString();
|
||||
}
|
||||
|
||||
GUI.Label( fakeField, m_fieldText[ row, column ], UIUtils.MainSkin.textField );
|
||||
}
|
||||
}
|
||||
GUI.enabled = guiEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
|
||||
m_precisionString = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_outputPorts[ 0 ].DataType );
|
||||
if ( m_currentParameterType != PropertyType.Constant )
|
||||
return PropertyData( dataCollector.PortCategory );
|
||||
|
||||
Matrix4x4 value = m_defaultValue;
|
||||
|
||||
return m_precisionString+"(" + value[ 0, 0 ] + "," + value[ 0, 1 ] + "," + value[ 0, 2 ] + "," + value[ 0, 3 ] + "," +
|
||||
+value[ 1, 0 ] + "," + value[ 1, 1 ] + "," + value[ 1, 2 ] + "," + value[ 1, 3 ] + "," +
|
||||
+value[ 2, 0 ] + "," + value[ 2, 1 ] + "," + value[ 2, 2 ] + "," + value[ 2, 3 ] + "," +
|
||||
+value[ 3, 0 ] + "," + value[ 3, 1 ] + "," + value[ 3, 2 ] + "," + value[ 3, 3 ] + ")";
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override void UpdateMaterial( Material mat )
|
||||
{
|
||||
base.UpdateMaterial( mat );
|
||||
if ( UIUtils.IsProperty( m_currentParameterType ) && !InsideShaderFunction )
|
||||
{
|
||||
mat.SetMatrix( m_propertyName, m_materialValue );
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetMaterialMode( Material mat , bool fetchMaterialValues )
|
||||
{
|
||||
base.SetMaterialMode( mat , fetchMaterialValues );
|
||||
if ( fetchMaterialValues && m_materialMode && UIUtils.IsProperty( m_currentParameterType ) && mat.HasProperty( m_propertyName ) )
|
||||
{
|
||||
m_materialValue = mat.GetMatrix( m_propertyName );
|
||||
}
|
||||
}
|
||||
|
||||
public override void ForceUpdateFromMaterial( Material material )
|
||||
{
|
||||
if( UIUtils.IsProperty( m_currentParameterType ) && material.HasProperty( m_propertyName ) )
|
||||
{
|
||||
m_materialValue = material.GetMatrix( m_propertyName );
|
||||
PreviewIsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void ReadFromString( ref string[] nodeParams )
|
||||
{
|
||||
base.ReadFromString( ref nodeParams );
|
||||
m_defaultValue = IOUtils.StringToMatrix4x4( GetCurrentParam( ref nodeParams ) );
|
||||
}
|
||||
|
||||
public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
|
||||
{
|
||||
base.WriteToString( ref nodeInfo, ref connectionsInfo );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, IOUtils.Matrix4x4ToString( m_defaultValue ) );
|
||||
}
|
||||
|
||||
public override void ReadAdditionalClipboardData( ref string[] nodeParams )
|
||||
{
|
||||
base.ReadAdditionalClipboardData( ref nodeParams );
|
||||
m_materialValue = IOUtils.StringToMatrix4x4( GetCurrentParam( ref nodeParams ) );
|
||||
}
|
||||
|
||||
public override void WriteAdditionalClipboardData( ref string nodeInfo )
|
||||
{
|
||||
base.WriteAdditionalClipboardData( ref nodeInfo );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, IOUtils.Matrix4x4ToString( m_materialValue ) );
|
||||
}
|
||||
|
||||
|
||||
public override string GetPropertyValStr()
|
||||
{
|
||||
return ( m_materialMode && m_currentParameterType != PropertyType.Constant ) ? m_materialValue[ 0, 0 ].ToString( Mathf.Abs( m_materialValue[ 0, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 0, 1 ].ToString( Mathf.Abs( m_materialValue[ 0, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 0, 2 ].ToString( Mathf.Abs( m_materialValue[ 0, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 0, 3 ].ToString( Mathf.Abs( m_materialValue[ 0, 3 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.MATRIX_DATA_SEPARATOR +
|
||||
m_materialValue[ 1, 0 ].ToString( Mathf.Abs( m_materialValue[ 1, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 1, 1 ].ToString( Mathf.Abs( m_materialValue[ 1, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 1, 2 ].ToString( Mathf.Abs( m_materialValue[ 1, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 1, 3 ].ToString( Mathf.Abs( m_materialValue[ 1, 3 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.MATRIX_DATA_SEPARATOR +
|
||||
m_materialValue[ 2, 0 ].ToString( Mathf.Abs( m_materialValue[ 2, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 2, 1 ].ToString( Mathf.Abs( m_materialValue[ 2, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 2, 2 ].ToString( Mathf.Abs( m_materialValue[ 2, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 2, 3 ].ToString( Mathf.Abs( m_materialValue[ 2, 3 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.MATRIX_DATA_SEPARATOR +
|
||||
m_materialValue[ 3, 0 ].ToString( Mathf.Abs( m_materialValue[ 3, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 3, 1 ].ToString( Mathf.Abs( m_materialValue[ 3, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 3, 2 ].ToString( Mathf.Abs( m_materialValue[ 3, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 3, 3 ].ToString( Mathf.Abs( m_materialValue[ 3, 3 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) :
|
||||
|
||||
m_defaultValue[ 0, 0 ].ToString( Mathf.Abs( m_defaultValue[ 0, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 0, 1 ].ToString( Mathf.Abs( m_defaultValue[ 0, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 0, 2 ].ToString( Mathf.Abs( m_defaultValue[ 0, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 0, 3 ].ToString( Mathf.Abs( m_defaultValue[ 0, 3 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.MATRIX_DATA_SEPARATOR +
|
||||
m_defaultValue[ 1, 0 ].ToString( Mathf.Abs( m_defaultValue[ 1, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 1, 1 ].ToString( Mathf.Abs( m_defaultValue[ 1, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 1, 2 ].ToString( Mathf.Abs( m_defaultValue[ 1, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 1, 3 ].ToString( Mathf.Abs( m_defaultValue[ 1, 3 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.MATRIX_DATA_SEPARATOR +
|
||||
m_defaultValue[ 2, 0 ].ToString( Mathf.Abs( m_defaultValue[ 2, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 2, 1 ].ToString( Mathf.Abs( m_defaultValue[ 2, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 2, 2 ].ToString( Mathf.Abs( m_defaultValue[ 2, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 2, 3 ].ToString( Mathf.Abs( m_defaultValue[ 2, 3 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.MATRIX_DATA_SEPARATOR +
|
||||
m_defaultValue[ 3, 0 ].ToString( Mathf.Abs( m_defaultValue[ 3, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 3, 1 ].ToString( Mathf.Abs( m_defaultValue[ 3, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 3, 2 ].ToString( Mathf.Abs( m_defaultValue[ 3, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 3, 3 ].ToString( Mathf.Abs( m_defaultValue[ 3, 3 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Matrix4X4Node.cs.meta
generated
Normal file
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Matrix4X4Node.cs.meta
generated
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4fa5db614b9379b4da27edafa0a8f4e9
|
||||
timeCreated: 1481126955
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,129 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[Serializable]
|
||||
public class MatrixParentNode : PropertyNode
|
||||
{
|
||||
private readonly string[] AvailablePropertyTypeLabels = { PropertyType.Constant.ToString(), PropertyType.Global.ToString(), "Instanced" };
|
||||
private readonly int[] AvailablePropertyTypeValues = { (int)PropertyType.Constant, (int)PropertyType.Global , (int)PropertyType.InstancedProperty };
|
||||
|
||||
private readonly string[] AvailablePropertyTypeLabelsSRP = { PropertyType.Constant.ToString() ,"CBuffer", PropertyType.Global.ToString() , "Instanced" };
|
||||
private readonly int[] AvailablePropertyTypeValuesSRP = { (int)PropertyType.Constant , (int)PropertyType.Property,( int)PropertyType.Global , (int)PropertyType.InstancedProperty };
|
||||
|
||||
|
||||
protected bool m_isEditingFields;
|
||||
|
||||
protected bool m_showCBuffer = false;
|
||||
|
||||
[SerializeField]
|
||||
protected Matrix4x4 m_defaultValue = Matrix4x4.identity;
|
||||
|
||||
[SerializeField]
|
||||
protected Matrix4x4 m_materialValue = Matrix4x4.identity;
|
||||
|
||||
[NonSerialized]
|
||||
protected Matrix4x4 m_previousValue;
|
||||
|
||||
private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper();
|
||||
|
||||
public MatrixParentNode() : base() { }
|
||||
public MatrixParentNode( int uniqueId, float x, float y, float width, float height ) : base( uniqueId, x, y, width, height ) { }
|
||||
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
m_freeType = false;
|
||||
m_showVariableMode = true;
|
||||
m_srpBatcherCompatible = true;
|
||||
}
|
||||
|
||||
public override void AfterCommonInit()
|
||||
{
|
||||
base.AfterCommonInit();
|
||||
m_hasLeftDropdown = true;
|
||||
m_drawAttributes = false;
|
||||
m_availableAttribs.Clear();
|
||||
|
||||
if( PaddingTitleLeft == 0 )
|
||||
{
|
||||
PaddingTitleLeft = Constants.PropertyPickerWidth + Constants.IconsLeftRightMargin;
|
||||
if( PaddingTitleRight == 0 )
|
||||
PaddingTitleRight = Constants.PropertyPickerWidth + Constants.IconsLeftRightMargin;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnNodeLogicUpdate( DrawInfo drawInfo )
|
||||
{
|
||||
base.OnNodeLogicUpdate( drawInfo );
|
||||
m_showCBuffer = m_containerGraph.IsSRP || m_containerGraph.CurrentShaderFunction != null;
|
||||
}
|
||||
|
||||
protected void DrawParameterType()
|
||||
{
|
||||
PropertyType parameterType;
|
||||
if( m_showCBuffer )
|
||||
{
|
||||
parameterType = (PropertyType)EditorGUILayoutIntPopup( ParameterTypeStr , (int)m_currentParameterType , AvailablePropertyTypeLabelsSRP , AvailablePropertyTypeValuesSRP );
|
||||
}
|
||||
else
|
||||
{
|
||||
parameterType = (PropertyType)EditorGUILayoutIntPopup( ParameterTypeStr , (int)m_currentParameterType , AvailablePropertyTypeLabels , AvailablePropertyTypeValues );
|
||||
}
|
||||
|
||||
if( parameterType != m_currentParameterType )
|
||||
{
|
||||
ChangeParameterType( parameterType );
|
||||
}
|
||||
}
|
||||
|
||||
public override void Draw( DrawInfo drawInfo )
|
||||
{
|
||||
base.Draw( drawInfo );
|
||||
PropertyType parameterType;
|
||||
if( m_showCBuffer )
|
||||
{
|
||||
parameterType = (PropertyType)m_upperLeftWidget.DrawWidget( this , (int)m_currentParameterType , AvailablePropertyTypeLabelsSRP , AvailablePropertyTypeValuesSRP );
|
||||
}
|
||||
else
|
||||
{
|
||||
parameterType = (PropertyType)m_upperLeftWidget.DrawWidget( this , (int)m_currentParameterType , AvailablePropertyTypeLabels , AvailablePropertyTypeValues );
|
||||
}
|
||||
|
||||
if( parameterType != m_currentParameterType )
|
||||
{
|
||||
ChangeParameterType( parameterType );
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawMainPropertyBlock()
|
||||
{
|
||||
DrawParameterType();
|
||||
base.DrawMainPropertyBlock();
|
||||
}
|
||||
|
||||
public override void Destroy()
|
||||
{
|
||||
base.Destroy();
|
||||
m_upperLeftWidget = null;
|
||||
}
|
||||
|
||||
public override void OnMasterNodeReplaced( MasterNode newMasterNode )
|
||||
{
|
||||
base.OnMasterNodeReplaced( newMasterNode );
|
||||
if( m_containerGraph.IsStandardSurface || !m_containerGraph.IsSRP )
|
||||
{
|
||||
if( m_currentParameterType == PropertyType.Property )
|
||||
{
|
||||
m_currentParameterType = PropertyType.Global;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetGlobalValue() { Shader.SetGlobalMatrix( m_propertyName, m_defaultValue ); }
|
||||
public override void FetchGlobalValue() { m_materialValue = Shader.GetGlobalMatrix( m_propertyName ); }
|
||||
}
|
||||
}
|
||||
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/MatrixParentNode.cs.meta
generated
Normal file
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/MatrixParentNode.cs.meta
generated
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d31dc25864c509a4f967e32079a27d6f
|
||||
timeCreated: 1507902748
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,63 @@
|
||||
// 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( "PI", "Constants And Properties", "PI constant : 3.14159265359" )]
|
||||
public sealed class PiNode : ParentNode
|
||||
{
|
||||
public PiNode() : base() { }
|
||||
public PiNode( int uniqueId, float x, float y, float width, float height ) : base( uniqueId, x, y, width, height ) { }
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
AddInputPort( WirePortDataType.FLOAT, true, "Multiplier" );
|
||||
AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue );
|
||||
m_textLabelWidth = 70;
|
||||
InputPorts[ 0 ].FloatInternalData = 1;
|
||||
m_useInternalPortData = true;
|
||||
m_previewShaderGUID = "bf4a65726dab3d445a69fb1d0945c33e";
|
||||
}
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
|
||||
string finalValue = string.Empty;
|
||||
string piString = dataCollector.IsSRP ? "PI" : "UNITY_PI";
|
||||
if( !InputPorts[ 0 ].IsConnected && InputPorts[ 0 ].FloatInternalData == 1 )
|
||||
{
|
||||
finalValue = piString;
|
||||
} else
|
||||
{
|
||||
string multiplier = InputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
|
||||
finalValue = "( " + multiplier + " * " + piString + " )";
|
||||
}
|
||||
|
||||
|
||||
if ( finalValue.Equals( string.Empty ) )
|
||||
{
|
||||
UIUtils.ShowMessage( UniqueId, "PINode generating empty code", MessageSeverity.Warning );
|
||||
}
|
||||
return finalValue;
|
||||
}
|
||||
|
||||
//public override void ReadFromString( ref string[] nodeParams )
|
||||
//{
|
||||
// base.ReadFromString( ref nodeParams );
|
||||
|
||||
// Removed on version 5004
|
||||
//m_value = Convert.ToSingle( GetCurrentParam( ref nodeParams ) );
|
||||
//}
|
||||
|
||||
//public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
|
||||
//{
|
||||
// base.WriteToString( ref nodeInfo, ref connectionsInfo );
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/PiNode.cs.meta
generated
Normal file
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/PiNode.cs.meta
generated
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a8a03953b97a594b81b2fb71d4a57ec
|
||||
timeCreated: 1481126957
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/PropertyNode.cs.meta
generated
Normal file
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/PropertyNode.cs.meta
generated
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5bbfd66571b12f84983b398231271694
|
||||
timeCreated: 1481126956
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,534 @@
|
||||
// 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( "Float", "Constants And Properties", "Float property", null, KeyCode.Alpha1 )]
|
||||
public sealed class RangedFloatNode : PropertyNode
|
||||
{
|
||||
private const int OriginalFontSize = 11;
|
||||
|
||||
private const string MinValueStr = "Min";
|
||||
private const string MaxValueStr = "Max";
|
||||
|
||||
private const float LabelWidth = 8;
|
||||
|
||||
[SerializeField]
|
||||
private float m_defaultValue = 0;
|
||||
|
||||
[SerializeField]
|
||||
private float m_materialValue = 0;
|
||||
|
||||
[SerializeField]
|
||||
private float m_min = 0;
|
||||
|
||||
[SerializeField]
|
||||
private float m_max = 0;
|
||||
|
||||
[SerializeField]
|
||||
private bool m_floatMode = true;
|
||||
|
||||
private int m_cachedPropertyId = -1;
|
||||
|
||||
private bool m_isEditingFields;
|
||||
private Vector3 m_previousValue = Vector3.zero;
|
||||
private string[] m_fieldText = new string[] { "0", "0", "0" };
|
||||
|
||||
public RangedFloatNode() : base() { }
|
||||
public RangedFloatNode( int uniqueId, float x, float y, float width, float height ) : base( uniqueId, x, y, width, height ) { }
|
||||
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
GlobalTypeWarningText = string.Format( GlobalTypeWarningText, "Float" );
|
||||
AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue );
|
||||
m_insideSize.Set( 50, 0 );
|
||||
m_showPreview = false;
|
||||
m_showHybridInstancedUI = true;
|
||||
m_selectedLocation = PreviewLocation.BottomCenter;
|
||||
m_availableAttribs.Add( new PropertyAttributes( "Toggle", "[Toggle]" ) );
|
||||
m_availableAttribs.Add( new PropertyAttributes( "No Keyword Toggle", "[ToggleUI]","[NoKeywordToggle]" ) );
|
||||
m_availableAttribs.Add( new PropertyAttributes( "Int Range", "[IntRange]" ) );
|
||||
m_availableAttribs.Add( new PropertyAttributes( "Enum", "[Enum]" ) );
|
||||
m_previewShaderGUID = "d9ca47581ac157145bff6f72ac5dd73e";
|
||||
m_srpBatcherCompatible = true;
|
||||
}
|
||||
|
||||
protected override void OnUniqueIDAssigned()
|
||||
{
|
||||
base.OnUniqueIDAssigned();
|
||||
UIUtils.RegisterFloatIntNode( this );
|
||||
}
|
||||
|
||||
public override void Destroy()
|
||||
{
|
||||
base.Destroy();
|
||||
UIUtils.UnregisterFloatIntNode( this );
|
||||
}
|
||||
|
||||
public override void OnDirtyProperty()
|
||||
{
|
||||
UIUtils.UpdateFloatIntDataNode( UniqueId, PropertyInspectorName );
|
||||
}
|
||||
|
||||
public override void RefreshExternalReferences()
|
||||
{
|
||||
base.RefreshExternalReferences();
|
||||
OnPropertyNameChanged();
|
||||
OnDirtyProperty();
|
||||
}
|
||||
|
||||
public void SetFloatMode( bool value )
|
||||
{
|
||||
if ( m_floatMode == value )
|
||||
return;
|
||||
|
||||
m_floatMode = value;
|
||||
if ( value )
|
||||
{
|
||||
m_insideSize.x = 50;// + ( m_showPreview ? 50 : 0 );
|
||||
//m_firstPreviewDraw = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_insideSize.x = 200;// + ( m_showPreview ? 0 : 0 );
|
||||
//m_firstPreviewDraw = true;
|
||||
}
|
||||
m_sizeIsDirty = true;
|
||||
}
|
||||
|
||||
public override void CopyDefaultsToMaterial()
|
||||
{
|
||||
m_materialValue = m_defaultValue;
|
||||
}
|
||||
|
||||
void DrawMinMaxUI()
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_min = EditorGUILayoutFloatField( MinValueStr, m_min );
|
||||
m_max = EditorGUILayoutFloatField( MaxValueStr, m_max );
|
||||
if ( m_min > m_max )
|
||||
m_min = m_max;
|
||||
|
||||
if ( m_max < m_min )
|
||||
m_max = m_min;
|
||||
|
||||
if ( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
SetFloatMode( m_min == m_max );
|
||||
}
|
||||
}
|
||||
public override void DrawSubProperties()
|
||||
{
|
||||
DrawMinMaxUI();
|
||||
|
||||
if ( m_floatMode )
|
||||
{
|
||||
m_defaultValue = EditorGUILayoutFloatField( Constants.DefaultValueLabel, m_defaultValue );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_defaultValue = EditorGUILayoutSlider( Constants.DefaultValueLabel, m_defaultValue, m_min, m_max );
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawMaterialProperties()
|
||||
{
|
||||
DrawMinMaxUI();
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
if ( m_floatMode )
|
||||
{
|
||||
m_materialValue = EditorGUILayoutFloatField( Constants.MaterialValueLabel, m_materialValue );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_materialValue = EditorGUILayoutSlider( Constants.MaterialValueLabel, m_materialValue, m_min, m_max );
|
||||
}
|
||||
if ( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
//MarkForPreviewUpdate();
|
||||
if ( m_materialMode )
|
||||
m_requireMaterialUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetPreviewInputs()
|
||||
{
|
||||
base.SetPreviewInputs();
|
||||
|
||||
if ( m_cachedPropertyId == -1 )
|
||||
m_cachedPropertyId = Shader.PropertyToID( "_InputFloat" );
|
||||
|
||||
if ( m_materialMode && m_currentParameterType != PropertyType.Constant )
|
||||
PreviewMaterial.SetFloat( m_cachedPropertyId, m_materialValue );
|
||||
else
|
||||
PreviewMaterial.SetFloat( m_cachedPropertyId, m_defaultValue );
|
||||
}
|
||||
|
||||
public override void OnNodeLayout( DrawInfo drawInfo )
|
||||
{
|
||||
base.OnNodeLayout( drawInfo );
|
||||
|
||||
if ( m_floatMode )
|
||||
{
|
||||
m_propertyDrawPos = m_remainingBox;
|
||||
m_propertyDrawPos.x = m_remainingBox.x - LabelWidth * drawInfo.InvertedZoom;
|
||||
m_propertyDrawPos.width = drawInfo.InvertedZoom * Constants.FLOAT_DRAW_WIDTH_FIELD_SIZE;
|
||||
m_propertyDrawPos.height = drawInfo.InvertedZoom * Constants.FLOAT_DRAW_HEIGHT_FIELD_SIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_propertyDrawPos = m_remainingBox;
|
||||
m_propertyDrawPos.width = m_outputPorts[ 0 ].Position.x - m_propertyDrawPos.x - (m_outputPorts[ 0 ].LabelSize.x + (Constants.PORT_TO_LABEL_SPACE_X + 3) * drawInfo.InvertedZoom + 2);
|
||||
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;
|
||||
}
|
||||
}
|
||||
void DrawFakeFloatMaterial( DrawInfo drawInfo )
|
||||
{
|
||||
if( m_floatMode )
|
||||
{
|
||||
//UIUtils.DrawFloat( this, ref m_propertyDrawPos, ref m_materialValue, LabelWidth * drawInfo.InvertedZoom );
|
||||
Rect fakeField = m_propertyDrawPos;
|
||||
fakeField.xMin += LabelWidth * drawInfo.InvertedZoom;
|
||||
if( GUI.enabled )
|
||||
{
|
||||
Rect fakeLabel = m_propertyDrawPos;
|
||||
fakeLabel.xMax = fakeField.xMin;
|
||||
EditorGUIUtility.AddCursorRect( fakeLabel, MouseCursor.SlideArrow );
|
||||
EditorGUIUtility.AddCursorRect( fakeField, MouseCursor.Text );
|
||||
}
|
||||
if( m_previousValue[ 0 ] != m_materialValue )
|
||||
{
|
||||
m_previousValue[ 0 ] = m_materialValue;
|
||||
m_fieldText[ 0 ] = m_materialValue.ToString();
|
||||
}
|
||||
|
||||
GUI.Label( fakeField, m_fieldText[ 0 ], UIUtils.MainSkin.textField );
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawFakeSlider( ref m_materialValue, drawInfo );
|
||||
}
|
||||
}
|
||||
|
||||
public override void Draw( DrawInfo drawInfo )
|
||||
{
|
||||
base.Draw( drawInfo );
|
||||
|
||||
if ( !m_isVisible )
|
||||
return;
|
||||
|
||||
if ( m_isEditingFields && m_currentParameterType != PropertyType.Global )
|
||||
{
|
||||
if ( m_materialMode && m_currentParameterType != PropertyType.Constant )
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
if ( m_floatMode )
|
||||
{
|
||||
UIUtils.DrawFloat( this, ref m_propertyDrawPos, ref m_materialValue, LabelWidth * drawInfo.InvertedZoom );
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawSlider( ref m_materialValue, drawInfo );
|
||||
}
|
||||
if ( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
PreviewIsDirty = true;
|
||||
m_requireMaterialUpdate = true;
|
||||
if ( m_currentParameterType != PropertyType.Constant )
|
||||
{
|
||||
BeginDelayedDirtyProperty();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
if ( m_floatMode )
|
||||
{
|
||||
UIUtils.DrawFloat( this, ref m_propertyDrawPos, ref m_defaultValue, LabelWidth * drawInfo.InvertedZoom );
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawSlider( ref m_defaultValue, drawInfo );
|
||||
}
|
||||
if ( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
PreviewIsDirty = true;
|
||||
BeginDelayedDirtyProperty();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if ( drawInfo.CurrentEventType == EventType.Repaint && ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD4 )
|
||||
{
|
||||
if( m_currentParameterType == PropertyType.Global )
|
||||
{
|
||||
bool guiEnabled = GUI.enabled;
|
||||
GUI.enabled = false;
|
||||
DrawFakeFloatMaterial( drawInfo );
|
||||
GUI.enabled = guiEnabled;
|
||||
}
|
||||
else if ( m_materialMode && m_currentParameterType != PropertyType.Constant )
|
||||
{
|
||||
DrawFakeFloatMaterial( drawInfo );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_floatMode )
|
||||
{
|
||||
//UIUtils.DrawFloat( this, ref m_propertyDrawPos, ref m_defaultValue, LabelWidth * drawInfo.InvertedZoom );
|
||||
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[ 0 ] != m_defaultValue )
|
||||
{
|
||||
m_previousValue[ 0 ] = m_defaultValue;
|
||||
m_fieldText[ 0 ] = m_defaultValue.ToString();
|
||||
}
|
||||
|
||||
GUI.Label( fakeField, m_fieldText[ 0 ], UIUtils.MainSkin.textField );
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawFakeSlider( ref m_defaultValue, drawInfo );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawFakeSlider( ref float value, DrawInfo drawInfo )
|
||||
{
|
||||
float rangeWidth = 30 * drawInfo.InvertedZoom;
|
||||
float rangeSpacing = 5 * drawInfo.InvertedZoom;
|
||||
|
||||
//Min
|
||||
Rect minRect = m_propertyDrawPos;
|
||||
minRect.width = rangeWidth;
|
||||
EditorGUIUtility.AddCursorRect( minRect, MouseCursor.Text );
|
||||
if ( m_previousValue[ 1 ] != m_min )
|
||||
{
|
||||
m_previousValue[ 1 ] = m_min;
|
||||
m_fieldText[ 1 ] = m_min.ToString();
|
||||
}
|
||||
GUI.Label( minRect, m_fieldText[ 1 ], UIUtils.MainSkin.textField );
|
||||
|
||||
//Value Area
|
||||
Rect valRect = m_propertyDrawPos;
|
||||
valRect.width = rangeWidth;
|
||||
valRect.x = m_propertyDrawPos.xMax - rangeWidth - rangeWidth - rangeSpacing;
|
||||
EditorGUIUtility.AddCursorRect( valRect, MouseCursor.Text );
|
||||
if ( m_previousValue[ 0 ] != value )
|
||||
{
|
||||
m_previousValue[ 0 ] = value;
|
||||
m_fieldText[ 0 ] = value.ToString();
|
||||
}
|
||||
GUI.Label( valRect, m_fieldText[ 0 ], UIUtils.MainSkin.textField );
|
||||
|
||||
//Max
|
||||
Rect maxRect = m_propertyDrawPos;
|
||||
maxRect.width = rangeWidth;
|
||||
maxRect.x = m_propertyDrawPos.xMax - rangeWidth;
|
||||
EditorGUIUtility.AddCursorRect( maxRect, MouseCursor.Text );
|
||||
if ( m_previousValue[ 2 ] != m_max )
|
||||
{
|
||||
m_previousValue[ 2 ] = m_max;
|
||||
m_fieldText[ 2 ] = m_max.ToString();
|
||||
}
|
||||
GUI.Label( maxRect, m_fieldText[ 2 ], UIUtils.MainSkin.textField );
|
||||
|
||||
Rect sliderValRect = m_propertyDrawPos;
|
||||
sliderValRect.x = minRect.xMax + rangeSpacing;
|
||||
sliderValRect.xMax = valRect.xMin - rangeSpacing;
|
||||
Rect sliderBackRect = sliderValRect;
|
||||
sliderBackRect.height = 5 * drawInfo.InvertedZoom;
|
||||
sliderBackRect.center = new Vector2( sliderValRect.center.x, Mathf.Round( sliderValRect.center.y ) );
|
||||
|
||||
|
||||
GUI.Label( sliderBackRect, string.Empty, UIUtils.GetCustomStyle( CustomStyle.SliderStyle ) );
|
||||
|
||||
sliderValRect.width = 10;
|
||||
float percent = ( value - m_min) / ( m_max-m_min );
|
||||
percent = Mathf.Clamp01( percent );
|
||||
sliderValRect.x += percent * (sliderBackRect.width - 10 * drawInfo.InvertedZoom );
|
||||
GUI.Label( sliderValRect, string.Empty, UIUtils.RangedFloatSliderThumbStyle );
|
||||
}
|
||||
|
||||
void DrawSlider( ref float value, DrawInfo drawInfo )
|
||||
{
|
||||
float rangeWidth = 30 * drawInfo.InvertedZoom;
|
||||
float rangeSpacing = 5 * drawInfo.InvertedZoom;
|
||||
|
||||
//Min
|
||||
Rect minRect = m_propertyDrawPos;
|
||||
minRect.width = rangeWidth;
|
||||
m_min = EditorGUIFloatField( minRect, m_min, UIUtils.MainSkin.textField );
|
||||
|
||||
//Value Area
|
||||
Rect valRect = m_propertyDrawPos;
|
||||
valRect.width = rangeWidth;
|
||||
valRect.x = m_propertyDrawPos.xMax - rangeWidth - rangeWidth - rangeSpacing;
|
||||
value = EditorGUIFloatField( valRect, value, UIUtils.MainSkin.textField );
|
||||
|
||||
//Max
|
||||
Rect maxRect = m_propertyDrawPos;
|
||||
maxRect.width = rangeWidth;
|
||||
maxRect.x = m_propertyDrawPos.xMax - rangeWidth;
|
||||
m_max = EditorGUIFloatField( maxRect, m_max, UIUtils.MainSkin.textField );
|
||||
|
||||
//Value Slider
|
||||
Rect sliderValRect = m_propertyDrawPos;
|
||||
sliderValRect.x = minRect.xMax + rangeSpacing;
|
||||
sliderValRect.xMax = valRect.xMin - rangeSpacing;
|
||||
Rect sliderBackRect = sliderValRect;
|
||||
sliderBackRect.height = 5 * drawInfo.InvertedZoom;
|
||||
sliderBackRect.center = new Vector2( sliderValRect.center.x, Mathf.Round( sliderValRect.center.y ));
|
||||
GUI.Label( sliderBackRect, string.Empty, UIUtils.GetCustomStyle( CustomStyle.SliderStyle ) );
|
||||
value = GUIHorizontalSlider( sliderValRect, value, m_min, m_max, GUIStyle.none, UIUtils.RangedFloatSliderThumbStyle );
|
||||
}
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
|
||||
m_precisionString = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_outputPorts[ 0 ].DataType );
|
||||
|
||||
if ( m_currentParameterType != PropertyType.Constant )
|
||||
return PropertyData( dataCollector.PortCategory );
|
||||
|
||||
return IOUtils.Floatify( m_defaultValue );
|
||||
}
|
||||
|
||||
public override string GetPropertyValue()
|
||||
{
|
||||
string value = UIUtils.PropertyFloatToString( m_defaultValue );
|
||||
if ( m_floatMode )
|
||||
{
|
||||
return PropertyAttributes + m_propertyName + "(\"" + m_propertyInspectorName + "\", Float) = " + value;
|
||||
}
|
||||
else
|
||||
{
|
||||
string min = UIUtils.PropertyFloatToString( m_min );
|
||||
string max = UIUtils.PropertyFloatToString( m_max );
|
||||
return PropertyAttributes + m_propertyName + "(\"" + m_propertyInspectorName + "\", Range( " + min + " , " + max + ")) = " + value;
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateMaterial( Material mat )
|
||||
{
|
||||
base.UpdateMaterial( mat );
|
||||
if ( UIUtils.IsProperty( m_currentParameterType ) && !InsideShaderFunction )
|
||||
{
|
||||
mat.SetFloat( m_propertyName, m_materialValue );
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetMaterialMode( Material mat , bool fetchMaterialValues )
|
||||
{
|
||||
base.SetMaterialMode( mat , fetchMaterialValues );
|
||||
if ( fetchMaterialValues && m_materialMode && UIUtils.IsProperty( m_currentParameterType ) && mat.HasProperty( m_propertyName ) )
|
||||
{
|
||||
m_materialValue = mat.GetFloat( m_propertyName );
|
||||
}
|
||||
}
|
||||
|
||||
public override void ForceUpdateFromMaterial( Material material )
|
||||
{
|
||||
if( UIUtils.IsProperty( m_currentParameterType ) && material.HasProperty( m_propertyName ) )
|
||||
{
|
||||
m_materialValue = material.GetFloat( m_propertyName );
|
||||
PreviewIsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void ReadFromString( ref string[] nodeParams )
|
||||
{
|
||||
base.ReadFromString( ref nodeParams );
|
||||
m_defaultValue = Convert.ToSingle( GetCurrentParam( ref nodeParams ) );
|
||||
if( UIUtils.CurrentShaderVersion() > 14101 )
|
||||
{
|
||||
m_materialValue = Convert.ToSingle( GetCurrentParam( ref nodeParams ) );
|
||||
}
|
||||
|
||||
m_min = Convert.ToSingle( GetCurrentParam( ref nodeParams ) );
|
||||
m_max = Convert.ToSingle( GetCurrentParam( ref nodeParams ) );
|
||||
SetFloatMode( m_min == m_max );
|
||||
}
|
||||
|
||||
public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
|
||||
{
|
||||
base.WriteToString( ref nodeInfo, ref connectionsInfo );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, m_defaultValue );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, m_materialValue );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, m_min );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, m_max );
|
||||
}
|
||||
|
||||
public override string GetPropertyValStr()
|
||||
{
|
||||
return ( m_materialMode && m_currentParameterType != PropertyType.Constant ) ?
|
||||
m_materialValue.ToString( Mathf.Abs( m_materialValue ) > 1000 ? Constants.PropertyBigFloatFormatLabel : Constants.PropertyFloatFormatLabel ) :
|
||||
m_defaultValue.ToString( Mathf.Abs( m_defaultValue ) > 1000 ? Constants.PropertyBigFloatFormatLabel : Constants.PropertyFloatFormatLabel );
|
||||
}
|
||||
|
||||
public override void SetGlobalValue() { Shader.SetGlobalFloat( m_propertyName, m_defaultValue ); }
|
||||
public override void FetchGlobalValue() { m_materialValue = Shader.GetGlobalFloat( m_propertyName ); }
|
||||
public float Value
|
||||
{
|
||||
get { return m_defaultValue; }
|
||||
set { m_defaultValue = value; }
|
||||
}
|
||||
|
||||
public void SetMaterialValueFromInline( float val )
|
||||
{
|
||||
m_materialValue = val;
|
||||
m_requireMaterialUpdate = true;
|
||||
}
|
||||
public override void GeneratePPSInfo( ref string propertyDeclaration, ref string propertySet )
|
||||
{
|
||||
string additionalHeaders = string.Empty;
|
||||
if( !m_floatMode )
|
||||
{
|
||||
additionalHeaders = string.Format( "Range( {0}, {1} ),", m_min, m_max );
|
||||
}
|
||||
propertyDeclaration += string.Format( ASEPPSHelperTool.PPSPropertyDecFormat, additionalHeaders, PropertyInspectorName,
|
||||
ASEPPSHelperTool.WireToPPSType[ WirePortDataType.FLOAT ], PropertyName, m_defaultValue );
|
||||
|
||||
propertySet += string.Format( ASEPPSHelperTool.PPSPropertySetFormat, "Float", PropertyName );
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/RangedFloatNode.cs.meta
generated
Normal file
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/RangedFloatNode.cs.meta
generated
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e81453c5ad3b8224db874b56bf00cad2
|
||||
timeCreated: 1481126960
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables.meta
generated
Normal file
9
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables.meta
generated
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 92f993d3ba8b1394eaf8c4fe308cab11
|
||||
folderAsset: yes
|
||||
timeCreated: 1481126946
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen.meta
generated
Normal file
9
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen.meta
generated
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c4b0845954941d4d9809abaa67bdc2b
|
||||
folderAsset: yes
|
||||
timeCreated: 1481126947
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,100 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
public enum BuiltInShaderCameraTypes
|
||||
{
|
||||
unity_CameraProjection = 0,
|
||||
unity_CameraInvProjection
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[NodeAttributes( "Projection Matrices", "Camera And Screen", "Camera's Projection/Inverse Projection matrix" )]
|
||||
public sealed class CameraProjectionNode : ShaderVariablesNode
|
||||
{
|
||||
private const string _projMatrixLabelStr = "Projection Matrix";
|
||||
private readonly string[] _projMatrixValuesStr = { "Camera Projection",
|
||||
"Inverse Camera Projection"};
|
||||
|
||||
|
||||
[SerializeField]
|
||||
private BuiltInShaderCameraTypes m_selectedType = BuiltInShaderCameraTypes.unity_CameraProjection;
|
||||
|
||||
private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper();
|
||||
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, _projMatrixValuesStr[ (int)m_selectedType ], WirePortDataType.FLOAT4x4 );
|
||||
m_textLabelWidth = 115;
|
||||
m_autoWrapProperties = true;
|
||||
m_hasLeftDropdown = true;
|
||||
}
|
||||
|
||||
public override void AfterCommonInit()
|
||||
{
|
||||
base.AfterCommonInit();
|
||||
if( PaddingTitleLeft == 0 )
|
||||
{
|
||||
PaddingTitleLeft = Constants.PropertyPickerWidth + Constants.IconsLeftRightMargin;
|
||||
if( PaddingTitleRight == 0 )
|
||||
PaddingTitleRight = Constants.PropertyPickerWidth + Constants.IconsLeftRightMargin;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Destroy()
|
||||
{
|
||||
base.Destroy();
|
||||
m_upperLeftWidget = null;
|
||||
}
|
||||
|
||||
public override void Draw( DrawInfo drawInfo )
|
||||
{
|
||||
base.Draw( drawInfo );
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_selectedType = (BuiltInShaderCameraTypes)m_upperLeftWidget.DrawWidget( this, (int)m_selectedType, _projMatrixValuesStr );
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
ChangeOutputName( 0, _projMatrixValuesStr[ (int)m_selectedType ] );
|
||||
SetSaveIsDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawProperties()
|
||||
{
|
||||
base.DrawProperties();
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_selectedType = (BuiltInShaderCameraTypes)EditorGUILayoutPopup( _projMatrixLabelStr, (int)m_selectedType, _projMatrixValuesStr );
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
ChangeOutputName( 0, _projMatrixValuesStr[ (int)m_selectedType ] );
|
||||
SetSaveIsDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
|
||||
GeneratorUtils.RegisterUnity2019MatrixDefines( ref dataCollector );
|
||||
return m_selectedType.ToString();
|
||||
}
|
||||
|
||||
public override void ReadFromString( ref string[] nodeParams )
|
||||
{
|
||||
base.ReadFromString( ref nodeParams );
|
||||
m_selectedType = (BuiltInShaderCameraTypes)Enum.Parse( typeof( BuiltInShaderCameraTypes ), GetCurrentParam( ref nodeParams ) );
|
||||
ChangeOutputName( 0, _projMatrixValuesStr[ (int)m_selectedType ] );
|
||||
}
|
||||
|
||||
public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
|
||||
{
|
||||
base.WriteToString( ref nodeInfo, ref connectionsInfo );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedType );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f776bdd36b750304c8e0de8ee1f31fc0
|
||||
timeCreated: 1481126960
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,130 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
public enum BuiltInShaderClipPlanesTypes
|
||||
{
|
||||
Left = 0,
|
||||
Right,
|
||||
Bottom,
|
||||
Top,
|
||||
Near,
|
||||
Far
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[NodeAttributes( "Clip Planes", "Camera And Screen", "Camera World Clip Planes" )]
|
||||
public sealed class CameraWorldClipPlanes : ShaderVariablesNode
|
||||
{
|
||||
[SerializeField]
|
||||
private BuiltInShaderClipPlanesTypes m_selectedType = BuiltInShaderClipPlanesTypes.Left;
|
||||
|
||||
private const string LabelStr = "Plane";
|
||||
|
||||
private const string ValueStr = "unity_CameraWorldClipPlanes";//L,R,B,T,N,F
|
||||
|
||||
private const string ValueHDRPStr = "_FrustumPlanes";// L,R,T,B,N,F
|
||||
|
||||
private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper();
|
||||
private int m_planeId;
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "ABCD", WirePortDataType.FLOAT4 );
|
||||
m_textLabelWidth = 55;
|
||||
m_autoWrapProperties = true;
|
||||
m_hasLeftDropdown = true;
|
||||
SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, m_selectedType ) );
|
||||
m_previewShaderGUID = "6afe5a4ad7bbd0e4ab352c758f543a09";
|
||||
}
|
||||
|
||||
public override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
m_planeId = Shader.PropertyToID( "_PlaneId" );
|
||||
}
|
||||
|
||||
public override void AfterCommonInit()
|
||||
{
|
||||
base.AfterCommonInit();
|
||||
if( PaddingTitleLeft == 0 )
|
||||
{
|
||||
PaddingTitleLeft = Constants.PropertyPickerWidth + Constants.IconsLeftRightMargin;
|
||||
if( PaddingTitleRight == 0 )
|
||||
PaddingTitleRight = Constants.PropertyPickerWidth + Constants.IconsLeftRightMargin;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Destroy()
|
||||
{
|
||||
base.Destroy();
|
||||
m_upperLeftWidget = null;
|
||||
}
|
||||
|
||||
public override void Draw( DrawInfo drawInfo )
|
||||
{
|
||||
base.Draw( drawInfo );
|
||||
m_upperLeftWidget.DrawWidget<BuiltInShaderClipPlanesTypes>(ref m_selectedType, this, OnWidgetUpdate );
|
||||
}
|
||||
|
||||
private readonly Action<ParentNode> OnWidgetUpdate = ( x ) => {
|
||||
x.SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, ( x as CameraWorldClipPlanes ).Type ) );
|
||||
};
|
||||
|
||||
public BuiltInShaderClipPlanesTypes Type { get { return m_selectedType; } }
|
||||
|
||||
public override void DrawProperties()
|
||||
{
|
||||
base.DrawProperties();
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_selectedType = ( BuiltInShaderClipPlanesTypes ) EditorGUILayoutEnumPopup( LabelStr, m_selectedType );
|
||||
if ( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, m_selectedType ) );
|
||||
SetSaveIsDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetPreviewInputs()
|
||||
{
|
||||
base.SetPreviewInputs();
|
||||
PreviewMaterial.SetInt( m_planeId, (int)m_selectedType );
|
||||
}
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
|
||||
if( dataCollector.TemplateDataCollectorInstance.IsHDRP )
|
||||
{
|
||||
switch( m_selectedType )
|
||||
{
|
||||
case BuiltInShaderClipPlanesTypes.Left: return ValueHDRPStr + "[0]";
|
||||
case BuiltInShaderClipPlanesTypes.Right: return ValueHDRPStr + "[1]";
|
||||
case BuiltInShaderClipPlanesTypes.Bottom: return ValueHDRPStr + "[3]";
|
||||
case BuiltInShaderClipPlanesTypes.Top: return ValueHDRPStr + "[2]";
|
||||
case BuiltInShaderClipPlanesTypes.Near: return ValueHDRPStr + "[4]";
|
||||
case BuiltInShaderClipPlanesTypes.Far: return ValueHDRPStr + "[5]";
|
||||
}
|
||||
}
|
||||
return ValueStr + "[" + ( int ) m_selectedType + "]";
|
||||
}
|
||||
|
||||
public override void ReadFromString( ref string[] nodeParams )
|
||||
{
|
||||
base.ReadFromString( ref nodeParams );
|
||||
m_selectedType = ( BuiltInShaderClipPlanesTypes ) Enum.Parse( typeof( BuiltInShaderClipPlanesTypes ), GetCurrentParam( ref nodeParams ) );
|
||||
SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, m_selectedType ) );
|
||||
}
|
||||
|
||||
public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
|
||||
{
|
||||
base.WriteToString( ref nodeInfo, ref connectionsInfo );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedType );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5a9a010f1c8dda449c8ca7ee9e25869
|
||||
timeCreated: 1481126959
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,38 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using System;
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[Serializable]
|
||||
[NodeAttributes( "Ortho Params", "Camera And Screen", "Orthographic Parameters" )]
|
||||
public sealed class OrthoParams : ConstVecShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputName( 1, "Ortho Cam Width" );
|
||||
ChangeOutputName( 2, "Ortho Cam Height" );
|
||||
ChangeOutputName( 3, "Unused" );
|
||||
ChangeOutputName( 4, "Projection Mode" );
|
||||
m_value = "unity_OrthoParams";
|
||||
m_previewShaderGUID = "88a910ece3dce224793e669bb1bc158d";
|
||||
}
|
||||
|
||||
public override void RefreshExternalReferences()
|
||||
{
|
||||
base.RefreshExternalReferences();
|
||||
if( !m_outputPorts[ 0 ].IsConnected )
|
||||
{
|
||||
m_outputPorts[ 0 ].Visible = false;
|
||||
m_sizeIsDirty = true;
|
||||
}
|
||||
|
||||
if( !m_outputPorts[ 3 ].IsConnected )
|
||||
{
|
||||
m_outputPorts[ 3 ].Visible = false;
|
||||
m_sizeIsDirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9431cdf8e81c1d4f902b3fa7d04f7ac
|
||||
timeCreated: 1481126960
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -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( "Projection Params", "Camera And Screen", "Projection Near/Far parameters" )]
|
||||
public sealed class ProjectionParams : ConstVecShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputName( 1, "Flipped" );
|
||||
ChangeOutputName( 2, "Near Plane" );
|
||||
ChangeOutputName( 3, "Far Plane" );
|
||||
ChangeOutputName( 4, "1/Far Plane" );
|
||||
m_value = "_ProjectionParams";
|
||||
m_previewShaderGUID = "97ae846cb0a6b044388fad3bc03bb4c2";
|
||||
}
|
||||
|
||||
public override void RefreshExternalReferences()
|
||||
{
|
||||
base.RefreshExternalReferences();
|
||||
if( !m_outputPorts[ 0 ].IsConnected )
|
||||
{
|
||||
m_outputPorts[ 0 ].Visible = false;
|
||||
m_sizeIsDirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba1ca8bace2c2dd4dafac6f73f4dfb1b
|
||||
timeCreated: 1481126958
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -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( "Screen Params", "Camera And Screen", "Camera's Render Target size parameters" )]
|
||||
public sealed class ScreenParams : ConstVecShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputName( 1, "RT Width" );
|
||||
ChangeOutputName( 2, "RT Height" );
|
||||
ChangeOutputName( 3, "1+1/Width" );
|
||||
ChangeOutputName( 4, "1+1/Height" );
|
||||
m_value = "_ScreenParams";
|
||||
m_previewShaderGUID = "78173633b803de4419206191fed3d61e";
|
||||
}
|
||||
|
||||
//public override void RefreshExternalReferences()
|
||||
//{
|
||||
// base.RefreshExternalReferences();
|
||||
// if( !m_outputPorts[ 0 ].IsConnected )
|
||||
// {
|
||||
// m_outputPorts[ 0 ].Visible = false;
|
||||
// m_sizeIsDirty = true;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e593f23857d59643b5b5f6dd6264e1b
|
||||
timeCreated: 1481126954
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,28 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using System;
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[Serializable]
|
||||
[NodeAttributes( "World Space Camera Pos", "Camera And Screen", "World Space Camera position" )]
|
||||
public sealed class WorldSpaceCameraPos : ConstantShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "XYZ", WirePortDataType.FLOAT3 );
|
||||
AddOutputPort( WirePortDataType.FLOAT, "X" );
|
||||
AddOutputPort( WirePortDataType.FLOAT, "Y" );
|
||||
AddOutputPort( WirePortDataType.FLOAT, "Z" );
|
||||
|
||||
m_value = "_WorldSpaceCameraPos";
|
||||
m_previewShaderGUID = "6b0c78411043dd24dac1152c84bb63ba";
|
||||
}
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
return GetOutputVectorItem( 0, outputId, base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 972d92a6008896f4292a61726e18f667
|
||||
timeCreated: 1481126957
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,31 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using System;
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[Serializable]
|
||||
[NodeAttributes( "Z-Buffer Params", "Camera And Screen", "Linearized Z buffer values" )]
|
||||
public sealed class ZBufferParams : ConstVecShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputName( 1, "1-far/near" );
|
||||
ChangeOutputName( 2, "far/near" );
|
||||
ChangeOutputName( 3, "[0]/far" );
|
||||
ChangeOutputName( 4, "[1]/far" );
|
||||
m_value = "_ZBufferParams";
|
||||
m_previewShaderGUID = "56c42c106bcb497439187f5bb6b6f94d";
|
||||
}
|
||||
public override void RefreshExternalReferences()
|
||||
{
|
||||
base.RefreshExternalReferences();
|
||||
if( !m_outputPorts[ 0 ].IsConnected )
|
||||
{
|
||||
m_outputPorts[ 0 ].Visible = false;
|
||||
m_sizeIsDirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2765a41106f478f4982e859b978bdec4
|
||||
timeCreated: 1481126954
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,39 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using UnityEngine;
|
||||
using System;
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[Serializable]
|
||||
public class ConstVecShaderVariable : ShaderVariablesNode
|
||||
{
|
||||
[SerializeField]
|
||||
protected string m_value;
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, " ", WirePortDataType.FLOAT4 );
|
||||
AddOutputPort( WirePortDataType.FLOAT, "0" );
|
||||
AddOutputPort( WirePortDataType.FLOAT, "1" );
|
||||
AddOutputPort( WirePortDataType.FLOAT, "2" );
|
||||
AddOutputPort( WirePortDataType.FLOAT, "3" );
|
||||
}
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
|
||||
switch ( outputId )
|
||||
{
|
||||
case 0: return m_value;
|
||||
case 1: return ( m_value + ".x" );
|
||||
case 2: return ( m_value + ".y" );
|
||||
case 3: return ( m_value + ".z" );
|
||||
case 4: return ( m_value + ".w" );
|
||||
}
|
||||
|
||||
UIUtils.ShowMessage( UniqueId, "ConstVecShaderVariable generating empty code", MessageSeverity.Warning );
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9102c0b554fd5ad4785acf870dcc17eb
|
||||
timeCreated: 1481126957
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -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]
|
||||
public class ConstantShaderVariable : ShaderVariablesNode
|
||||
{
|
||||
[SerializeField]
|
||||
protected string m_value;
|
||||
|
||||
[SerializeField]
|
||||
protected string m_valueHDRP = string.Empty;
|
||||
|
||||
[SerializeField]
|
||||
protected string m_valueURP = string.Empty;
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
|
||||
if( dataCollector.IsTemplate )
|
||||
{
|
||||
if( dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HDRP && !string.IsNullOrEmpty( m_valueHDRP ) )
|
||||
return m_valueHDRP;
|
||||
|
||||
if( dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.URP && !string.IsNullOrEmpty( m_valueURP ))
|
||||
return m_valueURP;
|
||||
}
|
||||
return m_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 266391c3c4308014e9ce246e5484b917
|
||||
timeCreated: 1481126954
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient.meta
generated
Normal file
9
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient.meta
generated
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 78eb7b1e34d423c40a949c9e75b5f24a
|
||||
folderAsset: yes
|
||||
timeCreated: 1481126946
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,126 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
public enum BuiltInFogAndAmbientColors
|
||||
{
|
||||
UNITY_LIGHTMODEL_AMBIENT = 0,
|
||||
unity_AmbientSky,
|
||||
unity_AmbientEquator,
|
||||
unity_AmbientGround,
|
||||
unity_FogColor
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[NodeAttributes( "Fog And Ambient Colors", "Lighting", "Fog and Ambient colors" )]
|
||||
public sealed class FogAndAmbientColorsNode : ShaderVariablesNode
|
||||
{
|
||||
private const string ColorLabelStr = "Color";
|
||||
private readonly string[] ColorValuesStr = {
|
||||
"Ambient light ( Legacy )",
|
||||
"Sky ambient light",
|
||||
"Equator ambient light",
|
||||
"Ground ambient light",
|
||||
"Fog"
|
||||
};
|
||||
|
||||
[SerializeField]
|
||||
private BuiltInFogAndAmbientColors m_selectedType = BuiltInFogAndAmbientColors.UNITY_LIGHTMODEL_AMBIENT;
|
||||
|
||||
private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper();
|
||||
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, ColorValuesStr[ ( int ) m_selectedType ], WirePortDataType.COLOR );
|
||||
m_textLabelWidth = 50;
|
||||
m_autoWrapProperties = true;
|
||||
m_hasLeftDropdown = true;
|
||||
m_previewShaderGUID = "937c7bde062f0f942b600d9950d2ebb2";
|
||||
}
|
||||
|
||||
public override void AfterCommonInit()
|
||||
{
|
||||
base.AfterCommonInit();
|
||||
if( PaddingTitleLeft == 0 )
|
||||
{
|
||||
PaddingTitleLeft = Constants.PropertyPickerWidth + Constants.IconsLeftRightMargin;
|
||||
if( PaddingTitleRight == 0 )
|
||||
PaddingTitleRight = Constants.PropertyPickerWidth + Constants.IconsLeftRightMargin;
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetPreviewInputs()
|
||||
{
|
||||
base.SetPreviewInputs();
|
||||
m_previewMaterialPassId = (int)m_selectedType;
|
||||
}
|
||||
|
||||
public override void Destroy()
|
||||
{
|
||||
base.Destroy();
|
||||
m_upperLeftWidget = null;
|
||||
}
|
||||
|
||||
public override void Draw( DrawInfo drawInfo )
|
||||
{
|
||||
base.Draw( drawInfo );
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_selectedType = (BuiltInFogAndAmbientColors)m_upperLeftWidget.DrawWidget( this, (int)m_selectedType, ColorValuesStr );
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
ChangeOutputName( 0, ColorValuesStr[ (int)m_selectedType ] );
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawProperties()
|
||||
{
|
||||
base.DrawProperties();
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_selectedType = ( BuiltInFogAndAmbientColors ) EditorGUILayoutPopup( ColorLabelStr, ( int ) m_selectedType, ColorValuesStr );
|
||||
|
||||
if ( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
ChangeOutputName( 0, ColorValuesStr[ ( int ) m_selectedType ] );
|
||||
}
|
||||
}
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
|
||||
if( dataCollector.IsTemplate && dataCollector.CurrentSRPType == TemplateSRPType.HDRP )
|
||||
{
|
||||
switch( m_selectedType )
|
||||
{
|
||||
case BuiltInFogAndAmbientColors.unity_AmbientSky:
|
||||
return "_Ambient_ColorSky";
|
||||
case BuiltInFogAndAmbientColors.unity_AmbientEquator:
|
||||
return "_Ambient_Equator";
|
||||
case BuiltInFogAndAmbientColors.unity_AmbientGround:
|
||||
return "_Ambient_Ground";
|
||||
case BuiltInFogAndAmbientColors.unity_FogColor:
|
||||
return "_FogColor";
|
||||
}
|
||||
}
|
||||
return m_selectedType.ToString();
|
||||
}
|
||||
|
||||
public override void ReadFromString( ref string[] nodeParams )
|
||||
{
|
||||
base.ReadFromString( ref nodeParams );
|
||||
m_selectedType = ( BuiltInFogAndAmbientColors ) Enum.Parse( typeof( BuiltInFogAndAmbientColors ), GetCurrentParam( ref nodeParams ) );
|
||||
ChangeOutputName( 0, ColorValuesStr[ ( int ) m_selectedType ] );
|
||||
}
|
||||
|
||||
public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
|
||||
{
|
||||
base.WriteToString( ref nodeInfo, ref connectionsInfo );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedType );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2bdfc2fa6fcd0640b01a8b7448a1a11
|
||||
timeCreated: 1481126959
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -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( "Fog Params", "Lighting", "Parameters for fog calculation" )]
|
||||
public sealed class FogParamsNode : ConstVecShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputName( 1, "Density/Sqrt(Ln(2))" );
|
||||
ChangeOutputName( 2, "Density/Ln(2)" );
|
||||
ChangeOutputName( 3, "-1/(End-Start)" );
|
||||
ChangeOutputName( 4, "End/(End-Start))" );
|
||||
m_value = "unity_FogParams";
|
||||
m_previewShaderGUID = "42abde3281b1848438c3b53443c91a1e";
|
||||
}
|
||||
|
||||
public override void RefreshExternalReferences()
|
||||
{
|
||||
base.RefreshExternalReferences();
|
||||
if( !m_outputPorts[ 0 ].IsConnected )
|
||||
{
|
||||
m_outputPorts[ 0 ].Visible = false;
|
||||
m_sizeIsDirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3d8c31159e07bc419a7484ab5e894ed
|
||||
timeCreated: 1481126958
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting.meta
generated
Normal file
9
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting.meta
generated
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 47f503bcb5935b649beee3296dd40260
|
||||
folderAsset: yes
|
||||
timeCreated: 1481126946
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,208 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
|
||||
public enum ASEStandardSurfaceWorkflow
|
||||
{
|
||||
Metallic = 0,
|
||||
Specular
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[NodeAttributes( "Standard Surface Light", "Lighting", "Provides a way to create a standard surface light model in custom lighting mode", NodeAvailabilityFlags = (int)NodeAvailability.CustomLighting )]
|
||||
public sealed class CustomStandardSurface : ParentNode
|
||||
{
|
||||
private const string WorkflowStr = "Workflow";
|
||||
|
||||
[SerializeField]
|
||||
private ASEStandardSurfaceWorkflow m_workflow = ASEStandardSurfaceWorkflow.Metallic;
|
||||
|
||||
[SerializeField]
|
||||
private ViewSpace m_normalSpace = ViewSpace.Tangent;
|
||||
|
||||
[SerializeField]
|
||||
private bool m_normalize = true;
|
||||
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
AddInputPort( WirePortDataType.FLOAT3, false, "Albedo" );
|
||||
AddInputPort( WirePortDataType.FLOAT3, false, "Normal" );
|
||||
m_inputPorts[ 1 ].Vector3InternalData = Vector3.forward;
|
||||
AddInputPort( WirePortDataType.FLOAT3, false, "Emission" );
|
||||
AddInputPort( WirePortDataType.FLOAT, false, "Metallic" );
|
||||
AddInputPort( WirePortDataType.FLOAT, false, "Smoothness" );
|
||||
AddInputPort( WirePortDataType.FLOAT, false, "Occlusion" );
|
||||
m_inputPorts[ 5 ].FloatInternalData = 1;
|
||||
AddOutputPort( WirePortDataType.FLOAT3, "RGB" );
|
||||
m_autoWrapProperties = true;
|
||||
m_textLabelWidth = 100;
|
||||
m_errorMessageTypeIsError = NodeMessageType.Warning;
|
||||
m_errorMessageTooltip = "This node only returns correct information using a custom light model, otherwise returns 0";
|
||||
}
|
||||
|
||||
public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector )
|
||||
{
|
||||
base.PropagateNodeData( nodeData, ref dataCollector );
|
||||
if( m_inputPorts[ 1 ].IsConnected && m_normalSpace == ViewSpace.Tangent )
|
||||
dataCollector.DirtyNormal = true;
|
||||
}
|
||||
|
||||
public override void DrawProperties()
|
||||
{
|
||||
base.DrawProperties();
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_workflow = (ASEStandardSurfaceWorkflow)EditorGUILayoutEnumPopup( WorkflowStr, m_workflow );
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
UpdateSpecularMetallicPorts();
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_normalSpace = (ViewSpace)EditorGUILayoutEnumPopup( "Normal Space", m_normalSpace );
|
||||
if( m_normalSpace != ViewSpace.World || !m_inputPorts[ 1 ].IsConnected )
|
||||
{
|
||||
m_normalize = EditorGUILayoutToggle("Normalize", m_normalize);
|
||||
}
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
UpdatePort();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdatePort()
|
||||
{
|
||||
if( m_normalSpace == ViewSpace.World )
|
||||
m_inputPorts[ 1 ].Name = "World Normal";
|
||||
else
|
||||
m_inputPorts[ 1 ].Name = "Normal";
|
||||
|
||||
m_sizeIsDirty = true;
|
||||
}
|
||||
|
||||
void UpdateSpecularMetallicPorts()
|
||||
{
|
||||
if( m_workflow == ASEStandardSurfaceWorkflow.Specular )
|
||||
m_inputPorts[ 3 ].ChangeProperties( "Specular", WirePortDataType.FLOAT3, false );
|
||||
else
|
||||
m_inputPorts[ 3 ].ChangeProperties( "Metallic", WirePortDataType.FLOAT, false );
|
||||
}
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
if( dataCollector.GenType == PortGenType.NonCustomLighting || dataCollector.CurrentCanvasMode != NodeAvailability.CustomLighting )
|
||||
return "float3(0,0,0)";
|
||||
|
||||
if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
|
||||
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
|
||||
|
||||
string specularMode = string.Empty;
|
||||
if( m_workflow == ASEStandardSurfaceWorkflow.Specular )
|
||||
specularMode = "Specular";
|
||||
|
||||
dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, UIUtils.CurrentWindow.CurrentGraph.CurrentPrecision );
|
||||
|
||||
if( dataCollector.DirtyNormal )
|
||||
{
|
||||
dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false );
|
||||
dataCollector.ForceNormal = true;
|
||||
}
|
||||
|
||||
dataCollector.AddLocalVariable( UniqueId, "SurfaceOutputStandard" + specularMode + " s" + OutputId + " = (SurfaceOutputStandard" + specularMode + " ) 0;" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "s" + OutputId + ".Albedo = " + m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ) + ";" );
|
||||
|
||||
string normal = string.Empty;
|
||||
|
||||
if( m_inputPorts[ 1 ].IsConnected )
|
||||
{
|
||||
normal = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector );
|
||||
if( m_normalSpace == ViewSpace.Tangent )
|
||||
{
|
||||
normal = "WorldNormalVector( " + Constants.InputVarStr + " , " + normal + " )";
|
||||
if( m_normalize )
|
||||
{
|
||||
normal = "normalize( " + normal + " )";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
normal = GeneratorUtils.GenerateWorldNormal( ref dataCollector, UniqueId, m_normalize );
|
||||
}
|
||||
|
||||
|
||||
|
||||
dataCollector.AddLocalVariable( UniqueId, "s" + OutputId + ".Normal = "+ normal + ";" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "s" + OutputId + ".Emission = " + m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ) + ";" );
|
||||
if( m_workflow == ASEStandardSurfaceWorkflow.Specular )
|
||||
dataCollector.AddLocalVariable( UniqueId, "s" + OutputId + ".Specular = " + m_inputPorts[ 3 ].GeneratePortInstructions( ref dataCollector ) + ";" );
|
||||
else
|
||||
dataCollector.AddLocalVariable( UniqueId, "s" + OutputId + ".Metallic = " + m_inputPorts[ 3 ].GeneratePortInstructions( ref dataCollector ) + ";" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "s" + OutputId + ".Smoothness = " + m_inputPorts[ 4 ].GeneratePortInstructions( ref dataCollector ) + ";" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "s" + OutputId + ".Occlusion = " + m_inputPorts[ 5 ].GeneratePortInstructions( ref dataCollector ) + ";\n" );
|
||||
|
||||
dataCollector.AddLocalVariable( UniqueId, "data.light = gi.light;\n", true );
|
||||
|
||||
dataCollector.AddLocalVariable( UniqueId, "UnityGI gi" + OutputId + " = gi;" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "#ifdef UNITY_PASS_FORWARDBASE", true );
|
||||
|
||||
dataCollector.AddLocalVariable( UniqueId, "Unity_GlossyEnvironmentData g" + OutputId + " = UnityGlossyEnvironmentSetup( s" + OutputId + ".Smoothness, data.worldViewDir, s" + OutputId + ".Normal, float3(0,0,0));" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "gi" + OutputId + " = UnityGlobalIllumination( data, s" + OutputId + ".Occlusion, s" + OutputId + ".Normal, g" + OutputId + " );" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "#endif\n", true );
|
||||
dataCollector.AddLocalVariable( UniqueId, "float3 surfResult" + OutputId + " = LightingStandard" + specularMode + " ( s" + OutputId + ", viewDir, gi" + OutputId + " ).rgb;" );
|
||||
//Emission must be always added to trick Unity, so it knows what needs to be created p.e. world pos
|
||||
dataCollector.AddLocalVariable( UniqueId, "surfResult" + OutputId + " += s" + OutputId + ".Emission;\n" );
|
||||
|
||||
m_outputPorts[ 0 ].SetLocalValue( "surfResult" + OutputId, dataCollector.PortCategory );
|
||||
|
||||
//Remove emission contribution from Forward Add
|
||||
dataCollector.AddLocalVariable( UniqueId, "#ifdef UNITY_PASS_FORWARDADD//" + OutputId );
|
||||
dataCollector.AddLocalVariable( UniqueId, string.Format( "surfResult{0} -= s{0}.Emission;", OutputId ));
|
||||
dataCollector.AddLocalVariable( UniqueId, "#endif//" + OutputId );
|
||||
|
||||
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
|
||||
}
|
||||
|
||||
public override void Draw( DrawInfo drawInfo )
|
||||
{
|
||||
base.Draw( drawInfo );
|
||||
if( ContainerGraph.CurrentCanvasMode == NodeAvailability.TemplateShader || ( ContainerGraph.CurrentStandardSurface != null && ContainerGraph.CurrentStandardSurface.CurrentLightingModel != StandardShaderLightModel.CustomLighting ) )
|
||||
m_showErrorMessage = true;
|
||||
else
|
||||
m_showErrorMessage = false;
|
||||
}
|
||||
|
||||
public override void ReadFromString( ref string[] nodeParams )
|
||||
{
|
||||
base.ReadFromString( ref nodeParams );
|
||||
if( UIUtils.CurrentShaderVersion() < 13204 )
|
||||
{
|
||||
m_workflow = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ) ? ASEStandardSurfaceWorkflow.Specular : ASEStandardSurfaceWorkflow.Metallic;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_workflow = (ASEStandardSurfaceWorkflow)Enum.Parse( typeof( ASEStandardSurfaceWorkflow ), GetCurrentParam( ref nodeParams ) );
|
||||
}
|
||||
UpdateSpecularMetallicPorts();
|
||||
|
||||
if( UIUtils.CurrentShaderVersion() >= 14402 )
|
||||
{
|
||||
m_normalSpace = (ViewSpace)Enum.Parse( typeof( ViewSpace ), GetCurrentParam( ref nodeParams ) );
|
||||
}
|
||||
UpdatePort();
|
||||
}
|
||||
|
||||
public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
|
||||
{
|
||||
base.WriteToString( ref nodeInfo, ref connectionsInfo );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, m_workflow );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, m_normalSpace );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 78916999fd7bc3c4e9767bc9cf0698c0
|
||||
timeCreated: 1500054866
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,484 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[Serializable]
|
||||
[NodeAttributes( "Indirect Diffuse Light", "Lighting", "Indirect Lighting", NodeAvailabilityFlags = (int)( NodeAvailability.CustomLighting | NodeAvailability.TemplateShader ) )]
|
||||
public sealed class IndirectDiffuseLighting : ParentNode
|
||||
{
|
||||
[SerializeField]
|
||||
private ViewSpace m_normalSpace = ViewSpace.Tangent;
|
||||
[SerializeField]
|
||||
private bool m_normalize = true;
|
||||
|
||||
private int m_cachedIntensityId = -1;
|
||||
|
||||
private const string FwdBasePragma = "#pragma multi_compile_fwdbase";
|
||||
|
||||
private readonly string IndirectDiffuseHeaderURP10 = "ASEIndirectDiffuse( {0}, {1} )";
|
||||
private readonly string[] IndirectDiffuseBodyURP10 =
|
||||
{
|
||||
"half3 ASEIndirectDiffuse( PackedVaryings input, half3 normalWS, float3 positionWS = 0, half3 viewDirWS = 0 )\n",
|
||||
"{\n",
|
||||
"#if defined( LIGHTMAP_ON )\n",
|
||||
"\treturn SampleLightmap( input.lightmapUVOrVertexSH.xy, normalWS );\n",
|
||||
"#else\n",
|
||||
"\treturn SampleSH( normalWS );\n",
|
||||
"#endif\n",
|
||||
"}\n"
|
||||
};
|
||||
|
||||
private readonly string IndirectDiffuseHeaderURP12 = "ASEIndirectDiffuse( {0}, {1} )";
|
||||
private readonly string[] IndirectDiffuseBodyURP12 =
|
||||
{
|
||||
"half3 ASEIndirectDiffuse( PackedVaryings input, half3 normalWS, float3 positionWS = 0, half3 viewDirWS = 0 )\n",
|
||||
"{\n",
|
||||
"#if defined( DYNAMICLIGHTMAP_ON )\n",
|
||||
"\treturn SAMPLE_GI( input.lightmapUVOrVertexSH.xy, input.dynamicLightmapUV.xy, 0, normalWS );\n",
|
||||
"#elif defined( LIGHTMAP_ON )\n",
|
||||
"\treturn SAMPLE_GI( input.lightmapUVOrVertexSH.xy, 0, normalWS );\n",
|
||||
"#else\n",
|
||||
"\treturn SampleSH( normalWS );\n",
|
||||
"#endif\n",
|
||||
"}\n"
|
||||
};
|
||||
|
||||
private readonly string IndirectDiffuseHeaderURP15 = "ASEIndirectDiffuse( {0}, {1}, {2}, {3} )";
|
||||
private readonly string[] IndirectDiffuseBodyURP15 =
|
||||
{
|
||||
"half3 ASEIndirectDiffuse( PackedVaryings input, half3 normalWS, float3 positionWS, half3 viewDirWS )\n",
|
||||
"{\n",
|
||||
"#if defined( DYNAMICLIGHTMAP_ON )\n",
|
||||
"\treturn SAMPLE_GI( input.lightmapUVOrVertexSH.xy, input.dynamicLightmapUV.xy, 0, normalWS );\n",
|
||||
"#elif defined( LIGHTMAP_ON )\n",
|
||||
"\treturn SAMPLE_GI( input.lightmapUVOrVertexSH.xy, 0, normalWS );\n",
|
||||
"#elif defined( PROBE_VOLUMES_L1 ) || defined( PROBE_VOLUMES_L2 )\n",
|
||||
"\return SAMPLE_GI( SampleSH( normalWS ), positionWS, normalWS, viewDirWS, input.positionCS.xy );\n",
|
||||
"#else\n",
|
||||
"\treturn SampleSH( normalWS );\n",
|
||||
"#endif\n",
|
||||
"}\n"
|
||||
};
|
||||
|
||||
private readonly string IndirectDiffuseHeaderURP17 = "ASEIndirectDiffuse( {0}, {1}, {2}, {3} )";
|
||||
private readonly string[] IndirectDiffuseBodyURP17 =
|
||||
{
|
||||
"half3 ASEIndirectDiffuse( PackedVaryings input, half3 normalWS, float3 positionWS, half3 viewDirWS )\n",
|
||||
"{\n",
|
||||
"#if defined( DYNAMICLIGHTMAP_ON )\n",
|
||||
"\treturn SAMPLE_GI( input.lightmapUVOrVertexSH.xy, input.dynamicLightmapUV.xy, 0, normalWS );\n",
|
||||
"#elif defined( LIGHTMAP_ON )\n",
|
||||
"\treturn SAMPLE_GI( input.lightmapUVOrVertexSH.xy, 0, normalWS );\n",
|
||||
"#elif defined( PROBE_VOLUMES_L1 ) || defined( PROBE_VOLUMES_L2 )\n",
|
||||
"\return SampleProbeVolumePixel( SampleSH( normalWS ), positionWS, normalWS, viewDirWS, input.positionCS.xy );\n",
|
||||
"#else\n",
|
||||
"\treturn SampleSH( normalWS );\n",
|
||||
"#endif\n",
|
||||
"}\n"
|
||||
};
|
||||
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
AddInputPort( WirePortDataType.FLOAT3, false, "Normal" );
|
||||
AddOutputPort( WirePortDataType.FLOAT3, "RGB" );
|
||||
m_inputPorts[ 0 ].Vector3InternalData = Vector3.forward;
|
||||
m_autoWrapProperties = true;
|
||||
m_errorMessageTypeIsError = NodeMessageType.Warning;
|
||||
m_errorMessageTooltip = "This node only returns correct information using a custom light model, otherwise returns 0";
|
||||
m_previewShaderGUID = "b45d57fa606c1ea438fe9a2c08426bc7";
|
||||
m_drawPreviewAsSphere = true;
|
||||
}
|
||||
|
||||
public override void SetPreviewInputs()
|
||||
{
|
||||
base.SetPreviewInputs();
|
||||
|
||||
if( m_inputPorts[ 0 ].IsConnected )
|
||||
{
|
||||
if( m_normalSpace == ViewSpace.Tangent )
|
||||
m_previewMaterialPassId = 1;
|
||||
else
|
||||
m_previewMaterialPassId = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_previewMaterialPassId = 0;
|
||||
}
|
||||
|
||||
if( m_cachedIntensityId == -1 )
|
||||
m_cachedIntensityId = Shader.PropertyToID( "_Intensity" );
|
||||
|
||||
PreviewMaterial.SetFloat( m_cachedIntensityId, RenderSettings.ambientIntensity );
|
||||
}
|
||||
|
||||
public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector )
|
||||
{
|
||||
base.PropagateNodeData( nodeData, ref dataCollector );
|
||||
// This needs to be rechecked
|
||||
//if( m_inputPorts[ 0 ].IsConnected )
|
||||
dataCollector.DirtyNormal = true;
|
||||
}
|
||||
|
||||
public override void DrawProperties()
|
||||
{
|
||||
base.DrawProperties();
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_normalSpace = (ViewSpace)EditorGUILayoutEnumPopup( "Normal Space", m_normalSpace );
|
||||
if( m_normalSpace != ViewSpace.World || !m_inputPorts[ 0 ].IsConnected )
|
||||
{
|
||||
m_normalize = EditorGUILayoutToggle("Normalize", m_normalize);
|
||||
}
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
UpdatePort();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdatePort()
|
||||
{
|
||||
if( m_normalSpace == ViewSpace.World )
|
||||
m_inputPorts[ 0 ].ChangeProperties( "World Normal", m_inputPorts[ 0 ].DataType, false );
|
||||
else
|
||||
m_inputPorts[ 0 ].ChangeProperties( "Normal", m_inputPorts[ 0 ].DataType, false );
|
||||
|
||||
m_sizeIsDirty = true;
|
||||
}
|
||||
|
||||
public override void Draw( DrawInfo drawInfo )
|
||||
{
|
||||
base.Draw( drawInfo );
|
||||
if( ( ContainerGraph.CurrentStandardSurface != null && ContainerGraph.CurrentStandardSurface.CurrentLightingModel != StandardShaderLightModel.CustomLighting ) )
|
||||
m_showErrorMessage = true;
|
||||
else
|
||||
m_showErrorMessage = 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 finalValue = string.Empty;
|
||||
|
||||
if( dataCollector.IsTemplate && dataCollector.IsFragmentCategory )
|
||||
{
|
||||
if( !dataCollector.IsSRP )
|
||||
{
|
||||
dataCollector.AddToIncludes( UniqueId, Constants.UnityLightingLib );
|
||||
dataCollector.AddToDirectives( FwdBasePragma );
|
||||
string texcoord1 = string.Empty;
|
||||
string texcoord2 = string.Empty;
|
||||
|
||||
if( dataCollector.TemplateDataCollectorInstance.HasInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES1, false, MasterNodePortCategory.Vertex ) )
|
||||
texcoord1 = dataCollector.TemplateDataCollectorInstance.GetInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES1, false, MasterNodePortCategory.Vertex ).VarName;
|
||||
else
|
||||
texcoord1 = dataCollector.TemplateDataCollectorInstance.RegisterInfoOnSemantic( MasterNodePortCategory.Vertex, TemplateInfoOnSematics.TEXTURE_COORDINATES1, TemplateSemantics.TEXCOORD1, "texcoord1", WirePortDataType.FLOAT4, PrecisionType.Float, false );
|
||||
|
||||
if( dataCollector.TemplateDataCollectorInstance.HasInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES2, false, MasterNodePortCategory.Vertex ) )
|
||||
texcoord2 = dataCollector.TemplateDataCollectorInstance.GetInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES2, false, MasterNodePortCategory.Vertex ).VarName;
|
||||
else
|
||||
texcoord2 = dataCollector.TemplateDataCollectorInstance.RegisterInfoOnSemantic( MasterNodePortCategory.Vertex, TemplateInfoOnSematics.TEXTURE_COORDINATES2, TemplateSemantics.TEXCOORD2, "texcoord2", WirePortDataType.FLOAT4, PrecisionType.Float, false );
|
||||
|
||||
string vOutName = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.VertexFunctionData.OutVarName;
|
||||
string fInName = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.FragmentFunctionData.InVarName;
|
||||
TemplateVertexData data = dataCollector.TemplateDataCollectorInstance.RequestNewInterpolator( WirePortDataType.FLOAT4, false, "ase_lmap" );
|
||||
|
||||
string varName = "ase_lmap";
|
||||
if( data != null )
|
||||
varName = data.VarName;
|
||||
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "#ifdef DYNAMICLIGHTMAP_ON //dynlm" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, vOutName + "." + varName + ".zw = " + texcoord2 + ".xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "#endif //dynlm" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "#ifdef LIGHTMAP_ON //stalm" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, vOutName + "." + varName + ".xy = " + texcoord1 + ".xy * unity_LightmapST.xy + unity_LightmapST.zw;" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "#endif //stalm" );
|
||||
|
||||
TemplateVertexData shdata = dataCollector.TemplateDataCollectorInstance.RequestNewInterpolator( WirePortDataType.FLOAT3, false, "ase_sh" );
|
||||
string worldPos = dataCollector.TemplateDataCollectorInstance.GetWorldPos( false, MasterNodePortCategory.Vertex );
|
||||
string worldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( PrecisionType.Float, false, MasterNodePortCategory.Vertex );
|
||||
//Debug.Log( shdata );
|
||||
string shVarName = "ase_sh";
|
||||
if( shdata != null )
|
||||
shVarName = shdata.VarName;
|
||||
string outSH = vOutName + "." + shVarName + ".xyz";
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "#ifndef LIGHTMAP_ON //nstalm" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "#if UNITY_SHOULD_SAMPLE_SH //sh" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, outSH + " = 0;" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "#ifdef VERTEXLIGHT_ON //vl" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, outSH + " += Shade4PointLights (" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0," );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "unity_LightColor[0].rgb, unity_LightColor[1].rgb, unity_LightColor[2].rgb, unity_LightColor[3].rgb," );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "unity_4LightAtten0, " + worldPos + ", " + worldNormal + ");" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "#endif //vl" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, outSH + " = ShadeSHPerVertex (" + worldNormal + ", " + outSH + ");" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "#endif //sh" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "#endif //nstalm" );
|
||||
|
||||
//dataCollector.AddToPragmas( UniqueId, "multi_compile_fwdbase" );
|
||||
|
||||
string fragWorldNormal = string.Empty;
|
||||
if( m_inputPorts[ 0 ].IsConnected )
|
||||
{
|
||||
if( m_normalSpace == ViewSpace.Tangent )
|
||||
fragWorldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( UniqueId, CurrentPrecisionType, m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ), OutputId );
|
||||
else
|
||||
fragWorldNormal = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
|
||||
}
|
||||
else
|
||||
{
|
||||
fragWorldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( PrecisionType.Float, false, MasterNodePortCategory.Fragment );
|
||||
}
|
||||
|
||||
dataCollector.AddLocalVariable( UniqueId, "UnityGIInput data" + OutputId + ";" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "UNITY_INITIALIZE_OUTPUT( UnityGIInput, data" + OutputId + " );" );
|
||||
|
||||
dataCollector.AddLocalVariable( UniqueId, "#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON) //dylm" + OutputId );
|
||||
dataCollector.AddLocalVariable( UniqueId, "data" + OutputId + ".lightmapUV = " + fInName + "." + varName + ";" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "#endif //dylm" + OutputId );
|
||||
|
||||
dataCollector.AddLocalVariable( UniqueId, "#if UNITY_SHOULD_SAMPLE_SH //fsh" + OutputId );
|
||||
dataCollector.AddLocalVariable( UniqueId, "data" + OutputId + ".ambient = " + fInName + "." + shVarName + ";" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "#endif //fsh" + OutputId );
|
||||
|
||||
dataCollector.AddToFragmentLocalVariables( UniqueId, "UnityGI gi" + OutputId + " = UnityGI_Base(data" + OutputId + ", 1, " + fragWorldNormal + ");" );
|
||||
|
||||
finalValue = "gi" + OutputId + ".indirect.diffuse";
|
||||
m_outputPorts[ 0 ].SetLocalValue( finalValue, dataCollector.PortCategory );
|
||||
return finalValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( dataCollector.CurrentSRPType == TemplateSRPType.URP )
|
||||
{
|
||||
string texcoord1 = string.Empty;
|
||||
|
||||
if( dataCollector.TemplateDataCollectorInstance.HasInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES1, false, MasterNodePortCategory.Vertex ) )
|
||||
texcoord1 = dataCollector.TemplateDataCollectorInstance.GetInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES1, false, MasterNodePortCategory.Vertex ).VarName;
|
||||
else
|
||||
texcoord1 = dataCollector.TemplateDataCollectorInstance.RegisterInfoOnSemantic( MasterNodePortCategory.Vertex, TemplateInfoOnSematics.TEXTURE_COORDINATES1, TemplateSemantics.TEXCOORD1, "texcoord1", WirePortDataType.FLOAT4, PrecisionType.Float, false );
|
||||
|
||||
string vOutName = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.VertexFunctionData.OutVarName;
|
||||
string fInName = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.FragmentFunctionData.InVarName;
|
||||
|
||||
if( !dataCollector.TemplateDataCollectorInstance.HasRawInterpolatorOfName( "lightmapUVOrVertexSH" ) )
|
||||
{
|
||||
string worldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( PrecisionType.Float, false, MasterNodePortCategory.Vertex );
|
||||
dataCollector.TemplateDataCollectorInstance.RequestNewInterpolator( WirePortDataType.FLOAT4, false, "lightmapUVOrVertexSH" );
|
||||
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "OUTPUT_LIGHTMAP_UV( " + texcoord1 + ", unity_LightmapST, " + vOutName + ".lightmapUVOrVertexSH.xy );", true );
|
||||
|
||||
if ( ASEPackageManagerHelper.PackageSRPVersion >= ( int )ASESRPBaseline.ASE_SRP_15 )
|
||||
{
|
||||
string worldPos = dataCollector.TemplateDataCollectorInstance.GetWorldPos( false, MasterNodePortCategory.Vertex );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "#if !defined( OUTPUT_SH4 )", true );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "OUTPUT_SH( " + worldPos + ", " + worldNormal + ", GetWorldSpaceNormalizeViewDir( " + worldPos + " ), " + vOutName + ".lightmapUVOrVertexSH.xyz );", true );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "#elif UNITY_VERSION > 60000009", true );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "OUTPUT_SH4( " + worldPos + ", " + worldNormal + ", GetWorldSpaceNormalizeViewDir( " + worldPos + " ), " + vOutName + ".lightmapUVOrVertexSH.xyz, " + vOutName + ".probeOcclusion );", true );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "#else", true );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "OUTPUT_SH4( " + worldPos + ", " + worldNormal + ", GetWorldSpaceNormalizeViewDir( " + worldPos + " ), " + vOutName + ".lightmapUVOrVertexSH.xyz );", true );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "#endif", true );
|
||||
}
|
||||
else
|
||||
{
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "OUTPUT_SH( " + worldNormal + ", " + vOutName + ".lightmapUVOrVertexSH.xyz );", true );
|
||||
}
|
||||
|
||||
dataCollector.AddToPragmas( UniqueId, "multi_compile _ DIRLIGHTMAP_COMBINED" );
|
||||
dataCollector.AddToPragmas( UniqueId, "multi_compile _ LIGHTMAP_ON" );
|
||||
dataCollector.AddToPragmas( UniqueId , "multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE" );
|
||||
|
||||
dataCollector.AddToPragmas( UniqueId , "multi_compile _ _MAIN_LIGHT_SHADOWS" );
|
||||
dataCollector.AddToPragmas( UniqueId , "multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE" );
|
||||
dataCollector.AddToPragmas( UniqueId , "multi_compile _ _SHADOWS_SOFT" );
|
||||
|
||||
}
|
||||
|
||||
string fragWorldNormal = string.Empty;
|
||||
if( m_inputPorts[ 0 ].IsConnected )
|
||||
{
|
||||
if( m_normalSpace == ViewSpace.Tangent )
|
||||
fragWorldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( UniqueId, CurrentPrecisionType, m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ), OutputId );
|
||||
else
|
||||
fragWorldNormal = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
|
||||
}
|
||||
else
|
||||
{
|
||||
fragWorldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( PrecisionType.Float, false, MasterNodePortCategory.Fragment );
|
||||
}
|
||||
|
||||
//SAMPLE_GI
|
||||
finalValue = "bakedGI" + OutputId;
|
||||
|
||||
string result;
|
||||
if ( ASEPackageManagerHelper.CurrentSRPVersion >= ( int )ASESRPBaseline.ASE_SRP_15 )
|
||||
{
|
||||
string positionWS = dataCollector.TemplateDataCollectorInstance.GetWorldPos();
|
||||
string viewDirWS = dataCollector.TemplateDataCollectorInstance.GetViewDir();
|
||||
|
||||
if ( ASEPackageManagerHelper.CurrentSRPVersion >= ( int )ASESRPBaseline.ASE_SRP_17 )
|
||||
{
|
||||
dataCollector.AddFunction( IndirectDiffuseBodyURP17[ 0 ], IndirectDiffuseBodyURP17, false );
|
||||
result = string.Format( IndirectDiffuseHeaderURP17, fInName, fragWorldNormal, positionWS, viewDirWS );
|
||||
}
|
||||
else
|
||||
{
|
||||
dataCollector.AddFunction( IndirectDiffuseBodyURP15[ 0 ], IndirectDiffuseBodyURP15, false );
|
||||
result = string.Format( IndirectDiffuseHeaderURP15, fInName, fragWorldNormal, positionWS, viewDirWS );
|
||||
}
|
||||
}
|
||||
else if ( ASEPackageManagerHelper.CurrentSRPVersion >= ( int )ASESRPBaseline.ASE_SRP_12 )
|
||||
{
|
||||
dataCollector.AddFunction( IndirectDiffuseBodyURP12[ 0 ], IndirectDiffuseBodyURP12, false );
|
||||
result = string.Format( IndirectDiffuseHeaderURP12, fInName, fragWorldNormal );
|
||||
}
|
||||
else // ASE_SRP_10
|
||||
{
|
||||
dataCollector.AddFunction( IndirectDiffuseBodyURP10[ 0 ], IndirectDiffuseBodyURP10, false );
|
||||
result = string.Format( IndirectDiffuseHeaderURP10, fInName, fragWorldNormal );
|
||||
}
|
||||
|
||||
dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT3, finalValue, result );
|
||||
|
||||
string mainLight = dataCollector.TemplateDataCollectorInstance.GetURPMainLight(UniqueId);
|
||||
dataCollector.AddLocalVariable( UniqueId , string.Format( "MixRealtimeAndBakedGI( {0}, {1}, {2}, half4( 0, 0, 0, 0 ) );", mainLight, fragWorldNormal, finalValue ) );
|
||||
|
||||
m_outputPorts[ 0 ].SetLocalValue( finalValue, dataCollector.PortCategory );
|
||||
return finalValue;
|
||||
}
|
||||
else if( dataCollector.CurrentSRPType == TemplateSRPType.HDRP )
|
||||
{
|
||||
string texcoord1 = string.Empty;
|
||||
string texcoord2 = string.Empty;
|
||||
|
||||
|
||||
if( dataCollector.TemplateDataCollectorInstance.HasInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES1, false, MasterNodePortCategory.Vertex ) )
|
||||
texcoord1 = dataCollector.TemplateDataCollectorInstance.GetInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES1, false, MasterNodePortCategory.Vertex ).VarName;
|
||||
else
|
||||
texcoord1 = dataCollector.TemplateDataCollectorInstance.RegisterInfoOnSemantic( MasterNodePortCategory.Vertex, TemplateInfoOnSematics.TEXTURE_COORDINATES1, TemplateSemantics.TEXCOORD1, "texcoord1", WirePortDataType.FLOAT4, PrecisionType.Float, false );
|
||||
|
||||
if( dataCollector.TemplateDataCollectorInstance.HasInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES2, false, MasterNodePortCategory.Vertex ) )
|
||||
texcoord2 = dataCollector.TemplateDataCollectorInstance.GetInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES2, false, MasterNodePortCategory.Vertex ).VarName;
|
||||
else
|
||||
texcoord2 = dataCollector.TemplateDataCollectorInstance.RegisterInfoOnSemantic( MasterNodePortCategory.Vertex, TemplateInfoOnSematics.TEXTURE_COORDINATES2, TemplateSemantics.TEXCOORD2, "texcoord2", WirePortDataType.FLOAT4, PrecisionType.Float, false );
|
||||
|
||||
dataCollector.TemplateDataCollectorInstance.RequestNewInterpolator( WirePortDataType.FLOAT4, false, "ase_lightmapUVs" );
|
||||
|
||||
string vOutName = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.VertexFunctionData.OutVarName;
|
||||
string fInName = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.FragmentFunctionData.InVarName;
|
||||
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, vOutName + ".ase_lightmapUVs.xy = " + texcoord1 + ".xy * unity_LightmapST.xy + unity_LightmapST.zw;" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, vOutName + ".ase_lightmapUVs.zw = " + texcoord2 + ".xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;" );
|
||||
|
||||
string worldPos = dataCollector.TemplateDataCollectorInstance.GetWorldPos( false, MasterNodePortCategory.Fragment );
|
||||
|
||||
dataCollector.AddToPragmas( UniqueId, "multi_compile _ LIGHTMAP_ON" );
|
||||
dataCollector.AddToPragmas( UniqueId, "multi_compile _ DIRLIGHTMAP_COMBINED" );
|
||||
dataCollector.AddToPragmas( UniqueId, "multi_compile _ DYNAMICLIGHTMAP_ON" );
|
||||
|
||||
string fragWorldNormal = string.Empty;
|
||||
if( m_inputPorts[ 0 ].IsConnected )
|
||||
{
|
||||
if( m_normalSpace == ViewSpace.Tangent )
|
||||
fragWorldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( UniqueId, CurrentPrecisionType, m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ), OutputId );
|
||||
else
|
||||
fragWorldNormal = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
|
||||
}
|
||||
else
|
||||
{
|
||||
fragWorldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( PrecisionType.Float, false, MasterNodePortCategory.Fragment );
|
||||
}
|
||||
|
||||
//SAMPLE_GI
|
||||
if ( ASEPackageManagerHelper.CurrentSRPVersion >= ( int )ASESRPBaseline.ASE_SRP_17 )
|
||||
{
|
||||
string screenPos = GeneratorUtils.GenerateScreenPositionRaw( ref dataCollector, UniqueId, CurrentPrecisionType );
|
||||
string positionSS = string.Format( "( uint2 )( {0}.xy / {0}.w * _ScreenSize.xy )", screenPos );
|
||||
|
||||
dataCollector.AddLocalVariable( UniqueId, "float3 bakedGI" + OutputId + " = SampleBakedGI( " + worldPos + ", " + fragWorldNormal + ", " + positionSS + ", " + fInName + ".ase_lightmapUVs.xy, " + fInName + ".ase_lightmapUVs.zw );" );
|
||||
}
|
||||
else
|
||||
{
|
||||
dataCollector.AddLocalVariable( UniqueId, "float3 bakedGI" + OutputId + " = SampleBakedGI( " + worldPos + ", " + fragWorldNormal + ", " + fInName + ".ase_lightmapUVs.xy, " + fInName + ".ase_lightmapUVs.zw );" );
|
||||
}
|
||||
finalValue = "bakedGI" + OutputId;
|
||||
m_outputPorts[ 0 ].SetLocalValue( finalValue, dataCollector.PortCategory );
|
||||
return finalValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( dataCollector.GenType == PortGenType.NonCustomLighting || dataCollector.CurrentCanvasMode != NodeAvailability.CustomLighting )
|
||||
return "float3(0,0,0)";
|
||||
|
||||
string normal = string.Empty;
|
||||
if( m_inputPorts[ 0 ].IsConnected )
|
||||
{
|
||||
dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, UIUtils.CurrentWindow.CurrentGraph.CurrentPrecision );
|
||||
dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false );
|
||||
dataCollector.ForceNormal = true;
|
||||
|
||||
normal = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
|
||||
if( m_normalSpace == ViewSpace.Tangent )
|
||||
{
|
||||
normal = "WorldNormalVector( " + Constants.InputVarStr + " , " + normal + " )";
|
||||
if( m_normalize )
|
||||
{
|
||||
normal = "normalize( " + normal + " )";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( dataCollector.IsFragmentCategory )
|
||||
{
|
||||
dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, UIUtils.CurrentWindow.CurrentGraph.CurrentPrecision );
|
||||
if( dataCollector.DirtyNormal )
|
||||
{
|
||||
dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false );
|
||||
dataCollector.ForceNormal = true;
|
||||
}
|
||||
}
|
||||
|
||||
normal = GeneratorUtils.GenerateWorldNormal( ref dataCollector, UniqueId, m_normalize );
|
||||
}
|
||||
|
||||
|
||||
if( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation )
|
||||
{
|
||||
dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT3, "indirectDiffuse" + OutputId, "ShadeSH9( float4( " + normal + ", 1 ) )" );
|
||||
}
|
||||
else
|
||||
{
|
||||
dataCollector.AddLocalVariable( UniqueId, "UnityGI gi" + OutputId + " = gi;" );
|
||||
dataCollector.AddLocalVariable( UniqueId, PrecisionType.Float, WirePortDataType.FLOAT3, "diffNorm" + OutputId, normal );
|
||||
dataCollector.AddLocalVariable( UniqueId, "gi" + OutputId + " = UnityGI_Base( data, 1, diffNorm" + OutputId + " );" );
|
||||
dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT3, "indirectDiffuse" + OutputId, "gi" + OutputId + ".indirect.diffuse + diffNorm" + OutputId + " * 0.0001" );
|
||||
}
|
||||
|
||||
finalValue = "indirectDiffuse" + OutputId;
|
||||
m_outputPorts[ 0 ].SetLocalValue( finalValue, dataCollector.PortCategory );
|
||||
return finalValue;
|
||||
}
|
||||
|
||||
public override void ReadFromString( ref string[] nodeParams )
|
||||
{
|
||||
base.ReadFromString( ref nodeParams );
|
||||
if( UIUtils.CurrentShaderVersion() > 13002 )
|
||||
m_normalSpace = (ViewSpace)Enum.Parse( typeof( ViewSpace ), GetCurrentParam( ref nodeParams ) );
|
||||
|
||||
UpdatePort();
|
||||
}
|
||||
|
||||
public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
|
||||
{
|
||||
base.WriteToString( ref nodeInfo, ref connectionsInfo );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, m_normalSpace );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 11bf17b0757d57c47add2eb50c62c75e
|
||||
timeCreated: 1495726164
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,310 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[Serializable]
|
||||
[NodeAttributes( "Indirect Specular Light", "Lighting", "Indirect Specular Light", NodeAvailabilityFlags = (int)( NodeAvailability.CustomLighting | NodeAvailability.TemplateShader ) )]
|
||||
public sealed class IndirectSpecularLight : ParentNode
|
||||
{
|
||||
[SerializeField]
|
||||
private ViewSpace m_normalSpace = ViewSpace.Tangent;
|
||||
[SerializeField]
|
||||
private bool m_normalize = true;
|
||||
|
||||
private const string DefaultErrorMessage = "This node only returns correct information using a custom light model, otherwise returns 0.";
|
||||
private const string UpgradeErrorMessage = "Smoothness port was previously being used as Roughness, please check if you are correctly using it and save to confirm.";
|
||||
private const string UnsupportedMessage = "Only valid on BiRP and URP templates.";
|
||||
private bool m_upgradeMessage = false;
|
||||
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
AddInputPort( WirePortDataType.FLOAT3, false, "Normal" );
|
||||
AddInputPort( WirePortDataType.FLOAT, false, "Smoothness" );
|
||||
AddInputPort( WirePortDataType.FLOAT, false, "Occlusion" );
|
||||
m_inputPorts[ 0 ].Vector3InternalData = Vector3.forward;
|
||||
m_inputPorts[ 1 ].FloatInternalData = 0.5f;
|
||||
m_inputPorts[ 2 ].FloatInternalData = 1;
|
||||
m_inputPorts[ 1 ].AutoDrawInternalData = true;
|
||||
m_inputPorts[ 2 ].AutoDrawInternalData = true;
|
||||
m_autoWrapProperties = true;
|
||||
AddOutputPort( WirePortDataType.FLOAT3, "RGB" );
|
||||
m_errorMessageTypeIsError = NodeMessageType.Warning;
|
||||
m_errorMessageTooltip = DefaultErrorMessage;
|
||||
m_previewShaderGUID = "d6e441d0a8608954c97fa347d3735e92";
|
||||
m_drawPreviewAsSphere = true;
|
||||
}
|
||||
|
||||
public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector )
|
||||
{
|
||||
base.PropagateNodeData( nodeData, ref dataCollector );
|
||||
if( m_inputPorts[ 0 ].IsConnected )
|
||||
dataCollector.DirtyNormal = true;
|
||||
}
|
||||
|
||||
public override void OnNodeLogicUpdate( DrawInfo drawInfo )
|
||||
{
|
||||
base.OnNodeLogicUpdate( drawInfo );
|
||||
|
||||
if ( m_upgradeMessage || ( ContainerGraph.CurrentStandardSurface != null && ContainerGraph.CurrentStandardSurface.CurrentLightingModel != StandardShaderLightModel.CustomLighting ) )
|
||||
{
|
||||
m_errorMessageTypeIsError = m_upgradeMessage ? NodeMessageType.Warning : NodeMessageType.Error;
|
||||
m_errorMessageTooltip = m_upgradeMessage ? UpgradeErrorMessage : DefaultErrorMessage;
|
||||
m_showErrorMessage = true;
|
||||
}
|
||||
else if ( ContainerGraph.CurrentCanvasMode == NodeAvailability.TemplateShader && ( ContainerGraph.CurrentSRPType != TemplateSRPType.URP && ContainerGraph.CurrentSRPType != TemplateSRPType.BiRP ) )
|
||||
{
|
||||
m_errorMessageTypeIsError = NodeMessageType.Error;
|
||||
m_errorMessageTooltip = UnsupportedMessage;
|
||||
m_showErrorMessage = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_showErrorMessage = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetPreviewInputs()
|
||||
{
|
||||
base.SetPreviewInputs();
|
||||
|
||||
if( m_inputPorts[ 0 ].IsConnected )
|
||||
{
|
||||
if( m_normalSpace == ViewSpace.Tangent )
|
||||
m_previewMaterialPassId = 1;
|
||||
else
|
||||
m_previewMaterialPassId = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_previewMaterialPassId = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawProperties()
|
||||
{
|
||||
base.DrawProperties();
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_normalSpace = (ViewSpace)EditorGUILayoutEnumPopup( "Normal Space", m_normalSpace );
|
||||
if( m_normalSpace != ViewSpace.World || !m_inputPorts[ 0 ].IsConnected )
|
||||
{
|
||||
m_normalize = EditorGUILayoutToggle("Normalize", m_normalize);
|
||||
}
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
UpdatePort();
|
||||
}
|
||||
if( !m_inputPorts[ 1 ].IsConnected )
|
||||
m_inputPorts[ 1 ].FloatInternalData = EditorGUILayout.FloatField( m_inputPorts[ 1 ].Name, m_inputPorts[ 1 ].FloatInternalData );
|
||||
if( !m_inputPorts[ 2 ].IsConnected )
|
||||
m_inputPorts[ 2 ].FloatInternalData = EditorGUILayout.FloatField( m_inputPorts[ 2 ].Name, m_inputPorts[ 2 ].FloatInternalData );
|
||||
|
||||
if ( m_showErrorMessage )
|
||||
{
|
||||
EditorGUILayout.HelpBox( m_errorMessageTooltip, ( m_errorMessageTypeIsError == NodeMessageType.Error ) ? MessageType.Error : MessageType.Warning );
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdatePort()
|
||||
{
|
||||
if( m_normalSpace == ViewSpace.World )
|
||||
m_inputPorts[ 0 ].ChangeProperties( "World Normal", m_inputPorts[ 0 ].DataType, false );
|
||||
else
|
||||
m_inputPorts[ 0 ].ChangeProperties( "Normal", m_inputPorts[ 0 ].DataType, false );
|
||||
|
||||
m_sizeIsDirty = true;
|
||||
}
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
if( dataCollector.IsTemplate )
|
||||
{
|
||||
if( !dataCollector.IsSRP )
|
||||
{
|
||||
dataCollector.AddToIncludes( UniqueId, Constants.UnityLightingLib );
|
||||
string worldPos = dataCollector.TemplateDataCollectorInstance.GetWorldPos();
|
||||
string worldViewDir = dataCollector.TemplateDataCollectorInstance.GetViewDir( useMasterNodeCategory:false, customCategory:MasterNodePortCategory.Fragment );
|
||||
|
||||
string worldNormal = string.Empty;
|
||||
if( m_inputPorts[ 0 ].IsConnected )
|
||||
{
|
||||
if( m_normalSpace == ViewSpace.Tangent )
|
||||
worldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( UniqueId, CurrentPrecisionType, m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ), OutputId );
|
||||
else
|
||||
worldNormal = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
|
||||
}
|
||||
else
|
||||
{
|
||||
worldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( PrecisionType.Float, false, MasterNodePortCategory.Fragment );
|
||||
}
|
||||
|
||||
string tempsmoothness = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector );
|
||||
string tempocclusion = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector );
|
||||
|
||||
dataCollector.AddLocalVariable( UniqueId, "UnityGIInput data;" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "UNITY_INITIALIZE_OUTPUT( UnityGIInput, data );" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "data.worldPos = " + worldPos + ";" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "data.worldViewDir = " + worldViewDir + ";" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "data.probeHDR[0] = unity_SpecCube0_HDR;" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "data.probeHDR[1] = unity_SpecCube1_HDR;" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "#if UNITY_SPECCUBE_BLENDING || UNITY_SPECCUBE_BOX_PROJECTION //specdataif0" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "\tdata.boxMin[0] = unity_SpecCube0_BoxMin;" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "#endif //specdataif0" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "#if UNITY_SPECCUBE_BOX_PROJECTION //specdataif1" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "\tdata.boxMax[0] = unity_SpecCube0_BoxMax;" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "\tdata.probePosition[0] = unity_SpecCube0_ProbePosition;" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "\tdata.boxMax[1] = unity_SpecCube1_BoxMax;" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "\tdata.boxMin[1] = unity_SpecCube1_BoxMin;" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "\tdata.probePosition[1] = unity_SpecCube1_ProbePosition;" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "#endif //specdataif1" );
|
||||
|
||||
dataCollector.AddLocalVariable( UniqueId, "Unity_GlossyEnvironmentData g" + OutputId + " = UnityGlossyEnvironmentSetup( " + tempsmoothness + ", " + worldViewDir + ", " + worldNormal + ", float3(0,0,0));" );
|
||||
dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT3, "indirectSpecular" + OutputId, "UnityGI_IndirectSpecular( data, " + tempocclusion + ", " + worldNormal + ", g" + OutputId + " )" );
|
||||
return "indirectSpecular" + OutputId;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( dataCollector.CurrentSRPType == TemplateSRPType.URP )
|
||||
{
|
||||
string worldViewDir = dataCollector.TemplateDataCollectorInstance.GetViewDir( useMasterNodeCategory: false, customCategory: MasterNodePortCategory.Fragment );
|
||||
string worldNormal = string.Empty;
|
||||
if( m_inputPorts[ 0 ].IsConnected )
|
||||
{
|
||||
if( m_normalSpace == ViewSpace.Tangent )
|
||||
worldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( UniqueId, CurrentPrecisionType, m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ), OutputId );
|
||||
else
|
||||
worldNormal = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
|
||||
}
|
||||
else
|
||||
{
|
||||
worldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( precisionType:PrecisionType.Float, useMasterNodeCategory: false, customCategory: MasterNodePortCategory.Fragment );
|
||||
}
|
||||
|
||||
string tempsmoothness = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector );
|
||||
string tempocclusion = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector );
|
||||
|
||||
dataCollector.AddLocalVariable( UniqueId, "half3 reflectVector" + OutputId + " = reflect( -" + worldViewDir + ", " + worldNormal + " );" );
|
||||
if ( ASEPackageManagerHelper.PackageSRPVersion >= ( int )ASESRPBaseline.ASE_SRP_14 )
|
||||
{
|
||||
dataCollector.AddToPragmas( UniqueId, "multi_compile _ _FORWARD_PLUS" );
|
||||
|
||||
string worldPos = dataCollector.TemplateDataCollectorInstance.GetWorldPos( useMasterNodeCategory: false, customCategory: MasterNodePortCategory.Fragment );
|
||||
string normalizedScreenUV = dataCollector.TemplateDataCollectorInstance.GetScreenPosNormalized( CurrentPrecisionType, useMasterNodeCategory: false, customCategory: MasterNodePortCategory.Fragment );
|
||||
|
||||
dataCollector.AddLocalVariable( UniqueId, string.Format( "float3 indirectSpecular{0} = GlossyEnvironmentReflection( reflectVector{0}, {1}, 1.0 - {2}, {3}, {4}.xy );",
|
||||
OutputId, worldPos, tempsmoothness, tempocclusion, normalizedScreenUV ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
dataCollector.AddLocalVariable( UniqueId, "float3 indirectSpecular" + OutputId + " = GlossyEnvironmentReflection( reflectVector" + OutputId + ", 1.0 - " + tempsmoothness + ", " + tempocclusion + " );" );
|
||||
}
|
||||
return "indirectSpecular" + OutputId;
|
||||
}
|
||||
else if( dataCollector.CurrentSRPType == TemplateSRPType.HDRP )
|
||||
{
|
||||
UIUtils.ShowMessage( UniqueId, "Indirect Specular Light node currently not supported on HDRP" );
|
||||
return m_outputPorts[0].ErrorValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( dataCollector.GenType == PortGenType.NonCustomLighting || dataCollector.CurrentCanvasMode != NodeAvailability.CustomLighting )
|
||||
return m_outputPorts[0].ErrorValue;
|
||||
|
||||
string normal = string.Empty;
|
||||
if( m_inputPorts[ 0 ].IsConnected )
|
||||
{
|
||||
dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, UIUtils.CurrentWindow.CurrentGraph.CurrentPrecision );
|
||||
dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false );
|
||||
dataCollector.ForceNormal = true;
|
||||
|
||||
normal = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
|
||||
if( m_normalSpace == ViewSpace.Tangent )
|
||||
{
|
||||
normal = "WorldNormalVector( " + Constants.InputVarStr + " , " + normal + " )";
|
||||
if( m_normalize )
|
||||
{
|
||||
normal = "normalize( " + normal + " )";
|
||||
}
|
||||
}
|
||||
|
||||
dataCollector.AddLocalVariable( UniqueId, "float3 indirectNormal" + OutputId + " = " + normal + ";" );
|
||||
normal = "indirectNormal" + OutputId;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( dataCollector.IsFragmentCategory )
|
||||
{
|
||||
dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, UIUtils.CurrentWindow.CurrentGraph.CurrentPrecision );
|
||||
if( dataCollector.DirtyNormal )
|
||||
{
|
||||
dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false );
|
||||
dataCollector.ForceNormal = true;
|
||||
}
|
||||
}
|
||||
|
||||
normal = GeneratorUtils.GenerateWorldNormal( ref dataCollector, UniqueId, m_normalize );
|
||||
}
|
||||
|
||||
string smoothness = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector );
|
||||
string occlusion = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector );
|
||||
string viewDir = "data.worldViewDir";
|
||||
|
||||
if( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation )
|
||||
{
|
||||
string worldPos = GeneratorUtils.GenerateWorldPosition( ref dataCollector, UniqueId );
|
||||
viewDir = GeneratorUtils.GenerateViewDirection( ref dataCollector, UniqueId );
|
||||
|
||||
dataCollector.AddLocalVariable( UniqueId, "UnityGIInput data;" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "UNITY_INITIALIZE_OUTPUT( UnityGIInput, data );" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "data.worldPos = " + worldPos + ";" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "data.worldViewDir = " + viewDir + ";" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "data.probeHDR[0] = unity_SpecCube0_HDR;" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "data.probeHDR[1] = unity_SpecCube1_HDR;" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "#if UNITY_SPECCUBE_BLENDING || UNITY_SPECCUBE_BOX_PROJECTION //specdataif0" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "data.boxMin[0] = unity_SpecCube0_BoxMin;" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "#endif //specdataif0" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "#if UNITY_SPECCUBE_BOX_PROJECTION //specdataif1" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "data.boxMax[0] = unity_SpecCube0_BoxMax;" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "data.probePosition[0] = unity_SpecCube0_ProbePosition;" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "data.boxMax[1] = unity_SpecCube1_BoxMax;" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "data.boxMin[1] = unity_SpecCube1_BoxMin;" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "data.probePosition[1] = unity_SpecCube1_ProbePosition;" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "#endif //specdataif1" );
|
||||
}
|
||||
|
||||
dataCollector.AddLocalVariable( UniqueId, "Unity_GlossyEnvironmentData g" + OutputId + " = UnityGlossyEnvironmentSetup( " + smoothness + ", " + viewDir + ", " + normal + ", float3(0,0,0));" );
|
||||
dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT3, "indirectSpecular" + OutputId, "UnityGI_IndirectSpecular( data, " + occlusion + ", " + normal + ", g" + OutputId + " )" );
|
||||
|
||||
return "indirectSpecular" + OutputId;
|
||||
}
|
||||
|
||||
public override void ReadFromString( ref string[] nodeParams )
|
||||
{
|
||||
base.ReadFromString( ref nodeParams );
|
||||
if( UIUtils.CurrentShaderVersion() > 13002 )
|
||||
m_normalSpace = (ViewSpace)Enum.Parse( typeof( ViewSpace ), GetCurrentParam( ref nodeParams ) );
|
||||
|
||||
if( UIUtils.CurrentShaderVersion() < 13804 )
|
||||
{
|
||||
m_upgradeMessage = true;
|
||||
UIUtils.ShowMessage( UniqueId, "Indirect Specular Light node: Smoothness port was previously being used as Roughness, please check if you are correctly using it and save to confirm." );
|
||||
}
|
||||
|
||||
UpdatePort();
|
||||
}
|
||||
|
||||
public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
|
||||
{
|
||||
base.WriteToString( ref nodeInfo, ref connectionsInfo );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, m_normalSpace );
|
||||
m_upgradeMessage = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0820850e74009954188ff84e2f5cc4f2
|
||||
timeCreated: 1495817589
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,210 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "Main Light Attenuation", "Lighting", "Attenuation/shadow of main Directional light.", NodeAvailabilityFlags = (int)( NodeAvailability.CustomLighting | NodeAvailability.TemplateShader ) )]
|
||||
public sealed class LightAttenuation : ParentNode
|
||||
{
|
||||
static readonly string SurfaceError = "This node only returns correct information using a custom light model, otherwise returns 1";
|
||||
static readonly string TemplateError = "This node will only produce proper attenuation if the template contains a shadow caster pass";
|
||||
|
||||
private const string ASEAttenVarName = "ase_lightAtten";
|
||||
|
||||
//private readonly string[] LightweightVertexInstructions =
|
||||
//{
|
||||
// /*local vertex position*/"VertexPositionInputs ase_vertexInput = GetVertexPositionInputs ({0});",
|
||||
// "#ifdef _MAIN_LIGHT_SHADOWS//ase_lightAtten_vert",
|
||||
// /*available interpolator*/"{0} = GetShadowCoord( ase_vertexInput );",
|
||||
// "#endif//ase_lightAtten_vert"
|
||||
//};
|
||||
private const string LightweightLightAttenDecl = "float ase_lightAtten = 0;";
|
||||
private readonly string[] LightweightFragmentInstructions =
|
||||
{
|
||||
/*shadow coords*/"Light ase_lightAtten_mainLight = GetMainLight( {0} );",
|
||||
//"ase_lightAtten = ase_lightAtten_mainLight.distanceAttenuation * ase_lightAtten_mainLight.shadowAttenuation;"
|
||||
"ase_lightAtten = {0}.distanceAttenuation * {0}.shadowAttenuation;"
|
||||
};
|
||||
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
AddOutputPort( WirePortDataType.FLOAT, "Out" );
|
||||
m_errorMessageTypeIsError = NodeMessageType.Warning;
|
||||
m_errorMessageTooltip = SurfaceError;
|
||||
m_previewShaderGUID = "4b12227498a5c8d46b6c44ea018e5b56";
|
||||
m_drawPreviewAsSphere = true;
|
||||
}
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
if( dataCollector.IsTemplate )
|
||||
{
|
||||
if( !dataCollector.IsSRP )
|
||||
{
|
||||
string result = string.Empty;
|
||||
if( dataCollector.TemplateDataCollectorInstance.ContainsSpecialLocalFragVar( TemplateInfoOnSematics.SHADOWCOORDS, WirePortDataType.FLOAT4, ref result ) )
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
return dataCollector.TemplateDataCollectorInstance.GetLightAtten( UniqueId );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( dataCollector.CurrentSRPType == TemplateSRPType.URP )
|
||||
{
|
||||
if( dataCollector.HasLocalVariable( LightweightLightAttenDecl ))
|
||||
return ASEAttenVarName;
|
||||
|
||||
bool isForward = dataCollector.CurrentPassName.Contains( "Forward" );
|
||||
bool isGBuffer = dataCollector.CurrentPassName.Contains( "GBuffer" );
|
||||
|
||||
// Pragmas
|
||||
var pragmas = new List<string>();
|
||||
if ( ASEPackageManagerHelper.CurrentSRPVersion >= 140009 )
|
||||
{
|
||||
if ( isForward || isGBuffer )
|
||||
{
|
||||
pragmas.Add( "multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN" );
|
||||
pragmas.Add( "multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH" );
|
||||
}
|
||||
|
||||
if ( isForward )
|
||||
{
|
||||
pragmas.Add( "multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS" );
|
||||
pragmas.Add( "multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS" );
|
||||
pragmas.Add( "multi_compile _ _FORWARD_PLUS" );
|
||||
}
|
||||
}
|
||||
else if ( ASEPackageManagerHelper.CurrentURPBaseline >= ASESRPBaseline.ASE_SRP_14 )
|
||||
{
|
||||
if ( isForward || isGBuffer )
|
||||
{
|
||||
pragmas.Add( "multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN" );
|
||||
pragmas.Add( "multi_compile_fragment _ _SHADOWS_SOFT" );
|
||||
}
|
||||
|
||||
if ( isForward )
|
||||
{
|
||||
pragmas.Add( "multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS" );
|
||||
pragmas.Add( "multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS" );
|
||||
pragmas.Add( "multi_compile _ _FORWARD_PLUS" );
|
||||
}
|
||||
}
|
||||
else if ( ASEPackageManagerHelper.CurrentURPBaseline >= ASESRPBaseline.ASE_SRP_12 )
|
||||
{
|
||||
if ( isForward || isGBuffer )
|
||||
{
|
||||
pragmas.Add( "multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN" );
|
||||
pragmas.Add( "multi_compile_fragment _ _SHADOWS_SOFT" );
|
||||
}
|
||||
|
||||
if ( isForward )
|
||||
{
|
||||
pragmas.Add( "multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS" );
|
||||
pragmas.Add( "multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS" );
|
||||
}
|
||||
}
|
||||
else if ( ASEPackageManagerHelper.CurrentURPBaseline >= ASESRPBaseline.ASE_SRP_11 )
|
||||
{
|
||||
if ( isForward || isGBuffer )
|
||||
{
|
||||
pragmas.Add( "multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN" );
|
||||
pragmas.Add( "multi_compile_fragment _ _SHADOWS_SOFT" );
|
||||
}
|
||||
|
||||
if ( isForward )
|
||||
{
|
||||
pragmas.Add( "multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS" );
|
||||
pragmas.Add( "multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS" );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isForward || isGBuffer )
|
||||
{
|
||||
pragmas.Add( "multi_compile _ _MAIN_LIGHT_SHADOWS" );
|
||||
pragmas.Add( "multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE" );
|
||||
pragmas.Add( "multi_compile_fragment _ _SHADOWS_SOFT" );
|
||||
}
|
||||
|
||||
if ( isForward )
|
||||
{
|
||||
pragmas.Add( "multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS" );
|
||||
pragmas.Add( "multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS" );
|
||||
}
|
||||
}
|
||||
|
||||
for ( int i = 0; i < pragmas.Count; i++ )
|
||||
{
|
||||
dataCollector.AddToPragmas( UniqueId, pragmas[ i ] );
|
||||
}
|
||||
|
||||
//string shadowCoords = dataCollector.TemplateDataCollectorInstance.GetShadowCoords( UniqueId/*, false, dataCollector.PortCategory*/ );
|
||||
//return shadowCoords;
|
||||
// Vertex Instructions
|
||||
//TemplateVertexData shadowCoordsData = dataCollector.TemplateDataCollectorInstance.RequestNewInterpolator( WirePortDataType.FLOAT4, false );
|
||||
//string vertexInterpName = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.VertexFunctionData.OutVarName;
|
||||
//string vertexShadowCoords = vertexInterpName + "." + shadowCoordsData.VarNameWithSwizzle;
|
||||
//string vertexPos = dataCollector.TemplateDataCollectorInstance.GetVertexPosition( WirePortDataType.FLOAT3, PrecisionType.Float ,false,MasterNodePortCategory.Vertex );
|
||||
|
||||
//dataCollector.AddToVertexLocalVariables( UniqueId, string.Format( LightweightVertexInstructions[ 0 ], vertexPos ));
|
||||
//dataCollector.AddToVertexLocalVariables( UniqueId, LightweightVertexInstructions[ 1 ]);
|
||||
//dataCollector.AddToVertexLocalVariables( UniqueId, string.Format( LightweightVertexInstructions[ 2 ], vertexShadowCoords ) );
|
||||
//dataCollector.AddToVertexLocalVariables( UniqueId, LightweightVertexInstructions[ 3 ]);
|
||||
|
||||
// Fragment Instructions
|
||||
//string fragmentInterpName = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.FragmentFunctionData.InVarName;
|
||||
//string fragmentShadowCoords = fragmentInterpName + "." + shadowCoordsData.VarNameWithSwizzle;
|
||||
|
||||
dataCollector.AddLocalVariable( UniqueId, LightweightLightAttenDecl );
|
||||
string mainLight = dataCollector.TemplateDataCollectorInstance.GetURPMainLight( UniqueId );
|
||||
//dataCollector.AddLocalVariable( UniqueId, string.Format( LightweightFragmentInstructions[ 0 ], shadowCoords ) );
|
||||
dataCollector.AddLocalVariable( UniqueId, string.Format( LightweightFragmentInstructions[ 1 ], mainLight) );
|
||||
return ASEAttenVarName;
|
||||
}
|
||||
else
|
||||
{
|
||||
UIUtils.ShowMessage( UniqueId, "Light Attenuation node currently not supported on HDRP" );
|
||||
return "1";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( dataCollector.GenType == PortGenType.NonCustomLighting || dataCollector.CurrentCanvasMode != NodeAvailability.CustomLighting )
|
||||
{
|
||||
UIUtils.ShowMessage( UniqueId, "Light Attenuation node currently not supported on non-custom lighting surface shaders" );
|
||||
return "1";
|
||||
}
|
||||
|
||||
dataCollector.UsingLightAttenuation = true;
|
||||
return ASEAttenVarName;
|
||||
}
|
||||
|
||||
public override void Draw( DrawInfo drawInfo )
|
||||
{
|
||||
base.Draw( drawInfo );
|
||||
if( ContainerGraph.CurrentCanvasMode == NodeAvailability.TemplateShader && ContainerGraph.CurrentSRPType != TemplateSRPType.URP )
|
||||
{
|
||||
m_showErrorMessage = true;
|
||||
m_errorMessageTypeIsError = NodeMessageType.Warning;
|
||||
m_errorMessageTooltip = TemplateError;
|
||||
} else
|
||||
{
|
||||
m_errorMessageTypeIsError = NodeMessageType.Error;
|
||||
m_errorMessageTooltip = SurfaceError;
|
||||
if ( ( ContainerGraph.CurrentStandardSurface != null && ContainerGraph.CurrentStandardSurface.CurrentLightingModel != StandardShaderLightModel.CustomLighting ) )
|
||||
m_showErrorMessage = true;
|
||||
else
|
||||
m_showErrorMessage = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e205b44d56609f459ffc558febe2792
|
||||
timeCreated: 1495449979
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,99 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "Main Light Color", "Lighting", "Light color of main Directional light. RGB value already contains light intensity while A only contains light intensity." )]
|
||||
public sealed class LightColorNode : ShaderVariablesNode
|
||||
{
|
||||
private const string m_lightColorValue = "_LightColor0";
|
||||
|
||||
private const string m_localIntensityVar = "ase_lightIntensity";
|
||||
private const string m_localColorVar = "ase_lightColor";
|
||||
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "RGBA", WirePortDataType.COLOR );
|
||||
AddOutputPort( WirePortDataType.FLOAT3, "Color" );
|
||||
AddOutputPort( WirePortDataType.FLOAT, "Intensity" );
|
||||
m_previewShaderGUID = "43f5d3c033eb5044e9aeb40241358349";
|
||||
}
|
||||
|
||||
public override void RenderNodePreview()
|
||||
{
|
||||
//Runs at least one time
|
||||
if( !m_initialized )
|
||||
{
|
||||
// nodes with no preview don't update at all
|
||||
PreviewIsDirty = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if( !PreviewIsDirty )
|
||||
return;
|
||||
if( !Preferences.User.DisablePreviews )
|
||||
{
|
||||
int count = m_outputPorts.Count;
|
||||
for( int i = 0 ; i < count ; i++ )
|
||||
{
|
||||
RenderTexture temp = RenderTexture.active;
|
||||
RenderTexture.active = m_outputPorts[ i ].OutputPreviewTexture;
|
||||
Graphics.Blit( null , m_outputPorts[ i ].OutputPreviewTexture , PreviewMaterial , i );
|
||||
RenderTexture.active = temp;
|
||||
}
|
||||
}
|
||||
|
||||
PreviewIsDirty = m_continuousPreviewRefresh;
|
||||
}
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
if( dataCollector.IsTemplate && !dataCollector.IsSRP )
|
||||
dataCollector.AddToIncludes( -1, Constants.UnityLightingLib );
|
||||
|
||||
base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
|
||||
|
||||
if ( dataCollector.IsTemplate && dataCollector.IsSRP )
|
||||
{
|
||||
string constantVar;
|
||||
if ( dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HDRP )
|
||||
{
|
||||
dataCollector.TemplateDataCollectorInstance.AddHDLightInfo();
|
||||
constantVar = string.Format( TemplateHelperFunctions.HDLightInfoFormat, "0", "color" ); ;
|
||||
}
|
||||
else
|
||||
{
|
||||
constantVar = "_MainLightColor";
|
||||
}
|
||||
|
||||
dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT, m_localIntensityVar,
|
||||
string.Format( "max( max( {0}.r, {0}.g ), {0}.b ) + 1e-7", constantVar ) );
|
||||
|
||||
dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT4, m_localColorVar,
|
||||
string.Format( "float4( {0}.rgb / {1}, {1} )", constantVar, m_localIntensityVar ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
dataCollector.AddLocalVariable( UniqueId, "#if defined(LIGHTMAP_ON) && ( UNITY_VERSION < 560 || ( defined(LIGHTMAP_SHADOW_MIXING) && !defined(SHADOWS_SHADOWMASK) && defined(SHADOWS_SCREEN) ) )//aselc" );
|
||||
dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT4, m_localColorVar, "0" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "#else //aselc" );
|
||||
dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT4, m_localColorVar, m_lightColorValue );
|
||||
dataCollector.AddLocalVariable( UniqueId, "#endif //aselc" );
|
||||
}
|
||||
//else if( ContainerGraph.CurrentStandardSurface.CurrentLightingModel == StandardShaderLightModel.CustomLighting )
|
||||
// finalVar = "gi.light.color";
|
||||
|
||||
switch ( outputId )
|
||||
{
|
||||
default:
|
||||
case 0: return m_localColorVar;
|
||||
case 1: return m_localColorVar + ".rgb";
|
||||
case 2: return m_localColorVar + ".a";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 275270020c577924caf04492f73b2ea6
|
||||
timeCreated: 1481126954
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,93 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "World Space Light Pos", "Lighting", "Light Position" )]
|
||||
public sealed class WorldSpaceLightPos : ShaderVariablesNode
|
||||
{
|
||||
private const string HelperText =
|
||||
"This node will behave differently according to light type." +
|
||||
"\n\n- For directional lights the Dir/Pos output will specify a world space direction and Type will be set to 0." +
|
||||
"\n\n- For other light types the Dir/Pos output will specify a world space position and Type will be set to 1.";
|
||||
private const string m_lightPosValue = "_WorldSpaceLightPos0";
|
||||
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, Constants.EmptyPortValue, WirePortDataType.FLOAT4 );
|
||||
AddOutputPort( WirePortDataType.FLOAT3, "Dir/Pos" );
|
||||
AddOutputPort( WirePortDataType.FLOAT, "Type" );
|
||||
m_previewShaderGUID = "2292a614672283c41a367b22cdde4620";
|
||||
m_drawPreviewAsSphere = true;
|
||||
}
|
||||
|
||||
public override void DrawProperties()
|
||||
{
|
||||
base.DrawProperties();
|
||||
EditorGUILayout.HelpBox( HelperText, MessageType.Info );
|
||||
}
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
|
||||
{
|
||||
base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalVar );
|
||||
string finalVar = m_lightPosValue;
|
||||
if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.IsSRP )
|
||||
finalVar = "_MainLightPosition";
|
||||
if( outputId == 1 )
|
||||
{
|
||||
return finalVar + ".xyz";
|
||||
}
|
||||
else if( outputId == 2 )
|
||||
{
|
||||
return finalVar + ".w";
|
||||
}
|
||||
else
|
||||
{
|
||||
return finalVar;
|
||||
}
|
||||
}
|
||||
|
||||
public override void RefreshExternalReferences()
|
||||
{
|
||||
base.RefreshExternalReferences();
|
||||
if( !m_outputPorts[ 0 ].IsConnected )
|
||||
{
|
||||
m_outputPorts[ 0 ].Visible = false;
|
||||
m_sizeIsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void RenderNodePreview()
|
||||
{
|
||||
//Runs at least one time
|
||||
if( !m_initialized )
|
||||
{
|
||||
// nodes with no preview don't update at all
|
||||
PreviewIsDirty = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if( !PreviewIsDirty )
|
||||
return;
|
||||
|
||||
SetPreviewInputs();
|
||||
if( !Preferences.User.DisablePreviews )
|
||||
{
|
||||
RenderTexture temp = RenderTexture.active;
|
||||
|
||||
RenderTexture.active = m_outputPorts[ 0 ].OutputPreviewTexture;
|
||||
Graphics.Blit( null , m_outputPorts[ 0 ].OutputPreviewTexture , PreviewMaterial , 0 );
|
||||
Graphics.Blit( m_outputPorts[ 0 ].OutputPreviewTexture , m_outputPorts[ 1 ].OutputPreviewTexture );
|
||||
|
||||
RenderTexture.active = m_outputPorts[ 2 ].OutputPreviewTexture;
|
||||
Graphics.Blit( null , m_outputPorts[ 2 ].OutputPreviewTexture , PreviewMaterial , 1 );
|
||||
RenderTexture.active = temp;
|
||||
}
|
||||
PreviewIsDirty = m_continuousPreviewRefresh;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db94d973647dae9488d3ef5ee2fd95a4
|
||||
timeCreated: 1481126959
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,27 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using System;
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[Serializable]
|
||||
public class ShaderVariablesNode : ParentNode
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
AddOutputPort( WirePortDataType.OBJECT, "Out" );
|
||||
}
|
||||
public override string GetIncludes()
|
||||
{
|
||||
return Constants.UnityShaderVariables;
|
||||
}
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
if( !( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.IsSRP ) )
|
||||
dataCollector.AddToIncludes( UniqueId, Constants.UnityShaderVariables );
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1eb723e6ceff9a345a9dbfe04aa3dc11
|
||||
timeCreated: 1481126954
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time.meta
generated
Normal file
9
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time.meta
generated
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c77e88b33fec7c429412624a7b2c620
|
||||
folderAsset: yes
|
||||
timeCreated: 1481126947
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,51 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using System;
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[Serializable]
|
||||
[NodeAttributes( "Cos Time", "Time", "Cosine of time" )]
|
||||
public sealed class CosTime : ConstVecShaderVariable
|
||||
{
|
||||
private readonly string[] SRPTime =
|
||||
{
|
||||
"cos( _TimeParameters.x * 0.125 )",
|
||||
"cos( _TimeParameters.x * 0.25 )",
|
||||
"cos( _TimeParameters.x * 0.5 )",
|
||||
"_TimeParameters.z",
|
||||
};
|
||||
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputName( 1, "t/8" );
|
||||
ChangeOutputName( 2, "t/4" );
|
||||
ChangeOutputName( 3, "t/2" );
|
||||
ChangeOutputName( 4, "t" );
|
||||
m_value = "_CosTime";
|
||||
m_previewShaderGUID = "3093999b42c3c0940a71799511d7781c";
|
||||
m_continuousPreviewRefresh = true;
|
||||
}
|
||||
|
||||
public override void RefreshExternalReferences()
|
||||
{
|
||||
base.RefreshExternalReferences();
|
||||
if( !m_outputPorts[ 0 ].IsConnected )
|
||||
{
|
||||
m_outputPorts[ 0 ].Visible = false;
|
||||
m_sizeIsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
if( outputId > 0 && dataCollector.IsTemplate )
|
||||
{
|
||||
if( dataCollector.TemplateDataCollectorInstance.IsHDRP || dataCollector.TemplateDataCollectorInstance.IsLWRP )
|
||||
return SRPTime[ outputId - 1 ];
|
||||
}
|
||||
return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/CosTime.cs.meta
generated
Normal file
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/CosTime.cs.meta
generated
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 447e504f2ca5aaf4bbf0fdbce33596bc
|
||||
timeCreated: 1481126955
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -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( "Delta Time", "Time", "Delta time" )]
|
||||
public sealed class DeltaTime : ConstVecShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputName( 1, "dt" );
|
||||
ChangeOutputName( 2, "1/dt" );
|
||||
ChangeOutputName( 3, "smoothDt" );
|
||||
ChangeOutputName( 4, "1/smoothDt" );
|
||||
m_value = "unity_DeltaTime";
|
||||
m_previewShaderGUID = "9d69a693042c443498f96d6da60535eb";
|
||||
m_continuousPreviewRefresh = true;
|
||||
}
|
||||
|
||||
public override void RefreshExternalReferences()
|
||||
{
|
||||
base.RefreshExternalReferences();
|
||||
if( !m_outputPorts[ 0 ].IsConnected )
|
||||
{
|
||||
m_outputPorts[ 0 ].Visible = false;
|
||||
m_sizeIsDirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/DeltaTime.cs.meta
generated
Normal file
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/DeltaTime.cs.meta
generated
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ddde7ed1ab4f8044a9a6aa3891f5ca4
|
||||
timeCreated: 1481126955
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,46 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using System;
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[Serializable]
|
||||
[NodeAttributes( "Time", "Time", "Time in seconds with a scale multiplier" )]
|
||||
public sealed class SimpleTimeNode : ShaderVariablesNode
|
||||
{
|
||||
private const string TimeStandard = "_Time.y";
|
||||
private const string TimeSRP = "_TimeParameters.x";
|
||||
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT );
|
||||
AddInputPort( WirePortDataType.FLOAT, false, "Scale" );
|
||||
m_inputPorts[ 0 ].FloatInternalData = 1;
|
||||
m_useInternalPortData = true;
|
||||
m_previewShaderGUID = "45b7107d5d11f124fad92bcb1fa53661";
|
||||
m_continuousPreviewRefresh = true;
|
||||
}
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
|
||||
string multiplier = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
|
||||
string timeGlobalVar = TimeStandard;
|
||||
|
||||
if( dataCollector.IsTemplate )
|
||||
{
|
||||
if( dataCollector.TemplateDataCollectorInstance.IsHDRP || dataCollector.TemplateDataCollectorInstance.IsLWRP )
|
||||
timeGlobalVar = TimeSRP;
|
||||
}
|
||||
|
||||
if( multiplier == "1.0" )
|
||||
return timeGlobalVar;
|
||||
|
||||
string scaledVarName = "mulTime" + OutputId;
|
||||
string scaledVarValue = timeGlobalVar + " * " + multiplier;
|
||||
dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT, scaledVarName, scaledVarValue );
|
||||
return scaledVarName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f36e4491ee33fe74fa51cfb5ad450c6e
|
||||
timeCreated: 1481126959
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,55 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[Serializable]
|
||||
[NodeAttributes( "Sin Time", "Time", "Unity sin time" )]
|
||||
public sealed class SinTimeNode : ConstVecShaderVariable
|
||||
{
|
||||
//double m_time;
|
||||
private readonly string[] SRPTime =
|
||||
{
|
||||
"sin( _TimeParameters.x * 0.125 )",
|
||||
"sin( _TimeParameters.x * 0.25 )",
|
||||
"sin( _TimeParameters.x * 0.5 )",
|
||||
"_TimeParameters.y",
|
||||
};
|
||||
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputName( 1, "t/8" );
|
||||
ChangeOutputName( 2, "t/4" );
|
||||
ChangeOutputName( 3, "t/2" );
|
||||
ChangeOutputName( 4, "t" );
|
||||
m_value = "_SinTime";
|
||||
m_previewShaderGUID = "e4ba809e0badeb94994170b2cbbbba10";
|
||||
m_continuousPreviewRefresh = true;
|
||||
}
|
||||
|
||||
public override void RefreshExternalReferences()
|
||||
{
|
||||
base.RefreshExternalReferences();
|
||||
if( !m_outputPorts[ 0 ].IsConnected )
|
||||
{
|
||||
m_outputPorts[ 0 ].Visible = false;
|
||||
m_sizeIsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
if( outputId > 0 && dataCollector.IsTemplate )
|
||||
{
|
||||
if( dataCollector.TemplateDataCollectorInstance.IsHDRP || dataCollector.TemplateDataCollectorInstance.IsLWRP )
|
||||
return SRPTime[ outputId - 1 ];
|
||||
}
|
||||
|
||||
return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SinTimeNode.cs.meta
generated
Normal file
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SinTimeNode.cs.meta
generated
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 796acd44fcf330e4e921855630007b9b
|
||||
timeCreated: 1481126957
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,52 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using System;
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[Serializable]
|
||||
[NodeAttributes( "Time Parameters", "Time", "Time since level load" )]
|
||||
public sealed class TimeNode : ConstVecShaderVariable
|
||||
{
|
||||
private readonly string[] SRPTime =
|
||||
{
|
||||
"( _TimeParameters.x * 0.05 )",
|
||||
"( _TimeParameters.x )",
|
||||
"( _TimeParameters.x * 2 )",
|
||||
"( _TimeParameters.x * 3 )",
|
||||
};
|
||||
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputName( 1, "t/20" );
|
||||
ChangeOutputName( 2, "t" );
|
||||
ChangeOutputName( 3, "t*2" );
|
||||
ChangeOutputName( 4, "t*3" );
|
||||
m_value = "_Time";
|
||||
m_previewShaderGUID = "73abc10c8d1399444827a7eeb9c24c2a";
|
||||
m_continuousPreviewRefresh = true;
|
||||
}
|
||||
|
||||
public override void RefreshExternalReferences()
|
||||
{
|
||||
base.RefreshExternalReferences();
|
||||
if( !m_outputPorts[ 0 ].IsConnected )
|
||||
{
|
||||
m_outputPorts[ 0 ].Visible = false;
|
||||
m_sizeIsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
if( outputId > 0 && dataCollector.IsTemplate )
|
||||
{
|
||||
if( dataCollector.TemplateDataCollectorInstance.IsHDRP || dataCollector.TemplateDataCollectorInstance.IsLWRP )
|
||||
return SRPTime[ outputId - 1 ];
|
||||
}
|
||||
|
||||
return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/TimeNode.cs.meta
generated
Normal file
12
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/TimeNode.cs.meta
generated
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8c6b7bfb7784e14d8708ab6fb981268
|
||||
timeCreated: 1481126959
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform.meta
generated
Normal file
9
Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform.meta
generated
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2ce97203c4871664493f8760d88d0d4d
|
||||
folderAsset: yes
|
||||
timeCreated: 1481126946
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,24 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "Camera To World Matrix", "Matrix Transform", "Current camera to world matrix" )]
|
||||
public sealed class CameraToWorldMatrix : ConstantShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
|
||||
m_value = "unity_CameraToWorld";
|
||||
m_drawPreview = false;
|
||||
}
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
GeneratorUtils.RegisterUnity2019MatrixDefines( ref dataCollector );
|
||||
return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6accfe0f350cf064dae07041fe90446b
|
||||
timeCreated: 1481126959
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,25 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "Inverse Model Matrix", "Matrix Transform", "Inverse of current model matrix" )]
|
||||
public sealed class IMMatrixNode : ConstantShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
|
||||
m_value = "unity_WorldToObject";
|
||||
m_valueHDRP = "GetWorldToObjectMatrix()";
|
||||
m_valueURP = "GetWorldToObjectMatrix()";
|
||||
m_drawPreview = false;
|
||||
}
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d327dba1ad1f314e93ee246c376684b
|
||||
timeCreated: 1481126955
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,24 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "Inverse Projection Matrix", "Matrix Transform", "Current inverse projection matrix" )]
|
||||
public sealed class InverseProjectionMatrixNode : ConstantShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
|
||||
m_value = "UNITY_MATRIX_I_P";
|
||||
m_drawPreview = false;
|
||||
m_matrixId = 1;
|
||||
}
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
return GeneratorUtils.GenerateInverseProjection( ref dataCollector, UniqueId, CurrentPrecisionType );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0fdbc380972c44b489c5f948a40b8e69
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,18 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "Inverse Transpose Model View Matrix", "Matrix Transform", "All Transformation types" )]
|
||||
public sealed class InverseTranspMVMatrixNode : ConstantShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
|
||||
m_value = "UNITY_MATRIX_IT_MV";
|
||||
m_drawPreview = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a71f1e560487aa4c8484c4153941884
|
||||
timeCreated: 1481126955
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,19 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "Inverse View Matrix", "Matrix Transform", "Current inverse view matrix" )]
|
||||
public sealed class InverseViewMatrixNode : ConstantShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
|
||||
m_value = "UNITY_MATRIX_I_V";
|
||||
m_drawPreview = false;
|
||||
m_matrixId = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd0c1c252c062184e9ad592b91e7fcd2
|
||||
timeCreated: 1481126956
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,24 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "Inverse View Projection Matrix", "Matrix Transform", "Current view inverse projection matrix" )]
|
||||
public sealed class InverseViewProjectionMatrixNode : ConstantShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
|
||||
m_value = "UNITY_MATRIX_I_VP";
|
||||
m_drawPreview = false;
|
||||
m_matrixId = 1;
|
||||
}
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
return GeneratorUtils.GenerateInverseViewProjection( ref dataCollector, UniqueId, CurrentPrecisionType );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f6f151774e252dd4fb2b9ee440ec8eed
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,18 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "Model Matrix", "Matrix Transform", "Current model matrix" )]
|
||||
public sealed class MMatrixNode : ConstantShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
|
||||
m_value = "unity_ObjectToWorld";
|
||||
m_drawPreview = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 503a386043991354eaca2410683d836a
|
||||
timeCreated: 1481126955
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,18 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "Model View Matrix", "Matrix Transform", "Current model * view matrix" )]
|
||||
public sealed class MVMatrixNode : ConstantShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
|
||||
m_value = "UNITY_MATRIX_MV";
|
||||
m_drawPreview = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 30c7936db4e6fe5488076d799841f857
|
||||
timeCreated: 1481126954
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,18 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "Model View Projection Matrix", "Matrix Transform", "Current model * view * projection matrix" )]
|
||||
public sealed class MVPMatrixNode : ConstantShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
|
||||
m_value = "UNITY_MATRIX_MVP";
|
||||
m_drawPreview = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 74e00fb3d8e161f498c078795184bae4
|
||||
timeCreated: 1481126956
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,19 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "Object To World Matrix", "Matrix Transform", "Current model matrix" )]
|
||||
public sealed class ObjectToWorldMatrixNode : ConstantShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
|
||||
m_value = "unity_ObjectToWorld";
|
||||
m_valueHDRP = "GetObjectToWorldMatrix()";
|
||||
m_valueURP = "GetObjectToWorldMatrix()";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0c0180a327eba54c832fbb695dd282f
|
||||
timeCreated: 1481126958
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,19 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "Projection Matrix", "Matrix Transform", "Current projection matrix" )]
|
||||
public sealed class ProjectionMatrixNode : ConstantShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
|
||||
m_value = "UNITY_MATRIX_P";
|
||||
m_drawPreview = false;
|
||||
m_matrixId = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 008fd07cf3f9a7140a9e23be43733f7c
|
||||
timeCreated: 1481126953
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,18 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "Texture 0 Matrix", "Matrix Transform", "Texture 0 Matrix", null, UnityEngine.KeyCode.None, true, true )]
|
||||
public sealed class Texture0MatrixNode : ConstantShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
|
||||
m_value = "UNITY_MATRIX_TEXTURE0";
|
||||
m_drawPreview = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f57a1d05f7a9c5847912566ff1605c6d
|
||||
timeCreated: 1481126960
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,18 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "Texture 1 Matrix", "Matrix Transform", "Texture 1 Matrix", null, UnityEngine.KeyCode.None, true, true )]
|
||||
public sealed class Texture1MatrixNode : ConstantShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
|
||||
m_value = "UNITY_MATRIX_TEXTURE1";
|
||||
m_drawPreview = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ef360a7c6005ad479d7a3e6db1d32f4
|
||||
timeCreated: 1481126958
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,18 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "Texture 2 Matrix", "Matrix Transform", "Texture 2 Matrix", null, UnityEngine.KeyCode.None, true, true )]
|
||||
public sealed class Texture2MatrixNode : ConstantShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
|
||||
m_value = "UNITY_MATRIX_TEXTURE2";
|
||||
m_drawPreview = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6cf4950dda0f6e6438ace404fbef19a7
|
||||
timeCreated: 1481126956
|
||||
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
Reference in New Issue
Block a user