You've already forked FateViewer
Add project files.
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c4b0845954941d4d9809abaa67bdc2b
|
||||
folderAsset: yes
|
||||
timeCreated: 1481126947
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,100 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
public enum BuiltInShaderCameraTypes
|
||||
{
|
||||
unity_CameraProjection = 0,
|
||||
unity_CameraInvProjection
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[NodeAttributes( "Projection Matrices", "Camera And Screen", "Camera's Projection/Inverse Projection matrix" )]
|
||||
public sealed class CameraProjectionNode : ShaderVariablesNode
|
||||
{
|
||||
private const string _projMatrixLabelStr = "Projection Matrix";
|
||||
private readonly string[] _projMatrixValuesStr = { "Camera Projection",
|
||||
"Inverse Camera Projection"};
|
||||
|
||||
|
||||
[SerializeField]
|
||||
private BuiltInShaderCameraTypes m_selectedType = BuiltInShaderCameraTypes.unity_CameraProjection;
|
||||
|
||||
private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper();
|
||||
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, _projMatrixValuesStr[ (int)m_selectedType ], WirePortDataType.FLOAT4x4 );
|
||||
m_textLabelWidth = 115;
|
||||
m_autoWrapProperties = true;
|
||||
m_hasLeftDropdown = true;
|
||||
}
|
||||
|
||||
public override void AfterCommonInit()
|
||||
{
|
||||
base.AfterCommonInit();
|
||||
if( PaddingTitleLeft == 0 )
|
||||
{
|
||||
PaddingTitleLeft = Constants.PropertyPickerWidth + Constants.IconsLeftRightMargin;
|
||||
if( PaddingTitleRight == 0 )
|
||||
PaddingTitleRight = Constants.PropertyPickerWidth + Constants.IconsLeftRightMargin;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Destroy()
|
||||
{
|
||||
base.Destroy();
|
||||
m_upperLeftWidget = null;
|
||||
}
|
||||
|
||||
public override void Draw( DrawInfo drawInfo )
|
||||
{
|
||||
base.Draw( drawInfo );
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_selectedType = (BuiltInShaderCameraTypes)m_upperLeftWidget.DrawWidget( this, (int)m_selectedType, _projMatrixValuesStr );
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
ChangeOutputName( 0, _projMatrixValuesStr[ (int)m_selectedType ] );
|
||||
SetSaveIsDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawProperties()
|
||||
{
|
||||
base.DrawProperties();
|
||||
EditorGUI.BeginChangeCheck();
|
||||
m_selectedType = (BuiltInShaderCameraTypes)EditorGUILayoutPopup( _projMatrixLabelStr, (int)m_selectedType, _projMatrixValuesStr );
|
||||
if( EditorGUI.EndChangeCheck() )
|
||||
{
|
||||
ChangeOutputName( 0, _projMatrixValuesStr[ (int)m_selectedType ] );
|
||||
SetSaveIsDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
|
||||
GeneratorUtils.RegisterUnity2019MatrixDefines( ref dataCollector );
|
||||
return m_selectedType.ToString();
|
||||
}
|
||||
|
||||
public override void ReadFromString( ref string[] nodeParams )
|
||||
{
|
||||
base.ReadFromString( ref nodeParams );
|
||||
m_selectedType = (BuiltInShaderCameraTypes)Enum.Parse( typeof( BuiltInShaderCameraTypes ), GetCurrentParam( ref nodeParams ) );
|
||||
ChangeOutputName( 0, _projMatrixValuesStr[ (int)m_selectedType ] );
|
||||
}
|
||||
|
||||
public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
|
||||
{
|
||||
base.WriteToString( ref nodeInfo, ref connectionsInfo );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedType );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f776bdd36b750304c8e0de8ee1f31fc0
|
||||
timeCreated: 1481126960
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5a9a010f1c8dda449c8ca7ee9e25869
|
||||
timeCreated: 1481126959
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,38 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using System;
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[Serializable]
|
||||
[NodeAttributes( "Ortho Params", "Camera And Screen", "Orthographic Parameters" )]
|
||||
public sealed class OrthoParams : ConstVecShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputName( 1, "Ortho Cam Width" );
|
||||
ChangeOutputName( 2, "Ortho Cam Height" );
|
||||
ChangeOutputName( 3, "Unused" );
|
||||
ChangeOutputName( 4, "Projection Mode" );
|
||||
m_value = "unity_OrthoParams";
|
||||
m_previewShaderGUID = "88a910ece3dce224793e669bb1bc158d";
|
||||
}
|
||||
|
||||
public override void RefreshExternalReferences()
|
||||
{
|
||||
base.RefreshExternalReferences();
|
||||
if( !m_outputPorts[ 0 ].IsConnected )
|
||||
{
|
||||
m_outputPorts[ 0 ].Visible = false;
|
||||
m_sizeIsDirty = true;
|
||||
}
|
||||
|
||||
if( !m_outputPorts[ 3 ].IsConnected )
|
||||
{
|
||||
m_outputPorts[ 3 ].Visible = false;
|
||||
m_sizeIsDirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9431cdf8e81c1d4f902b3fa7d04f7ac
|
||||
timeCreated: 1481126960
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using System;
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[Serializable]
|
||||
[NodeAttributes( "Projection Params", "Camera And Screen", "Projection Near/Far parameters" )]
|
||||
public sealed class ProjectionParams : ConstVecShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputName( 1, "Flipped" );
|
||||
ChangeOutputName( 2, "Near Plane" );
|
||||
ChangeOutputName( 3, "Far Plane" );
|
||||
ChangeOutputName( 4, "1/Far Plane" );
|
||||
m_value = "_ProjectionParams";
|
||||
m_previewShaderGUID = "97ae846cb0a6b044388fad3bc03bb4c2";
|
||||
}
|
||||
|
||||
public override void RefreshExternalReferences()
|
||||
{
|
||||
base.RefreshExternalReferences();
|
||||
if( !m_outputPorts[ 0 ].IsConnected )
|
||||
{
|
||||
m_outputPorts[ 0 ].Visible = false;
|
||||
m_sizeIsDirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba1ca8bace2c2dd4dafac6f73f4dfb1b
|
||||
timeCreated: 1481126958
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using System;
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[Serializable]
|
||||
[NodeAttributes( "Screen Params", "Camera And Screen", "Camera's Render Target size parameters" )]
|
||||
public sealed class ScreenParams : ConstVecShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputName( 1, "RT Width" );
|
||||
ChangeOutputName( 2, "RT Height" );
|
||||
ChangeOutputName( 3, "1+1/Width" );
|
||||
ChangeOutputName( 4, "1+1/Height" );
|
||||
m_value = "_ScreenParams";
|
||||
m_previewShaderGUID = "78173633b803de4419206191fed3d61e";
|
||||
}
|
||||
|
||||
//public override void RefreshExternalReferences()
|
||||
//{
|
||||
// base.RefreshExternalReferences();
|
||||
// if( !m_outputPorts[ 0 ].IsConnected )
|
||||
// {
|
||||
// m_outputPorts[ 0 ].Visible = false;
|
||||
// m_sizeIsDirty = true;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e593f23857d59643b5b5f6dd6264e1b
|
||||
timeCreated: 1481126954
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,28 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using System;
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[Serializable]
|
||||
[NodeAttributes( "World Space Camera Pos", "Camera And Screen", "World Space Camera position" )]
|
||||
public sealed class WorldSpaceCameraPos : ConstantShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "XYZ", WirePortDataType.FLOAT3 );
|
||||
AddOutputPort( WirePortDataType.FLOAT, "X" );
|
||||
AddOutputPort( WirePortDataType.FLOAT, "Y" );
|
||||
AddOutputPort( WirePortDataType.FLOAT, "Z" );
|
||||
|
||||
m_value = "_WorldSpaceCameraPos";
|
||||
m_previewShaderGUID = "6b0c78411043dd24dac1152c84bb63ba";
|
||||
}
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
return GetOutputVectorItem( 0, outputId, base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 972d92a6008896f4292a61726e18f667
|
||||
timeCreated: 1481126957
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,31 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using System;
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[Serializable]
|
||||
[NodeAttributes( "Z-Buffer Params", "Camera And Screen", "Linearized Z buffer values" )]
|
||||
public sealed class ZBufferParams : ConstVecShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputName( 1, "1-far/near" );
|
||||
ChangeOutputName( 2, "far/near" );
|
||||
ChangeOutputName( 3, "[0]/far" );
|
||||
ChangeOutputName( 4, "[1]/far" );
|
||||
m_value = "_ZBufferParams";
|
||||
m_previewShaderGUID = "56c42c106bcb497439187f5bb6b6f94d";
|
||||
}
|
||||
public override void RefreshExternalReferences()
|
||||
{
|
||||
base.RefreshExternalReferences();
|
||||
if( !m_outputPorts[ 0 ].IsConnected )
|
||||
{
|
||||
m_outputPorts[ 0 ].Visible = false;
|
||||
m_sizeIsDirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2765a41106f478f4982e859b978bdec4
|
||||
timeCreated: 1481126954
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,39 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using UnityEngine;
|
||||
using System;
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[Serializable]
|
||||
public class ConstVecShaderVariable : ShaderVariablesNode
|
||||
{
|
||||
[SerializeField]
|
||||
protected string m_value;
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, " ", WirePortDataType.FLOAT4 );
|
||||
AddOutputPort( WirePortDataType.FLOAT, "0" );
|
||||
AddOutputPort( WirePortDataType.FLOAT, "1" );
|
||||
AddOutputPort( WirePortDataType.FLOAT, "2" );
|
||||
AddOutputPort( WirePortDataType.FLOAT, "3" );
|
||||
}
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
|
||||
switch ( outputId )
|
||||
{
|
||||
case 0: return m_value;
|
||||
case 1: return ( m_value + ".x" );
|
||||
case 2: return ( m_value + ".y" );
|
||||
case 3: return ( m_value + ".z" );
|
||||
case 4: return ( m_value + ".w" );
|
||||
}
|
||||
|
||||
UIUtils.ShowMessage( UniqueId, "ConstVecShaderVariable generating empty code", MessageSeverity.Warning );
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9102c0b554fd5ad4785acf870dcc17eb
|
||||
timeCreated: 1481126957
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,35 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[Serializable]
|
||||
public class ConstantShaderVariable : ShaderVariablesNode
|
||||
{
|
||||
[SerializeField]
|
||||
protected string m_value;
|
||||
|
||||
[SerializeField]
|
||||
protected string m_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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 266391c3c4308014e9ce246e5484b917
|
||||
timeCreated: 1481126954
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 78eb7b1e34d423c40a949c9e75b5f24a
|
||||
folderAsset: yes
|
||||
timeCreated: 1481126946
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,126 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
public enum BuiltInFogAndAmbientColors
|
||||
{
|
||||
UNITY_LIGHTMODEL_AMBIENT = 0,
|
||||
unity_AmbientSky,
|
||||
unity_AmbientEquator,
|
||||
unity_AmbientGround,
|
||||
unity_FogColor
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[NodeAttributes( "Fog And Ambient Colors", "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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2bdfc2fa6fcd0640b01a8b7448a1a11
|
||||
timeCreated: 1481126959
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using System;
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[Serializable]
|
||||
[NodeAttributes( "Fog Params", "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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3d8c31159e07bc419a7484ab5e894ed
|
||||
timeCreated: 1481126958
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 47f503bcb5935b649beee3296dd40260
|
||||
folderAsset: yes
|
||||
timeCreated: 1481126946
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 78916999fd7bc3c4e9767bc9cf0698c0
|
||||
timeCreated: 1500054866
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,367 @@
|
||||
// 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 const string FwdBasePragma = "#pragma multi_compile_fwdbase";
|
||||
|
||||
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 );
|
||||
dataCollector.AddToDirectives( FwdBasePragma );
|
||||
string texcoord1 = string.Empty;
|
||||
string texcoord2 = string.Empty;
|
||||
|
||||
if( dataCollector.TemplateDataCollectorInstance.HasInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES1, false, MasterNodePortCategory.Vertex ) )
|
||||
texcoord1 = dataCollector.TemplateDataCollectorInstance.GetInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES1, false, MasterNodePortCategory.Vertex ).VarName;
|
||||
else
|
||||
texcoord1 = dataCollector.TemplateDataCollectorInstance.RegisterInfoOnSemantic( MasterNodePortCategory.Vertex, TemplateInfoOnSematics.TEXTURE_COORDINATES1, TemplateSemantics.TEXCOORD1, "texcoord1", WirePortDataType.FLOAT4, PrecisionType.Float, false );
|
||||
|
||||
if( dataCollector.TemplateDataCollectorInstance.HasInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES2, false, MasterNodePortCategory.Vertex ) )
|
||||
texcoord2 = dataCollector.TemplateDataCollectorInstance.GetInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES2, false, MasterNodePortCategory.Vertex ).VarName;
|
||||
else
|
||||
texcoord2 = dataCollector.TemplateDataCollectorInstance.RegisterInfoOnSemantic( MasterNodePortCategory.Vertex, TemplateInfoOnSematics.TEXTURE_COORDINATES2, TemplateSemantics.TEXCOORD2, "texcoord2", WirePortDataType.FLOAT4, PrecisionType.Float, false );
|
||||
|
||||
string vOutName = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.VertexFunctionData.OutVarName;
|
||||
string fInName = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.FragmentFunctionData.InVarName;
|
||||
TemplateVertexData data = dataCollector.TemplateDataCollectorInstance.RequestNewInterpolator( WirePortDataType.FLOAT4, false, "ase_lmap" );
|
||||
|
||||
string varName = "ase_lmap";
|
||||
if( data != null )
|
||||
varName = data.VarName;
|
||||
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "#ifdef DYNAMICLIGHTMAP_ON //dynlm" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, vOutName + "." + varName + ".zw = " + texcoord2 + ".xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "#endif //dynlm" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "#ifdef LIGHTMAP_ON //stalm" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, vOutName + "." + varName + ".xy = " + texcoord1 + ".xy * unity_LightmapST.xy + unity_LightmapST.zw;" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "#endif //stalm" );
|
||||
|
||||
TemplateVertexData shdata = dataCollector.TemplateDataCollectorInstance.RequestNewInterpolator( WirePortDataType.FLOAT3, false, "ase_sh" );
|
||||
string worldPos = dataCollector.TemplateDataCollectorInstance.GetWorldPos( false, MasterNodePortCategory.Vertex );
|
||||
string worldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( PrecisionType.Float, false, MasterNodePortCategory.Vertex );
|
||||
//Debug.Log( shdata );
|
||||
string shVarName = "ase_sh";
|
||||
if( shdata != null )
|
||||
shVarName = shdata.VarName;
|
||||
string outSH = vOutName + "." + shVarName + ".xyz";
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "#ifndef LIGHTMAP_ON //nstalm" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "#if UNITY_SHOULD_SAMPLE_SH //sh" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, outSH + " = 0;" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "#ifdef VERTEXLIGHT_ON //vl" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, outSH + " += Shade4PointLights (" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0," );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "unity_LightColor[0].rgb, unity_LightColor[1].rgb, unity_LightColor[2].rgb, unity_LightColor[3].rgb," );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "unity_4LightAtten0, " + worldPos + ", " + worldNormal + ");" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "#endif //vl" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, outSH + " = ShadeSHPerVertex (" + worldNormal + ", " + outSH + ");" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "#endif //sh" );
|
||||
dataCollector.AddToVertexLocalVariables( UniqueId, "#endif //nstalm" );
|
||||
|
||||
//dataCollector.AddToPragmas( UniqueId, "multi_compile_fwdbase" );
|
||||
|
||||
string fragWorldNormal = string.Empty;
|
||||
if( m_inputPorts[ 0 ].IsConnected )
|
||||
{
|
||||
if( m_normalSpace == ViewSpace.Tangent )
|
||||
fragWorldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( UniqueId, CurrentPrecisionType, m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ), OutputId );
|
||||
else
|
||||
fragWorldNormal = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
|
||||
}
|
||||
else
|
||||
{
|
||||
fragWorldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( PrecisionType.Float, false, MasterNodePortCategory.Fragment );
|
||||
}
|
||||
|
||||
dataCollector.AddLocalVariable( UniqueId, "UnityGIInput data" + OutputId + ";" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "UNITY_INITIALIZE_OUTPUT( UnityGIInput, data" + OutputId + " );" );
|
||||
|
||||
dataCollector.AddLocalVariable( UniqueId, "#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON) //dylm" + OutputId );
|
||||
dataCollector.AddLocalVariable( UniqueId, "data" + OutputId + ".lightmapUV = " + fInName + "." + varName + ";" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "#endif //dylm" + OutputId );
|
||||
|
||||
dataCollector.AddLocalVariable( UniqueId, "#if UNITY_SHOULD_SAMPLE_SH //fsh" + OutputId );
|
||||
dataCollector.AddLocalVariable( UniqueId, "data" + OutputId + ".ambient = " + fInName + "." + shVarName + ";" );
|
||||
dataCollector.AddLocalVariable( UniqueId, "#endif //fsh" + OutputId );
|
||||
|
||||
dataCollector.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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 11bf17b0757d57c47add2eb50c62c75e
|
||||
timeCreated: 1495726164
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0820850e74009954188ff84e2f5cc4f2
|
||||
timeCreated: 1495817589
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,134 @@
|
||||
// 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 )
|
||||
{
|
||||
string result = string.Empty;
|
||||
if( dataCollector.TemplateDataCollectorInstance.ContainsSpecialLocalFragVar( TemplateInfoOnSematics.SHADOWCOORDS, WirePortDataType.FLOAT4, ref result ) )
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
return dataCollector.TemplateDataCollectorInstance.GetLightAtten( UniqueId );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( dataCollector.CurrentSRPType == TemplateSRPType.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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e205b44d56609f459ffc558febe2792
|
||||
timeCreated: 1495449979
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,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";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 275270020c577924caf04492f73b2ea6
|
||||
timeCreated: 1481126954
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db94d973647dae9488d3ef5ee2fd95a4
|
||||
timeCreated: 1481126959
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,27 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using System;
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[Serializable]
|
||||
public class ShaderVariablesNode : ParentNode
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
AddOutputPort( WirePortDataType.OBJECT, "Out" );
|
||||
}
|
||||
public override string GetIncludes()
|
||||
{
|
||||
return Constants.UnityShaderVariables;
|
||||
}
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
if( !( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.IsSRP ) )
|
||||
dataCollector.AddToIncludes( UniqueId, Constants.UnityShaderVariables );
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1eb723e6ceff9a345a9dbfe04aa3dc11
|
||||
timeCreated: 1481126954
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c77e88b33fec7c429412624a7b2c620
|
||||
folderAsset: yes
|
||||
timeCreated: 1481126947
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 447e504f2ca5aaf4bbf0fdbce33596bc
|
||||
timeCreated: 1481126955
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,33 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
using System;
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[Serializable]
|
||||
[NodeAttributes( "Delta Time", "Time", "Delta time" )]
|
||||
public sealed class DeltaTime : ConstVecShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputName( 1, "dt" );
|
||||
ChangeOutputName( 2, "1/dt" );
|
||||
ChangeOutputName( 3, "smoothDt" );
|
||||
ChangeOutputName( 4, "1/smoothDt" );
|
||||
m_value = "unity_DeltaTime";
|
||||
m_previewShaderGUID = "9d69a693042c443498f96d6da60535eb";
|
||||
m_continuousPreviewRefresh = true;
|
||||
}
|
||||
|
||||
public override void RefreshExternalReferences()
|
||||
{
|
||||
base.RefreshExternalReferences();
|
||||
if( !m_outputPorts[ 0 ].IsConnected )
|
||||
{
|
||||
m_outputPorts[ 0 ].Visible = false;
|
||||
m_sizeIsDirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ddde7ed1ab4f8044a9a6aa3891f5ca4
|
||||
timeCreated: 1481126955
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f36e4491ee33fe74fa51cfb5ad450c6e
|
||||
timeCreated: 1481126959
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 796acd44fcf330e4e921855630007b9b
|
||||
timeCreated: 1481126957
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8c6b7bfb7784e14d8708ab6fb981268
|
||||
timeCreated: 1481126959
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2ce97203c4871664493f8760d88d0d4d
|
||||
folderAsset: yes
|
||||
timeCreated: 1481126946
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,24 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "Camera To World Matrix", "Matrix Transform", "Current camera to world matrix" )]
|
||||
public sealed class CameraToWorldMatrix : ConstantShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
|
||||
m_value = "unity_CameraToWorld";
|
||||
m_drawPreview = false;
|
||||
}
|
||||
|
||||
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
|
||||
{
|
||||
GeneratorUtils.RegisterUnity2019MatrixDefines( ref dataCollector );
|
||||
return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6accfe0f350cf064dae07041fe90446b
|
||||
timeCreated: 1481126959
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,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)";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0fdbc380972c44b489c5f948a40b8e69
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "Inverse Transpose Model View Matrix", "Matrix Transform", "All Transformation types" )]
|
||||
public sealed class InverseTranspMVMatrixNode : ConstantShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
|
||||
m_value = "UNITY_MATRIX_IT_MV";
|
||||
m_drawPreview = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a71f1e560487aa4c8484c4153941884
|
||||
timeCreated: 1481126955
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,19 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "Inverse View Matrix", "Matrix Transform", "Current inverse view matrix" )]
|
||||
public sealed class InverseViewMatrixNode : ConstantShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
|
||||
m_value = "UNITY_MATRIX_I_V";
|
||||
m_drawPreview = false;
|
||||
m_matrixId = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd0c1c252c062184e9ad592b91e7fcd2
|
||||
timeCreated: 1481126956
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,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)";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f6f151774e252dd4fb2b9ee440ec8eed
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "Model Matrix", "Matrix Transform", "Current model matrix" )]
|
||||
public sealed class MMatrixNode : ConstantShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
|
||||
m_value = "UNITY_MATRIX_M";
|
||||
m_drawPreview = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 503a386043991354eaca2410683d836a
|
||||
timeCreated: 1481126955
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "Model View Matrix", "Matrix Transform", "Current model * view matrix" )]
|
||||
public sealed class MVMatrixNode : ConstantShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
|
||||
m_value = "UNITY_MATRIX_MV";
|
||||
m_drawPreview = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 30c7936db4e6fe5488076d799841f857
|
||||
timeCreated: 1481126954
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "Model View Projection Matrix", "Matrix Transform", "Current model * view * projection matrix" )]
|
||||
public sealed class MVPMatrixNode : ConstantShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
|
||||
m_value = "UNITY_MATRIX_MVP";
|
||||
m_drawPreview = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 74e00fb3d8e161f498c078795184bae4
|
||||
timeCreated: 1481126956
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,19 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "Object To World Matrix", "Matrix Transform", "Current model matrix" )]
|
||||
public sealed class ObjectToWorldMatrixNode : ConstantShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
|
||||
m_value = "unity_ObjectToWorld";
|
||||
m_HDValue = "GetObjectToWorldMatrix()";
|
||||
m_LWValue = "GetObjectToWorldMatrix()";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0c0180a327eba54c832fbb695dd282f
|
||||
timeCreated: 1481126958
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,19 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "Projection Matrix", "Matrix Transform", "Current projection matrix" )]
|
||||
public sealed class ProjectionMatrixNode : ConstantShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
|
||||
m_value = "UNITY_MATRIX_P";
|
||||
m_drawPreview = false;
|
||||
m_matrixId = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 008fd07cf3f9a7140a9e23be43733f7c
|
||||
timeCreated: 1481126953
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "Texture 0 Matrix", "Matrix Transform", "Texture 0 Matrix", null, UnityEngine.KeyCode.None, true, true )]
|
||||
public sealed class Texture0MatrixNode : ConstantShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
|
||||
m_value = "UNITY_MATRIX_TEXTURE0";
|
||||
m_drawPreview = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f57a1d05f7a9c5847912566ff1605c6d
|
||||
timeCreated: 1481126960
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "Texture 1 Matrix", "Matrix Transform", "Texture 1 Matrix", null, UnityEngine.KeyCode.None, true, true )]
|
||||
public sealed class Texture1MatrixNode : ConstantShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
|
||||
m_value = "UNITY_MATRIX_TEXTURE1";
|
||||
m_drawPreview = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ef360a7c6005ad479d7a3e6db1d32f4
|
||||
timeCreated: 1481126958
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "Texture 2 Matrix", "Matrix Transform", "Texture 2 Matrix", null, UnityEngine.KeyCode.None, true, true )]
|
||||
public sealed class Texture2MatrixNode : ConstantShaderVariable
|
||||
{
|
||||
protected override void CommonInit( int uniqueId )
|
||||
{
|
||||
base.CommonInit( uniqueId );
|
||||
ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 );
|
||||
m_value = "UNITY_MATRIX_TEXTURE2";
|
||||
m_drawPreview = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6cf4950dda0f6e6438ace404fbef19a7
|
||||
timeCreated: 1481126956
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 02a9fb7a3a104974e941f4109567b97f
|
||||
timeCreated: 1481126953
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,579 @@
|
||||
// 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 bool m_safeNormalize = false;
|
||||
|
||||
[SerializeField]
|
||||
private InverseTangentType m_inverseTangentType = InverseTangentType.Fast;
|
||||
|
||||
private string InverseTBNStr = "Inverse TBN";
|
||||
|
||||
private const string NormalizeOptionStr = "Normalize";
|
||||
private const string SafeNormalizeOptionStr = "Safe";
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
if( m_normalize )
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
m_safeNormalize = EditorGUILayoutToggle( SafeNormalizeOptionStr , m_safeNormalize );
|
||||
EditorGUILayout.HelpBox( Constants.SafeNormalizeInfoStr , MessageType.Info );
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
|
||||
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 = GeneratorUtils.NormalizeValue( ref dataCollector , m_safeNormalize , m_inputPorts[ 0 ].DataType , 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 ) );
|
||||
}
|
||||
if( UIUtils.CurrentShaderVersion() > 18814 )
|
||||
{
|
||||
m_safeNormalize = 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_normalize );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo, m_inverseTangentType );
|
||||
IOUtils.AddFieldValueToString( ref nodeInfo , m_safeNormalize );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5088261e4c0031f4aba961a253707b80
|
||||
timeCreated: 1525857790
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,626 @@
|
||||
// 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 );
|
||||
if( dataCollector.IsTemplate &&
|
||||
dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD &&
|
||||
m_absoluteWorldPos )
|
||||
{
|
||||
result = string.Format( ASEHDAbsoluteWordPos , 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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 274dde08d42e4b041b9be7a22a8c09d6
|
||||
timeCreated: 1525857790
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 04aad5172ee1d4d4795e20bfae0ff64d
|
||||
timeCreated: 1481126953
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5762b195353d629448631bfb15fb8372
|
||||
timeCreated: 1481126955
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6095e3e4dc186f146bc109813901ccc8
|
||||
timeCreated: 1512062884
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3efd02b48473d94b92302654b671ddc
|
||||
timeCreated: 1512062884
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28a04286716e19f4aa58954888374428
|
||||
timeCreated: 1481126954
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,19 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5aa75cc5e6044a44a9a4439eac1d948b
|
||||
timeCreated: 1481126956
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
// Amplify Shader Editor - Visual Shader Editing Tool
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
namespace AmplifyShaderEditor
|
||||
{
|
||||
[System.Serializable]
|
||||
[NodeAttributes( "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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fe26c99932382e047aebc05b7e67a3d0
|
||||
timeCreated: 1481126960
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 584bea5554dc1b64c8965d8fcfc54e23
|
||||
timeCreated: 1481126959
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user