summaryrefslogtreecommitdiff
path: root/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables')
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen.meta9
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraProjectionNode.cs100
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraProjectionNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraWorldClipPlanes.cs115
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraWorldClipPlanes.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/OrthoParams.cs38
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/OrthoParams.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ProjectionParams.cs32
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ProjectionParams.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ScreenParams.cs32
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ScreenParams.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/WorldSpaceCameraPos.cs28
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/WorldSpaceCameraPos.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ZBufferParams.cs31
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ZBufferParams.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstVecShaderVariable.cs39
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstVecShaderVariable.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstantShaderVariable.cs35
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstantShaderVariable.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient.meta9
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogAndAmbientColorsNode.cs126
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogAndAmbientColorsNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogParamsNode.cs32
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogParamsNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting.meta9
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/CustomStandardSurface.cs197
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/CustomStandardSurface.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectDiffuseLighting.cs366
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectDiffuseLighting.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectSpecularLight.cs268
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectSpecularLight.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightAttenuation.cs128
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightAttenuation.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightColorNode.cs88
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightColorNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/WorldSpaceLightPos.cs92
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/WorldSpaceLightPos.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ShaderVariablesNode.cs27
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ShaderVariablesNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time.meta9
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/CosTime.cs55
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/CosTime.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/DeltaTime.cs33
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/DeltaTime.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SimpleTimeNode.cs48
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SimpleTimeNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SinTimeNode.cs58
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SinTimeNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/TimeNode.cs55
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/TimeNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform.meta9
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/CameraToWorldMatrix.cs24
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/CameraToWorldMatrix.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseProjectionMatrixNode.cs46
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseProjectionMatrixNode.cs.meta11
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseTranspMVMatrixNode.cs18
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseTranspMVMatrixNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewMatrixNode.cs19
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewMatrixNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewProjectionMatrixNode.cs46
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewProjectionMatrixNode.cs.meta11
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MMatrixNode.cs18
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MMatrixNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVMatrixNode.cs18
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVMatrixNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVPMatrixNode.cs18
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVPMatrixNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ObjectToWorldMatrixNode.cs19
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ObjectToWorldMatrixNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ProjectionMatrixNode.cs19
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ProjectionMatrixNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture0MatrixNode.cs18
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture0MatrixNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture1MatrixNode.cs18
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture1MatrixNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture2MatrixNode.cs18
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture2MatrixNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture3MatrixNode.cs18
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture3MatrixNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformDirectionNode.cs560
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformDirectionNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformPositionNode.cs620
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformPositionNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformVariables.cs166
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformVariables.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransposeMVMatrix.cs18
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransposeMVMatrix.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorClipMatrixNode.cs23
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorClipMatrixNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorMatrixNode.cs23
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorMatrixNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityScaleMatrix.cs18
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityScaleMatrix.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewMatrixNode.cs19
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewMatrixNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewProjectionMatrixNode.cs18
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewProjectionMatrixNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToCameraMatrix.cs23
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToCameraMatrix.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToObjectMatrix.cs20
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToObjectMatrix.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToTangentMatrix.cs47
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToTangentMatrix.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various.meta9
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/ColorSpaceDouble.cs37
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/ColorSpaceDouble.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/FaceVariableNode.cs53
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/FaceVariableNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/InstanceIdNode.cs43
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/InstanceIdNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/LODFadeNode.cs44
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/LODFadeNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/PrimitiveIdVariableNode.cs38
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/PrimitiveIdVariableNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/SwitchByFaceNode.cs70
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/SwitchByFaceNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/VertexIdVariableNode.cs54
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/VertexIdVariableNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/WorldTransformParams.cs32
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/WorldTransformParams.cs.meta12
120 files changed, 5002 insertions, 0 deletions
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen.meta
new file mode 100644
index 00000000..e1fbf68d
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen.meta
@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 8c4b0845954941d4d9809abaa67bdc2b
+folderAsset: yes
+timeCreated: 1481126947
+licenseType: Store
+DefaultImporter:
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraProjectionNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraProjectionNode.cs
new file mode 100644
index 00000000..0591ba12
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraProjectionNode.cs
@@ -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 );
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraProjectionNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraProjectionNode.cs.meta
new file mode 100644
index 00000000..11a1c16b
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraProjectionNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: f776bdd36b750304c8e0de8ee1f31fc0
+timeCreated: 1481126960
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraWorldClipPlanes.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraWorldClipPlanes.cs
new file mode 100644
index 00000000..fd23099e
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraWorldClipPlanes.cs
@@ -0,0 +1,115 @@
+// 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";
+
+ 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 );
+ 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 );
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraWorldClipPlanes.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraWorldClipPlanes.cs.meta
new file mode 100644
index 00000000..3b17b846
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraWorldClipPlanes.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: e5a9a010f1c8dda449c8ca7ee9e25869
+timeCreated: 1481126959
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/OrthoParams.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/OrthoParams.cs
new file mode 100644
index 00000000..c2e93c26
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/OrthoParams.cs
@@ -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;
+ }
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/OrthoParams.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/OrthoParams.cs.meta
new file mode 100644
index 00000000..d406a63e
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/OrthoParams.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: f9431cdf8e81c1d4f902b3fa7d04f7ac
+timeCreated: 1481126960
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ProjectionParams.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ProjectionParams.cs
new file mode 100644
index 00000000..9e4357b7
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ProjectionParams.cs
@@ -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;
+ }
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ProjectionParams.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ProjectionParams.cs.meta
new file mode 100644
index 00000000..8e87d5a2
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ProjectionParams.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: ba1ca8bace2c2dd4dafac6f73f4dfb1b
+timeCreated: 1481126958
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ScreenParams.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ScreenParams.cs
new file mode 100644
index 00000000..5446ac2f
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ScreenParams.cs
@@ -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;
+ // }
+ //}
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ScreenParams.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ScreenParams.cs.meta
new file mode 100644
index 00000000..f43db824
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ScreenParams.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 2e593f23857d59643b5b5f6dd6264e1b
+timeCreated: 1481126954
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/WorldSpaceCameraPos.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/WorldSpaceCameraPos.cs
new file mode 100644
index 00000000..2342f158
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/WorldSpaceCameraPos.cs
@@ -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 ) );
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/WorldSpaceCameraPos.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/WorldSpaceCameraPos.cs.meta
new file mode 100644
index 00000000..8a47447f
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/WorldSpaceCameraPos.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 972d92a6008896f4292a61726e18f667
+timeCreated: 1481126957
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ZBufferParams.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ZBufferParams.cs
new file mode 100644
index 00000000..4fcb5e19
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ZBufferParams.cs
@@ -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;
+ }
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ZBufferParams.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ZBufferParams.cs.meta
new file mode 100644
index 00000000..e8b668c8
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ZBufferParams.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 2765a41106f478f4982e859b978bdec4
+timeCreated: 1481126954
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstVecShaderVariable.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstVecShaderVariable.cs
new file mode 100644
index 00000000..d74d8a5f
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstVecShaderVariable.cs
@@ -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;
+ }
+
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstVecShaderVariable.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstVecShaderVariable.cs.meta
new file mode 100644
index 00000000..97976c8a
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstVecShaderVariable.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 9102c0b554fd5ad4785acf870dcc17eb
+timeCreated: 1481126957
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstantShaderVariable.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstantShaderVariable.cs
new file mode 100644
index 00000000..ff6279e7
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstantShaderVariable.cs
@@ -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_HDValue = string.Empty;
+
+ [SerializeField]
+ protected string m_LWValue = 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.HD && !string.IsNullOrEmpty( m_HDValue ) )
+ return m_HDValue;
+
+ if( dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.Lightweight && !string.IsNullOrEmpty( m_LWValue ))
+ return m_LWValue;
+ }
+ return m_value;
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstantShaderVariable.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstantShaderVariable.cs.meta
new file mode 100644
index 00000000..55110165
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstantShaderVariable.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 266391c3c4308014e9ce246e5484b917
+timeCreated: 1481126954
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient.meta
new file mode 100644
index 00000000..e0c69e86
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient.meta
@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 78eb7b1e34d423c40a949c9e75b5f24a
+folderAsset: yes
+timeCreated: 1481126946
+licenseType: Store
+DefaultImporter:
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogAndAmbientColorsNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogAndAmbientColorsNode.cs
new file mode 100644
index 00000000..2af78f78
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogAndAmbientColorsNode.cs
@@ -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", "Light", "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.HD )
+ {
+ 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 );
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogAndAmbientColorsNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogAndAmbientColorsNode.cs.meta
new file mode 100644
index 00000000..f2ab7d02
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogAndAmbientColorsNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: e2bdfc2fa6fcd0640b01a8b7448a1a11
+timeCreated: 1481126959
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogParamsNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogParamsNode.cs
new file mode 100644
index 00000000..63a635d1
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogParamsNode.cs
@@ -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", "Light", "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;
+ }
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogParamsNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogParamsNode.cs.meta
new file mode 100644
index 00000000..ccc0df5e
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogParamsNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: a3d8c31159e07bc419a7484ab5e894ed
+timeCreated: 1481126958
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting.meta
new file mode 100644
index 00000000..86287e65
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting.meta
@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 47f503bcb5935b649beee3296dd40260
+folderAsset: yes
+timeCreated: 1481126946
+licenseType: Store
+DefaultImporter:
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/CustomStandardSurface.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/CustomStandardSurface.cs
new file mode 100644
index 00000000..d985714c
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/CustomStandardSurface.cs
@@ -0,0 +1,197 @@
+// 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", "Light", "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;
+
+ 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( 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, CurrentPrecisionType );
+
+ 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 + " )";
+ }
+ }
+ else
+ {
+ normal = GeneratorUtils.GenerateWorldNormal( ref dataCollector, UniqueId );
+ }
+
+
+
+ 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 );
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/CustomStandardSurface.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/CustomStandardSurface.cs.meta
new file mode 100644
index 00000000..172f37cd
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/CustomStandardSurface.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 78916999fd7bc3c4e9767bc9cf0698c0
+timeCreated: 1500054866
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectDiffuseLighting.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectDiffuseLighting.cs
new file mode 100644
index 00000000..c58da735
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectDiffuseLighting.cs
@@ -0,0 +1,366 @@
+// 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", "Light", "Indirect Lighting", NodeAvailabilityFlags = (int)( NodeAvailability.CustomLighting | NodeAvailability.TemplateShader ) )]
+ public sealed class IndirectDiffuseLighting : ParentNode
+ {
+ [SerializeField]
+ private ViewSpace m_normalSpace = ViewSpace.Tangent;
+
+ private int m_cachedIntensityId = -1;
+
+
+ private readonly string LWIndirectDiffuseHeader = "ASEIndirectDiffuse( {0}, {1})";
+ private readonly string[] LWIndirectDiffuseBody =
+ {
+ "float3 ASEIndirectDiffuse( float2 uvStaticLightmap, float3 normalWS )\n",
+ "{\n",
+ "#ifdef LIGHTMAP_ON\n",
+ "\treturn SampleLightmap( uvStaticLightmap, normalWS );\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( 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 );
+
+ 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.AddToLocalVariables( 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.Lightweight )
+ {
+ 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 );" );
+ dataCollector.AddToVertexLocalVariables( UniqueId, "OUTPUT_SH( " + worldNormal + ", " + vOutName + ".lightmapUVOrVertexSH.xyz );" );
+
+ dataCollector.AddToPragmas( UniqueId, "multi_compile _ DIRLIGHTMAP_COMBINED" );
+ dataCollector.AddToPragmas( UniqueId, "multi_compile _ LIGHTMAP_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
+
+ //This function may not do full pixel and does not behave correctly with given normal thus is commented out
+ //dataCollector.AddLocalVariable( UniqueId, "float3 bakedGI" + OutputId + " = SAMPLE_GI( " + fInName + ".lightmapUVOrVertexSH.xy, " + fInName + ".lightmapUVOrVertexSH.xyz, " + fragWorldNormal + " );" );
+ dataCollector.AddFunction( LWIndirectDiffuseBody[ 0 ], LWIndirectDiffuseBody, false );
+ finalValue = "bakedGI" + OutputId;
+ string result = string.Format( LWIndirectDiffuseHeader, fInName + ".lightmapUVOrVertexSH.xy", fragWorldNormal );
+ dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT3, finalValue, result );
+
+ m_outputPorts[ 0 ].SetLocalValue( finalValue, dataCollector.PortCategory );
+ return finalValue;
+ }
+ else if( dataCollector.CurrentSRPType == TemplateSRPType.HD )
+ {
+ 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
+ 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, CurrentPrecisionType );
+ 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 + " )";
+ }
+ else
+ {
+ if( dataCollector.IsFragmentCategory )
+ {
+ dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, CurrentPrecisionType );
+ if( dataCollector.DirtyNormal )
+ {
+ dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false );
+ dataCollector.ForceNormal = true;
+ }
+ }
+
+ normal = GeneratorUtils.GenerateWorldNormal( ref dataCollector, UniqueId );
+ }
+
+
+ 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 );
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectDiffuseLighting.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectDiffuseLighting.cs.meta
new file mode 100644
index 00000000..2e9b5ba5
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectDiffuseLighting.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 11bf17b0757d57c47add2eb50c62c75e
+timeCreated: 1495726164
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectSpecularLight.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectSpecularLight.cs
new file mode 100644
index 00000000..197e193e
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectSpecularLight.cs
@@ -0,0 +1,268 @@
+// 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", "Light", "Indirect Specular Light", NodeAvailabilityFlags = (int)( NodeAvailability.CustomLighting | NodeAvailability.TemplateShader ) )]
+ public sealed class IndirectSpecularLight : ParentNode
+ {
+ [SerializeField]
+ private ViewSpace m_normalSpace = ViewSpace.Tangent;
+
+ private const string DefaultErrorMessage = "This node only returns correct information using a custom light model, otherwise returns 0";
+ 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 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( 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 );
+ }
+
+ 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( m_upgradeMessage || ( 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( dataCollector.IsTemplate )
+ {
+ if( !dataCollector.IsSRP )
+ {
+ dataCollector.AddToIncludes( UniqueId, Constants.UnityLightingLib );
+ string worldPos = dataCollector.TemplateDataCollectorInstance.GetWorldPos();
+ string worldViewDir = dataCollector.TemplateDataCollectorInstance.GetViewDir( false, 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.Lightweight )
+ {
+ string worldViewDir = dataCollector.TemplateDataCollectorInstance.GetViewDir( false, 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, "half3 reflectVector" + OutputId + " = reflect( -" + worldViewDir + ", " + worldNormal + " );" );
+ dataCollector.AddLocalVariable( UniqueId, "float3 indirectSpecular" + OutputId + " = GlossyEnvironmentReflection( reflectVector" + OutputId + ", 1.0 - " + tempsmoothness + ", " + tempocclusion + " );" );
+ return "indirectSpecular" + OutputId;
+ }
+ else if( dataCollector.CurrentSRPType == TemplateSRPType.HD )
+ {
+ 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, CurrentPrecisionType );
+ 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 + " )";
+
+ dataCollector.AddLocalVariable( UniqueId, "float3 indirectNormal" + OutputId + " = " + normal + ";" );
+ normal = "indirectNormal" + OutputId;
+ }
+ else
+ {
+ if( dataCollector.IsFragmentCategory )
+ {
+ dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, CurrentPrecisionType );
+ if( dataCollector.DirtyNormal )
+ {
+ dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false );
+ dataCollector.ForceNormal = true;
+ }
+ }
+
+ normal = GeneratorUtils.GenerateWorldNormal( ref dataCollector, UniqueId );
+ }
+
+ 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_errorMessageTooltip = "Smoothness port was previously being used as Roughness, please check if you are correctly using it and save to confirm.";
+ 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_errorMessageTooltip = DefaultErrorMessage;
+ m_upgradeMessage = false;
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectSpecularLight.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectSpecularLight.cs.meta
new file mode 100644
index 00000000..0c0bb141
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectSpecularLight.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 0820850e74009954188ff84e2f5cc4f2
+timeCreated: 1495817589
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightAttenuation.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightAttenuation.cs
new file mode 100644
index 00000000..57ad0f44
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightAttenuation.cs
@@ -0,0 +1,128 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+using UnityEditor;
+using UnityEngine;
+
+namespace AmplifyShaderEditor
+{
+ [System.Serializable]
+ [NodeAttributes( "Light Attenuation", "Light", "Contains light attenuation for all types of 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[] LightweightPragmaMultiCompiles =
+ {
+ "multi_compile _ _MAIN_LIGHT_SHADOWS",
+ "multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE",
+ "multi_compile _ _SHADOWS_SOFT"
+ };
+
+ //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;"
+ };
+
+ 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 )
+ {
+ return dataCollector.TemplateDataCollectorInstance.GetLightAtten( UniqueId );
+ }
+ else
+ {
+ if( dataCollector.CurrentSRPType == TemplateSRPType.Lightweight )
+ {
+ if( dataCollector.HasLocalVariable( LightweightLightAttenDecl ))
+ return ASEAttenVarName;
+
+ // Pragmas
+ for( int i = 0; i < LightweightPragmaMultiCompiles.Length; i++ )
+ dataCollector.AddToPragmas( UniqueId, LightweightPragmaMultiCompiles[ 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 );
+ dataCollector.AddLocalVariable( UniqueId, string.Format( LightweightFragmentInstructions[ 0 ], shadowCoords ) );
+ dataCollector.AddLocalVariable( UniqueId, LightweightFragmentInstructions[ 1 ] );
+ 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.Lightweight )
+ {
+ 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;
+ }
+
+
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightAttenuation.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightAttenuation.cs.meta
new file mode 100644
index 00000000..05a8aa70
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightAttenuation.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 4e205b44d56609f459ffc558febe2792
+timeCreated: 1495449979
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightColorNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightColorNode.cs
new file mode 100644
index 00000000..92021081
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightColorNode.cs
@@ -0,0 +1,88 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+using UnityEngine;
+
+namespace AmplifyShaderEditor
+{
+ [System.Serializable]
+ [NodeAttributes( "Light Color", "Light", "Light Color, RGB value already contains light intensity while A only contains light intensity" )]
+ public sealed class LightColorNode : ShaderVariablesNode
+ {
+ private const string m_lightColorValue = "_LightColor0";
+ 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;
+
+ 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 );
+
+ string finalVar = m_lightColorValue;
+ if( dataCollector.IsTemplate && dataCollector.IsSRP )
+ {
+ if( dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD )
+ {
+ dataCollector.TemplateDataCollectorInstance.AddHDLightInfo();
+ finalVar = string.Format( TemplateHelperFunctions.HDLightInfoFormat, "0", "color" ); ;
+ }
+ else
+ {
+ finalVar = "_MainLightColor";
+ }
+ }
+ 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, "ase_lightColor", "0" );
+ dataCollector.AddLocalVariable( UniqueId, "#else //aselc" );
+ dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT4, "ase_lightColor", finalVar );
+ dataCollector.AddLocalVariable( UniqueId, "#endif //aselc" );
+ finalVar = "ase_lightColor";
+ }
+ //else if( ContainerGraph.CurrentStandardSurface.CurrentLightingModel == StandardShaderLightModel.CustomLighting )
+ // finalVar = "gi.light.color";
+
+ switch( outputId )
+ {
+ default:
+ case 0: return finalVar;
+ case 1: return finalVar + ".rgb";
+ case 2: return finalVar + ".a";
+ }
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightColorNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightColorNode.cs.meta
new file mode 100644
index 00000000..9acf2a10
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightColorNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 275270020c577924caf04492f73b2ea6
+timeCreated: 1481126954
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/WorldSpaceLightPos.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/WorldSpaceLightPos.cs
new file mode 100644
index 00000000..80aae5df
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/WorldSpaceLightPos.cs
@@ -0,0 +1,92 @@
+// 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", "Light", "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();
+
+ 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;
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/WorldSpaceLightPos.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/WorldSpaceLightPos.cs.meta
new file mode 100644
index 00000000..79f4fc5b
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/WorldSpaceLightPos.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: db94d973647dae9488d3ef5ee2fd95a4
+timeCreated: 1481126959
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ShaderVariablesNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ShaderVariablesNode.cs
new file mode 100644
index 00000000..499999f1
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ShaderVariablesNode.cs
@@ -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;
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ShaderVariablesNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ShaderVariablesNode.cs.meta
new file mode 100644
index 00000000..dce292dc
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ShaderVariablesNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 1eb723e6ceff9a345a9dbfe04aa3dc11
+timeCreated: 1481126954
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time.meta
new file mode 100644
index 00000000..bfd7fd96
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time.meta
@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 7c77e88b33fec7c429412624a7b2c620
+folderAsset: yes
+timeCreated: 1481126947
+licenseType: Store
+DefaultImporter:
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/CosTime.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/CosTime.cs
new file mode 100644
index 00000000..096676f2
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/CosTime.cs
@@ -0,0 +1,55 @@
+// 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
+ {
+#if UNITY_2018_3_OR_NEWER
+ private readonly string[] SRPTime =
+ {
+ "cos( _TimeParameters.x * 0.125 )",
+ "cos( _TimeParameters.x * 0.25 )",
+ "cos( _TimeParameters.x * 0.5 )",
+ "_TimeParameters.z",
+ };
+#endif
+ 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 UNITY_2018_3_OR_NEWER
+ if( outputId > 0 && dataCollector.IsTemplate )
+ {
+ if( ( dataCollector.TemplateDataCollectorInstance.IsHDRP && ASEPackageManagerHelper.CurrentHDVersion > ASESRPVersions.ASE_SRP_5_16_1 ) ||
+ ( dataCollector.TemplateDataCollectorInstance.IsLWRP && ASEPackageManagerHelper.CurrentLWVersion > ASESRPVersions.ASE_SRP_5_16_1 ) )
+ return SRPTime[ outputId - 1 ];
+ }
+#endif
+ return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/CosTime.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/CosTime.cs.meta
new file mode 100644
index 00000000..80373c18
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/CosTime.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 447e504f2ca5aaf4bbf0fdbce33596bc
+timeCreated: 1481126955
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/DeltaTime.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/DeltaTime.cs
new file mode 100644
index 00000000..a1f3380f
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/DeltaTime.cs
@@ -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;
+ }
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/DeltaTime.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/DeltaTime.cs.meta
new file mode 100644
index 00000000..400f94fe
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/DeltaTime.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 3ddde7ed1ab4f8044a9a6aa3891f5ca4
+timeCreated: 1481126955
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SimpleTimeNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SimpleTimeNode.cs
new file mode 100644
index 00000000..8445f90b
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SimpleTimeNode.cs
@@ -0,0 +1,48 @@
+// 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";
+#if UNITY_2018_3_OR_NEWER
+ private const string TimeSRP = "_TimeParameters.x";
+#endif
+ 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 UNITY_2018_3_OR_NEWER
+ if( dataCollector.IsTemplate )
+ {
+ if( ( dataCollector.TemplateDataCollectorInstance.IsHDRP && ASEPackageManagerHelper.CurrentHDVersion > ASESRPVersions.ASE_SRP_5_16_1 ) ||
+ ( dataCollector.TemplateDataCollectorInstance.IsLWRP && ASEPackageManagerHelper.CurrentLWVersion > ASESRPVersions.ASE_SRP_5_16_1 ) )
+ timeGlobalVar = TimeSRP;
+ }
+#endif
+ if( multiplier == "1.0" )
+ return timeGlobalVar;
+
+ string scaledVarName = "mulTime" + OutputId;
+ string scaledVarValue = timeGlobalVar + " * " + multiplier;
+ dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT, scaledVarName, scaledVarValue );
+ return scaledVarName;
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SimpleTimeNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SimpleTimeNode.cs.meta
new file mode 100644
index 00000000..313b9315
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SimpleTimeNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: f36e4491ee33fe74fa51cfb5ad450c6e
+timeCreated: 1481126959
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SinTimeNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SinTimeNode.cs
new file mode 100644
index 00000000..aac2b1eb
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SinTimeNode.cs
@@ -0,0 +1,58 @@
+// 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;
+#if UNITY_2018_3_OR_NEWER
+ private readonly string[] SRPTime =
+ {
+ "sin( _TimeParameters.x * 0.125 )",
+ "sin( _TimeParameters.x * 0.25 )",
+ "sin( _TimeParameters.x * 0.5 )",
+ "_TimeParameters.y",
+ };
+#endif
+ 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 UNITY_2018_3_OR_NEWER
+ if( outputId > 0 && dataCollector.IsTemplate )
+ {
+ if( ( dataCollector.TemplateDataCollectorInstance.IsHDRP && ASEPackageManagerHelper.CurrentHDVersion > ASESRPVersions.ASE_SRP_5_16_1 ) ||
+ ( dataCollector.TemplateDataCollectorInstance.IsLWRP && ASEPackageManagerHelper.CurrentLWVersion > ASESRPVersions.ASE_SRP_5_16_1 ) )
+ return SRPTime[ outputId - 1 ];
+ }
+#endif
+ return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SinTimeNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SinTimeNode.cs.meta
new file mode 100644
index 00000000..876a7748
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SinTimeNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 796acd44fcf330e4e921855630007b9b
+timeCreated: 1481126957
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/TimeNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/TimeNode.cs
new file mode 100644
index 00000000..258d5177
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/TimeNode.cs
@@ -0,0 +1,55 @@
+// 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
+ {
+#if UNITY_2018_3_OR_NEWER
+ private readonly string[] SRPTime =
+ {
+ "( _TimeParameters.x * 0.05 )",
+ "( _TimeParameters.x )",
+ "( _TimeParameters.x * 2 )",
+ "( _TimeParameters.x * 3 )",
+ };
+#endif
+ 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 UNITY_2018_3_OR_NEWER
+ if( outputId > 0 && dataCollector.IsTemplate )
+ {
+ if( ( dataCollector.TemplateDataCollectorInstance.IsHDRP && ASEPackageManagerHelper.CurrentHDVersion > ASESRPVersions.ASE_SRP_5_16_1 ) ||
+ ( dataCollector.TemplateDataCollectorInstance.IsLWRP && ASEPackageManagerHelper.CurrentLWVersion > ASESRPVersions.ASE_SRP_5_16_1 ))
+ return SRPTime[ outputId - 1 ];
+ }
+#endif
+ return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/TimeNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/TimeNode.cs.meta
new file mode 100644
index 00000000..521dcf41
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/TimeNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: d8c6b7bfb7784e14d8708ab6fb981268
+timeCreated: 1481126959
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform.meta
new file mode 100644
index 00000000..008be40e
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform.meta
@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 2ce97203c4871664493f8760d88d0d4d
+folderAsset: yes
+timeCreated: 1481126946
+licenseType: Store
+DefaultImporter:
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/CameraToWorldMatrix.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/CameraToWorldMatrix.cs
new file mode 100644
index 00000000..1238566a
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/CameraToWorldMatrix.cs
@@ -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 );
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/CameraToWorldMatrix.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/CameraToWorldMatrix.cs.meta
new file mode 100644
index 00000000..2e13b7e9
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/CameraToWorldMatrix.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 6accfe0f350cf064dae07041fe90446b
+timeCreated: 1481126959
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseProjectionMatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseProjectionMatrixNode.cs
new file mode 100644
index 00000000..0b53040c
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseProjectionMatrixNode.cs
@@ -0,0 +1,46 @@
+// 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", NodeAvailabilityFlags = (int)( NodeAvailability.TemplateShader ) )]
+ 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 )
+ {
+ if( dataCollector.IsTemplate && dataCollector.IsSRP )
+ {
+ return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
+ }
+ else
+ {
+ return GeneratorUtils.GenerateIdentity4x4( ref dataCollector, UniqueId );
+ }
+ }
+
+ public override void Draw( DrawInfo drawInfo )
+ {
+ base.Draw( drawInfo );
+ if( ContainerGraph.IsSRP )
+ {
+ m_showErrorMessage = false;
+ }
+ else
+ {
+ m_showErrorMessage = true;
+ m_errorMessageTypeIsError = NodeMessageType.Warning;
+ m_errorMessageTooltip = "This node only works for Scriptable Render Pipeline (LWRP, HDRP, URP)";
+ }
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseProjectionMatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseProjectionMatrixNode.cs.meta
new file mode 100644
index 00000000..302ccf23
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseProjectionMatrixNode.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 0fdbc380972c44b489c5f948a40b8e69
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseTranspMVMatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseTranspMVMatrixNode.cs
new file mode 100644
index 00000000..e4071ba0
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseTranspMVMatrixNode.cs
@@ -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;
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseTranspMVMatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseTranspMVMatrixNode.cs.meta
new file mode 100644
index 00000000..1b3b8fd3
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseTranspMVMatrixNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 3a71f1e560487aa4c8484c4153941884
+timeCreated: 1481126955
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewMatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewMatrixNode.cs
new file mode 100644
index 00000000..c21aa195
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewMatrixNode.cs
@@ -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;
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewMatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewMatrixNode.cs.meta
new file mode 100644
index 00000000..61b23243
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewMatrixNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: dd0c1c252c062184e9ad592b91e7fcd2
+timeCreated: 1481126956
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewProjectionMatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewProjectionMatrixNode.cs
new file mode 100644
index 00000000..d812cc23
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewProjectionMatrixNode.cs
@@ -0,0 +1,46 @@
+// 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", NodeAvailabilityFlags = (int)( NodeAvailability.TemplateShader ) )]
+ 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 )
+ {
+ if( dataCollector.IsTemplate && dataCollector.IsSRP )
+ {
+ return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
+ }
+ else
+ {
+ return GeneratorUtils.GenerateIdentity4x4( ref dataCollector, UniqueId );
+ }
+ }
+
+ public override void Draw( DrawInfo drawInfo )
+ {
+ base.Draw( drawInfo );
+ if( ContainerGraph.IsSRP )
+ {
+ m_showErrorMessage = false;
+ }
+ else
+ {
+ m_showErrorMessage = true;
+ m_errorMessageTypeIsError = NodeMessageType.Warning;
+ m_errorMessageTooltip = "This node only works for Scriptable Render Pipeline (LWRP, HDRP, URP)";
+ }
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewProjectionMatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewProjectionMatrixNode.cs.meta
new file mode 100644
index 00000000..6b221613
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewProjectionMatrixNode.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: f6f151774e252dd4fb2b9ee440ec8eed
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MMatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MMatrixNode.cs
new file mode 100644
index 00000000..ed903397
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MMatrixNode.cs
@@ -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_MATRIX_M";
+ m_drawPreview = false;
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MMatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MMatrixNode.cs.meta
new file mode 100644
index 00000000..51c6d1f8
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MMatrixNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 503a386043991354eaca2410683d836a
+timeCreated: 1481126955
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVMatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVMatrixNode.cs
new file mode 100644
index 00000000..a99d8518
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVMatrixNode.cs
@@ -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;
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVMatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVMatrixNode.cs.meta
new file mode 100644
index 00000000..6c0355ea
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVMatrixNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 30c7936db4e6fe5488076d799841f857
+timeCreated: 1481126954
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVPMatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVPMatrixNode.cs
new file mode 100644
index 00000000..324a1532
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVPMatrixNode.cs
@@ -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;
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVPMatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVPMatrixNode.cs.meta
new file mode 100644
index 00000000..8275deff
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVPMatrixNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 74e00fb3d8e161f498c078795184bae4
+timeCreated: 1481126956
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ObjectToWorldMatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ObjectToWorldMatrixNode.cs
new file mode 100644
index 00000000..2f5873be
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ObjectToWorldMatrixNode.cs
@@ -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_HDValue = "GetObjectToWorldMatrix()";
+ m_LWValue = "GetObjectToWorldMatrix()";
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ObjectToWorldMatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ObjectToWorldMatrixNode.cs.meta
new file mode 100644
index 00000000..7d008d9d
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ObjectToWorldMatrixNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: a0c0180a327eba54c832fbb695dd282f
+timeCreated: 1481126958
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ProjectionMatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ProjectionMatrixNode.cs
new file mode 100644
index 00000000..a80058d2
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ProjectionMatrixNode.cs
@@ -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;
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ProjectionMatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ProjectionMatrixNode.cs.meta
new file mode 100644
index 00000000..5f2d19b1
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ProjectionMatrixNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 008fd07cf3f9a7140a9e23be43733f7c
+timeCreated: 1481126953
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture0MatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture0MatrixNode.cs
new file mode 100644
index 00000000..4f568726
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture0MatrixNode.cs
@@ -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;
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture0MatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture0MatrixNode.cs.meta
new file mode 100644
index 00000000..fbdf6114
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture0MatrixNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: f57a1d05f7a9c5847912566ff1605c6d
+timeCreated: 1481126960
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture1MatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture1MatrixNode.cs
new file mode 100644
index 00000000..a9debbe5
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture1MatrixNode.cs
@@ -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;
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture1MatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture1MatrixNode.cs.meta
new file mode 100644
index 00000000..429b1082
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture1MatrixNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 9ef360a7c6005ad479d7a3e6db1d32f4
+timeCreated: 1481126958
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture2MatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture2MatrixNode.cs
new file mode 100644
index 00000000..c0938e7a
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture2MatrixNode.cs
@@ -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;
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture2MatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture2MatrixNode.cs.meta
new file mode 100644
index 00000000..dc1e0080
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture2MatrixNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 6cf4950dda0f6e6438ace404fbef19a7
+timeCreated: 1481126956
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture3MatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture3MatrixNode.cs
new file mode 100644
index 00000000..8b5f86ae
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture3MatrixNode.cs
@@ -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 3 Matrix", "Matrix Transform", "Texture 3 Matrix", null, UnityEngine.KeyCode.None, true, true )]
+ public sealed class Texture3MatrixNode : ConstantShaderVariable
+ {
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
+ m_value = "UNITY_MATRIX_TEXTURE3";
+ m_drawPreview = false;
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture3MatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture3MatrixNode.cs.meta
new file mode 100644
index 00000000..00df6e3e
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture3MatrixNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 02a9fb7a3a104974e941f4109567b97f
+timeCreated: 1481126953
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformDirectionNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformDirectionNode.cs
new file mode 100644
index 00000000..bc7ee22a
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformDirectionNode.cs
@@ -0,0 +1,560 @@
+// 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 InverseTangentType
+ {
+ Fast,
+ Precise
+ }
+
+ [Serializable]
+ [NodeAttributes( "Transform Direction", "Vector Operators", "Transforms a direction vector from one space to another" )]
+ public sealed class TransformDirectionNode : ParentNode
+ {
+
+ [SerializeField]
+ private TransformSpaceFrom m_from = TransformSpaceFrom.Object;
+
+ [SerializeField]
+ private TransformSpaceTo m_to = TransformSpaceTo.World;
+
+ [SerializeField]
+ private bool m_normalize = false;
+
+ [SerializeField]
+ private InverseTangentType m_inverseTangentType = InverseTangentType.Fast;
+
+ private string InverseTBNStr = "Inverse TBN";
+
+ private const string NormalizeOptionStr = "Normalize";
+ private const string NormalizeFunc = "normalize( {0} )";
+
+ private const string AseObjectToWorldDirVarName = "objToWorldDir";
+ private const string AseObjectToWorldDirFormat = "mul( unity_ObjectToWorld, float4( {0}, 0 ) ).xyz";
+ private const string AseSRPObjectToWorldDirFormat = "mul( GetObjectToWorldMatrix(), float4( {0}, 0 ) ).xyz";
+
+ private const string AseObjectToViewDirVarName = "objToViewDir";
+ private const string AseObjectToViewDirFormat = "mul( UNITY_MATRIX_IT_MV, float4( {0}, 0 ) ).xyz";
+ private const string AseHDObjectToViewDirFormat = "TransformWorldToViewDir( TransformObjectToWorldDir( {0} ))";
+
+ private const string AseWorldToObjectDirVarName = "worldToObjDir";
+ private const string AseWorldToObjectDirFormat = "mul( unity_WorldToObject, float4( {0}, 0 ) ).xyz";
+ private const string AseSRPWorldToObjectDirFormat = "mul( GetWorldToObjectMatrix(), float4( {0}, 0 ) ).xyz";
+
+
+ private const string AseWorldToViewDirVarName = "worldToViewDir";
+ private const string AseWorldToViewDirFormat = "mul( UNITY_MATRIX_V, float4( {0}, 0 ) ).xyz";
+
+ private const string AseViewToObjectDirVarName = "viewToObjDir";
+ private const string AseViewToObjectDirFormat = "mul( UNITY_MATRIX_T_MV, float4( {0}, 0 ) ).xyz";
+
+ private const string AseViewToWorldDirVarName = "viewToWorldDir";
+ private const string AseViewToWorldDirFormat = "mul( UNITY_MATRIX_I_V, float4( {0}, 0 ) ).xyz";
+
+ ///////////////////////////////////////////////////////////
+ private const string AseObjectToClipDirVarName = "objectToClipDir";
+ private const string AseObjectToClipDirFormat = "mul(UNITY_MATRIX_VP, mul(unity_ObjectToWorld, float4({0}, 0.0)))";
+ private const string AseSRPObjectToClipDirFormat = "TransformWorldToHClipDir(TransformObjectToWorldDir({0}))";
+
+ private const string AseWorldToClipDirVarName = "worldToClipDir";
+ private const string AseWorldToClipDirFormat = "mul(UNITY_MATRIX_VP, float4({0}, 0.0))";
+ private const string AseSRPWorldToClipDirFormat = "TransformWorldToHClipDir({0})";
+
+ private const string AseViewToClipDirVarName = "viewToClipDir";
+ private const string AseViewToClipDirFormat = "mul(UNITY_MATRIX_P, float4({0}, 0.0))";
+ private const string AseSRPViewToClipDirFormat = "mul(GetViewToHClipMatrix(), float4({0}, 1.0))";
+ //
+ private const string AseClipToObjectDirVarName = "clipToObjectDir";
+
+ private const string AseClipToObjectDirFormat = "mul( UNITY_MATRIX_IT_MV, mul( unity_CameraInvProjection,float4({0},0)) ).xyz";
+ private const string AseClipToWorldDirFormat = "mul( UNITY_MATRIX_I_V, mul( unity_CameraInvProjection,float4({0},0)) ).xyz";
+ private const string AseClipToViewDirFormat = " mul( unity_CameraInvProjection,float4({0},0)).xyz";
+ private const string AseHDClipToObjectDirFormat = "mul( UNITY_MATRIX_I_M, mul( UNITY_MATRIX_I_VP,float4({0},0)) ).xyz";
+
+ private const string AseClipToWorldDirVarName = "clipToWorldDir";
+ private const string AseHDClipToWorldDirFormat = "mul( UNITY_MATRIX_I_VP, float4({0},0) ).xyz";
+
+ private const string AseClipToViewDirVarName = "clipToViewDir";
+ private const string AseHDClipToViewDirFormat = " mul( UNITY_MATRIX_I_P,float4({0},0)).xyz";
+ private const string AseClipToNDC = "{0}.xyz/{0}.w";
+
+ /////////////////////////////////////////////////////
+ private const string AseObjectToTangentDirVarName = "objectToTangentDir";
+ private const string AseWorldToTangentDirVarName = "worldToTangentDir";
+ private const string AseViewToTangentDirVarName = "viewToTangentDir";
+ private const string AseClipToTangentDirVarName = "clipToTangentDir";
+ private const string ASEWorldToTangentFormat = "mul( ase_worldToTangent, {0})";
+
+
+ private const string AseTangentToObjectDirVarName = "tangentTobjectDir";
+ private const string AseTangentToWorldDirVarName = "tangentToWorldDir";
+ private const string AseTangentToViewDirVarName = "tangentToViewDir";
+ private const string AseTangentToClipDirVarName = "tangentToClipDir";
+ private const string ASEMulOpFormat = "mul( {0}, {1} )";
+
+
+
+ ///////////////////////////////////////////////////////////
+ private const string FromStr = "From";
+ private const string ToStr = "To";
+ private const string SubtitleFormat = "{0} to {1}";
+
+ private readonly string[] m_spaceOptionsFrom =
+ {
+ "Object",
+ "World",
+ "View",
+ "Tangent"
+ };
+
+ private readonly string[] m_spaceOptionsTo =
+ {
+ "Object",
+ "World",
+ "View",
+ "Tangent",
+ "Clip"
+ };
+
+
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ AddInputPort( WirePortDataType.FLOAT3, false, Constants.EmptyPortValue );
+ AddOutputVectorPorts( WirePortDataType.FLOAT3, "XYZ" );
+ m_useInternalPortData = true;
+ m_autoWrapProperties = true;
+ m_previewShaderGUID = "74e4d859fbdb2c0468de3612145f4929";
+ m_textLabelWidth = 100;
+ UpdateSubtitle();
+ }
+
+ private void UpdateSubtitle()
+ {
+ SetAdditonalTitleText( string.Format( SubtitleFormat, m_from, m_to ) );
+ }
+
+ public override void DrawProperties()
+ {
+ base.DrawProperties();
+ EditorGUI.BeginChangeCheck();
+ m_from = (TransformSpaceFrom)EditorGUILayoutPopup( FromStr, (int)m_from, m_spaceOptionsFrom );
+ m_to = (TransformSpaceTo)EditorGUILayoutPopup( ToStr, (int)m_to, m_spaceOptionsTo );
+ if( m_from == TransformSpaceFrom.Tangent )
+ {
+ m_inverseTangentType = (InverseTangentType)EditorGUILayoutEnumPopup( InverseTBNStr, m_inverseTangentType );
+ }
+
+ m_normalize = EditorGUILayoutToggle( NormalizeOptionStr, m_normalize );
+ if( EditorGUI.EndChangeCheck() )
+ {
+ UpdateSubtitle();
+ }
+ }
+
+ public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector )
+ {
+ base.PropagateNodeData( nodeData, ref dataCollector );
+ if( (int)m_from != (int)m_to && ( m_from == TransformSpaceFrom.Tangent || m_to == TransformSpaceTo.Tangent ) )
+ dataCollector.DirtyNormal = true;
+ }
+
+ void CalculateTransform( TransformSpaceFrom from, TransformSpaceTo to, ref MasterNodeDataCollector dataCollector, ref string varName, ref string result )
+ {
+ switch( from )
+ {
+ case TransformSpaceFrom.Object:
+ {
+ switch( to )
+ {
+ default: case TransformSpaceTo.Object: break;
+ case TransformSpaceTo.World:
+ {
+ if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType != TemplateSRPType.BuiltIn )
+ result = string.Format( AseSRPObjectToWorldDirFormat, result );
+ else
+ result = string.Format( AseObjectToWorldDirFormat, result );
+ varName = AseObjectToWorldDirVarName + OutputId;
+ }
+ break;
+ case TransformSpaceTo.View:
+ {
+ if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD )
+ result = string.Format( AseHDObjectToViewDirFormat, result );
+ else
+ result = string.Format( AseObjectToViewDirFormat, result );
+ varName = AseObjectToViewDirVarName + OutputId;
+ }
+ break;
+ case TransformSpaceTo.Clip:
+ {
+ if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType != TemplateSRPType.BuiltIn )
+ {
+ result = string.Format( AseSRPObjectToClipDirFormat, result );
+ }
+ else
+ {
+ result = string.Format( AseObjectToClipDirFormat, result );
+ }
+ varName = AseObjectToClipDirVarName + OutputId;
+ }
+ break;
+ }
+ }
+ break;
+ case TransformSpaceFrom.World:
+ {
+ switch( to )
+ {
+ case TransformSpaceTo.Object:
+ {
+ if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType != TemplateSRPType.BuiltIn )
+ result = string.Format( AseSRPWorldToObjectDirFormat, result );
+ else
+ result = string.Format( AseWorldToObjectDirFormat, result );
+ varName = AseWorldToObjectDirVarName + OutputId;
+ }
+ break;
+ default:
+ case TransformSpaceTo.World: break;
+ case TransformSpaceTo.View:
+ {
+ result = string.Format( AseWorldToViewDirFormat, result );
+ varName = AseWorldToViewDirVarName + OutputId;
+ }
+ break;
+ case TransformSpaceTo.Clip:
+ {
+ if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType != TemplateSRPType.BuiltIn )
+ {
+ result = string.Format( AseSRPWorldToClipDirFormat, result );
+ }
+ else
+ {
+ result = string.Format( AseWorldToClipDirFormat, result );
+ }
+ varName = AseWorldToClipDirVarName + OutputId;
+ }
+ break;
+ }
+ }
+ break;
+ case TransformSpaceFrom.View:
+ {
+ switch( to )
+ {
+ case TransformSpaceTo.Object:
+ {
+ result = string.Format( AseViewToObjectDirFormat, result );
+ varName = AseViewToObjectDirVarName + OutputId;
+ }
+ break;
+ case TransformSpaceTo.World:
+ {
+ result = string.Format( AseViewToWorldDirFormat, result );
+ varName = AseViewToWorldDirVarName + OutputId;
+ }
+ break;
+ default: case TransformSpaceTo.View: break;
+ case TransformSpaceTo.Clip:
+ {
+ if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType != TemplateSRPType.BuiltIn )
+ {
+ result = string.Format( AseSRPViewToClipDirFormat, result );
+ }
+ else
+ {
+ result = string.Format( AseViewToClipDirFormat, result );
+ }
+ varName = AseViewToClipDirVarName + OutputId;
+ }
+ break;
+ }
+ }
+ break;
+ //case TransformSpace.Clip:
+ //{
+ // switch( to )
+ // {
+ // case TransformSpace.Object:
+ // {
+ // if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD )
+ // {
+ // result = string.Format( AseHDClipToObjectDirFormat, result );
+ // }
+ // else
+ // {
+ // result = string.Format( AseClipToObjectDirFormat, result );
+ // }
+ // varName = AseClipToObjectDirVarName + OutputId;
+ // }
+ // break;
+ // case TransformSpace.World:
+ // {
+ // if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD )
+ // {
+ // result = string.Format( AseHDClipToWorldDirFormat, result );
+ // }
+ // else
+ // {
+ // result = string.Format( AseClipToWorldDirFormat, result );
+ // }
+ // varName = AseClipToWorldDirVarName + OutputId;
+ // }
+ // break;
+ // case TransformSpace.View:
+ // {
+ // if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD )
+ // {
+ // result = string.Format( AseHDClipToViewDirFormat, result );
+ // }
+ // else
+ // {
+ // result = string.Format( AseClipToViewDirFormat, result );
+ // }
+ // varName = AseClipToViewDirVarName + OutputId;
+ // }
+ // break;
+ // case TransformSpace.Clip: break;
+ // default:
+ // break;
+ // }
+ //}
+ //break;
+ default: break;
+ }
+ }
+
+ public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
+ {
+ if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
+ return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
+
+ GeneratorUtils.RegisterUnity2019MatrixDefines( ref dataCollector );
+
+ string result = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
+ string varName = string.Empty;
+
+ if( (int)m_from == (int)m_to )
+ {
+ RegisterLocalVariable( 0, result, ref dataCollector );
+ return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
+ }
+
+ switch( m_from )
+ {
+ case TransformSpaceFrom.Object:
+ {
+ switch( m_to )
+ {
+ default: case TransformSpaceTo.Object: break;
+ case TransformSpaceTo.World:
+ {
+ CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result );
+ }
+ break;
+ case TransformSpaceTo.View:
+ {
+ CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result );
+ }
+ break;
+ case TransformSpaceTo.Clip:
+ {
+ CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result );
+ }
+ break;
+ case TransformSpaceTo.Tangent:
+ {
+ GeneratorUtils.GenerateWorldToTangentMatrix( ref dataCollector, UniqueId, CurrentPrecisionType );
+ CalculateTransform( m_from, TransformSpaceTo.World, ref dataCollector, ref varName, ref result );
+ result = string.Format( ASEWorldToTangentFormat, result );
+ varName = AseObjectToTangentDirVarName + OutputId;
+ }
+ break;
+ }
+ }
+ break;
+ case TransformSpaceFrom.World:
+ {
+ switch( m_to )
+ {
+ case TransformSpaceTo.Object:
+ {
+ CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result );
+ }
+ break;
+ default:
+ case TransformSpaceTo.World: break;
+ case TransformSpaceTo.View:
+ {
+ CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result );
+ }
+ break;
+ case TransformSpaceTo.Clip:
+ {
+ CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result );
+ }
+ break;
+ case TransformSpaceTo.Tangent:
+ {
+ GeneratorUtils.GenerateWorldToTangentMatrix( ref dataCollector, UniqueId, CurrentPrecisionType );
+ result = string.Format( ASEWorldToTangentFormat, result );
+ varName = AseWorldToTangentDirVarName + OutputId;
+ }
+ break;
+ }
+ }
+ break;
+ case TransformSpaceFrom.View:
+ {
+ switch( m_to )
+ {
+ case TransformSpaceTo.Object:
+ {
+ CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result );
+ }
+ break;
+ case TransformSpaceTo.World:
+ {
+ CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result );
+ }
+ break;
+ default: case TransformSpaceTo.View: break;
+ case TransformSpaceTo.Clip:
+ {
+ CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result );
+ }
+ break;
+ case TransformSpaceTo.Tangent:
+ {
+ GeneratorUtils.GenerateWorldToTangentMatrix( ref dataCollector, UniqueId, CurrentPrecisionType );
+ CalculateTransform( m_from, TransformSpaceTo.World, ref dataCollector, ref varName, ref result );
+ result = string.Format( ASEWorldToTangentFormat, result );
+ varName = AseViewToTangentDirVarName + OutputId;
+ }
+ break;
+ }
+ }
+ break;
+ //case TransformSpace.Clip:
+ //{
+ // switch( m_to )
+ // {
+ // case TransformSpace.Object:
+ // {
+ // CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result );
+ // }
+ // break;
+ // case TransformSpace.World:
+ // {
+ // CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result );
+ // }
+ // break;
+ // case TransformSpace.View:
+ // {
+ // CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result );
+ // }
+ // break;
+ // case TransformSpace.Clip: break;
+ // case TransformSpace.Tangent:
+ // {
+ // GeneratorUtils.GenerateWorldToTangentMatrix( ref dataCollector, UniqueId, CurrentPrecisionType );
+ // CalculateTransform( m_from, TransformSpace.World, ref dataCollector, ref varName, ref result );
+ // result = string.Format( ASEWorldToTangentFormat, result );
+ // varName = AseClipToTangentDirVarName + OutputId;
+ // }
+ // break;
+ // default:
+ // break;
+ // }
+ //}break;
+ case TransformSpaceFrom.Tangent:
+ {
+ string matrixVal = string.Empty;
+ if( m_inverseTangentType == InverseTangentType.Fast )
+ matrixVal = GeneratorUtils.GenerateTangentToWorldMatrixFast( ref dataCollector, UniqueId, CurrentPrecisionType );
+ else
+ matrixVal = GeneratorUtils.GenerateTangentToWorldMatrixPrecise( ref dataCollector, UniqueId, CurrentPrecisionType );
+
+ switch( m_to )
+ {
+ case TransformSpaceTo.Object:
+ {
+ result = string.Format( ASEMulOpFormat, matrixVal, result );
+ CalculateTransform( TransformSpaceFrom.World, m_to, ref dataCollector, ref varName, ref result );
+ varName = AseTangentToObjectDirVarName + OutputId;
+ }
+ break;
+ case TransformSpaceTo.World:
+ {
+ result = string.Format( ASEMulOpFormat, matrixVal, result );
+ varName = AseTangentToWorldDirVarName + OutputId;
+ }
+ break;
+ case TransformSpaceTo.View:
+ {
+ result = string.Format( ASEMulOpFormat, matrixVal, result );
+ CalculateTransform( TransformSpaceFrom.World, m_to, ref dataCollector, ref varName, ref result );
+ varName = AseTangentToViewDirVarName + OutputId;
+ }
+ break;
+ case TransformSpaceTo.Clip:
+ {
+ result = string.Format( ASEMulOpFormat, matrixVal, result );
+ CalculateTransform( TransformSpaceFrom.World, m_to, ref dataCollector, ref varName, ref result );
+ varName = AseTangentToClipDirVarName + OutputId;
+ }
+ break;
+ case TransformSpaceTo.Tangent:
+ default:
+ break;
+ }
+ }
+ break;
+ default: break;
+ }
+
+ if( m_normalize )
+ result = string.Format( NormalizeFunc, result );
+
+ RegisterLocalVariable( 0, result, ref dataCollector, varName );
+ return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
+ }
+
+ public override void ReadFromString( ref string[] nodeParams )
+ {
+ base.ReadFromString( ref nodeParams );
+ string from = GetCurrentParam( ref nodeParams );
+ if( UIUtils.CurrentShaderVersion() < 17500 && from.Equals( "Clip" ) )
+ {
+ UIUtils.ShowMessage( UniqueId, "Clip Space no longer supported on From field over Transform Direction node" );
+ }
+ else
+ {
+ m_from = (TransformSpaceFrom)Enum.Parse( typeof( TransformSpaceFrom ), from );
+ }
+ m_to = (TransformSpaceTo)Enum.Parse( typeof( TransformSpaceTo ), GetCurrentParam( ref nodeParams ) );
+ m_normalize = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
+ if( UIUtils.CurrentShaderVersion() > 15800 )
+ {
+ m_inverseTangentType = (InverseTangentType)Enum.Parse( typeof( InverseTangentType ), GetCurrentParam( ref nodeParams ) );
+ }
+ UpdateSubtitle();
+ }
+
+ public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
+ {
+ base.WriteToString( ref nodeInfo, ref connectionsInfo );
+ IOUtils.AddFieldValueToString( ref nodeInfo, m_from );
+ IOUtils.AddFieldValueToString( ref nodeInfo, m_to );
+ IOUtils.AddFieldValueToString( ref nodeInfo, m_normalize );
+ IOUtils.AddFieldValueToString( ref nodeInfo, m_inverseTangentType );
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformDirectionNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformDirectionNode.cs.meta
new file mode 100644
index 00000000..123dc9ff
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformDirectionNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 5088261e4c0031f4aba961a253707b80
+timeCreated: 1525857790
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformPositionNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformPositionNode.cs
new file mode 100644
index 00000000..850f1a51
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformPositionNode.cs
@@ -0,0 +1,620 @@
+// 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( "Transform Position", "Object Transform", "Transforms a position value from one space to another" )]
+ public sealed class TransformPositionNode : ParentNode
+ {
+ [SerializeField]
+ private TransformSpaceFrom m_from = TransformSpaceFrom.Object;
+
+ [SerializeField]
+ private TransformSpaceTo m_to = TransformSpaceTo.World;
+
+ [SerializeField]
+ private bool m_perspectiveDivide = false;
+
+ [SerializeField]
+ private InverseTangentType m_inverseTangentType = InverseTangentType.Fast;
+
+ [SerializeField]
+ private bool m_absoluteWorldPos = true;
+
+ private const string AbsoluteWorldPosStr = "Absolute";
+
+ private string InverseTBNStr = "Inverse TBN";
+
+ private const string AseObjectToWorldPosVarName = "objToWorld";
+ private const string AseObjectToWorldPosFormat = "mul( unity_ObjectToWorld, float4( {0}, 1 ) ).xyz";
+ private const string AseHDObjectToWorldPosFormat = "mul( GetObjectToWorldMatrix(), float4( {0}, 1 ) ).xyz";
+ private const string ASEHDAbsoluteWordPos = "GetAbsolutePositionWS({0})";
+ private const string ASEHDRelaviveCameraPos = "GetCameraRelativePositionWS({0})";
+ private const string AseObjectToViewPosVarName = "objToView";
+ private const string AseObjectToViewPosFormat = "mul( UNITY_MATRIX_MV, float4( {0}, 1 ) ).xyz";
+ private const string AseHDObjectToViewPosFormat = "TransformWorldToView( TransformObjectToWorld({0}) )";
+
+ private const string AseWorldToObjectPosVarName = "worldToObj";
+ private const string AseWorldToObjectPosFormat = "mul( unity_WorldToObject, float4( {0}, 1 ) ).xyz";
+ private const string AseSRPWorldToObjectPosFormat = "mul( GetWorldToObjectMatrix(), float4( {0}, 1 ) ).xyz";
+
+
+ private const string AseWorldToViewPosVarName = "worldToView";
+ private const string AseWorldToViewPosFormat = "mul( UNITY_MATRIX_V, float4( {0}, 1 ) ).xyz";
+
+ private const string AseViewToObjectPosVarName = "viewToObj";
+ private const string AseViewToObjectPosFormat = "mul( unity_WorldToObject, mul( UNITY_MATRIX_I_V , float4( {0}, 1 ) ) ).xyz";
+ private const string AseHDViewToObjectPosFormat = "mul( GetWorldToObjectMatrix(), mul( UNITY_MATRIX_I_V , float4( {0}, 1 ) ) ).xyz";
+
+ private const string AseViewToWorldPosVarName = "viewToWorld";
+ private const string AseViewToWorldPosFormat = "mul( UNITY_MATRIX_I_V, float4( {0}, 1 ) ).xyz";
+
+ ///////////////////////////////////////////////////////////
+ private const string AseObjectToClipPosVarName = "objectToClip";
+ private const string AseObjectToClipPosFormat = "UnityObjectToClipPos({0})";
+ private const string AseSRPObjectToClipPosFormat = "TransformWorldToHClip(TransformObjectToWorld({0}))";
+
+ private const string AseWorldToClipPosVarName = "worldToClip";
+ private const string AseWorldToClipPosFormat = "mul(UNITY_MATRIX_VP, float4({0}, 1.0))";
+ private const string AseSRPWorldToClipPosFormat = "TransformWorldToHClip({0})";
+
+ private const string AseViewToClipPosVarName = "viewToClip";
+ private const string AseViewToClipPosFormat = "mul(UNITY_MATRIX_P, float4({0}, 1.0))";
+ private const string AseSRPViewToClipPosFormat = "TransformWViewToHClip({0})";
+ //
+
+ private const string AseClipToObjectPosVarName = "clipToObject";
+ private const string AseClipToObjectPosFormat = "mul( UNITY_MATRIX_IT_MV, mul( unity_CameraInvProjection,float4({0},1)) ).xyz";
+ private const string AseHDClipToObjectPosFormat = "mul( UNITY_MATRIX_I_M, mul( UNITY_MATRIX_I_VP,float4({0},1)) ).xyz";
+
+ private const string AseClipToWorldPosVarName = "clipToWorld";
+ private const string AseClipToWorldPosFormat = "mul( UNITY_MATRIX_I_V, mul( unity_CameraInvProjection,float4({0},1)) ).xyz";
+ private const string AseHDClipToWorldPosFormat = "mul( UNITY_MATRIX_I_VP, float4({0},1) ).xyz";
+
+ private const string AseClipToViewPosVarName = "clipToView";
+ private const string AseClipToViewPosFormat = " mul( unity_CameraInvProjection,float4({0},1)).xyz";
+ private const string AseHDClipToViewPosFormat = " mul( UNITY_MATRIX_I_P,float4({0},1)).xyz";
+ private const string AseClipToNDC = "{0}.xyz/{0}.w";
+ /////////////////////////////////////////////////////
+ private const string AseObjectToTangentPosVarName = "objectToTangentPos";
+ private const string AseWorldToTangentPosVarName = "worldToTangentPos";
+ private const string AseViewToTangentPosVarName = "viewToTangentPos";
+ private const string AseClipToTangentPosVarName = "clipToTangentPos";
+ private const string ASEWorldToTangentFormat = "mul( ase_worldToTangent, {0})";
+
+
+ private const string AseTangentToObjectPosVarName = "tangentTobjectPos";
+ private const string AseTangentToWorldPosVarName = "tangentToWorldPos";
+ private const string AseTangentToViewPosVarName = "tangentToViewPos";
+ private const string AseTangentToClipPosVarName = "tangentToClipPos";
+ private const string ASEMulOpFormat = "mul( {0}, {1} )";
+
+
+ ///////////////////////////////////////////////////////////
+ private const string FromStr = "From";
+ private const string ToStr = "To";
+ private const string PerpectiveDivideStr = "Perpective Divide";
+ private const string SubtitleFormat = "{0} to {1}";
+
+ private readonly string[] m_spaceOptionsFrom =
+ {
+ "Object",
+ "World",
+ "View",
+ "Tangent"
+ };
+
+ private readonly string[] m_spaceOptionsTo =
+ {
+ "Object",
+ "World",
+ "View",
+ "Tangent",
+ "Clip"
+ };
+
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ AddInputPort( WirePortDataType.FLOAT3, false, Constants.EmptyPortValue );
+ AddOutputVectorPorts( WirePortDataType.FLOAT3, "XYZ" );
+ m_useInternalPortData = true;
+ m_autoWrapProperties = true;
+ m_previewShaderGUID = "74e4d859fbdb2c0468de3612145f4929";
+ m_textLabelWidth = 120;
+ UpdateSubtitle();
+ }
+
+ private void UpdateSubtitle()
+ {
+ SetAdditonalTitleText( string.Format( SubtitleFormat, m_from, m_to ) );
+ }
+
+ public override void DrawProperties()
+ {
+ base.DrawProperties();
+ EditorGUI.BeginChangeCheck();
+ m_from = (TransformSpaceFrom)EditorGUILayoutPopup( FromStr, (int)m_from, m_spaceOptionsFrom );
+ m_to = (TransformSpaceTo)EditorGUILayoutPopup( ToStr, (int)m_to, m_spaceOptionsTo );
+ if( m_from == TransformSpaceFrom.Tangent )
+ {
+ m_inverseTangentType = (InverseTangentType)EditorGUILayoutEnumPopup( InverseTBNStr, m_inverseTangentType );
+ }
+ if( EditorGUI.EndChangeCheck() )
+ {
+ UpdateSubtitle();
+ }
+
+ if( m_to == TransformSpaceTo.Clip )
+ {
+ m_perspectiveDivide = EditorGUILayoutToggle( PerpectiveDivideStr, m_perspectiveDivide );
+ }
+
+ //if( m_containerGraph.IsHDRP && ( m_from == TransformSpace.Object && m_to == TransformSpace.World ) ||
+ // ( m_from == TransformSpace.World && m_to == TransformSpace.Object ) )
+ //{
+ // m_absoluteWorldPos = EditorGUILayoutToggle( AbsoluteWorldPosStr, m_absoluteWorldPos );
+ //}
+ }
+
+ public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector )
+ {
+ base.PropagateNodeData( nodeData, ref dataCollector );
+ if( (int)m_from != (int)m_to && ( m_from == TransformSpaceFrom.Tangent || m_to == TransformSpaceTo.Tangent ) )
+ dataCollector.DirtyNormal = true;
+ }
+
+ void CalculateTransform( TransformSpaceFrom from, TransformSpaceTo to, ref MasterNodeDataCollector dataCollector, ref string varName, ref string result )
+ {
+ switch( from )
+ {
+ case TransformSpaceFrom.Object:
+ {
+ switch( to )
+ {
+ default:
+ case TransformSpaceTo.Object: break;
+ case TransformSpaceTo.World:
+ {
+ if( dataCollector.IsTemplate && dataCollector.IsSRP )
+ {
+ if( dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD )
+ {
+ result = string.Format( AseHDObjectToWorldPosFormat, result );
+ if( m_absoluteWorldPos )
+ {
+ result = string.Format( ASEHDAbsoluteWordPos, result );
+ }
+ }
+ else if( dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.Lightweight )
+ {
+ result = string.Format( AseHDObjectToWorldPosFormat, result );
+ }
+ }
+ else
+ result = string.Format( AseObjectToWorldPosFormat, result );
+
+
+ varName = AseObjectToWorldPosVarName + OutputId;
+ }
+ break;
+ case TransformSpaceTo.View:
+ {
+ if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD )
+ result = string.Format( AseHDObjectToViewPosFormat, result );
+ else
+ result = string.Format( AseObjectToViewPosFormat, result );
+ varName = AseObjectToViewPosVarName + OutputId;
+ }
+ break;
+ case TransformSpaceTo.Clip:
+ {
+ if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType != TemplateSRPType.BuiltIn )
+ {
+ result = string.Format( AseSRPObjectToClipPosFormat, result );
+ }
+ else
+ {
+ result = string.Format( AseObjectToClipPosFormat, result );
+ }
+ varName = AseObjectToClipPosVarName + OutputId;
+ }
+ break;
+ }
+ }
+ break;
+ case TransformSpaceFrom.World:
+ {
+ switch( to )
+ {
+ case TransformSpaceTo.Object:
+ {
+ if( dataCollector.IsTemplate && dataCollector.IsSRP )
+ {
+ if( dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD )
+ {
+ if( m_absoluteWorldPos )
+ {
+ result = string.Format( ASEHDRelaviveCameraPos, result );
+ }
+ result = string.Format( AseSRPWorldToObjectPosFormat, result );
+ }
+ else if( dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.Lightweight )
+ {
+ result = string.Format( AseSRPWorldToObjectPosFormat, result );
+ }
+
+ }
+ else
+ result = string.Format( AseWorldToObjectPosFormat, result );
+ varName = AseWorldToObjectPosVarName + OutputId;
+ }
+ break;
+ default:
+ case TransformSpaceTo.World: break;
+ case TransformSpaceTo.View:
+ {
+ result = string.Format( AseWorldToViewPosFormat, result );
+ varName = AseWorldToViewPosVarName + OutputId;
+ }
+ break;
+ case TransformSpaceTo.Clip:
+ {
+ if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType != TemplateSRPType.BuiltIn )
+ {
+ result = string.Format( AseSRPWorldToClipPosFormat, result );
+ }
+ else
+ {
+ result = string.Format( AseWorldToClipPosFormat, result );
+ }
+ varName = AseWorldToClipPosVarName + OutputId;
+ }
+ break;
+ }
+ }
+ break;
+ case TransformSpaceFrom.View:
+ {
+ switch( to )
+ {
+ case TransformSpaceTo.Object:
+ {
+ if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD )
+ result = string.Format( AseHDViewToObjectPosFormat, result );
+ else
+ result = string.Format( AseViewToObjectPosFormat, result );
+ varName = AseViewToObjectPosVarName + OutputId;
+ }
+ break;
+ case TransformSpaceTo.World:
+ {
+ result = string.Format( AseViewToWorldPosFormat, result );
+ varName = AseViewToWorldPosVarName + OutputId;
+ }
+ break;
+ default:
+ case TransformSpaceTo.View: break;
+ case TransformSpaceTo.Clip:
+ {
+ if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType != TemplateSRPType.BuiltIn )
+ {
+ result = string.Format( AseSRPViewToClipPosFormat, result );
+ }
+ else
+ {
+ result = string.Format( AseViewToClipPosFormat, result );
+ }
+ varName = AseViewToClipPosVarName + OutputId;
+ }
+ break;
+ }
+ }
+ break;
+ //case TransformSpace.Clip:
+ //{
+ // switch( to )
+ // {
+ // case TransformSpace.Object:
+ // {
+ // if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD )
+ // {
+ // result = string.Format( AseHDClipToObjectPosFormat, result );
+ // }
+ // else
+ // {
+ // result = string.Format( AseClipToObjectPosFormat, result );
+ // }
+ // varName = AseClipToObjectPosVarName + OutputId;
+ // }
+ // break;
+ // case TransformSpace.World:
+ // {
+ // if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD )
+ // {
+ // result = string.Format( AseHDClipToWorldPosFormat, result );
+ // }
+ // else
+ // {
+ // result = string.Format( AseClipToWorldPosFormat, result );
+ // }
+ // varName = AseClipToWorldPosVarName + OutputId;
+ // }
+ // break;
+ // case TransformSpace.View:
+ // {
+ // if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD )
+ // {
+ // result = string.Format( AseHDClipToViewPosFormat, result );
+ // }
+ // else
+ // {
+ // result = string.Format( AseClipToViewPosFormat, result );
+ // }
+ // varName = AseClipToViewPosVarName + OutputId;
+ // }
+ // break;
+ // case TransformSpace.Clip: break;
+ // default:
+ // break;
+ // }
+ //}
+ //break;
+ default: break;
+ }
+ }
+
+ public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
+ {
+ if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
+ return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
+
+ GeneratorUtils.RegisterUnity2019MatrixDefines( ref dataCollector );
+
+ string result = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
+ string varName = string.Empty;
+
+ if( (int)m_from == (int)m_to )
+ {
+ RegisterLocalVariable( 0, result, ref dataCollector );
+ return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
+ }
+
+ switch( m_from )
+ {
+ case TransformSpaceFrom.Object:
+ {
+ switch( m_to )
+ {
+ default:
+ case TransformSpaceTo.Object: break;
+ case TransformSpaceTo.World:
+ {
+ CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result );
+ }
+ break;
+ case TransformSpaceTo.View:
+ {
+ CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result );
+ }
+ break;
+ case TransformSpaceTo.Clip:
+ {
+ CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result );
+ }
+ break;
+ case TransformSpaceTo.Tangent:
+ {
+ GeneratorUtils.GenerateWorldToTangentMatrix( ref dataCollector, UniqueId, CurrentPrecisionType );
+ CalculateTransform( m_from, TransformSpaceTo.World, ref dataCollector, ref varName, ref result );
+ result = string.Format( ASEWorldToTangentFormat, result );
+ varName = AseObjectToTangentPosVarName + OutputId;
+ }
+ break;
+ }
+ }
+ break;
+ case TransformSpaceFrom.World:
+ {
+ switch( m_to )
+ {
+ case TransformSpaceTo.Object:
+ {
+ CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result );
+ }
+ break;
+ default:
+ case TransformSpaceTo.World: break;
+ case TransformSpaceTo.View:
+ {
+ CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result );
+ }
+ break;
+ case TransformSpaceTo.Clip:
+ {
+ CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result );
+ }
+ break;
+ case TransformSpaceTo.Tangent:
+ {
+ GeneratorUtils.GenerateWorldToTangentMatrix( ref dataCollector, UniqueId, CurrentPrecisionType );
+ result = string.Format( ASEWorldToTangentFormat, result );
+ varName = AseWorldToTangentPosVarName + OutputId;
+ }
+ break;
+ }
+ }
+ break;
+ case TransformSpaceFrom.View:
+ {
+ switch( m_to )
+ {
+ case TransformSpaceTo.Object:
+ {
+ CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result );
+ }
+ break;
+ case TransformSpaceTo.World:
+ {
+ CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result ); ;
+ }
+ break;
+ default:
+ case TransformSpaceTo.View: break;
+ case TransformSpaceTo.Clip:
+ {
+ CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result );
+ }
+ break;
+ case TransformSpaceTo.Tangent:
+ {
+ GeneratorUtils.GenerateWorldToTangentMatrix( ref dataCollector, UniqueId, CurrentPrecisionType );
+ CalculateTransform( m_from, TransformSpaceTo.World, ref dataCollector, ref varName, ref result );
+ result = string.Format( ASEWorldToTangentFormat, result );
+ varName = AseViewToTangentPosVarName + OutputId;
+ }
+ break;
+ }
+ }
+ break;
+ //case TransformSpace.Clip:
+ //{
+ // switch( m_to )
+ // {
+ // case TransformSpace.Object:
+ // {
+ // CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result );
+ // }
+ // break;
+ // case TransformSpace.World:
+ // {
+ // CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result );
+ // }
+ // break;
+ // case TransformSpace.View:
+ // {
+ // CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result );
+ // }
+ // break;
+ // case TransformSpace.Clip: break;
+ // case TransformSpace.Tangent:
+ // {
+ // GeneratorUtils.GenerateWorldToTangentMatrix( ref dataCollector, UniqueId, CurrentPrecisionType );
+ // CalculateTransform( m_from, TransformSpace.World, ref dataCollector, ref varName, ref result );
+ // result = string.Format( ASEWorldToTangentFormat, result );
+ // varName = AseClipToTangentPosVarName + OutputId;
+ // }
+ // break;
+ // default:
+ // break;
+ // }
+ //}
+ //break;
+ case TransformSpaceFrom.Tangent:
+ {
+ string matrixVal = string.Empty;
+ if( m_inverseTangentType == InverseTangentType.Fast )
+ matrixVal = GeneratorUtils.GenerateTangentToWorldMatrixFast( ref dataCollector, UniqueId, CurrentPrecisionType );
+ else
+ matrixVal = GeneratorUtils.GenerateTangentToWorldMatrixPrecise( ref dataCollector, UniqueId, CurrentPrecisionType );
+
+ switch( m_to )
+ {
+ case TransformSpaceTo.Object:
+ {
+ result = string.Format( ASEMulOpFormat, matrixVal, result );
+ CalculateTransform( TransformSpaceFrom.World, m_to, ref dataCollector, ref varName, ref result );
+ varName = AseTangentToObjectPosVarName + OutputId;
+ }
+ break;
+ case TransformSpaceTo.World:
+ {
+ result = string.Format( ASEMulOpFormat, matrixVal, result );
+ varName = AseTangentToWorldPosVarName + OutputId;
+ }
+ break;
+ case TransformSpaceTo.View:
+ {
+ result = string.Format( ASEMulOpFormat, matrixVal, result );
+ CalculateTransform( TransformSpaceFrom.World, m_to, ref dataCollector, ref varName, ref result );
+ varName = AseTangentToViewPosVarName + OutputId;
+ }
+ break;
+ case TransformSpaceTo.Clip:
+ {
+ result = string.Format( ASEMulOpFormat, matrixVal, result );
+ CalculateTransform( TransformSpaceFrom.World, m_to, ref dataCollector, ref varName, ref result );
+ varName = AseTangentToClipPosVarName + OutputId;
+ }
+ break;
+ case TransformSpaceTo.Tangent:
+ default:
+ break;
+ }
+ }
+ break;
+ default: break;
+ }
+
+ if( m_to == TransformSpaceTo.Clip )
+ {
+ if( m_perspectiveDivide )
+ {
+ dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT4, varName, result );
+ result = string.Format( AseClipToNDC, varName );
+ varName += "NDC";
+ }
+ else
+ {
+ result += ".xyz";
+ }
+ }
+
+ RegisterLocalVariable( 0, result, ref dataCollector, varName );
+ return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
+ }
+
+ public override void ReadFromString( ref string[] nodeParams )
+ {
+ base.ReadFromString( ref nodeParams );
+ string from = GetCurrentParam( ref nodeParams );
+ if( UIUtils.CurrentShaderVersion() < 17500 && from.Equals( "Clip" ) )
+ {
+ UIUtils.ShowMessage( UniqueId, "Clip Space no longer supported on From field over Transform Position node" );
+ }
+ else
+ {
+ m_from = (TransformSpaceFrom)Enum.Parse( typeof( TransformSpaceFrom ), from );
+ }
+ m_to = (TransformSpaceTo)Enum.Parse( typeof( TransformSpaceTo ), GetCurrentParam( ref nodeParams ) );
+ if( UIUtils.CurrentShaderVersion() > 15701 )
+ {
+ m_perspectiveDivide = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
+ }
+ if( UIUtils.CurrentShaderVersion() > 15800 )
+ {
+ m_inverseTangentType = (InverseTangentType)Enum.Parse( typeof( InverseTangentType ), GetCurrentParam( ref nodeParams ) );
+ }
+ if( UIUtils.CurrentShaderVersion() > 16103 )
+ {
+ m_absoluteWorldPos = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
+ }
+ UpdateSubtitle();
+ }
+
+ public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
+ {
+ base.WriteToString( ref nodeInfo, ref connectionsInfo );
+ IOUtils.AddFieldValueToString( ref nodeInfo, m_from );
+ IOUtils.AddFieldValueToString( ref nodeInfo, m_to );
+ IOUtils.AddFieldValueToString( ref nodeInfo, m_perspectiveDivide );
+ IOUtils.AddFieldValueToString( ref nodeInfo, m_inverseTangentType );
+ IOUtils.AddFieldValueToString( ref nodeInfo, m_absoluteWorldPos );
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformPositionNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformPositionNode.cs.meta
new file mode 100644
index 00000000..84e1fcd2
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformPositionNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 274dde08d42e4b041b9be7a22a8c09d6
+timeCreated: 1525857790
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformVariables.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformVariables.cs
new file mode 100644
index 00000000..1802fe55
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformVariables.cs
@@ -0,0 +1,166 @@
+// 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 BuiltInShaderTransformTypes
+ {
+ UNITY_MATRIX_MVP = 0,
+ UNITY_MATRIX_MV,
+ UNITY_MATRIX_V,
+ UNITY_MATRIX_P,
+ UNITY_MATRIX_VP,
+ UNITY_MATRIX_T_MV,
+ UNITY_MATRIX_IT_MV,
+ //UNITY_MATRIX_TEXTURE0,
+ //UNITY_MATRIX_TEXTURE1,
+ //UNITY_MATRIX_TEXTURE2,
+ //UNITY_MATRIX_TEXTURE3,
+ _Object2World,
+ _World2Object//,
+ //unity_Scale
+ }
+
+ [Serializable]
+ [NodeAttributes( "Common Transform Matrices", "Matrix Transform", "All Transformation types" )]
+ public sealed class TransformVariables : ShaderVariablesNode
+ {
+ [SerializeField]
+ private BuiltInShaderTransformTypes m_selectedType = BuiltInShaderTransformTypes.UNITY_MATRIX_MVP;
+
+ private const string MatrixLabelStr = "Matrix";
+ private readonly string[] ValuesStr =
+ {
+ "Model View Projection",
+ "Model View",
+ "View",
+ "Projection",
+ "View Projection",
+ "Transpose Model View",
+ "Inverse Transpose Model View",
+ "Object to World",
+ "Word to Object"
+ };
+
+ private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper();
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ ChangeOutputProperties( 0, ValuesStr[ ( int ) m_selectedType ], WirePortDataType.FLOAT4x4 );
+ m_textLabelWidth = 60;
+ m_hasLeftDropdown = true;
+ m_autoWrapProperties = true;
+ m_drawPreview = false;
+ }
+
+ 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 Draw( DrawInfo drawInfo )
+ {
+ base.Draw( drawInfo );
+ EditorGUI.BeginChangeCheck();
+ m_selectedType = (BuiltInShaderTransformTypes)m_upperLeftWidget.DrawWidget( this, (int)m_selectedType, ValuesStr );
+ if( EditorGUI.EndChangeCheck() )
+ {
+ ChangeOutputName( 0, ValuesStr[ (int)m_selectedType ] );
+ m_sizeIsDirty = true;
+ }
+ }
+
+ public override void DrawProperties()
+ {
+ base.DrawProperties();
+ EditorGUI.BeginChangeCheck();
+ m_selectedType = ( BuiltInShaderTransformTypes ) EditorGUILayoutPopup( MatrixLabelStr, ( int ) m_selectedType, ValuesStr );
+ if ( EditorGUI.EndChangeCheck() )
+ {
+ ChangeOutputName( 0, ValuesStr[ ( int ) m_selectedType ] );
+ m_sizeIsDirty = true;
+ }
+ }
+
+ public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
+ {
+ base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
+ if( dataCollector.IsTemplate && dataCollector.IsSRP )
+ {
+ switch( m_selectedType )
+ {
+ case BuiltInShaderTransformTypes.UNITY_MATRIX_MVP:
+ return "mul(GetWorldToHClipMatrix(),GetObjectToWorldMatrix())";
+ case BuiltInShaderTransformTypes.UNITY_MATRIX_MV:
+ return "mul( GetWorldToViewMatrix(),GetObjectToWorldMatrix())";
+ case BuiltInShaderTransformTypes.UNITY_MATRIX_V:
+ return "GetWorldToViewMatrix()";
+ case BuiltInShaderTransformTypes.UNITY_MATRIX_P:
+ return "GetViewToHClipMatrix()";
+ case BuiltInShaderTransformTypes.UNITY_MATRIX_VP:
+ return "GetWorldToHClipMatrix()";
+ case BuiltInShaderTransformTypes._Object2World:
+ return "GetObjectToWorldMatrix()";
+ case BuiltInShaderTransformTypes._World2Object:
+ return "GetWorldToObjectMatrix()";
+ case BuiltInShaderTransformTypes.UNITY_MATRIX_T_MV:
+ case BuiltInShaderTransformTypes.UNITY_MATRIX_IT_MV:
+ default:
+ {
+ UIUtils.ShowMessage( UniqueId, "Matrix not declared natively on SRP. Must create it manually inside ASE" );
+ return "float4x4(" +
+ "1,0,0,0," +
+ "0,1,0,0," +
+ "0,0,1,0," +
+ "0,0,0,1)";
+ }
+ }
+ }
+ else
+ {
+ return m_selectedType.ToString();
+ }
+ }
+
+ public override void ReadFromString( ref string[] nodeParams )
+ {
+ base.ReadFromString( ref nodeParams );
+ string selectedTypeStr = GetCurrentParam( ref nodeParams );
+ try
+ {
+ BuiltInShaderTransformTypes selectedType = (BuiltInShaderTransformTypes)Enum.Parse( typeof( BuiltInShaderTransformTypes ), selectedTypeStr );
+ m_selectedType = selectedType;
+ }
+ catch( Exception e )
+ {
+ switch( selectedTypeStr )
+ {
+ default: Debug.LogException( e );break;
+ case "UNITY_MATRIX_TEXTURE0":UIUtils.ShowMessage( UniqueId, "Texture 0 matrix is no longer supported",MessageSeverity.Warning);break;
+ case "UNITY_MATRIX_TEXTURE1":UIUtils.ShowMessage( UniqueId, "Texture 1 matrix is no longer supported",MessageSeverity.Warning);break;
+ case "UNITY_MATRIX_TEXTURE2":UIUtils.ShowMessage( UniqueId, "Texture 2 matrix is no longer supported",MessageSeverity.Warning);break;
+ case "UNITY_MATRIX_TEXTURE3":UIUtils.ShowMessage( UniqueId, "Texture 3 matrix is no longer supported",MessageSeverity.Warning); break;
+ case "unity_Scale": UIUtils.ShowMessage( UniqueId, "Scale matrix is no longer supported", MessageSeverity.Warning ); break;
+ }
+ }
+
+ ChangeOutputName( 0, ValuesStr[ ( 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 );
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformVariables.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformVariables.cs.meta
new file mode 100644
index 00000000..d0e613af
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformVariables.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 04aad5172ee1d4d4795e20bfae0ff64d
+timeCreated: 1481126953
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransposeMVMatrix.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransposeMVMatrix.cs
new file mode 100644
index 00000000..c7c46fe8
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransposeMVMatrix.cs
@@ -0,0 +1,18 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+namespace AmplifyShaderEditor
+{
+ [System.Serializable]
+ [NodeAttributes( "Transpose Model View Matrix", "Matrix Transform", "Transpose of model * view matrix" )]
+ public sealed class TransposeMVMatrix : ConstantShaderVariable
+ {
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
+ m_value = "UNITY_MATRIX_T_MV";
+ m_drawPreview = false;
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransposeMVMatrix.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransposeMVMatrix.cs.meta
new file mode 100644
index 00000000..871d6018
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransposeMVMatrix.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 5762b195353d629448631bfb15fb8372
+timeCreated: 1481126955
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorClipMatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorClipMatrixNode.cs
new file mode 100644
index 00000000..09325ec7
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorClipMatrixNode.cs
@@ -0,0 +1,23 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+namespace AmplifyShaderEditor
+{
+ [System.Serializable]
+ [NodeAttributes( "Projector Clip Matrix", "Matrix Transform", "Current Projector Clip matrix. To be used when working with Unity projector." )]
+ public sealed class UnityProjectorClipMatrixNode : ConstantShaderVariable
+ {
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
+ m_value = "unity_ProjectorClip";
+ }
+
+ public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
+ {
+ dataCollector.AddToUniforms( UniqueId, "float4x4 unity_ProjectorClip;" );
+ return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorClipMatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorClipMatrixNode.cs.meta
new file mode 100644
index 00000000..6bc17bde
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorClipMatrixNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 6095e3e4dc186f146bc109813901ccc8
+timeCreated: 1512062884
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorMatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorMatrixNode.cs
new file mode 100644
index 00000000..4cfb63c8
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorMatrixNode.cs
@@ -0,0 +1,23 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+namespace AmplifyShaderEditor
+{
+ [System.Serializable]
+ [NodeAttributes( "Projector Matrix", "Matrix Transform", "Current Projector Clip matrix. To be used when working with Unity projector." )]
+ public sealed class UnityProjectorMatrixNode : ConstantShaderVariable
+ {
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
+ m_value = "unity_Projector";
+ }
+
+ public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
+ {
+ dataCollector.AddToUniforms( UniqueId, "float4x4 unity_Projector;" );
+ return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorMatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorMatrixNode.cs.meta
new file mode 100644
index 00000000..0a62ab9f
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorMatrixNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: c3efd02b48473d94b92302654b671ddc
+timeCreated: 1512062884
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityScaleMatrix.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityScaleMatrix.cs
new file mode 100644
index 00000000..2d2f00c9
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityScaleMatrix.cs
@@ -0,0 +1,18 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+namespace AmplifyShaderEditor
+{
+ [System.Serializable]
+ [NodeAttributes( "Scale Matrix", "Matrix Transform", "Scale Matrix",null, UnityEngine.KeyCode.None, true, true, "Object Scale" )]
+ public sealed class UnityScaleMatrix : ConstantShaderVariable
+ {
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
+ m_value = "unity_Scale";
+ m_drawPreview = false;
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityScaleMatrix.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityScaleMatrix.cs.meta
new file mode 100644
index 00000000..26f2df76
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityScaleMatrix.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 28a04286716e19f4aa58954888374428
+timeCreated: 1481126954
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewMatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewMatrixNode.cs
new file mode 100644
index 00000000..2291bc32
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewMatrixNode.cs
@@ -0,0 +1,19 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+namespace AmplifyShaderEditor
+{
+ [System.Serializable]
+ [NodeAttributes( "View Matrix", "Matrix Transform", "Current view matrix" )]
+ public sealed class ViewMatrixNode : ConstantShaderVariable
+ {
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
+ m_value = "UNITY_MATRIX_V";
+ m_drawPreview = false;
+ m_matrixId = 0;
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewMatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewMatrixNode.cs.meta
new file mode 100644
index 00000000..bcfb2edc
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewMatrixNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 5aa75cc5e6044a44a9a4439eac1d948b
+timeCreated: 1481126956
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewProjectionMatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewProjectionMatrixNode.cs
new file mode 100644
index 00000000..23e53e40
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewProjectionMatrixNode.cs
@@ -0,0 +1,18 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+namespace AmplifyShaderEditor
+{
+ [System.Serializable]
+ [NodeAttributes( "View Projection Matrix", "Matrix Transform", "Current view * projection matrix." )]
+ public sealed class ViewProjectionMatrixNode : ConstantShaderVariable
+ {
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
+ m_value = "UNITY_MATRIX_VP";
+ m_drawPreview = false;
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewProjectionMatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewProjectionMatrixNode.cs.meta
new file mode 100644
index 00000000..1a1cd1c4
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewProjectionMatrixNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: fe26c99932382e047aebc05b7e67a3d0
+timeCreated: 1481126960
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToCameraMatrix.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToCameraMatrix.cs
new file mode 100644
index 00000000..65d9e082
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToCameraMatrix.cs
@@ -0,0 +1,23 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+namespace AmplifyShaderEditor
+{
+ [System.Serializable]
+ [NodeAttributes( "World To Camera Matrix", "Matrix Transform", "Inverse of current camera to world matrix" )]
+ public sealed class WorldToCameraMatrix : ConstantShaderVariable
+ {
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
+ m_value = "unity_WorldToCamera";
+ 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 );
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToCameraMatrix.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToCameraMatrix.cs.meta
new file mode 100644
index 00000000..a8d0b7a1
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToCameraMatrix.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 584bea5554dc1b64c8965d8fcfc54e23
+timeCreated: 1481126959
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToObjectMatrix.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToObjectMatrix.cs
new file mode 100644
index 00000000..dd82ebb1
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToObjectMatrix.cs
@@ -0,0 +1,20 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+namespace AmplifyShaderEditor
+{
+ [System.Serializable]
+ [NodeAttributes( "World To Object Matrix", "Matrix Transform", "Inverse of current world matrix" )]
+ public sealed class WorldToObjectMatrix : ConstantShaderVariable
+ {
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
+ m_value = "unity_WorldToObject";
+ m_HDValue = "GetWorldToObjectMatrix()";
+ m_LWValue = "GetWorldToObjectMatrix()";
+ m_drawPreview = false;
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToObjectMatrix.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToObjectMatrix.cs.meta
new file mode 100644
index 00000000..dd284eb7
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToObjectMatrix.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: d9e2a5077cc29de439d5c845eac35a04
+timeCreated: 1481126959
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToTangentMatrix.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToTangentMatrix.cs
new file mode 100644
index 00000000..194802ef
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToTangentMatrix.cs
@@ -0,0 +1,47 @@
+using System;
+
+namespace AmplifyShaderEditor
+{
+ [Serializable]
+ [NodeAttributes( "World To Tangent Matrix", "Matrix Transform", "World to tangent transform matrix" )]
+ public sealed class WorldToTangentMatrix : ParentNode
+ {
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ AddOutputPort( WirePortDataType.FLOAT3x3, "Out" );
+ //UIUtils.AddNormalDependentCount();
+ m_drawPreview = false;
+ }
+
+ //public override void Destroy()
+ //{
+ // ContainerGraph.RemoveNormalDependentCount();
+ // base.Destroy();
+ //}
+
+ public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector )
+ {
+ base.PropagateNodeData( nodeData, ref dataCollector );
+ dataCollector.DirtyNormal = true;
+ }
+
+ public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
+ {
+ if( dataCollector.IsTemplate )
+ return dataCollector.TemplateDataCollectorInstance.GetWorldToTangentMatrix( CurrentPrecisionType );
+
+ if( dataCollector.IsFragmentCategory )
+ {
+ dataCollector.ForceNormal = true;
+
+ dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, CurrentPrecisionType );
+ dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false );
+ }
+
+ GeneratorUtils.GenerateWorldToTangentMatrix( ref dataCollector, UniqueId, CurrentPrecisionType );
+
+ return GeneratorUtils.WorldToTangentStr;
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToTangentMatrix.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToTangentMatrix.cs.meta
new file mode 100644
index 00000000..ed19db78
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToTangentMatrix.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: b598d9ebc2d7be44a97270732f55f9bc
+timeCreated: 1484747592
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various.meta
new file mode 100644
index 00000000..89ede46c
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various.meta
@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 5bbb49ec7f4a3524d9950847c88d4afc
+folderAsset: yes
+timeCreated: 1481126946
+licenseType: Store
+DefaultImporter:
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/ColorSpaceDouble.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/ColorSpaceDouble.cs
new file mode 100644
index 00000000..231a0111
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/ColorSpaceDouble.cs
@@ -0,0 +1,37 @@
+namespace AmplifyShaderEditor
+{
+ [System.Serializable]
+ [NodeAttributes( "Color Space Double", "Miscellaneous", "Color Space Double" )]
+ public class ColorSpaceDouble : ParentNode
+ {
+ private const string ColorSpaceDoubleStr = "unity_ColorSpaceDouble";
+
+ private readonly string[] ColorSpaceDoubleDef =
+ {
+ "#ifdef UNITY_COLORSPACE_GAMMA//ASE Color Space Def",
+ "#define unity_ColorSpaceDouble half4(2.0, 2.0, 2.0, 2.0)//ASE Color Space Def",
+ "#else // Linear values//ASE Color Space Def",
+ "#define unity_ColorSpaceDouble half4(4.59479380, 4.59479380, 4.59479380, 2.0)//ASE Color Space Def",
+ "#endif//ASE Color Space Def"
+ };
+
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ AddOutputColorPorts( "RGBA" );
+ m_previewShaderGUID = "ac680a8772bb97c46851a7f075fd04e3";
+ }
+
+ public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
+ {
+ if( dataCollector.IsTemplate && dataCollector.IsSRP )
+ {
+ for( int i = 0; i < ColorSpaceDoubleDef.Length; i++ )
+ {
+ dataCollector.AddToDirectives( ColorSpaceDoubleDef[ i ], -1 );
+ }
+ }
+ return GetOutputVectorItem( 0, outputId, ColorSpaceDoubleStr ); ;
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/ColorSpaceDouble.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/ColorSpaceDouble.cs.meta
new file mode 100644
index 00000000..32721b88
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/ColorSpaceDouble.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 7d1204234983b3c4499da752961185be
+timeCreated: 1481888315
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/FaceVariableNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/FaceVariableNode.cs
new file mode 100644
index 00000000..0570939c
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/FaceVariableNode.cs
@@ -0,0 +1,53 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+using System;
+
+namespace AmplifyShaderEditor
+{
+ [Serializable]
+ [NodeAttributes( "Face", "Vertex Data", "Indicates whether the rendered surface is facing the camera (1), or facing away from the camera(-1)" )]
+ public class FaceVariableNode : ParentNode
+ {
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ AddOutputPort( WirePortDataType.FLOAT, "Out" );
+ m_previewShaderGUID = "4b0b5b9f16353b840a5f5ad2baab3c3c";
+ }
+
+ public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
+ {
+ if ( dataCollector.PortCategory == MasterNodePortCategory.Tessellation )
+ {
+ UIUtils.ShowMessage( UniqueId, m_nodeAttribs.Name + " node does not work on Tessellation port" );
+ return m_outputPorts[0].ErrorValue;
+ }
+
+ if ( dataCollector.PortCategory == MasterNodePortCategory.Vertex )
+ {
+ if ( dataCollector.TesselationActive )
+ {
+ UIUtils.ShowMessage( UniqueId, m_nodeAttribs.Name + " node does not work properly on Vertex/Tessellation ports" );
+ return m_outputPorts[ 0 ].ErrorValue;
+ }
+ else
+ {
+ UIUtils.ShowMessage( UniqueId, m_nodeAttribs.Name + " node does not work propery on Vertex ports" );
+ return m_outputPorts[ 0 ].ErrorValue;
+ }
+ }
+
+ if ( dataCollector.IsTemplate )
+ {
+ return dataCollector.TemplateDataCollectorInstance.GetVFace( UniqueId );
+ }
+ else
+ {
+ dataCollector.AddToInput( UniqueId, SurfaceInputs.VFACE );
+ string variable = ( dataCollector.PortCategory == MasterNodePortCategory.Vertex ) ? Constants.VertexShaderOutputStr : Constants.InputVarStr;
+ return variable + "." + Constants.VFaceVariable;
+ }
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/FaceVariableNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/FaceVariableNode.cs.meta
new file mode 100644
index 00000000..b583327e
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/FaceVariableNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 4b4a6f07436b05a4cbc2559e4e704000
+timeCreated: 1492513159
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/InstanceIdNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/InstanceIdNode.cs
new file mode 100644
index 00000000..c845e063
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/InstanceIdNode.cs
@@ -0,0 +1,43 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+using System;
+
+namespace AmplifyShaderEditor
+{
+ [Serializable]
+ [NodeAttributes( "Instance ID", "Vertex Data", "Indicates the per-instance identifier" )]
+ public class InstanceIdNode : ParentNode
+ {
+ private readonly string[] InstancingVariableAttrib =
+ { "uint currInstanceId = 0;",
+ "#ifdef UNITY_INSTANCING_ENABLED",
+ "currInstanceId = unity_InstanceID;",
+ "#endif"};
+ private const string InstancingInnerVariable = "currInstanceId";
+
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ AddOutputPort( WirePortDataType.INT, "Out" );
+ m_previewShaderGUID = "03febce56a8cf354b90e7d5180c1dbd7";
+ }
+
+ public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
+ {
+ if( dataCollector.IsTemplate )
+ {
+ dataCollector.TemplateDataCollectorInstance.SetupInstancing();
+ }
+
+ if( !dataCollector.HasLocalVariable( InstancingVariableAttrib[ 0 ] ) )
+ {
+ dataCollector.AddLocalVariable( UniqueId, InstancingVariableAttrib[ 0 ] ,true );
+ dataCollector.AddLocalVariable( UniqueId, InstancingVariableAttrib[ 1 ] ,true );
+ dataCollector.AddLocalVariable( UniqueId, InstancingVariableAttrib[ 2 ] ,true );
+ dataCollector.AddLocalVariable( UniqueId, InstancingVariableAttrib[ 3 ] ,true );
+ }
+ return InstancingInnerVariable;
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/InstanceIdNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/InstanceIdNode.cs.meta
new file mode 100644
index 00000000..efae4fb9
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/InstanceIdNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: c449923583a9fbe4283acebc97756ea1
+timeCreated: 1547811127
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/LODFadeNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/LODFadeNode.cs
new file mode 100644
index 00000000..f2a1959f
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/LODFadeNode.cs
@@ -0,0 +1,44 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+using System;
+namespace AmplifyShaderEditor
+{
+ [Serializable]
+ [NodeAttributes( "LOD Fade", "Miscellaneous", "LODFadeNode" )]
+ public sealed class LODFadeNode : ConstVecShaderVariable
+ {
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ ChangeOutputName( 1, "Fade[0...1]" );
+ ChangeOutputName( 2, "Fade[16Lvl]" );
+ ChangeOutputName( 3, "Unused" );
+ ChangeOutputName( 4, "Unused" );
+ m_value = "unity_LODFade";
+ m_previewShaderGUID = "fcd4d93f57ffc51458d4ade10df2fdb4";
+ }
+
+ 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;
+ }
+
+ if( !m_outputPorts[ 4 ].IsConnected )
+ {
+ m_outputPorts[ 4 ].Visible = false;
+ m_sizeIsDirty = true;
+ }
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/LODFadeNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/LODFadeNode.cs.meta
new file mode 100644
index 00000000..a83635a4
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/LODFadeNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: f96cf34c2936c96458403e9cf75e8e10
+timeCreated: 1481126960
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/PrimitiveIdVariableNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/PrimitiveIdVariableNode.cs
new file mode 100644
index 00000000..b60f8472
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/PrimitiveIdVariableNode.cs
@@ -0,0 +1,38 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+#if UNITY_EDITOR_WIN
+using System;
+
+namespace AmplifyShaderEditor
+{
+ [Serializable]
+ [NodeAttributes( "Primitive ID", "Vertex Data", "Per-primitive identifier automatically generated by the runtime" )]
+ public class PrimitiveIDVariableNode : ParentNode
+ {
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ AddOutputPort( WirePortDataType.INT, "Out" );
+ m_previewShaderGUID = "92c1b588d7658594cb219696f593f64b";
+ }
+
+ public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
+ {
+ if( !dataCollector.IsTemplate )
+ {
+ UIUtils.ShowMessage( UniqueId, m_nodeAttribs.Name + " is not supported on surface shaders." );
+ return m_outputPorts[0].ErrorValue;
+ }
+
+ if ( dataCollector.PortCategory == MasterNodePortCategory.Vertex )
+ {
+ UIUtils.ShowMessage( UniqueId, m_nodeAttribs.Name + " is not supported on Vertex ports" );
+ return m_outputPorts[0].ErrorValue;
+ }
+
+ return dataCollector.TemplateDataCollectorInstance.GetPrimitiveId();
+ }
+ }
+}
+#endif
+
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/PrimitiveIdVariableNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/PrimitiveIdVariableNode.cs.meta
new file mode 100644
index 00000000..6d7d119b
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/PrimitiveIdVariableNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: dd0af9fbbba750341a7b09316178f285
+timeCreated: 1492513159
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/SwitchByFaceNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/SwitchByFaceNode.cs
new file mode 100644
index 00000000..6bfd7f36
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/SwitchByFaceNode.cs
@@ -0,0 +1,70 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+using System;
+
+using UnityEngine;
+
+namespace AmplifyShaderEditor
+{
+ [Serializable]
+ [NodeAttributes( "Switch by Face", "Miscellaneous", "Switch which automaticaly uses a Face variable to select which input to use" )]
+ public class SwitchByFaceNode : DynamicTypeNode
+ {
+ private const string SwitchOp = "((({0}>0)?({1}):({2})))";
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ m_inputPorts[ 0 ].Name = "Front";
+ m_inputPorts[ 1 ].Name = "Back";
+ m_textLabelWidth = 50;
+ m_previewShaderGUID = "f4edf6febb54dc743b25bd5b56facea8";
+ }
+
+
+
+ public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
+ {
+ if ( dataCollector.PortCategory == MasterNodePortCategory.Tessellation )
+ {
+ UIUtils.ShowMessage( UniqueId, m_nodeAttribs.Name + " does not work on Tessellation port" );
+ return GenerateErrorValue();
+ }
+
+ if ( dataCollector.PortCategory == MasterNodePortCategory.Vertex )
+ {
+ if ( dataCollector.TesselationActive )
+ {
+ UIUtils.ShowMessage( UniqueId, m_nodeAttribs.Name + " does not work properly on Vertex/Tessellation ports" );
+ return GenerateErrorValue();
+ }
+ else
+ {
+ UIUtils.ShowMessage( UniqueId, m_nodeAttribs.Name + " does not work properly on Vertex ports" );
+ return GenerateErrorValue();
+ }
+ }
+
+ if ( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
+ return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
+
+ string front = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
+ string back = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector );
+
+ dataCollector.AddToInput( UniqueId, SurfaceInputs.VFACE );
+ string variable = string.Empty;
+ if ( dataCollector.IsTemplate )
+ {
+ variable = dataCollector.TemplateDataCollectorInstance.GetVFace( UniqueId );
+ }
+ else
+ {
+ variable = ( ( dataCollector.PortCategory == MasterNodePortCategory.Vertex ) ? Constants.VertexShaderOutputStr : Constants.InputVarStr ) + "." + Constants.VFaceVariable;
+ }
+
+ string value = string.Format( SwitchOp, variable, front, back );
+ RegisterLocalVariable( 0, value, ref dataCollector, "switchResult" + OutputId );
+ return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/SwitchByFaceNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/SwitchByFaceNode.cs.meta
new file mode 100644
index 00000000..b12692c4
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/SwitchByFaceNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: b0464d8b27caa7d4d8fa5d1828934da8
+timeCreated: 1492515561
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/VertexIdVariableNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/VertexIdVariableNode.cs
new file mode 100644
index 00000000..d2b75192
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/VertexIdVariableNode.cs
@@ -0,0 +1,54 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+using System;
+
+namespace AmplifyShaderEditor
+{
+ [Serializable]
+ [NodeAttributes( "Vertex ID", "Vertex Data", "Indicates current vertex number" )]
+ public class VertexIdVariableNode : ParentNode
+ {
+ private const string VertexIdVarName = "ase_vertexId";
+ private const string VertexIdRegistry = "uint "+ VertexIdVarName + " : SV_VertexID;";
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ AddOutputPort( WirePortDataType.INT, "Out" );
+ m_previewShaderGUID = "5934bf2c10b127a459177a3b622cea65";
+ }
+
+ public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
+ {
+ if ( dataCollector.PortCategory == MasterNodePortCategory.Tessellation )
+ {
+ UIUtils.ShowMessage( UniqueId, m_nodeAttribs.Name + " does not work on Tessellation port" );
+ return m_outputPorts[0].ErrorValue;
+ }
+
+ if ( dataCollector.IsTemplate )
+ {
+ return dataCollector.TemplateDataCollectorInstance.GetVertexId();
+ }
+ else
+ {
+ if( dataCollector.IsFragmentCategory )
+ {
+ GenerateValueInVertex( ref dataCollector, WirePortDataType.UINT, Constants.VertexShaderInputStr + "."+ VertexIdVarName, VertexIdVarName, true );
+ return Constants.InputVarStr + "."+ VertexIdVarName;
+ }
+ else
+ {
+ return Constants.VertexShaderInputStr + "."+ VertexIdVarName;
+ }
+ }
+ }
+ public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector )
+ {
+ if( !dataCollector.IsTemplate )
+ dataCollector.AddCustomAppData( VertexIdRegistry );
+
+ base.PropagateNodeData( nodeData, ref dataCollector );
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/VertexIdVariableNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/VertexIdVariableNode.cs.meta
new file mode 100644
index 00000000..cad8fe04
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/VertexIdVariableNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: ce37a30cae7677942ad44f0945ab7b77
+timeCreated: 1492513159
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/WorldTransformParams.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/WorldTransformParams.cs
new file mode 100644
index 00000000..49966a09
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/WorldTransformParams.cs
@@ -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( "World Transform Params", "Object Transform", "World Transform Params contains information about the transform, W is usually 1.0, or -1.0 for odd-negative scale transforms" )]
+ public sealed class WorldTransformParams : ConstVecShaderVariable
+ {
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ ChangeOutputName( 1, "X" );
+ ChangeOutputName( 2, "Y" );
+ ChangeOutputName( 3, "Z" );
+ ChangeOutputName( 4, "W" );
+ m_value = "unity_WorldTransformParams";
+ m_previewShaderGUID = "5a2642605f085da458d6e03ade47b87a";
+ }
+
+ public override void RefreshExternalReferences()
+ {
+ base.RefreshExternalReferences();
+ if( !m_outputPorts[ 0 ].IsConnected )
+ {
+ m_outputPorts[ 0 ].Visible = false;
+ m_sizeIsDirty = true;
+ }
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/WorldTransformParams.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/WorldTransformParams.cs.meta
new file mode 100644
index 00000000..b28aa84a
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/WorldTransformParams.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: aec376443deca354789bc36ba18af898
+timeCreated: 1481126960
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: