Add project files.

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

View File

@@ -0,0 +1,104 @@
// 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( "Blend Normals", "Textures", "Blend Normals" )]
public class BlendNormalsNode : ParentNode
{
public readonly static string[] ModeListStr = { "Tangent Normals", "Reoriented Tangent Normals", "Reoriented World Normals" };
public readonly static int[] ModeListInt = { 0, 1, 2 };
[SerializeField]
public int m_selectedMode = 0;
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
AddInputPort( WirePortDataType.FLOAT3, false, "Normal A" );
AddInputPort( WirePortDataType.FLOAT3, false, "Normal B" );
AddInputPort( WirePortDataType.FLOAT3, false, "Vertex Normal" );
m_inputPorts[ 2 ].Visible = false;
AddOutputPort( WirePortDataType.FLOAT3, "XYZ" );
m_useInternalPortData = true;
m_previewShaderGUID = "bcdf750ff5f70444f98b8a3efa50dc6f";
}
public override void SetPreviewInputs()
{
base.SetPreviewInputs();
m_previewMaterialPassId = m_selectedMode;
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
{
if( !( dataCollector.IsTemplate && dataCollector.IsSRP ) )
dataCollector.AddToIncludes( UniqueId, Constants.UnityStandardUtilsLibFuncs );
string _inputA = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
string _inputB = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector );
string result = "BlendNormals( " + _inputA + " , " + _inputB + " )";
if( dataCollector.IsTemplate && dataCollector.IsSRP )
{
switch( m_selectedMode )
{
default:
case 0:
result = "BlendNormal( " + _inputA + " , " + _inputB + " )";
break;
case 1:
result = "BlendNormalRNM( " + _inputA + " , " + _inputB + " )";
break;
case 2:
string inputC = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector );
result = "BlendNormalWorldspaceRNM( " + _inputA + " , " + _inputB + ", " + inputC + " )";
break;
}
}
return CreateOutputLocalVariable( 0, result, ref dataCollector );
}
public override void DrawProperties()
{
base.DrawProperties();
if( ContainerGraph.IsSRP )
{
NodeUtils.DrawPropertyGroup( ref m_propertiesFoldout, Constants.ParameterLabelStr, () =>
{
EditorGUI.BeginChangeCheck();
m_selectedMode = EditorGUILayoutIntPopup( "Mode", m_selectedMode, ModeListStr, ModeListInt );
if( EditorGUI.EndChangeCheck() )
{
if( m_selectedMode == 2 )
{
m_inputPorts[ 2 ].Visible = true;
}
else
{
m_inputPorts[ 2 ].Visible = false;
}
m_sizeIsDirty = true;
}
} );
}
}
public override void ReadFromString( ref string[] nodeParams )
{
base.ReadFromString( ref nodeParams );
if( UIUtils.CurrentShaderVersion() > 14503 )
m_selectedMode = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
}
public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
{
base.WriteToString( ref nodeInfo, ref connectionsInfo );
IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedMode );
}
}
}

View File

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

View File

@@ -0,0 +1,53 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
//
// Custom Node HeightMap Texture Masking
// Donated by Rea
using UnityEngine;
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "HeightMap Texture Blend", "Textures", "Advanced Texture Blending by using heightMap and splatMask, usefull for texture layering ", null, KeyCode.None, true, false, null, null, "Rea" )]
public sealed class HeightMapBlendNode : ParentNode
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
AddInputPort( WirePortDataType.FLOAT, false, "HeightMap" );
AddInputPort( WirePortDataType.FLOAT, false, "SplatMask" );
AddInputPort( WirePortDataType.FLOAT, false, "BlendStrength" );
AddOutputVectorPorts( WirePortDataType.FLOAT, Constants.EmptyPortValue );
m_textLabelWidth = 120;
m_useInternalPortData = true;
m_inputPorts[ 2 ].FloatInternalData = 1;
m_previewShaderGUID = "b2ac23d6d5dcb334982b6f31c2e7a734";
}
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 HeightMap = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
string SplatMask = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector);
string Blend = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector );
string HeightMask = "saturate(pow(((" + HeightMap + "*" + SplatMask + ")*4)+(" + SplatMask + "*2)," + Blend + "))";
string varName = "HeightMask" + OutputId;
RegisterLocalVariable( 0, HeightMask, ref dataCollector , varName );
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
}
/*
A = (heightMap * SplatMask)*4
B = SplatMask*2
C = pow(A+B,Blend)
saturate(C)
saturate(pow(((heightMap * SplatMask)*4)+(SplatMask*2),Blend));
*/
}
}

View File

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

View File

@@ -0,0 +1,110 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Panner", "UV Coordinates", "Pans UV texture coordinates according to its inputs" )]
public sealed class PannerNode : ParentNode
{
private const string _speedXStr = "Speed X";
private const string _speedYStr = "Speed Y";
private int m_cachedUsingEditorId = -1;
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
AddInputPort( WirePortDataType.FLOAT2, false, "UV" ,-1,MasterNodePortCategory.Fragment,0);
AddInputPort( WirePortDataType.FLOAT2, false, "Speed", -1, MasterNodePortCategory.Fragment, 2 );
AddInputPort( WirePortDataType.FLOAT, false, "Time", -1, MasterNodePortCategory.Fragment, 1 );
AddOutputPort( WirePortDataType.FLOAT2, "Out" );
m_textLabelWidth = 70;
m_useInternalPortData = true;
m_previewShaderGUID = "6f89a5d96bdad114b9bbd0c236cac622";
m_inputPorts[ 2 ].FloatInternalData = 1;
m_continuousPreviewRefresh = true;
}
public override void SetPreviewInputs()
{
base.SetPreviewInputs();
if ( m_cachedUsingEditorId == -1 )
m_cachedUsingEditorId = Shader.PropertyToID( "_UsingEditor" );
PreviewMaterial.SetFloat( m_cachedUsingEditorId, ( m_inputPorts[ 2 ].IsConnected ? 0 : 1 ) );
}
public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true )
{
base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode );
if( portId == 1 )
{
m_continuousPreviewRefresh = false;
}
}
public override void OnInputPortDisconnected( int portId )
{
base.OnInputPortDisconnected( portId );
if( portId == 1 )
{
m_continuousPreviewRefresh = true;
}
}
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 timePort = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector );
if( !m_inputPorts[ 2 ].IsConnected )
{
if( !( dataCollector.IsTemplate && dataCollector.IsSRP ) )
dataCollector.AddToIncludes( UniqueId, Constants.UnityShaderVariables );
timePort += " * _Time.y";
}
string speed = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector );
string result = "( " + timePort + " * " + speed + " + " + m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ) + ")";
RegisterLocalVariable( 0, result, ref dataCollector, "panner" + OutputId );
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
}
public override void ReadFromString( ref string[] nodeParams )
{
base.ReadFromString( ref nodeParams );
if( UIUtils.CurrentShaderVersion() < 13107 )
{
// The internal data for the new port can be set in here since it didn't existed
// on older shader versions
float speedX = Convert.ToSingle( GetCurrentParam( ref nodeParams ) );
float speedY = Convert.ToSingle( GetCurrentParam( ref nodeParams ) );
m_inputPorts[ 1 ].Vector2InternalData = new Vector2( speedX, speedY );
}
}
public override void ReadInputDataFromString( ref string[] nodeParams )
{
base.ReadInputDataFromString( ref nodeParams );
if( UIUtils.CurrentShaderVersion() < 13107 )
{
//Time Port must be rewritten after internal data is read
// already existed in previous shaders
m_inputPorts[ 2 ].FloatInternalData = 1;
}
}
public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
{
base.WriteToString( ref nodeInfo, ref connectionsInfo );
}
}
}

View File

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

View File

@@ -0,0 +1,96 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Rotator", "UV Coordinates", "Rotates UVs or any Vector2 value from an Anchor point for a specified Time value")]
public sealed class RotatorNode : ParentNode
{
private int m_cachedUsingEditorId = -1;
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
AddInputPort( WirePortDataType.FLOAT2, false, "UV" );
AddInputPort( WirePortDataType.FLOAT2, false, "Anchor" );
AddInputPort( WirePortDataType.FLOAT, false, "Time" );
AddOutputPort( WirePortDataType.FLOAT2, "Out" );
m_useInternalPortData = true;
m_inputPorts[ 2 ].FloatInternalData = 1;
m_textLabelWidth = 50;
m_previewShaderGUID = "e21408a1c7f12f14bbc2652f69bce1fc";
}
public override void SetPreviewInputs()
{
base.SetPreviewInputs();
if ( m_cachedUsingEditorId == -1 )
m_cachedUsingEditorId = Shader.PropertyToID( "_UsingEditor" );
PreviewMaterial.SetFloat( m_cachedUsingEditorId, (m_inputPorts[ 2 ].IsConnected ? 0 : 1 ) );
}
public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true )
{
base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode );
if( portId == 2 )
{
m_continuousPreviewRefresh = false;
}
}
public override void OnInputPortDisconnected( int portId )
{
base.OnInputPortDisconnected( portId );
if( portId == 2 )
{
m_continuousPreviewRefresh = true;
}
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
{
if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
string result = string.Empty;
string uv = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
string anchor = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector );
string time = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector );
if ( !m_inputPorts[ 2 ].IsConnected )
{
if( !( dataCollector.IsTemplate && dataCollector.IsSRP ) )
dataCollector.AddToIncludes( UniqueId, Constants.UnityShaderVariables );
time += " * _Time.y";
}
result += uv;
string cosVar = "cos" + OutputId;
string sinVar = "sin" + OutputId;
dataCollector.AddLocalVariable( UniqueId, "float " + cosVar + " = cos( "+time+" );");
dataCollector.AddLocalVariable( UniqueId, "float " + sinVar + " = sin( "+time+" );");
string value = "mul( " + result + " - " + anchor + " , float2x2( "+cosVar+" , -"+sinVar+" , "+sinVar+" , "+cosVar+" )) + "+anchor;
RegisterLocalVariable( 0, value, ref dataCollector, "rotator" + OutputId );
return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
}
public override void RefreshExternalReferences()
{
base.RefreshExternalReferences();
if( UIUtils.CurrentShaderVersion() < 13107 )
{
m_inputPorts[ 2 ].FloatInternalData = 1;
}
}
}
}

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -0,0 +1,378 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Sampler State", "Textures", "Creates a custom sampler state or returns the default one of a selected texture object" )]
public class SamplerStateNode : ParentNode
{
private readonly string[] Dummy = { string.Empty };
private const string WrapModeStr = "Wrap Mode";
private const string UAxisStr = "U axis";
private const string VAxisStr = "V axis";
private const string FilterModeStr = "Filter Mode";
private const string MessageMacrosOFF = "Sampling Macros option is turned OFF, this node will not generate any sampler state";
private const string MessageTextureObject = "Only Texture Objects that are actually being sampled within the shader generate valid sampler states.\n\nPlease make sure the referenced Texture Object is being sampled otherwise the shader will fail to compile.";
private const string MessageUnitSuppport = "Unity support for sampler states in versions below Unity 2018.1 is limited.\n\nNotably, only vertex/frag shaders support it and not surfaces shaders and sampler states can only be reused and not created if the version is below 2017.1";
[SerializeField]
protected int m_wrapMode = 0;
[SerializeField]
protected TextureWrapMode m_wrapModeU = TextureWrapMode.Repeat;
[SerializeField]
protected TextureWrapMode m_wrapModeV = TextureWrapMode.Repeat;
[SerializeField]
protected FilterMode m_filterMode = FilterMode.Bilinear;
[SerializeField]
private int m_referenceSamplerId = -1;
[SerializeField]
private int m_referenceNodeId = -1;
[SerializeField]
private TexturePropertyNode m_inputReferenceNode = null;
private TexturePropertyNode m_referenceNode = null;
private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper();
private InputPort m_texPort;
private readonly string[] m_wrapModeStr = {
"Repeat",
"Clamp",
#if UNITY_2018_3_OR_NEWER
"Mirror",
"Mirror Once",
"Per-axis"
#endif
};
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
AddInputPort( WirePortDataType.SAMPLER2D, false, "Tex" );
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.SAMPLER1D, WirePortDataType.SAMPLER2D, WirePortDataType.SAMPLER3D, WirePortDataType.SAMPLERCUBE, WirePortDataType.SAMPLER2DARRAY );
AddOutputPort( WirePortDataType.SAMPLERSTATE, "Out" );
m_texPort = m_inputPorts[ 0 ];
m_hasLeftDropdown = true;
m_autoWrapProperties = true;
m_errorMessageTypeIsError = NodeMessageType.Warning;
m_errorMessageTooltip = MessageMacrosOFF;
}
public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true )
{
base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode );
m_inputPorts[ 0 ].MatchPortToConnection();
m_inputReferenceNode = m_inputPorts[ 0 ].GetOutputNodeWhichIsNotRelay() as TexturePropertyNode;
UpdateTitle();
}
public override void OnInputPortDisconnected( int portId )
{
base.OnInputPortDisconnected( portId );
m_inputReferenceNode = null;
UpdateTitle();
}
public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type )
{
base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type );
m_inputPorts[ 0 ].MatchPortToConnection();
UpdateTitle();
}
void UpdateTitle()
{
if( m_inputReferenceNode != null )
{
m_additionalContent.text = string.Format( Constants.PropertyValueLabel, m_inputReferenceNode.PropertyInspectorName );
}
else if( m_referenceSamplerId > -1 && m_referenceNode != null )
{
m_additionalContent.text = string.Format( Constants.PropertyValueLabel, m_referenceNode.PropertyInspectorName );
}
else
{
m_additionalContent.text = string.Empty;
}
m_sizeIsDirty = true;
}
public override void DrawProperties()
{
base.DrawProperties();
bool guiEnabledBuffer = GUI.enabled;
EditorGUI.BeginChangeCheck();
List<string> arr = new List<string>( UIUtils.TexturePropertyNodeArr() );
if( arr != null && arr.Count > 0 )
{
arr.Insert( 0, "None" );
GUI.enabled = true && ( !m_inputPorts[ 0 ].IsConnected );
m_referenceSamplerId = EditorGUILayoutPopup( Constants.AvailableReferenceStr, m_referenceSamplerId + 1, arr.ToArray() ) - 1;
}
else
{
m_referenceSamplerId = -1;
GUI.enabled = false;
EditorGUILayoutPopup( Constants.AvailableReferenceStr, m_referenceSamplerId, Dummy );
}
GUI.enabled = guiEnabledBuffer;
if( EditorGUI.EndChangeCheck() )
{
m_referenceNode = UIUtils.GetTexturePropertyNode( m_referenceSamplerId );
if( m_referenceNode != null )
{
m_referenceNodeId = m_referenceNode.UniqueId;
}
else
{
m_referenceNodeId = -1;
m_referenceSamplerId = -1;
}
UpdateTitle();
}
EditorGUI.BeginDisabledGroup( m_texPort.IsConnected || m_referenceNodeId >= 0 );
EditorGUI.BeginChangeCheck();
m_wrapMode = EditorGUILayoutPopup( WrapModeStr, m_wrapMode, m_wrapModeStr );
if( EditorGUI.EndChangeCheck() )
{
switch( m_wrapMode )
{
case 0:
m_wrapModeU = TextureWrapMode.Repeat;
m_wrapModeV = TextureWrapMode.Repeat;
break;
case 1:
m_wrapModeU = TextureWrapMode.Clamp;
m_wrapModeV = TextureWrapMode.Clamp;
break;
#if UNITY_2018_3_OR_NEWER
case 2:
m_wrapModeU = TextureWrapMode.Mirror;
m_wrapModeV = TextureWrapMode.Mirror;
break;
case 3:
m_wrapModeU = TextureWrapMode.MirrorOnce;
m_wrapModeV = TextureWrapMode.MirrorOnce;
break;
#endif
}
}
if( m_wrapMode == 4 )
{
EditorGUI.indentLevel++;
m_wrapModeU = (TextureWrapMode)EditorGUILayoutEnumPopup( UAxisStr, m_wrapModeU );
m_wrapModeV = (TextureWrapMode)EditorGUILayoutEnumPopup( VAxisStr, m_wrapModeV );
EditorGUI.indentLevel--;
}
m_filterMode = (FilterMode)EditorGUILayoutEnumPopup( FilterModeStr, m_filterMode );
EditorGUI.EndDisabledGroup();
if( !UIUtils.CurrentWindow.OutsideGraph.SamplingMacros )
EditorGUILayout.HelpBox( MessageMacrosOFF, MessageType.Warning );
if( m_texPort.IsConnected || m_referenceNodeId >= 0 )
EditorGUILayout.HelpBox( MessageTextureObject, MessageType.Info );
#if !UNITY_2018_1_OR_NEWER
EditorGUILayout.HelpBox( MessageUnitSuppport, MessageType.Warning );
#endif
}
public override void Draw( DrawInfo drawInfo )
{
base.Draw( drawInfo );
if( !UIUtils.CurrentWindow.OutsideGraph.SamplingMacros && ContainerGraph.CurrentShaderFunction == null )
m_showErrorMessage = true;
else
m_showErrorMessage = false;
EditorGUI.BeginChangeCheck();
{
List<string> arr = new List<string>( UIUtils.TexturePropertyNodeArr() );
bool guiEnabledBuffer = GUI.enabled;
if( arr != null && arr.Count > 0 )
{
arr.Insert( 0, "None" );
GUI.enabled = true && ( !m_inputPorts[ 0 ].IsConnected );
m_referenceSamplerId = m_upperLeftWidget.DrawWidget( this, m_referenceSamplerId + 1, arr.ToArray() ) - 1;
}
else
{
m_referenceSamplerId = -1;
GUI.enabled = false;
m_upperLeftWidget.DrawWidget( this, m_referenceSamplerId, Dummy );
}
GUI.enabled = guiEnabledBuffer;
}
if( EditorGUI.EndChangeCheck() )
{
m_referenceNode = UIUtils.GetTexturePropertyNode( m_referenceSamplerId );
if( m_referenceNode != null )
{
m_referenceNodeId = m_referenceNode.UniqueId;
}
else
{
m_referenceNodeId = -1;
m_referenceSamplerId = -1;
}
UpdateTitle();
}
}
public string GenerateSamplerAttributes()
{
string result = string.Empty;
switch( m_filterMode )
{
case FilterMode.Point:
result += "_point";
break;
default:
case FilterMode.Bilinear:
result += "_linear";
break;
case FilterMode.Trilinear:
result += "_trilinear";
break;
}
int finalWrap = m_wrapModeU == m_wrapModeV ? (int)m_wrapModeU : m_wrapMode;
switch( finalWrap )
{
case 0:
default:
result += "_repeat";
break;
case 1:
result += "_clamp";
break;
#if UNITY_2018_3_OR_NEWER
case 2:
result += "_mirror";
break;
case 3:
result += "_mirrorOnce";
break;
#endif
case 4:
{
switch( m_wrapModeU )
{
default:
case TextureWrapMode.Repeat:
result += "_repeatU";
break;
case TextureWrapMode.Clamp:
result += "_clampU";
break;
#if UNITY_2018_3_OR_NEWER
case TextureWrapMode.Mirror:
result += "_mirrorU";
break;
case TextureWrapMode.MirrorOnce:
result += "_mirrorOnceU";
break;
#endif
}
switch( m_wrapModeV )
{
default:
case TextureWrapMode.Repeat:
result += "_repeatV";
break;
case TextureWrapMode.Clamp:
result += "_clampV";
break;
#if UNITY_2018_3_OR_NEWER
case TextureWrapMode.Mirror:
result += "_mirrorV";
break;
case TextureWrapMode.MirrorOnce:
result += "_mirrorOnceV";
break;
#endif
}
}
break;
}
return result;
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
{
if( !m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
{
string propertyOrOptions = string.Empty;
if( m_texPort.IsConnected )
{
propertyOrOptions = m_texPort.GeneratePortInstructions( ref dataCollector );
}
else if( m_referenceNode != null )
{
m_referenceNode.BaseGenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
propertyOrOptions = m_referenceNode.PropertyName;
}
else
{
propertyOrOptions = GenerateSamplerAttributes();
}
string sampler = GeneratorUtils.GenerateSamplerState( ref dataCollector, UniqueId, propertyOrOptions );
m_outputPorts[ 0 ].SetLocalValue( sampler, dataCollector.PortCategory );
}
return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory );
}
public override void RefreshExternalReferences()
{
base.RefreshExternalReferences();
m_referenceNode = UIUtils.GetNode( m_referenceNodeId ) as TexturePropertyNode;
m_referenceSamplerId = UIUtils.GetTexturePropertyNodeRegisterId( m_referenceNodeId );
UpdateTitle();
}
public override void ReadFromString( ref string[] nodeParams )
{
base.ReadFromString( ref nodeParams );
m_wrapMode = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
m_wrapModeU = (TextureWrapMode)Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
m_wrapModeV = (TextureWrapMode)Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
m_filterMode = (FilterMode)Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
m_referenceNodeId = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
}
public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
{
base.WriteToString( ref nodeInfo, ref connectionsInfo );
IOUtils.AddFieldValueToString( ref nodeInfo, m_wrapMode );
IOUtils.AddFieldValueToString( ref nodeInfo, (int)m_wrapModeU );
IOUtils.AddFieldValueToString( ref nodeInfo, (int)m_wrapModeV );
IOUtils.AddFieldValueToString( ref nodeInfo, (int)m_filterMode );
IOUtils.AddFieldValueToString( ref nodeInfo, m_referenceNodeId );
}
}
}

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -0,0 +1,238 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
//
// Custom Node Flipbook UV Animation
// Donated by The Four Headed Cat - @fourheadedcat
using UnityEngine;
using UnityEditor;
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Flipbook UV Animation", "UV Coordinates", "Animate a Flipbook Texture Modifying UV Coordinates.", null, KeyCode.None, true, false, null, null, "The Four Headed Cat - @fourheadedcat" )]
public sealed class TFHCFlipBookUVAnimation : ParentNode
{
private const string TextureVerticalDirectionStr = "Texture Direction";
private const string NegativeSpeedBehaviorStr = "If Negative Speed";
[SerializeField]
private int m_selectedTextureVerticalDirection = 0;
[SerializeField]
private int m_negativeSpeedBehavior = 0;
[SerializeField]
private readonly string[] m_textureVerticalDirectionValues = { "Top To Bottom", "Bottom To Top" };
[SerializeField]
private readonly string[] m_negativeSpeedBehaviorValues = { "Switch to Positive", "Reverse Animation" };
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
AddInputPort( WirePortDataType.FLOAT2, false, "UV" );
AddInputPort( WirePortDataType.FLOAT, false, "Columns" );
AddInputPort( WirePortDataType.FLOAT, false, "Rows" );
AddInputPort( WirePortDataType.FLOAT, false, "Speed" );
AddInputPort( WirePortDataType.FLOAT, false, "Start Frame" );
AddInputPort( WirePortDataType.FLOAT, false, "Time" );
AddOutputVectorPorts( WirePortDataType.FLOAT2, "UV" );
m_outputPorts[ 1 ].Name = "U";
m_outputPorts[ 2 ].Name = "V";
m_textLabelWidth = 125;
m_useInternalPortData = true;
m_autoWrapProperties = true;
m_previewShaderGUID = "04fe24be792bfd5428b92132d7cf0f7d";
}
public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true )
{
base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode );
if( portId == 5 )
{
m_previewMaterialPassId = 1;
}
}
public override void OnInputPortDisconnected( int portId )
{
base.OnInputPortDisconnected( portId );
if( portId == 5 )
{
m_previewMaterialPassId = 0;
}
}
public override void DrawProperties()
{
base.DrawProperties();
EditorGUILayout.BeginVertical();
m_selectedTextureVerticalDirection = EditorGUILayoutPopup( TextureVerticalDirectionStr, m_selectedTextureVerticalDirection, m_textureVerticalDirectionValues );
m_negativeSpeedBehavior = EditorGUILayoutPopup( NegativeSpeedBehaviorStr, m_negativeSpeedBehavior, m_negativeSpeedBehaviorValues );
EditorGUILayout.EndVertical();
EditorGUILayout.HelpBox( "Flipbook UV Animation:\n\n - UV: Texture Coordinates to Flipbook.\n - Columns: number of Columns (X) of the Flipbook Texture.\n - Rows: number of Rows (Y) of the Flipbook Textures.\n - Speed: speed of the animation.\n - Texture Direction: set the vertical order of the texture tiles.\n - If Negative Speed: set the behavior when speed is negative.\n\n - Out: UV Coordinates.", MessageType.None );
}
public override void ReadFromString( ref string[] nodeParams )
{
base.ReadFromString( ref nodeParams );
m_selectedTextureVerticalDirection = ( int ) int.Parse( GetCurrentParam( ref nodeParams ) );
m_negativeSpeedBehavior = ( int ) int.Parse( GetCurrentParam( ref nodeParams ) );
}
public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
{
base.WriteToString( ref nodeInfo, ref connectionsInfo );
IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedTextureVerticalDirection );
IOUtils.AddFieldValueToString( ref nodeInfo, m_negativeSpeedBehavior );
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
{
// OPTIMIZATION NOTES
//
// round( fmod( x, y ) ) can be replaced with a faster
// floor( frac( x / y ) * y + 0.5 ) => div can be muls with 1/y, almost always static/constant
//
if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
string uv = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
string columns = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector );
if ( !m_inputPorts[ 1 ].IsConnected )
columns = ( float.Parse( columns ) == 0f ? "1" : columns );
string rows = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector );
if ( !m_inputPorts[ 2 ].IsConnected )
rows = ( float.Parse( rows ) == 0f ? "1" : rows );
string speed = m_inputPorts[ 3 ].GeneratePortInstructions( ref dataCollector );
string startframe = m_inputPorts[ 4 ].GeneratePortInstructions( ref dataCollector );
string timer = m_inputPorts[ 5 ].IsConnected ? m_inputPorts[ 5 ].GeneratePortInstructions( ref dataCollector ) : "_Time[ 1 ]";
string vcomment1 = "// *** BEGIN Flipbook UV Animation vars ***";
string vcomment2 = "// Total tiles of Flipbook Texture";
string vtotaltiles = "float fbtotaltiles" + OutputId + " = " + columns + " * " + rows + ";";
string vcomment3 = "// Offsets for cols and rows of Flipbook Texture";
string vcolsoffset = "float fbcolsoffset" + OutputId + " = 1.0f / " + columns + ";";
string vrowssoffset = "float fbrowsoffset" + OutputId + " = 1.0f / " + rows + ";";
string vcomment4 = "// Speed of animation";
string vspeed = string.Format( "float fbspeed{0} = {1} * {2};", OutputId,timer,speed);
string vcomment5 = "// UV Tiling (col and row offset)";
string vtiling = "float2 fbtiling" + OutputId + " = float2(fbcolsoffset" + OutputId + ", fbrowsoffset" + OutputId + ");";
string vcomment6 = "// UV Offset - calculate current tile linear index, and convert it to (X * coloffset, Y * rowoffset)";
string vcomment7 = "// Calculate current tile linear index";
//float fbcurrenttileindex1 = round( fmod( fbspeed1 + _Float0, fbtotaltiles1 ) );
string vcurrenttileindex = "float fbcurrenttileindex" + OutputId + " = round( fmod( fbspeed" + OutputId + " + " + startframe + ", fbtotaltiles" + OutputId + ") );";
string vcurrenttileindex1 = "fbcurrenttileindex" + OutputId + " += ( fbcurrenttileindex" + OutputId + " < 0) ? fbtotaltiles" + OutputId + " : 0;";
//fbcurrenttileindex1 += ( fbcurrenttileindex1 < 0 ) ? fbtotaltiles1 : 0;
//string vcurrenttileindex = "int fbcurrenttileindex" + m_uniqueId + " = (int)fmod( fbspeed" + m_uniqueId + ", fbtotaltiles" + m_uniqueId + ") + " + startframe + ";";
string vcomment8 = "// Obtain Offset X coordinate from current tile linear index";
//float fblinearindextox1 = round( fmod( fbcurrenttileindex1, 5.0 ) );
//string voffsetx1 = "int fblinearindextox" + m_uniqueId + " = fbcurrenttileindex" + m_uniqueId + " % (int)" + columns + ";";
string voffsetx1 = "float fblinearindextox" + OutputId + " = round ( fmod ( fbcurrenttileindex" + OutputId + ", " + columns + " ) );";
string vcomment9 = String.Empty;
string voffsetx2 = String.Empty;
if ( m_negativeSpeedBehavior != 0 )
{
vcomment9 = "// Reverse X animation if speed is negative";
voffsetx2 = "fblinearindextox" + OutputId + " = (" + speed + " > 0 ? fblinearindextox" + OutputId + " : (int)" + columns + " - fblinearindextox" + OutputId + ");";
}
string vcomment10 = "// Multiply Offset X by coloffset";
string voffsetx3 = "float fboffsetx" + OutputId + " = fblinearindextox" + OutputId + " * fbcolsoffset" + OutputId + ";";
string vcomment11 = "// Obtain Offset Y coordinate from current tile linear index";
//float fblinearindextoy1 = round( fmod( ( fbcurrenttileindex1 - fblinearindextox1 ) / 5.0, 5.0 ) );
string voffsety1 = "float fblinearindextoy" + OutputId + " = round( fmod( ( fbcurrenttileindex" + OutputId + " - fblinearindextox" + OutputId + " ) / " + columns + ", " + rows + " ) );";
//string voffsety1 = "int fblinearindextoy" + m_uniqueId + " = (int)( ( fbcurrenttileindex" + m_uniqueId + " - fblinearindextox" + m_uniqueId + " ) / " + columns + " ) % (int)" + rows + ";";
//string vcomment10 = "// Reverse Y to get from Top to Bottom";
//string voffsety2 = "fblinearindextoy" + m_uniqueId + " = (int)" + rows + " - fblinearindextoy" + m_uniqueId + ";";
string vcomment12 = String.Empty;
string voffsety2 = String.Empty;
if ( m_negativeSpeedBehavior == 0 )
{
if ( m_selectedTextureVerticalDirection == 0 )
{
vcomment12 = "// Reverse Y to get tiles from Top to Bottom";
voffsety2 = "fblinearindextoy" + OutputId + " = (int)(" + rows + "-1) - fblinearindextoy" + OutputId + ";";
}
}
else
{
string reverseanimationoperator = String.Empty;
if ( m_selectedTextureVerticalDirection == 0 )
{
vcomment12 = "// Reverse Y to get tiles from Top to Bottom and Reverse Y animation if speed is negative";
reverseanimationoperator = " < ";
}
else
{
vcomment12 = "// Reverse Y animation if speed is negative";
reverseanimationoperator = " > ";
}
voffsety2 = "fblinearindextoy" + OutputId + " = (" + speed + reverseanimationoperator + " 0 ? fblinearindextoy" + OutputId + " : (int)" + rows + " - fblinearindextoy" + OutputId + ");";
}
string vcomment13 = "// Multiply Offset Y by rowoffset";
string voffsety3 = "float fboffsety" + OutputId + " = fblinearindextoy" + OutputId + " * fbrowsoffset" + OutputId + ";";
string vcomment14 = "// UV Offset";
string voffset = "float2 fboffset" + OutputId + " = float2(fboffsetx" + OutputId + ", fboffsety" + OutputId + ");";
//string voffset = "float2 fboffset" + m_uniqueId + " = float2( ( ( (int)fmod( fbspeed" + m_uniqueId + " , fbtotaltiles" + m_uniqueId + ") % (int)" + columns + " ) * fbcolsoffset" + m_OutputId + " ) , ( ( (int)" + rows + " - ( (int)( ( (int)fmod( fbspeed" + m_uniqueId + " , fbtotaltiles" + m_uniqueId + " ) - ( (int)fmod( fbspeed" + m_uniqueId + " , fbtotaltiles" + m_uniqueId + " ) % (int)" + columns + " ) ) / " + columns + " ) % (int)" + rows + " ) ) * fbrowsoffset" + m_uniqueId + " ) );";
string vcomment15 = "// Flipbook UV";
string vfbuv = "half2 fbuv" + OutputId + " = " + uv + " * fbtiling" + OutputId + " + fboffset" + OutputId + ";";
string vcomment16 = "// *** END Flipbook UV Animation vars ***";
string result = "fbuv" + OutputId;
dataCollector.AddLocalVariable( UniqueId, vcomment1 );
dataCollector.AddLocalVariable( UniqueId, vcomment2 );
dataCollector.AddLocalVariable( UniqueId, vtotaltiles );
dataCollector.AddLocalVariable( UniqueId, vcomment3 );
dataCollector.AddLocalVariable( UniqueId, vcolsoffset );
dataCollector.AddLocalVariable( UniqueId, vrowssoffset );
dataCollector.AddLocalVariable( UniqueId, vcomment4 );
dataCollector.AddLocalVariable( UniqueId, vspeed );
dataCollector.AddLocalVariable( UniqueId, vcomment5 );
dataCollector.AddLocalVariable( UniqueId, vtiling );
dataCollector.AddLocalVariable( UniqueId, vcomment6 );
dataCollector.AddLocalVariable( UniqueId, vcomment7 );
dataCollector.AddLocalVariable( UniqueId, vcurrenttileindex );
dataCollector.AddLocalVariable( UniqueId, vcurrenttileindex1 );
dataCollector.AddLocalVariable( UniqueId, vcomment8 );
dataCollector.AddLocalVariable( UniqueId, voffsetx1 );
if ( m_negativeSpeedBehavior != 0 )
{
dataCollector.AddLocalVariable( UniqueId, vcomment9 );
dataCollector.AddLocalVariable( UniqueId, voffsetx2 );
}
dataCollector.AddLocalVariable( UniqueId, vcomment10 );
dataCollector.AddLocalVariable( UniqueId, voffsetx3 );
dataCollector.AddLocalVariable( UniqueId, vcomment11 );
dataCollector.AddLocalVariable( UniqueId, voffsety1 );
if ( m_selectedTextureVerticalDirection == 0 || m_negativeSpeedBehavior != 0 )
{
dataCollector.AddLocalVariable( UniqueId, vcomment12 );
dataCollector.AddLocalVariable( UniqueId, voffsety2 );
}
dataCollector.AddLocalVariable( UniqueId, vcomment13 );
dataCollector.AddLocalVariable( UniqueId, voffsety3 );
dataCollector.AddLocalVariable( UniqueId, vcomment14 );
dataCollector.AddLocalVariable( UniqueId, voffset );
dataCollector.AddLocalVariable( UniqueId, vcomment15 );
dataCollector.AddLocalVariable( UniqueId, vfbuv );
dataCollector.AddLocalVariable( UniqueId, vcomment16 );
m_outputPorts[ 0 ].SetLocalValue( result, dataCollector.PortCategory );
return GetOutputVectorItem( 0, outputId, result );
}
}
}

View File

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

View File

@@ -0,0 +1,54 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
//
// Custom Node Pixelate UV
// Donated by The Four Headed Cat - @fourheadedcat
using UnityEngine;
using UnityEditor;
using System;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Pixelate UV", "UV Coordinates", "Pixelate Texture Modifying UV.", null, KeyCode.None, true, false, null, null, "The Four Headed Cat - @fourheadedcat" )]
public sealed class TFHCPixelate : ParentNode
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
AddInputPort( WirePortDataType.FLOAT2, true, "UV" );
AddInputPort( WirePortDataType.FLOAT, false, "Pixels X" );
AddInputPort( WirePortDataType.FLOAT, false, "Pixels Y" );
AddOutputPort( WirePortDataType.FLOAT2, "Out" );
m_useInternalPortData = true;
m_previewShaderGUID = "e2f7e3c513ed18340868b8cbd0d85cfb";
}
public override void DrawProperties()
{
base.DrawProperties ();
EditorGUILayout.HelpBox ("Pixelate UV.\n\n - UV is the Texture Coordinates to pixelate.\n - Pixels X is the number of horizontal pixels\n - Pixels Y is the number of vertical pixels.", MessageType.None);
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
{
string uv = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
string PixelCount_X = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector );
string PixelCount_Y = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector );
string pixelWidth = "float pixelWidth" + OutputId + " = 1.0f / " + PixelCount_X + ";";
string pixelHeight = "float pixelHeight" + OutputId + " = 1.0f / " + PixelCount_Y + ";";
string pixelatedUV = "half2 pixelateduv" + OutputId + " = half2((int)(" + uv + ".x / pixelWidth" + OutputId + ") * pixelWidth" + OutputId + ", (int)(" + uv + ".y / pixelHeight" + OutputId + ") * pixelHeight" + OutputId + ");";
string result = "pixelateduv" + OutputId;
dataCollector.AddLocalVariable( UniqueId, pixelWidth );
dataCollector.AddLocalVariable( UniqueId, pixelHeight );
dataCollector.AddLocalVariable( UniqueId, pixelatedUV );
return GetOutputVectorItem( 0, outputId, result);
}
}
}

View File

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

View File

@@ -0,0 +1,628 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using UnityEditor;
using System;
using System.Collections.Generic;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Texture Coordinates", "UV Coordinates", "Texture UV coordinates set, if <b>Tex</b> is connected to a texture object it will use that texture scale factors, otherwise uses <b>Tilling</b> and <b>Offset</b> port values", null, KeyCode.U, tags: "uv" )]
public sealed class TextureCoordinatesNode : ParentNode
{
private const string DummyPropertyDec = "[HideInInspector] _DummyTex{0}( \"\", 2D ) = \"white\"";
private const string DummyUniformDec = "uniform sampler2D _DummyTex{0};";
private const string DummyTexCoordDef = "uv{0}_DummyTex{0}";
private const string DummyTexCoordSurfDef = "float2 texCoordDummy{0} = {1}.uv{2}_DummyTex{2}*{3} + {4};";
private const string DummyTexCoordSurfVar = "texCoordDummy{0}";
private readonly string[] Dummy = { string.Empty };
private const string TilingStr = "Tiling";
private const string OffsetStr = "Offset";
private const string TexCoordStr = "texcoord_";
[SerializeField]
private int m_referenceArrayId = -1;
[SerializeField]
private int m_referenceNodeId = -1;
[SerializeField]
private int m_textureCoordChannel = 0;
//[SerializeField]
//private int m_texcoordId = -1;
[SerializeField]
private int m_texcoordSize = 2;
[SerializeField]
private string m_surfaceTexcoordName = string.Empty;
[SerializeField]
private TexturePropertyNode m_inputReferenceNode = null;
private Vector4Node m_texCoordsHelper;
private TexturePropertyNode m_referenceNode = null;
private InputPort m_texPort = null;
private InputPort m_tilingPort = null;
private InputPort m_offsetPort = null;
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
AddInputPort( WirePortDataType.SAMPLER2D, false, "Tex", -1, MasterNodePortCategory.Fragment, 2 );
m_texPort = m_inputPorts[ m_inputPorts.Count - 1 ];
m_texPort.CreatePortRestrictions( WirePortDataType.SAMPLER1D, WirePortDataType.SAMPLER2D, WirePortDataType.SAMPLER3D, WirePortDataType.SAMPLERCUBE, WirePortDataType.SAMPLER2DARRAY, WirePortDataType.OBJECT );
AddInputPort( WirePortDataType.FLOAT2, false, "Tiling", -1, MasterNodePortCategory.Fragment, 0 );
m_tilingPort = m_inputPorts[ m_inputPorts.Count - 1 ];
m_tilingPort.Vector2InternalData = new Vector2( 1, 1 );
AddInputPort( WirePortDataType.FLOAT2, false, "Offset", -1, MasterNodePortCategory.Fragment, 1 );
m_offsetPort = m_inputPorts[ m_inputPorts.Count - 1 ];
AddOutputVectorPorts( WirePortDataType.FLOAT2, "UV" );
m_outputPorts[ 1 ].Name = "U";
m_outputPorts[ 2 ].Name = "V";
AddOutputPort( WirePortDataType.FLOAT, "W" );
AddOutputPort( WirePortDataType.FLOAT, "T" );
m_textLabelWidth = 90;
m_useInternalPortData = true;
m_autoWrapProperties = true;
m_hasLeftDropdown = true;
m_tilingPort.Category = MasterNodePortCategory.Vertex;
m_offsetPort.Category = MasterNodePortCategory.Vertex;
UpdateOutput();
m_previewShaderGUID = "085e462b2de441a42949be0e666cf5d2";
}
public override void Reset()
{
m_surfaceTexcoordName = string.Empty;
}
public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true )
{
base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode );
if( portId == 2 )
{
m_texPort.MatchPortToConnection();
m_inputReferenceNode = m_texPort.GetOutputNodeWhichIsNotRelay() as TexturePropertyNode;
UpdatePorts();
}
UpdateTitle();
}
public override void OnInputPortDisconnected( int portId )
{
base.OnInputPortDisconnected( portId );
if( portId == 2 )
{
m_inputReferenceNode = null;
UpdatePorts();
}
UpdateTitle();
}
public override void OnConnectedOutputNodeChanges( int portId, int otherNodeId, int otherPortId, string name, WirePortDataType type )
{
base.OnConnectedOutputNodeChanges( portId, otherNodeId, otherPortId, name, type );
if( portId == 2 )
{
m_texPort.MatchPortToConnection();
UpdateTitle();
}
}
void UpdateTitle()
{
if( m_inputReferenceNode != null )
{
m_additionalContent.text = string.Format( "Value( {0} )", m_inputReferenceNode.PropertyInspectorName );
}
else if( m_referenceArrayId > -1 && m_referenceNode != null )
{
m_additionalContent.text = string.Format( "Value( {0} )", m_referenceNode.PropertyInspectorName );
}
else
{
m_additionalContent.text = string.Empty;
}
m_sizeIsDirty = true;
}
void UpdatePorts()
{
if( m_inputReferenceNode != null || m_texPort.IsConnected )
{
m_tilingPort.Locked = true;
m_offsetPort.Locked = true;
}
else if( m_referenceArrayId > -1 )
{
m_tilingPort.Locked = true;
m_offsetPort.Locked = true;
}
else
{
m_tilingPort.Locked = false;
m_offsetPort.Locked = false;
}
}
public override void DrawProperties()
{
bool guiEnabledBuffer = GUI.enabled;
EditorGUI.BeginChangeCheck();
List<string> arr = new List<string>( UIUtils.TexturePropertyNodeArr() );
if( arr != null && arr.Count > 0 )
{
arr.Insert( 0, "None" );
GUI.enabled = true && ( !m_texPort.IsConnected );
m_referenceArrayId = EditorGUILayoutPopup( Constants.AvailableReferenceStr, m_referenceArrayId + 1, arr.ToArray() ) - 1;
}
else
{
m_referenceArrayId = -1;
GUI.enabled = false;
EditorGUILayoutPopup( Constants.AvailableReferenceStr, 0, Dummy );
}
GUI.enabled = guiEnabledBuffer;
if( EditorGUI.EndChangeCheck() )
{
m_referenceNode = UIUtils.GetTexturePropertyNode( m_referenceArrayId );
if( m_referenceNode != null )
{
m_referenceNodeId = m_referenceNode.UniqueId;
}
else
{
m_referenceNodeId = -1;
m_referenceArrayId = -1;
}
UpdateTitle();
UpdatePorts();
}
EditorGUI.BeginChangeCheck();
m_texcoordSize = EditorGUILayoutIntPopup( Constants.AvailableUVSizesLabel, m_texcoordSize, Constants.AvailableUVSizesStr, Constants.AvailableUVSizes );
if( EditorGUI.EndChangeCheck() )
{
UpdateOutput();
}
m_textureCoordChannel = EditorGUILayoutIntPopup( Constants.AvailableUVSetsLabel, m_textureCoordChannel, Constants.AvailableUVSetsStr, Constants.AvailableUVSets );
if( m_referenceArrayId > -1 )
GUI.enabled = false;
base.DrawProperties();
GUI.enabled = guiEnabledBuffer;
}
private void UpdateOutput()
{
if( m_texcoordSize == 3 )
{
m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT3, false );
m_outputPorts[ 0 ].Name = "UVW";
m_outputPorts[ 3 ].Visible = true;
m_outputPorts[ 4 ].Visible = false;
}
else if( m_texcoordSize == 4 )
{
m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false );
m_outputPorts[ 0 ].Name = "UVWT";
m_outputPorts[ 3 ].Visible = true;
m_outputPorts[ 4 ].Visible = true;
}
else
{
m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT2, false );
m_outputPorts[ 0 ].Name = "UV";
m_outputPorts[ 3 ].Visible = false;
m_outputPorts[ 4 ].Visible = false;
}
m_sizeIsDirty = true;
}
public override void OnNodeLogicUpdate( DrawInfo drawInfo )
{
base.OnNodeLogicUpdate( drawInfo );
CheckReference();
}
//public override void Draw( DrawInfo drawInfo )
//{
// base.Draw( drawInfo );
// //CheckReference();
//}
public override void Draw( DrawInfo drawInfo )
{
base.Draw( drawInfo );
if( m_dropdownEditing )
{
EditorGUI.BeginChangeCheck();
m_texcoordSize = EditorGUIIntPopup( m_dropdownRect, m_texcoordSize, Constants.AvailableUVSizesStr, Constants.AvailableUVSizes, UIUtils.PropertyPopUp );
if( EditorGUI.EndChangeCheck() )
{
UpdateOutput();
DropdownEditing = false;
}
}
}
void CheckReference()
{
if( m_referenceArrayId > -1 )
{
ParentNode newNode = UIUtils.GetTexturePropertyNode( m_referenceArrayId );
if( newNode == null || newNode.UniqueId != m_referenceNodeId )
{
m_referenceNode = null;
int count = UIUtils.GetTexturePropertyNodeAmount();
for( int i = 0; i < count; i++ )
{
ParentNode node = UIUtils.GetTexturePropertyNode( i );
if( node.UniqueId == m_referenceNodeId )
{
m_referenceNode = node as TexturePropertyNode;
m_referenceArrayId = i;
break;
}
}
}
}
if( m_referenceNode == null && m_referenceNodeId > -1 )
{
m_referenceNodeId = -1;
m_referenceArrayId = -1;
UpdateTitle();
UpdatePorts();
}
}
public override void ReadFromString( ref string[] nodeParams )
{
base.ReadFromString( ref nodeParams );
m_textureCoordChannel = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
if( UIUtils.CurrentShaderVersion() > 2402 )
{
if( UIUtils.CurrentShaderVersion() > 2404 )
{
m_referenceNodeId = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
}
else
{
m_referenceArrayId = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
}
}
if( UIUtils.CurrentShaderVersion() > 5001 )
{
m_texcoordSize = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
UpdateOutput();
}
}
public override void RefreshExternalReferences()
{
base.RefreshExternalReferences();
if( UIUtils.CurrentShaderVersion() > 2402 )
{
if( UIUtils.CurrentShaderVersion() > 2404 )
{
m_referenceNode = UIUtils.GetNode( m_referenceNodeId ) as TexturePropertyNode;
if( m_referenceNodeId > -1 )
m_referenceArrayId = UIUtils.GetTexturePropertyNodeRegisterId( m_referenceNodeId );
}
else
{
m_referenceNode = UIUtils.GetTexturePropertyNode( m_referenceArrayId );
if( m_referenceNode != null )
{
m_referenceNodeId = m_referenceNode.UniqueId;
}
}
UpdateTitle();
UpdatePorts();
}
}
public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector )
{
if( dataCollector != null && dataCollector.TesselationActive )
{
base.PropagateNodeData( nodeData, ref dataCollector );
return;
}
if( dataCollector.IsTemplate )
{
dataCollector.TemplateDataCollectorInstance.SetUVUsage( m_textureCoordChannel, m_texcoordSize );
}
else if( m_textureCoordChannel > 3 )
{
dataCollector.AddCustomAppData( string.Format( TemplateHelperFunctions.TexUVFullSemantic, m_textureCoordChannel ) );
}
UIUtils.SetCategoryInBitArray( ref m_category, nodeData.Category );
MasterNodePortCategory propagateCategory = ( nodeData.Category != MasterNodePortCategory.Vertex && nodeData.Category != MasterNodePortCategory.Tessellation ) ? MasterNodePortCategory.Vertex : nodeData.Category;
nodeData.Category = propagateCategory;
nodeData.GraphDepth += 1;
if( nodeData.GraphDepth > m_graphDepth )
{
m_graphDepth = nodeData.GraphDepth;
}
int count = m_inputPorts.Count;
for( int i = 0; i < count; i++ )
{
if( m_inputPorts[ i ].IsConnected )
{
//m_inputPorts[ i ].GetOutputNode().PropagateNodeCategory( category );
m_inputPorts[ i ].GetOutputNode().PropagateNodeData( nodeData, ref dataCollector );
}
}
}
public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
{
base.WriteToString( ref nodeInfo, ref connectionsInfo );
IOUtils.AddFieldValueToString( ref nodeInfo, m_textureCoordChannel );
IOUtils.AddFieldValueToString( ref nodeInfo, ( ( m_referenceNode != null ) ? m_referenceNode.UniqueId : -1 ) );
IOUtils.AddFieldValueToString( ref nodeInfo, m_texcoordSize );
}
string GetValidPropertyName()
{
string propertyName = string.Empty;
if( m_inputReferenceNode != null )
{
propertyName = m_inputReferenceNode.PropertyName;
}
else if( m_referenceArrayId > -1 )
{
m_referenceNode = UIUtils.GetTexturePropertyNode( m_referenceArrayId );
if( m_referenceNode != null )
{
propertyName = m_referenceNode.PropertyName;
}
}
return propertyName;
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
{
if( dataCollector.PortCategory == MasterNodePortCategory.Tessellation )
{
UIUtils.ShowMessage( UniqueId, m_nodeAttribs.Name + " cannot be used on Master Node Tessellation port" );
return "-1";
}
//bool isVertex = ( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation );
string tiling = string.Empty;
string offset = string.Empty;
string portProperty = string.Empty;
if( m_texPort.IsConnected )
{
portProperty = m_texPort.GeneratePortInstructions( ref dataCollector );
}
else if( m_referenceArrayId > -1 )
{
TexturePropertyNode temp = UIUtils.GetTexturePropertyNode( m_referenceArrayId );
if( temp != null )
{
portProperty = temp.BaseGenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalVar );
}
}
//TEMPLATES
if( dataCollector.MasterNodeCategory == AvailableShaderTypes.Template )
{
if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
string uvName = string.Empty;
string result = string.Empty;
string indexStr = m_textureCoordChannel > 0 ? ( m_textureCoordChannel + 1 ).ToString() : "";
string sizeDif = string.Empty;
if( m_texcoordSize == 3 )
sizeDif = "3";
else if( m_texcoordSize == 4 )
sizeDif = "4";
if( dataCollector.TemplateDataCollectorInstance.GetCustomInterpolatedData( TemplateHelperFunctions.IntToUVChannelInfo[ m_textureCoordChannel ], m_outputPorts[ 0 ].DataType, PrecisionType.Float, ref result, false, dataCollector.PortCategory ) )
{
uvName = result;
}
else if( dataCollector.TemplateDataCollectorInstance.HasUV( m_textureCoordChannel ) )
{
uvName = dataCollector.TemplateDataCollectorInstance.GetUVName( m_textureCoordChannel, m_outputPorts[ 0 ].DataType );
}
else
{
uvName = dataCollector.TemplateDataCollectorInstance.RegisterUV( m_textureCoordChannel, m_outputPorts[ 0 ].DataType );
}
string currPropertyName = GetValidPropertyName();
if( !string.IsNullOrEmpty( portProperty ) && portProperty != "0.0" )
{
currPropertyName = portProperty;
}
if( !string.IsNullOrEmpty( currPropertyName ) )
{
string finalTexCoordName = "uv" + indexStr + ( m_texcoordSize > 2 ? "s" + sizeDif : "" ) + currPropertyName;
string dummyPropertyTexcoords = currPropertyName + "_ST";
if( m_texCoordsHelper == null )
{
m_texCoordsHelper = CreateInstance<Vector4Node>();
m_texCoordsHelper.ContainerGraph = ContainerGraph;
m_texCoordsHelper.SetBaseUniqueId( UniqueId, true );
m_texCoordsHelper.RegisterPropertyOnInstancing = false;
m_texCoordsHelper.AddGlobalToSRPBatcher = true;
}
if( UIUtils.CurrentWindow.OutsideGraph.IsInstancedShader )
{
m_texCoordsHelper.CurrentParameterType = PropertyType.InstancedProperty;
}
else
{
m_texCoordsHelper.CurrentParameterType = PropertyType.Global;
}
m_texCoordsHelper.ResetOutputLocals();
m_texCoordsHelper.SetRawPropertyName( dummyPropertyTexcoords );
dummyPropertyTexcoords = m_texCoordsHelper.GenerateShaderForOutput( 0, ref dataCollector, false );
if( m_texcoordSize > 2 )
{
dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, m_outputPorts[ 0 ].DataType, finalTexCoordName, uvName );
dataCollector.AddLocalVariable( UniqueId, finalTexCoordName + ".xy", string.Format( Constants.TilingOffsetFormat, uvName + ".xy", dummyPropertyTexcoords + ".xy", dummyPropertyTexcoords + ".zw" ) + ";" );
m_outputPorts[ 0 ].SetLocalValue( finalTexCoordName, dataCollector.PortCategory );
}
else
{
RegisterLocalVariable( 0, string.Format( Constants.TilingOffsetFormat, uvName, dummyPropertyTexcoords + ".xy", dummyPropertyTexcoords + ".zw" ), ref dataCollector, finalTexCoordName );
}
//RegisterLocalVariable( 0, string.Format( Constants.TilingOffsetFormat, uvName, dummyPropertyTexcoords+".xy", dummyPropertyTexcoords+".zw" ), ref dataCollector, finalTexCoordName );
}
else
{
string finalTexCoordName = "texCoord" + OutputId;
tiling = m_tilingPort.GeneratePortInstructions( ref dataCollector );
offset = m_offsetPort.GeneratePortInstructions( ref dataCollector );
if( m_texcoordSize > 2 )
{
dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, m_outputPorts[ 0 ].DataType, finalTexCoordName, uvName );
dataCollector.AddLocalVariable( UniqueId, finalTexCoordName + ".xy", string.Format( Constants.TilingOffsetFormat, uvName + ".xy", tiling, offset ) + ";" );
m_outputPorts[ 0 ].SetLocalValue( finalTexCoordName, dataCollector.PortCategory );
}
else
{
RegisterLocalVariable( 0, string.Format( Constants.TilingOffsetFormat, uvName, tiling, offset ), ref dataCollector, finalTexCoordName );
}
//RegisterLocalVariable( 0, string.Format( Constants.TilingOffsetFormat, uvName, tiling, offset ), ref dataCollector, finalTexCoordName );
}
return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
}
//SURFACE
string propertyName = GetValidPropertyName();
if( !string.IsNullOrEmpty( portProperty ) && portProperty != "0.0" )
{
propertyName = portProperty;
}
if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
if( !m_tilingPort.IsConnected && m_tilingPort.Vector2InternalData == Vector2.one )
tiling = null;
else
tiling = m_tilingPort.GeneratePortInstructions( ref dataCollector );
if( !m_offsetPort.IsConnected && m_offsetPort.Vector2InternalData == Vector2.zero )
offset = null;
else
offset = m_offsetPort.GeneratePortInstructions( ref dataCollector );
if( !string.IsNullOrEmpty( propertyName ) /*m_referenceArrayId > -1*/ )
{
m_surfaceTexcoordName = GeneratorUtils.GenerateAutoUVs( ref dataCollector, UniqueId, m_textureCoordChannel, propertyName, m_outputPorts[ 0 ].DataType, tiling, offset, OutputId );
}
else
{
m_surfaceTexcoordName = GeneratorUtils.GenerateAutoUVs( ref dataCollector, UniqueId, m_textureCoordChannel, null, m_outputPorts[ 0 ].DataType, tiling, offset, OutputId );
}
m_outputPorts[ 0 ].SetLocalValue( m_surfaceTexcoordName, dataCollector.PortCategory );
return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
}
public override void ReadInputDataFromString( ref string[] nodeParams )
{
if( UIUtils.CurrentShaderVersion() > 7003 )
{
base.ReadInputDataFromString( ref nodeParams );
}
else
{
for( int i = 0; i < 2 && i < nodeParams.Length && m_currentReadParamIdx < nodeParams.Length; i++ )
{
if( UIUtils.CurrentShaderVersion() < 5003 )
{
int newId = VersionConvertInputPortId( i ) + 1;
if( UIUtils.CurrentShaderVersion() > 23 )
{
m_inputPorts[ newId ].DataType = (WirePortDataType)Enum.Parse( typeof( WirePortDataType ), nodeParams[ m_currentReadParamIdx++ ] );
}
m_inputPorts[ newId ].InternalData = nodeParams[ m_currentReadParamIdx++ ];
if( m_inputPorts[ newId ].IsEditable && UIUtils.CurrentShaderVersion() >= 3100 && m_currentReadParamIdx < nodeParams.Length )
{
m_inputPorts[ newId ].Name = nodeParams[ m_currentReadParamIdx++ ];
}
}
else
{
int portId = Convert.ToInt32( nodeParams[ m_currentReadParamIdx++ ] );
WirePortDataType DataType = (WirePortDataType)Enum.Parse( typeof( WirePortDataType ), nodeParams[ m_currentReadParamIdx++ ] );
string InternalData = nodeParams[ m_currentReadParamIdx++ ];
bool isEditable = Convert.ToBoolean( nodeParams[ m_currentReadParamIdx++ ] );
string Name = string.Empty;
if( isEditable && m_currentReadParamIdx < nodeParams.Length )
{
Name = nodeParams[ m_currentReadParamIdx++ ];
}
InputPort inputPort = GetInputPortByUniqueId( portId );
if( inputPort != null )
{
inputPort.DataType = DataType;
inputPort.InternalData = InternalData;
if( !string.IsNullOrEmpty( Name ) )
{
inputPort.Name = Name;
}
}
}
}
}
}
public override void Destroy()
{
base.Destroy();
m_referenceNode = null;
if( m_texCoordsHelper != null )
{
//Not calling m_texCoordsHelper.Destroy() on purpose so UIUtils does not incorrectly unregister stuff
DestroyImmediate( m_texCoordsHelper );
m_texCoordsHelper = null;
}
}
}
}

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -0,0 +1,361 @@
using UnityEngine;
using UnityEditor;
using System;
using System.Collections.Generic;
namespace AmplifyShaderEditor
{
[Serializable]
[NodeAttributes( "Texture Transform", "Textures", "Gives access to texture tiling and offset as set on the material inspector" )]
public sealed class TextureTransformNode : ParentNode
{
private readonly string[] Dummy = { string.Empty };
private const string InstancedLabelStr = "Instanced";
[SerializeField]
private bool m_instanced = false;
[SerializeField]
private int m_referenceSamplerId = -1;
[SerializeField]
private int m_referenceNodeId = -1;
[SerializeField]
private TexturePropertyNode m_inputReferenceNode = null;
private TexturePropertyNode m_referenceNode = null;
private Vector4Node m_texCoordsHelper;
private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper();
private int m_cachedSamplerId = -1;
private int m_cachedSamplerIdArray = -1;
private int m_cachedSamplerIdCube = -1;
private int m_cachedSamplerId3D = -1;
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
AddInputPort( WirePortDataType.SAMPLER2D, false, "Tex" );
m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.SAMPLER1D, WirePortDataType.SAMPLER2D, WirePortDataType.SAMPLER3D, WirePortDataType.SAMPLERCUBE, WirePortDataType.SAMPLER2DARRAY, WirePortDataType.OBJECT );
AddOutputPort( WirePortDataType.FLOAT2, "Tiling" );
AddOutputPort( WirePortDataType.FLOAT2, "Offset" );
m_textLabelWidth = 80;
m_autoWrapProperties = true;
m_hasLeftDropdown = true;
m_previewShaderGUID = "25ba2903568b00343ae06788994cab54";
}
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 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;
PreviewMaterial.SetInt( "_PreviewID", 0 );
Graphics.Blit( null, m_outputPorts[ 0 ].OutputPreviewTexture, PreviewMaterial, m_previewMaterialPassId );
RenderTexture.active = m_outputPorts[ 1 ].OutputPreviewTexture;
PreviewMaterial.SetInt( "_PreviewID", 1 );
Graphics.Blit( null, m_outputPorts[ 1 ].OutputPreviewTexture, PreviewMaterial, m_previewMaterialPassId );
RenderTexture.active = temp;
PreviewIsDirty = m_continuousPreviewRefresh;
FinishPreviewRender = true;
}
void SetPreviewTexture( Texture newValue )
{
if( newValue is Cubemap )
{
m_previewMaterialPassId = 3;
if( m_cachedSamplerIdCube == -1 )
m_cachedSamplerIdCube = Shader.PropertyToID( "_Cube" );
PreviewMaterial.SetTexture( m_cachedSamplerIdCube, newValue as Cubemap );
}
else if( newValue is Texture2DArray )
{
m_previewMaterialPassId = 2;
if( m_cachedSamplerIdArray == -1 )
m_cachedSamplerIdArray = Shader.PropertyToID( "_Array" );
PreviewMaterial.SetTexture( m_cachedSamplerIdArray, newValue as Texture2DArray );
}
else if( newValue is Texture3D )
{
m_previewMaterialPassId = 1;
if( m_cachedSamplerId3D == -1 )
m_cachedSamplerId3D = Shader.PropertyToID( "_Sampler3D" );
PreviewMaterial.SetTexture( m_cachedSamplerId3D, newValue as Texture3D );
}
else
{
m_previewMaterialPassId = 0;
if( m_cachedSamplerId == -1 )
m_cachedSamplerId = Shader.PropertyToID( "_Sampler" );
PreviewMaterial.SetTexture( m_cachedSamplerId, newValue );
}
}
public override void SetPreviewInputs()
{
base.SetPreviewInputs();
if( m_inputPorts[ 0 ].IsConnected )
{
SetPreviewTexture( m_inputPorts[ 0 ].InputPreviewTexture( ContainerGraph ) );
}
else if( m_referenceNode != null )
{
if( m_referenceNode.Value != null )
{
SetPreviewTexture( m_referenceNode.Value );
}
else
{
SetPreviewTexture( m_referenceNode.PreviewTexture );
}
}
}
public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true )
{
base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode );
m_inputPorts[ 0 ].MatchPortToConnection();
m_inputReferenceNode = m_inputPorts[ 0 ].GetOutputNodeWhichIsNotRelay() as TexturePropertyNode;
UpdateTitle();
}
public override void OnInputPortDisconnected( int portId )
{
base.OnInputPortDisconnected( portId );
m_inputReferenceNode = null;
UpdateTitle();
}
public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type )
{
base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type );
m_inputPorts[ 0 ].MatchPortToConnection();
UpdateTitle();
}
void UpdateTitle()
{
if( m_inputReferenceNode != null )
{
m_additionalContent.text = string.Format( Constants.PropertyValueLabel, m_inputReferenceNode.PropertyInspectorName );
}
else if( m_referenceSamplerId > -1 && m_referenceNode != null )
{
m_additionalContent.text = string.Format( Constants.PropertyValueLabel, m_referenceNode.PropertyInspectorName );
}
else
{
m_additionalContent.text = string.Empty;
}
m_sizeIsDirty = true;
}
public override void DrawProperties()
{
base.DrawProperties();
bool guiEnabledBuffer = GUI.enabled;
EditorGUI.BeginChangeCheck();
List<string> arr = new List<string>( UIUtils.TexturePropertyNodeArr() );
if( arr != null && arr.Count > 0 )
{
arr.Insert( 0, "None" );
GUI.enabled = true && ( !m_inputPorts[ 0 ].IsConnected );
m_referenceSamplerId = EditorGUILayoutPopup( Constants.AvailableReferenceStr, m_referenceSamplerId + 1, arr.ToArray() ) - 1;
}
else
{
m_referenceSamplerId = -1;
GUI.enabled = false;
EditorGUILayoutPopup( Constants.AvailableReferenceStr, m_referenceSamplerId, Dummy );
}
GUI.enabled = guiEnabledBuffer;
if( EditorGUI.EndChangeCheck() )
{
m_referenceNode = UIUtils.GetTexturePropertyNode( m_referenceSamplerId );
if( m_referenceNode != null )
{
m_referenceNodeId = m_referenceNode.UniqueId;
}
else
{
m_referenceNodeId = -1;
m_referenceSamplerId = -1;
}
UpdateTitle();
}
m_instanced = EditorGUILayoutToggle( InstancedLabelStr, m_instanced );
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
{
if( !m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
{
base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
string texTransform = string.Empty;
if( m_inputPorts[ 0 ].IsConnected )
{
texTransform = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ) + "_ST";
}
else if( m_referenceNode != null )
{
m_referenceNode.BaseGenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
texTransform = m_referenceNode.PropertyName + "_ST";
}
else
{
texTransform = "_ST";
UIUtils.ShowMessage( UniqueId, "Please specify a texture sample on the Texture Transform Size node", MessageSeverity.Warning );
}
//bool excludeUniformKeyword = UIUtils.CurrentWindow.OutsideGraph.IsInstancedShader || UIUtils.CurrentWindow.OutsideGraph.IsSRP;
//string uniformRegister = UIUtils.GenerateUniformName( excludeUniformKeyword, WirePortDataType.FLOAT4, texTransform );
//dataCollector.AddToUniforms( UniqueId, uniformRegister, true );
if( m_texCoordsHelper == null )
{
m_texCoordsHelper = CreateInstance<Vector4Node>();
m_texCoordsHelper.ContainerGraph = ContainerGraph;
m_texCoordsHelper.SetBaseUniqueId( UniqueId, true );
m_texCoordsHelper.RegisterPropertyOnInstancing = false;
m_texCoordsHelper.AddGlobalToSRPBatcher = true;
}
if( m_instanced )
{
m_texCoordsHelper.CurrentParameterType = PropertyType.InstancedProperty;
}
else
{
m_texCoordsHelper.CurrentParameterType = PropertyType.Global;
}
m_texCoordsHelper.ResetOutputLocals();
m_texCoordsHelper.SetRawPropertyName( texTransform );
texTransform = m_texCoordsHelper.GenerateShaderForOutput( 0, ref dataCollector, false );
m_outputPorts[ 0 ].SetLocalValue( texTransform + ".xy", dataCollector.PortCategory );
m_outputPorts[ 1 ].SetLocalValue( texTransform + ".zw", dataCollector.PortCategory );
}
return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory );
}
public override void Draw( DrawInfo drawInfo )
{
base.Draw( drawInfo );
EditorGUI.BeginChangeCheck();
{
List<string> arr = new List<string>( UIUtils.TexturePropertyNodeArr() );
bool guiEnabledBuffer = GUI.enabled;
if( arr != null && arr.Count > 0 )
{
arr.Insert( 0, "None" );
GUI.enabled = true && ( !m_inputPorts[ 0 ].IsConnected );
m_referenceSamplerId = m_upperLeftWidget.DrawWidget( this, m_referenceSamplerId + 1, arr.ToArray() ) - 1;
}
else
{
m_referenceSamplerId = -1;
GUI.enabled = false;
m_upperLeftWidget.DrawWidget( this, m_referenceSamplerId, Dummy );
}
GUI.enabled = guiEnabledBuffer;
}
if( EditorGUI.EndChangeCheck() )
{
m_referenceNode = UIUtils.GetTexturePropertyNode( m_referenceSamplerId );
if( m_referenceNode != null )
{
m_referenceNodeId = m_referenceNode.UniqueId;
}
else
{
m_referenceNodeId = -1;
m_referenceSamplerId = -1;
}
UpdateTitle();
}
}
public override void RefreshExternalReferences()
{
base.RefreshExternalReferences();
m_referenceNode = UIUtils.GetNode( m_referenceNodeId ) as TexturePropertyNode;
m_referenceSamplerId = UIUtils.GetTexturePropertyNodeRegisterId( m_referenceNodeId );
UpdateTitle();
}
public override void ReadFromString( ref string[] nodeParams )
{
base.ReadFromString( ref nodeParams );
m_referenceNodeId = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
if( UIUtils.CurrentShaderVersion() > 17200 )
{
m_instanced = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
}
}
public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
{
base.WriteToString( ref nodeInfo, ref connectionsInfo );
IOUtils.AddFieldValueToString( ref nodeInfo, m_referenceNodeId );
IOUtils.AddFieldValueToString( ref nodeInfo, m_instanced );
}
public override void Destroy()
{
base.Destroy();
m_referenceNode = null;
m_inputReferenceNode = null;
m_upperLeftWidget = null;
if( m_texCoordsHelper != null )
{
//Not calling m_texCoordsHelper.Destroy() on purpose so UIUtils does not incorrectly unregister stuff
DestroyImmediate( m_texCoordsHelper );
m_texCoordsHelper = null;
}
}
}
}

View File

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

View File

@@ -0,0 +1,68 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyShaderEditor
{
[NodeAttributes( "Unpack Scale Normal", "Textures", "Applies UnpackNormal/UnpackScaleNormal function" )]
[Serializable]
public class UnpackScaleNormalNode : ParentNode
{
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
AddInputPort( WirePortDataType.FLOAT4, false, "Value" );
AddInputPort( WirePortDataType.FLOAT, false, "Scale" );
m_inputPorts[ 1 ].FloatInternalData = 1;
AddOutputVectorPorts( WirePortDataType.FLOAT3, "XYZ" );
m_useInternalPortData = true;
m_previewShaderGUID = "8b0ae05e25d280c45af81ded56f8012e";
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
{
string src = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
bool isScaledNormal = false;
if ( m_inputPorts[ 1 ].IsConnected )
{
isScaledNormal = true;
}
else
{
if ( m_inputPorts[ 1 ].FloatInternalData != 1 )
{
isScaledNormal = true;
}
}
string normalMapUnpackMode = string.Empty;
string scaleValue = isScaledNormal?m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ):"1.0";
normalMapUnpackMode = GeneratorUtils.GenerateUnpackNormalStr( ref dataCollector, CurrentPrecisionType, UniqueId, OutputId, src, isScaledNormal, scaleValue );
if( isScaledNormal && !( dataCollector.IsTemplate && dataCollector.IsSRP ) )
{
dataCollector.AddToIncludes( UniqueId, Constants.UnityStandardUtilsLibFuncs );
}
int outputUsage = 0;
for ( int i = 0; i < m_outputPorts.Count; i++ )
{
if ( m_outputPorts[ i ].IsConnected )
outputUsage += 1;
}
if ( outputUsage > 1 && !dataCollector.IsSRP )
{
string varName = "localUnpackNormal" + OutputId;
dataCollector.AddLocalVariable( UniqueId, "float3 " + varName + " = " + normalMapUnpackMode + ";" );
return GetOutputVectorItem( 0, outputId, varName );
}
else
{
return GetOutputVectorItem( 0, outputId, normalMapUnpackMode );
}
}
}
}

View File

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

View File

@@ -0,0 +1,296 @@
// 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 VirtualPreset
{
Unity_Legacy,
Unity5,
Alloy,
UBER,
Skyshop,
Lux
}
public enum VirtualChannel
{
Albedo = 0,
Base,
Normal,
Height,
Occlusion,
Displacement,
Specular,
SpecMet,
Material,
}
[Serializable]
[NodeAttributes( "Virtual Texture Object", "Textures", "Represents a Virtual Texture Asset", SortOrderPriority = 1 )]
public class VirtualTextureObject : TexturePropertyNode
{
protected const string VirtualPresetStr = "Layout Preset";
protected const string VirtualChannelStr = "Virtual Layer";
private const string VirtualTextureObjectInfo = "Can only be used alongside a Texture Sample node by connecting to its Tex Input Port.\n" +
"\nProperty name must match the value set on your Virtual Texture.\n" +
"Default e.g Albedo = _MainTex\n" +
"\nName your node according to the respective channel property in your Virtual Texture. The Albedo must be set to _MainTex ( temporary requirement ).";
private readonly string[] ChannelTypeStr = {
"Albedo - D.RGBA",
"Base - D.RGBA",
"Normal - N.GA",
"Height - N.B",
"Occlusion - N.R",
"Displacement - N.B",
"Specular - S.RGBA",
"Specular|Metallic - S.RGBA",
"Material - S.RGBA",};
private readonly string[] Dummy = { string.Empty };
private string[] m_channelTypeStr;
[SerializeField]
protected VirtualPreset m_virtualPreset = VirtualPreset.Unity5;
[SerializeField]
protected VirtualChannel m_virtualChannel = VirtualChannel.Albedo;
[SerializeField]
private int m_selectedChannelInt = 0;
protected override void CommonInit( int uniqueId )
{
base.CommonInit( uniqueId );
ChangeChannels();
}
protected override void OnUniqueIDAssigned()
{
base.OnUniqueIDAssigned();
if ( UniqueId != -1 )
UIUtils.AddVirtualTextureCount();
}
public override void DrawSubProperties()
{
ShowDefaults();
base.DrawSubProperties();
}
public override void DrawMaterialProperties()
{
ShowDefaults();
base.DrawMaterialProperties();
}
new void ShowDefaults()
{
EditorGUI.BeginChangeCheck();
m_virtualPreset = ( VirtualPreset ) EditorGUILayoutEnumPopup( VirtualPresetStr, m_virtualPreset );
if ( EditorGUI.EndChangeCheck() )
{
ChangeChannels();
}
EditorGUI.BeginChangeCheck();
m_selectedChannelInt = EditorGUILayoutPopup( VirtualChannelStr, m_selectedChannelInt, m_channelTypeStr );
if ( EditorGUI.EndChangeCheck() )
{
m_virtualChannel = GetChannel( m_selectedChannelInt );
}
}
public override void DrawProperties()
{
base.DrawProperties();
EditorGUILayout.HelpBox( VirtualTextureObjectInfo, MessageType.Info );
}
private VirtualChannel GetChannel( int popupInt )
{
int remapInt = 0;
switch ( m_virtualPreset )
{
case VirtualPreset.Unity_Legacy:
remapInt = popupInt == 0 ? 1 : popupInt == 1 ? 2 : popupInt == 2 ? 4 : popupInt == 3 ? 5 : 0;
break;
default:
case VirtualPreset.Unity5:
case VirtualPreset.UBER:
remapInt = popupInt == 0 ? 0 : popupInt == 1 ? 7 : popupInt == 2 ? 2 : popupInt == 3 ? 3 : popupInt == 4 ? 4 : 0;
break;
case VirtualPreset.Alloy:
remapInt = popupInt == 0 ? 1 : popupInt == 1 ? 2 : popupInt == 2 ? 8 : popupInt == 3 ? 3 : 0;
break;
case VirtualPreset.Skyshop:
case VirtualPreset.Lux:
remapInt = popupInt == 0 ? 1 : popupInt == 1 ? 2 : popupInt == 2 ? 6 : 0;
break;
}
return ( VirtualChannel ) remapInt;
}
private void ChangeChannels()
{
m_channelTypeStr = Dummy;
switch ( m_virtualPreset )
{
case VirtualPreset.Unity_Legacy:
m_channelTypeStr = new string[] { ChannelTypeStr[ 1 ], ChannelTypeStr[ 2 ], ChannelTypeStr[ 4 ], ChannelTypeStr[ 5 ] };
break;
default:
case VirtualPreset.Unity5:
case VirtualPreset.UBER:
m_channelTypeStr = new string[] { ChannelTypeStr[ 0 ], ChannelTypeStr[ 7 ], ChannelTypeStr[ 2 ], ChannelTypeStr[ 3 ], ChannelTypeStr[ 4 ] };
break;
case VirtualPreset.Alloy:
m_channelTypeStr = new string[] { ChannelTypeStr[ 1 ], ChannelTypeStr[ 2 ], ChannelTypeStr[ 8 ], ChannelTypeStr[ 3 ] };
break;
case VirtualPreset.Skyshop:
case VirtualPreset.Lux:
m_channelTypeStr = new string[] { ChannelTypeStr[ 1 ], ChannelTypeStr[ 2 ], ChannelTypeStr[ 6 ] };
break;
}
}
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
{
base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalVar );
dataCollector.AddToProperties( UniqueId, "[HideInInspector] _VTInfoBlock( \"VT( auto )\", Vector ) = ( 0, 0, 0, 0 )", -1 );
return PropertyName;
}
public override string GetPropertyValue()
{
string propertyValue = string.Empty;
switch ( m_virtualChannel )
{
default:
case VirtualChannel.Albedo:
case VirtualChannel.Base:
propertyValue = PropertyName + "(\"" + m_propertyInspectorName + "\", 2D) = \"" + m_defaultTextureValue + "\" {}";
break;
case VirtualChannel.Normal:
propertyValue = PropertyName + "(\"" + m_propertyInspectorName + "\", 2D) = \"" + m_defaultTextureValue + "\" {}";
break;
case VirtualChannel.SpecMet:
propertyValue = PropertyName + "(\"" + m_propertyInspectorName + "\", 2D) = \"" + m_defaultTextureValue + "\" {}";
break;
}
return PropertyAttributes + propertyValue;
}
public override string GetUniformValue()
{
return "uniform sampler2D " + PropertyName + ";";
}
public override bool GetUniformData( out string dataType, out string dataName, ref bool fullValue )
{
dataType = "sampler2D";
dataName = PropertyName;
return true;
}
public override void ReadFromString( ref string[] nodeParams )
{
base.ReadFromString( ref nodeParams );
string defaultTextureGUID = GetCurrentParam( ref nodeParams );
//m_defaultValue = AssetDatabase.LoadAssetAtPath<Texture>( textureName );
if( UIUtils.CurrentShaderVersion() > 14101 )
{
m_defaultValue = AssetDatabase.LoadAssetAtPath<Texture>( AssetDatabase.GUIDToAssetPath( defaultTextureGUID ) );
string materialTextureGUID = GetCurrentParam( ref nodeParams );
m_materialValue = AssetDatabase.LoadAssetAtPath<Texture>( AssetDatabase.GUIDToAssetPath( materialTextureGUID ) );
}
else
{
m_defaultValue = AssetDatabase.LoadAssetAtPath<Texture>( defaultTextureGUID );
}
m_isNormalMap = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
m_defaultTextureValue = ( TexturePropertyValues ) Enum.Parse( typeof( TexturePropertyValues ), GetCurrentParam( ref nodeParams ) );
m_autocastMode = ( AutoCastType ) Enum.Parse( typeof( AutoCastType ), GetCurrentParam( ref nodeParams ) );
m_virtualPreset = ( VirtualPreset ) Enum.Parse( typeof( VirtualPreset ), GetCurrentParam( ref nodeParams ) );
m_selectedChannelInt = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
ChangeChannels();
m_virtualChannel = GetChannel( m_selectedChannelInt );
//m_forceNodeUpdate = true;
//ConfigFromObject( m_defaultValue );
if( m_materialValue == null )
{
ConfigFromObject( m_defaultValue );
}
else
{
CheckTextureImporter( true, true );
}
ConfigureInputPorts();
ConfigureOutputPorts();
}
public override void ReadAdditionalData( ref string[] nodeParams ) { }
public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
{
base.WriteToString( ref nodeInfo, ref connectionsInfo );
//IOUtils.AddFieldValueToString( ref nodeInfo, ( m_defaultValue != null ) ? AssetDatabase.GetAssetPath( m_defaultValue ) : Constants.NoStringValue );
IOUtils.AddFieldValueToString( ref nodeInfo, ( m_defaultValue != null ) ? AssetDatabase.AssetPathToGUID( AssetDatabase.GetAssetPath( m_defaultValue ) ) : Constants.NoStringValue );
IOUtils.AddFieldValueToString( ref nodeInfo, ( m_materialValue != null ) ? AssetDatabase.AssetPathToGUID( AssetDatabase.GetAssetPath( m_materialValue ) ) : Constants.NoStringValue );
IOUtils.AddFieldValueToString( ref nodeInfo, m_isNormalMap.ToString() );
IOUtils.AddFieldValueToString( ref nodeInfo, m_defaultTextureValue );
IOUtils.AddFieldValueToString( ref nodeInfo, m_autocastMode );
IOUtils.AddFieldValueToString( ref nodeInfo, m_virtualPreset );
IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedChannelInt );
}
public override void WriteAdditionalToString( ref string nodeInfo, ref string connectionsInfo ) { }
//public override string PropertyName
//{
// get
// {
// string propertyName = string.Empty;
// switch ( m_virtualChannel )
// {
// default:
// case VirtualChannel.Albedo:
// case VirtualChannel.Base:
// propertyName = "_MainTex";
// break;
// case VirtualChannel.Normal:
// propertyName = "_BumpMap";
// break;
// case VirtualChannel.SpecMet:
// propertyName = "_MetallicGlossMap";
// break;
// case VirtualChannel.Occlusion:
// propertyName = "_OcclusionMap";
// break;
// }
// return propertyName;
// }
//}
public override void Destroy()
{
base.Destroy();
UIUtils.RemoveVirtualTextureCount();
}
public override bool IsNormalMap { get { return m_isNormalMap || m_virtualChannel == VirtualChannel.Normal; } }
public VirtualChannel Channel { get { return m_virtualChannel; } }
}
}

View File

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