master
HJD 2 years ago
parent 8c4366dfe0
commit a2b5bac462

@ -0,0 +1,6 @@
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Workload.ManagedGame"
]
}

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7e05d995503df924aad67c4c2bd80fdf
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,15 @@
{
"name": "AmplifyShaderEditor",
"references": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": true,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f540dafdfbc0586439d98823585550d4
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 580cccd3e608b7f4cac35ea46d62d429
timeCreated: 1481127071
licenseType: Store
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,58 @@
Creating terrains with Amplify Shader Editor is really quick and easy. We will give you a brief explanation on how you can start creating terrain shaders with ASE in no time.
A standard unity terrain is a regular surface shader using properties with a specific naming.
Besides these properties, a small configuration is necessary.
[Create Shader]
As with any other ASE shaders, right-click on the Project view, select Create > Amplify Shader > Surface Shader and name it as you like. We advise you to have 'First-Pass' included on the shader name since it performs what is called a first pass over the terrain.
[Queue Index]
Set the Queue Index to -100 on the Output Node Properties General tab.
[Render Type]
By default a created shader already comes with the Opaque shader type selected, which is required by the terrain, but please go to the Blend Mode tab and check that Opaque is the selected option.
[Specify Base Shader]
A Base shader must be specified. This shader will be responsible to render the terrain when over a certain distance specified at the Base Map Distance on the terrain settings. Beyond this distance, a lower resolution composite image will be used with this shader for efficiency reasons.
We already have a base shader created and ready to be used, so you only need to:
- Go to your Dependencies Tab on the Output Node Properties
- Click on the Add Button to add a new entry
- Write BaseMapShader into the Name textfield
- Write ASESampleShaders/SimpleTerrainBase on the Value textfield
Feel free to open the ASESampleShaders/SimpleTerrainBase shader located at AmplifyShaderEditor > Examples > Official > SimpleTerrain > SimpleTerrainBase.shader and check what is being done. Please note that property naming in the base shader is very strict and property names must be maintained.
[Specify Splat Count]
ASE only supports up to four splats (single-pass) for now, this needs to be specified into the shader through a custom tag.
In order to do that:
- Go to Custom SubShader Tags tab on the Output Node Properties
- Click on the Add Button to add a new entry
- Write SplatCount into the Name textfield
- Write 4 into the Value textfield
Future versions will introduce multi-pass support for more complex effects.
[Create Properties]
This is the meat of how the terrain shader will behave.
We already have a shader function, Four Splats First Pass Terrain, which replicates Unity standard terrain and should be used as starting point on creating your own shader.
[[Diffuse]]
Each splat can be accessed via their properties, having yet again strict naming to be maintained.
The splat diffuse colors are accessed through the sampler variables _Splat0 through _Splat3, so in your shader you must create four Texture Sampler nodes with the names Splat 0 through Splat 3 as the _ is automatically placed and the empty spaces are also automatically removed from the created variable name.
[[Normal]]
The same goes to normal maps, they are accessed through the sampler variables _Normal0 through _Normal3 so, like with diffuse, in your shader you must create four Texture Sampler nodes with the names Normal 0 through Normal 3. One detail to take into account is that Unpack Normal Map should be turned off for each one of the nodes and an Unpack Scale Normal node should be applied after their values are combined.
[[Smoothness + Metallic]]
Smoothness and Metallic values must also have specific variable names, _Smoothness0 through _Smoothness3 and _Metallic0 through _Metallic3 respectively.
These variables however are Float properties, so to access them you need to create Float nodes, set them to Properties with the names Smoothness 0 through Smoothness 3 and Metallic 0 through Metallic 3 respectively.
To maintain consistency with the Unity terrain shader, you should add the Gamma attribute to the Metallic property nodes.
[[Combining Maps]]
The weight of each layer is given by yet another sampler variable. The _Control sampler variable contains, in each of its channels, the contribution each layer/splat have on the final result.
To get access to it, simply create a Texture Sampler node in your shader with its name being Control.
This Control texture is dynamically created when you paint your terrain with the Terrain tools and can be inspected by selecting the terrain asset on the Project view.
Again, we invite you to check the Four Splats First Pass Terrain shader function located at AmplifyShaderEditor > Plugins > EditorResources > ShaderFunctions > Four Splats First Pass Terrain for a more in-depth view on how the Control texture is used.

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f11d5aaf59fc38544b8419242801ff97
timeCreated: 1513615640
licenseType: Store
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 425c3aed47dd05444960ca41af18e591
folderAsset: yes
timeCreated: 1481126943
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e00e6f90ab8233e46a41c5e33917c642
timeCreated: 1585839223
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
Fire texture - http://suicidecrew.deviantart.com/art/Fire-Seamless-tile-116721709
Screen Space Curvature - http://madebyevan.com/shaders/curvature/
Grass Blades texture from:
http://www.fuzzimo.com/free-hi-res-ornamental-grass-blade-textures/
Keep them coming, contribute today!
http://amplify.pt/unity/amplify-shader-editor/contribute

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 451790f45b4e5434586d16e924540ee7
timeCreated: 1481127071
licenseType: Store
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
Use your Unity Asset Store invoice number in the Amplify Product download page to download the latest Amplify Shader Editor package and Shader Samples package.
1 - Go to http://amplify.pt/download
2 - Enter your Unity Asset Store and click Unlock
3 - Scroll down to the Amplify Shader Editor entry
4 - Click the Sample button to download the sample package.
NOTE: You can also use the product download page to download the latest Amplify Shader Editor package. Due to Asset Store review times and update cycles, the version hosted there is usually more recent.

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 03fe3bdcb7262a84ca060ff336c7d8d1
timeCreated: 1481127071
licenseType: Store
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: dff05fea7446d7b4e9029bfab77455d2
timeCreated: 1559836117
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d1c0b77896049554fa4b635531caf741
timeCreated: 1533059192
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f7c4e22642de60d448f4e4809190f7b1
timeCreated: 1559837332
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6ecbfd0a046659943a69328c98ff0442
timeCreated: 1520956522
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,12 @@
Samples are provided by pipeline, if you want to import the samples please use the "Start Screen" to do so instead of unpacking manually, this will ensure that they are imported correctly. Go to Windows > Amplify Shader Editor > Start Screen and under "Shader Samples" select the ones you want to import. Do be aware that importing any SRP samples requires to first install the respective pipeline using the package manager.
However if you still want to import them manually here is the breakdown of the included packages:
* "Sample Resources": constains the assets shared between all pipelines, like textures and meshes, this should always be imported first
* "Built-In Samples": contains the samples shaders with their scenes for the built-in rendering system
* "HDRP Samples": contains the samples shaders with their scenes for HDRP 7.X.X and up (Unity 2019.3 and up)
* "HDRP Samples (Legacy)": contains the samples shaders with their scenes for HDRP 6.X.X and down (from Unity 2018.2 to Unity 2019.2)
* "URP Samples": contains the samples shaders with their scenes for URP 7.X.X and up (Unity 2019.3 and up)
* "LWRP Samples": contains the samples shaders with their scenes for LWRP between 4.X.X and 6.X.X (from Unity 2018.3 to Unity 2019.2)
* "LWRP Samples (Legacy)": contains the samples shaders with their scenes for LWRP 3.X.X (Unity 2018.2)
Please notice that in some cases the sample may have been created in a different version from the SRP that you are using which can produce "pink" shaders. If that happens it's usually the case that you only need to open the shader in ASE and save it to update it.

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5c5208e121a880c4fbb9de7aaeaa8aa2
timeCreated: 1541776170
licenseType: Store
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c0a0a980c9ba86345bc15411db88d34f
timeCreated: 1585839223
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a9d68dd8913f05d4d9ce75e7b40c6044
timeCreated: 1575902011
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 3306ce0ede814a84c8d289893da72b7a
folderAsset: yes
timeCreated: 1481126943
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 4a66239afbf6d2c4eb99238642c8d40f
folderAsset: yes
timeCreated: 1481126943
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: a2ba8588f45692f4ea2fa5afa9faf434
folderAsset: yes
timeCreated: 1481126944
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,336 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using UnityEngine;
namespace AmplifyShaderEditor
{
public class ActionData
{
public virtual void ExecuteForward() { }
public virtual void ExecuteReverse() { }
}
// NODES
// Create node
public class CreateNodeActionData : ActionData
{
private int m_nodeId;
private System.Type m_nodeType;
private Vector2 m_nodePos;
public CreateNodeActionData( ParentNode node )
{
m_nodeId = node.UniqueId;
m_nodePos = node.Vec2Position;
m_nodeType = node.GetType();
}
public CreateNodeActionData( int nodeId, System.Type nodeType, Vector2 nodePos )
{
m_nodeId = nodeId;
m_nodePos = nodePos;
m_nodeType = nodeType;
}
public override void ExecuteForward()
{
UIUtils.CreateNode( m_nodeType, false, m_nodePos, m_nodeId );
}
public override void ExecuteReverse()
{
UIUtils.DestroyNode( m_nodeId );
}
public override string ToString()
{
return "Create Node - Type: " + m_nodeType + " Node: " + m_nodeId + " Position: " + m_nodePos;
}
}
// Destroy node
public class DestroyNodeActionData : ActionData
{
private int m_nodeId;
private System.Type m_nodeType;
private Vector2 m_nodePos;
public DestroyNodeActionData( ParentNode node )
{
m_nodeId = node.UniqueId;
m_nodePos = node.Vec2Position;
m_nodeType = node.GetType();
}
public DestroyNodeActionData( int nodeId, System.Type nodeType, Vector2 nodePos )
{
m_nodeId = nodeId;
m_nodePos = nodePos;
m_nodeType = nodeType;
}
public override void ExecuteForward()
{
UIUtils.DestroyNode( m_nodeId );
}
public override void ExecuteReverse()
{
UIUtils.CreateNode( m_nodeType, false, m_nodePos, m_nodeId );
}
public override string ToString()
{
return "Destroy Node - Type: " + m_nodeType + " Node: " + m_nodeId + " Position: " + m_nodePos;
}
}
// Move node
public class MoveNodeActionData : ActionData
{
private int m_nodeId;
private Vector2 m_nodeInitalPos;
private Vector2 m_nodeFinalPos;
public MoveNodeActionData( int nodeId, Vector2 nodeInitialPos, Vector2 nodeFinalPos )
{
m_nodeId = nodeId;
m_nodeInitalPos = nodeInitialPos;
m_nodeFinalPos = nodeFinalPos;
}
public override void ExecuteForward()
{
ParentNode node = UIUtils.GetNode( m_nodeId );
if ( node != null )
node.Vec2Position = m_nodeFinalPos;
}
public override void ExecuteReverse()
{
ParentNode node = UIUtils.GetNode( m_nodeId );
if ( node != null )
node.Vec2Position = m_nodeInitalPos;
}
public override string ToString()
{
return "Move Node - Node: " + m_nodeId + " Initial Position: " + m_nodeInitalPos + " Final Position: " + m_nodeFinalPos;
}
}
// CONNECTIONS
// Create connection
public class CreateConnectionActionData : ActionData
{
private int m_inputNodeId;
private int m_inputPortId;
private int m_outputNodeId;
private int m_outputPortId;
public CreateConnectionActionData( int inputNodeId, int inputPortId, int outputNodeId, int outputPortId )
{
m_inputNodeId = inputNodeId;
m_inputPortId = inputPortId;
m_outputNodeId = outputNodeId;
m_outputPortId = outputPortId;
}
public override void ExecuteForward()
{
UIUtils.ConnectInputToOutput( m_inputNodeId, m_inputPortId, m_outputNodeId, m_outputPortId );
}
public override void ExecuteReverse()
{
UIUtils.DeleteConnection( true, m_inputNodeId, m_inputPortId, false, true );
}
public override string ToString()
{
return "Create Connection Node - Input Node: " + m_inputNodeId + " Input Port: " + m_inputPortId + " Output Node: " + m_outputNodeId + " Output Port: " + m_outputPortId;
}
}
// Destroy connection
public class DestroyConnectionActionData : ActionData
{
private int m_inputNodeId;
private int m_inputPortId;
private int m_outputNodeId;
private int m_outputPortId;
public DestroyConnectionActionData( int inputNodeId, int inputPortId, int outputNodeId, int outputPortId )
{
m_inputNodeId = inputNodeId;
m_inputPortId = inputPortId;
m_outputNodeId = outputNodeId;
m_outputPortId = outputPortId;
}
public override void ExecuteForward()
{
UIUtils.DeleteConnection( true, m_inputNodeId, m_inputPortId, false, true );
}
public override void ExecuteReverse()
{
UIUtils.ConnectInputToOutput( m_inputNodeId, m_inputPortId, m_outputNodeId, m_outputPortId );
}
public override string ToString()
{
return "Destroy Connection Node - Input Node: " + m_inputNodeId + " Input Port: " + m_inputPortId + " Output Node: " + m_outputNodeId + " Output Port: " + m_outputPortId;
}
}
// Move connection
public class MoveInputConnectionActionData : ActionData
{
private int m_oldInputNodeId;
private int m_oldInputNodePortId;
private int m_newInputNodeId;
private int m_newInputNodePortId;
private int m_outputNodeId;
private int m_outputPortId;
public MoveInputConnectionActionData( int oldInputNodeId, int oldInputPortId, int newInputNodeId, int newInputPortId, int outputNodeId, int outputPortId )
{
m_oldInputNodeId = oldInputNodeId;
m_oldInputNodePortId = oldInputPortId;
m_newInputNodeId = newInputNodeId;
m_newInputNodePortId = newInputPortId;
m_outputNodeId = outputNodeId;
m_outputPortId = outputPortId;
}
public override void ExecuteForward()
{
UIUtils.DeleteConnection( true, m_oldInputNodeId, m_oldInputNodePortId, false, true );
UIUtils.ConnectInputToOutput( m_newInputNodeId, m_newInputNodePortId, m_outputNodeId, m_outputPortId );
}
public override void ExecuteReverse()
{
base.ExecuteReverse();
UIUtils.DeleteConnection( true, m_newInputNodeId, m_newInputNodePortId, false, true );
UIUtils.ConnectInputToOutput( m_oldInputNodeId, m_oldInputNodePortId, m_outputNodeId, m_outputPortId );
}
public override string ToString()
{
return "Move Input Connection Node - Old Input Node: " + m_oldInputNodeId + " Old Input Port: " + m_oldInputNodePortId + " New Input Node: " + m_newInputNodeId + " New Input Port: " + m_newInputNodePortId + " Output Node: " + m_outputNodeId + " Output Port: " + m_outputPortId;
}
}
public class MoveOutputConnectionActionData : ActionData
{
private int m_inputNodeId;
private int m_inputPortId;
private int m_newOutputNodeId;
private int m_newOutputPortId;
private int m_oldOutputNodeId;
private int m_oldOutputPortId;
public MoveOutputConnectionActionData( int inputNodeId, int inputPortId, int newOutputNodeId, int newOutputPortId, int oldOutputNodeId, int oldOutputPortId )
{
m_inputNodeId = inputNodeId;
m_inputPortId = inputPortId;
m_newOutputNodeId = newOutputNodeId;
m_newOutputPortId = newOutputPortId;
m_oldOutputNodeId = oldOutputNodeId;
m_oldOutputPortId = oldOutputPortId;
}
public override void ExecuteForward()
{
UIUtils.DeleteConnection( false, m_oldOutputNodeId, m_oldOutputNodeId, false, true );
UIUtils.ConnectInputToOutput( m_inputNodeId, m_inputPortId, m_newOutputNodeId, m_newOutputPortId );
}
public override void ExecuteReverse()
{
base.ExecuteReverse();
UIUtils.DeleteConnection( false, m_newOutputNodeId, m_newOutputPortId, false, true );
UIUtils.ConnectInputToOutput( m_inputNodeId, m_inputPortId, m_oldOutputNodeId, m_oldOutputPortId );
}
public override string ToString()
{
return "Move Input Connection Node - Input Node: " + m_inputNodeId + " Input Port: " + m_inputPortId + " Old Output Node: " + m_oldOutputNodeId + " Old Output Port: " + m_oldOutputPortId + " New Output Node: " + m_newOutputNodeId + " New Output Port: " + m_newOutputPortId;
}
}
public class CreateNewGraphActionData : ActionData
{
private string m_name;
public CreateNewGraphActionData( string name )
{
m_name = name;
}
public override void ExecuteForward()
{
UIUtils.CreateNewGraph( m_name );
}
}
public class ChangeNodePropertiesActionData : ActionData
{
private string m_originalProperties;
private string m_newProperties;
private int m_nodeId;
public ChangeNodePropertiesActionData( ParentNode node, string originalProperties )
{
m_nodeId = node.UniqueId;
m_originalProperties = originalProperties;
m_newProperties = string.Empty;
string trash = string.Empty;
node.WriteToString( ref m_newProperties, ref trash );
}
public ChangeNodePropertiesActionData( int nodeId, string originalProperties )
{
m_nodeId = nodeId;
m_originalProperties = originalProperties;
m_newProperties = string.Empty;
string trash = string.Empty;
UIUtils.GetNode( nodeId ).WriteToString( ref m_newProperties, ref trash );
}
public override void ExecuteForward()
{
string[] properties = m_newProperties.Split( IOUtils.FIELD_SEPARATOR );
UIUtils.GetNode( m_nodeId ).ReadFromString( ref properties );
}
public override void ExecuteReverse()
{
string[] properties = m_originalProperties.Split( IOUtils.FIELD_SEPARATOR );
UIUtils.GetNode( m_nodeId ).ReadFromString( ref properties );
}
public override string ToString()
{
return "Change Node Propertie - Node: " + m_nodeId + "\nOriginal Properties:\n" + m_originalProperties + "\nNew Properties:\n" + m_newProperties;
}
}
}

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 29204f353101f46439a93f1c503d3197
timeCreated: 1481126954
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.Collections.Generic;
namespace AmplifyShaderEditor
{
public class ActionLog
{
private int m_maxCount;
private int m_index;
private List<ActionData> m_sequence;
public ActionLog(int maxCount)
{
m_maxCount = maxCount;
m_index = 0;
m_sequence = new List<ActionData>();
}
public void AddToLog(ActionData actionData)
{
if (m_sequence.Count > m_maxCount)
{
m_sequence.RemoveAt(0);
}
m_sequence.Add(actionData);
m_index = m_sequence.Count - 1;
}
public void UndoLastAction()
{
if ( m_index > -1 && m_index < m_sequence.Count )
m_sequence[m_index--].ExecuteReverse();
}
public void RedoLastAction()
{
if (m_index < (m_sequence.Count - 1))
m_sequence[++m_index].ExecuteForward();
}
public void ClearLog()
{
m_sequence.Clear();
m_index = 0;
}
public void Destroy()
{
m_sequence.Clear();
m_sequence = null;
}
}
}

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: bc089a69595d8994cb89946a919517c2
timeCreated: 1481126958
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 System.Collections.Generic;
namespace AmplifyShaderEditor
{
public class ActionSequence
{
private string m_name;
private List<ActionData> m_sequence;
public ActionSequence( string name )
{
m_name = name;
m_sequence = new List<ActionData>();
}
public void AddToSequence( ActionData actionData )
{
m_sequence.Add( actionData );
}
public void Execute()
{
for ( int i = 0; i < m_sequence.Count; i++ )
{
m_sequence[ i ].ExecuteForward();
}
}
public void Destroy()
{
m_sequence.Clear();
m_sequence = null;
}
public string Name { get { return m_name; } }
}
}

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

@ -0,0 +1,664 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using System.Collections.Generic;
namespace AmplifyShaderEditor
{
public struct Constants
{
/*public readonly static string[] CustomASEStandardArgsMacros =
{
"#if defined(SHADER_API_D3D11) || defined(SHADER_API_XBOXONE) || defined(UNITY_COMPILER_HLSLCC)//ASE Args Macros",
"#define ASE_TEXTURE2D_ARGS(textureName) Texture2D textureName, SamplerState sampler##textureName",
"#define ASE_TEXTURE3D_ARGS(textureName) Texture3D textureName, SamplerState sampler##textureName",
"#define ASE_TEXTURECUBE_ARGS(textureName) TextureCube textureName, SamplerState sampler##textureName",
"#define ASE_TEXTURE2D_PARAMS(textureName) textureName, sampler##textureName",
"#define ASE_TEXTURE3D_PARAMS(textureName) textureName, sampler##textureName",
"#define ASE_TEXTURECUBE_PARAMS(textureName) textureName, sampler##textureName",
"#define ASE_TEXTURE2D_ARRAY_PARAMS(textureName) textureName, sampler##textureName",
"#else//ASE Args Macros",
"#define ASE_TEXTURE2D_ARGS(textureName) sampler2D textureName",
"#define ASE_TEXTURE3D_ARGS(textureName) sampler3D textureName",
"#define ASE_TEXTURECUBE_ARGS(textureName) samplerCUBE textureName",
"#define ASE_TEXTURE2D_PARAMS(textureName) textureName",
"#define ASE_TEXTURE3D_PARAMS(textureName) textureName",
"#define ASE_TEXTURECUBE_PARAMS(textureName) textureName",
"#define ASE_TEXTURE2D_ARRAY_PARAMS(textureName) textureName",
"#endif//ASE Args Macros\n"
};
public readonly static string[] CustomASEDeclararionMacros =
{
"#define ASE_TEXTURE2D(textureName) {0}2D(textureName)",
"#define ASE_TEXTURE2D_ARRAY(textureName) {0}2D_ARRAY(textureName)",
"#define ASE_TEXTURE3D(textureName) {0}3D(textureName)",
"#define ASE_TEXTURECUBE(textureName) {0}CUBE(textureName)\n"
};
public readonly static string[] CustomASEStandarSamplingMacrosHelper =
{
"#if defined(SHADER_API_D3D11) || defined(SHADER_API_XBOXONE) || defined(UNITY_COMPILER_HLSLCC)//ASE Sampling Macros",
"#else//ASE Sampling Macros",
"#endif//ASE Sampling Macros\n"
};*/
/*public readonly static string[] CustomASESamplingMacros =
{
"#define ASE_SAMPLE_TEXTURE2D(textureName,{0}coords) {1}2D{2}(textureName,{0}coords)",
"#define ASE_SAMPLE_TEXTURE2D_LOD(textureName, {0}coord2, lod) {1}2D{2}_LOD(textureName, {0}coord2, lod)",
"#define ASE_SAMPLE_TEXTURE2D_BIAS(textureName,{0}coord2, bias) {1}2D{2}_BIAS(textureName,{0}coord2, bias)",
"#define ASE_SAMPLE_TEXTURE2D_GRAD(textureName,{0}coord2, dpdx, dpdy) {1}2D{2}_GRAD(textureName,{0}coord2, dpdx, dpdy)",
"#define ASE_SAMPLE_TEXTURE3D(textureName,{0}coord3) {1}3D{2}(textureName,{0}coord3)",
"#define ASE_SAMPLE_TEXTURE3D_LOD(textureName,{0}coord3, lod) {1}3D{2}_LOD(textureName,{0}coord3, lod)",
"#define ASE_SAMPLE_TEXTURE3D_BIAS(textureName,{0}coord3, bias) {1}3D{2}_BIAS(textureName,{0}coord3, bias)",
"#define ASE_SAMPLE_TEXTURE3D_GRAD(textureName,{0}coord3, dpdx, dpdy) {1}3D{2}_GRAD(textureName,{0}coord3, dpdx, dpdy)",
"#define ASE_SAMPLE_TEXTURECUBE(textureName,{0}coord3) {1}CUBE{2}(textureName,{0}coord3)",
"#define ASE_SAMPLE_TEXTURECUBE_LOD(textureName,{0}coord3, lod) {1}CUBE{2}_LOD(textureName,{0}coord3, lod)",
"#define ASE_SAMPLE_TEXTURECUBE_BIAS(textureName,{0}coord3, bias) {1}CUBE{2}_BIAS(textureName,{0}coord3, bias)\n"
};*/
// SRP
/*public readonly static string[] CustomASESRPArgsMacros =
{
"#define ASE_TEXTURE2D_ARGS(textureName) TEXTURE2D(textureName), SAMPLER(textureName)",
"#define ASE_TEXTURE3D_ARGS(textureName) TEXTURE3D(textureName), SAMPLER(textureName)",
"#define ASE_TEXTURECUBE_ARGS(textureName) TEXTURECUBE(textureName), SAMPLER(textureName)",
"#define ASE_TEXTURE2D_PARAMS(textureName) textureName, sampler##textureName",
"#define ASE_TEXTURE3D_PARAMS(textureName) textureName, sampler##textureName",
"#define ASE_TEXTURECUBE_PARAMS(textureName) textureName, sampler##textureName",
"#define ASE_TEXTURE2D_ARRAY_PARAMS(textureName) textureName, sampler##textureName\n"
};*/
public readonly static List<string> UnityNativeInspectors = new List<string>
{
"Rendering.HighDefinition.LightingShaderGraphGUI",
"Rendering.HighDefinition.HDUnlitGUI",
"UnityEditor.Rendering.HighDefinition.HDLitGUI",
"UnityEditor.ShaderGraph.PBRMasterGUI",
"UnityEditor.Rendering.HighDefinition.DecalGUI",
"UnityEditor.Rendering.HighDefinition.FabricGUI",
"UnityEditor.Experimental.Rendering.HDPipeline.HDLitGUI",
"Rendering.HighDefinition.DecalGUI",
"Rendering.HighDefinition.LitShaderGraphGUI",
};
public readonly static Dictionary<string, string> CustomInspectorHD7To10 = new Dictionary<string, string>
{
{ "UnityEditor.Rendering.HighDefinition.DecalGUI","Rendering.HighDefinition.DecalGUI"},
{ "UnityEditor.Rendering.HighDefinition.FabricGUI","Rendering.HighDefinition.LightingShaderGraphGUI"},
{ "UnityEditor.Rendering.HighDefinition.HDLitGUI","Rendering.HighDefinition.LitShaderGraphGUI"},
{ "UnityEditor.Experimental.Rendering.HDPipeline.HDLitGUI","Rendering.HighDefinition.LitShaderGraphGUI"},
};
public readonly static string CustomASEStandardSamplerParams = "#define ASE_TEXTURE_PARAMS(textureName) textureName\n";
public readonly static string[] CustomASESRPTextureArrayMacros =
{
"#define ASE_TEXTURE2D_ARRAY_ARGS(textureName) TEXTURE2D_ARRAY_ARGS(textureName,sampler##textureName)\n" ,
"#define ASE_TEXTURE2D_ARRAY_PARAM(textureName) TEXTURE2D_ARRAY_PARAM(textureName,sampler##textureName)\n" ,
"#define ASE_SAMPLE_TEXTURE2D_ARRAY(textureName, coord3) textureName.Sample(sampler##textureName, coord3)",
"#define ASE_SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, coord3, lod) textureName.SampleLevel(sampler##textureName, coord3, lod)"
};
public readonly static string CustomASESRPSamplerParams = "#define ASE_TEXTURE_PARAMS(textureName) textureName, sampler##textureName\n";
public readonly static string[] CustomSRPSamplingMacros =
{
"#if defined(SHADER_API_D3D11) || defined(SHADER_API_XBOXONE) || defined(UNITY_COMPILER_HLSLCC) || defined(SHADER_API_PSSL) || (defined(SHADER_TARGET_SURFACE_ANALYSIS) && !defined(SHADER_TARGET_SURFACE_ANALYSIS_MOJOSHADER))//3D SRP MACROS",
"#define SAMPLE_TEXTURE3D_GRAD(textureName, samplerName, coord3, dpdx, dpdy) textureName.SampleGrad(samplerName, coord3, dpdx, dpdy)",
"#define SAMPLE_TEXTURE3D_BIAS(textureName, samplerName, coord3, bias) textureName.SampleBias(samplerName, coord3, bias)",
"#else//3D SRP MACROS",
"#define SAMPLE_TEXTURE3D_GRAD(textureName, samplerName, coord3, dpdx, dpdy) SAMPLE_TEXTURE3D(textureName, samplerName, coord3)",
"#define SAMPLE_TEXTURE3D_BIAS(textureName, samplerName, coord3, bias) SAMPLE_TEXTURE3D(textureName, samplerName, coord3)",
"#endif//3D SRP MACROS\n"
};
public readonly static Dictionary<TextureType, string> TexDeclarationSRPMacros = new Dictionary<TextureType, string>
{
{ TextureType.Texture2D,"TEXTURE2D({0}); SAMPLER(sampler{0});"},
{ TextureType.Texture3D,"TEXTURE3D({0}); SAMPLER(sampler{0});"},
{ TextureType.Cube,"TEXTURECUBE({0}); SAMPLER(sampler{0});"},
{ TextureType.Texture2DArray,"TEXTURE2D_ARRAY({0}); SAMPLER(sampler{0});"},
};
public readonly static Dictionary<TextureType, string> SamplerDeclarationSRPMacros = new Dictionary<TextureType, string>
{
{ TextureType.Texture2D,"SAMPLER(sampler{0});"},
{ TextureType.Texture3D,"SAMPLER(sampler{0});"},
{ TextureType.Cube,"SAMPLER(sampler{0});"},
{ TextureType.Texture2DArray,"SAMPLER(sampler{0});"},
};
public readonly static Dictionary<TextureType, string> TexDeclarationNoSamplerSRPMacros = new Dictionary<TextureType, string>
{
{ TextureType.Texture2D,"TEXTURE2D({0})"},
{ TextureType.Texture3D,"TEXTURE3D({0})"},
{ TextureType.Cube,"TEXTURECUBE({0})"},
{ TextureType.Texture2DArray,"TEXTURE2D_ARRAY({0})"},
};
public readonly static Dictionary<TextureType, string> TexSampleSRPMacros = new Dictionary<TextureType, string>
{
{ TextureType.Texture2D,"SAMPLE_TEXTURE2D{0}( {1}, {2}, {3} )"},
{ TextureType.Texture3D,"SAMPLE_TEXTURE3D{0}( {1}, {2}, {3} )"},
{ TextureType.Cube,"SAMPLE_TEXTURECUBE{0}( {1}, {2}, {3} )"},
{ TextureType.Texture2DArray,"SAMPLE_TEXTURE2D_ARRAY{0}( {1}, {2}, {3} )"},
};
public readonly static Dictionary<TextureType, string> TexParams = new Dictionary<TextureType, string>
{
{ TextureType.Texture2D,"ASE_TEXTURE2D_PARAMS({0})"},
{ TextureType.Texture3D,"ASE_TEXTURE3D_PARAMS({0})"},
{ TextureType.Cube,"ASE_TEXTURECUBE_PARAMS({0})"},
{ TextureType.Texture2DArray,"ASE_TEXTURE2D_ARRAY_PARAMS({0})"},
};
public readonly static Dictionary<WirePortDataType, TextureType> WireToTexture = new Dictionary<WirePortDataType, TextureType>
{
{ WirePortDataType.SAMPLER1D,TextureType.Texture1D},
{ WirePortDataType.SAMPLER2D,TextureType.Texture2D},
{ WirePortDataType.SAMPLER3D,TextureType.Texture3D},
{ WirePortDataType.SAMPLERCUBE,TextureType.Cube},
{ WirePortDataType.SAMPLER2DARRAY,TextureType.Texture2DArray},
};
public readonly static Dictionary<TextureType, WirePortDataType> TextureToWire = new Dictionary<TextureType, WirePortDataType>
{
{ TextureType.Texture1D,WirePortDataType.SAMPLER1D},
{ TextureType.Texture2D,WirePortDataType.SAMPLER2D},
{ TextureType.Texture3D, WirePortDataType.SAMPLER3D},
{ TextureType.Cube,WirePortDataType.SAMPLERCUBE},
{ TextureType.Texture2DArray,WirePortDataType.SAMPLER2DARRAY},
{ TextureType.ProceduralTexture,WirePortDataType.SAMPLER2D},
};
public readonly static string SamplingMacrosDirective = "#define ASE_USING_SAMPLING_MACROS 1";
// STANDARD
public readonly static string[] CustomASEStandarSamplingMacrosHelper =
{
#if UNITY_2018_1_OR_NEWER
"#if defined(SHADER_API_D3D11) || defined(SHADER_API_XBOXONE) || defined(UNITY_COMPILER_HLSLCC) || defined(SHADER_API_PSSL) || (defined(SHADER_TARGET_SURFACE_ANALYSIS) && !defined(SHADER_TARGET_SURFACE_ANALYSIS_MOJOSHADER))//ASE Sampler Macros",
#else
"#if defined(SHADER_API_D3D11) || defined(SHADER_API_XBOXONE) || defined(UNITY_COMPILER_HLSLCC) || defined(SHADER_API_PSSL)//ASE Sampler Macros",
#endif
"#else//ASE Sampling Macros",
"#endif//ASE Sampling Macros\n"
};
public readonly static string[] CustomASEArraySamplingMacrosRecent =
{
"#define UNITY_SAMPLE_TEX2DARRAY(tex,coord) tex.Sample(sampler##tex,coord)",
"#define UNITY_SAMPLE_TEX2DARRAY_LOD(tex,coord,lod) tex.SampleLevel(sampler##tex,coord, lod)",
"#define UNITY_SAMPLE_TEX2DARRAY_BIAS(tex,coord,bias) tex.SampleBias(sampler##tex,coord,bias)",
"#define UNITY_SAMPLE_TEX2DARRAY_GRAD(tex,coord,ddx,ddy) tex.SampleGrad(sampler##tex,coord,ddx,ddy)",
};
public readonly static string[] CustomASEArraySamplingMacrosOlder =
{
"#define UNITY_SAMPLE_TEX2DARRAY(tex,coord) tex2DArray(tex,coord)",
"#define UNITY_SAMPLE_TEX2DARRAY_LOD(tex,coord,lod) tex2DArraylod(tex, float4(coord,lod))",
"#define UNITY_SAMPLE_TEX2DARRAY_BIAS(tex,coord,bias) tex2DArray(tex,coord)",
"#define UNITY_SAMPLE_TEX2DARRAY_GRAD(tex,coord,ddx,ddy) tex2DArray(tex,coord)",
};
public readonly static string[] CustomASEStandarSamplingMacrosRecent =
{
"#define SAMPLE_TEXTURE2D(tex,samplerTex,coord) tex.Sample(samplerTex,coord)",
"#define SAMPLE_TEXTURE2D_LOD(tex,samplerTex,coord,lod) tex.SampleLevel(samplerTex,coord, lod)",
"#define SAMPLE_TEXTURE2D_BIAS(tex,samplerTex,coord,bias) tex.SampleBias(samplerTex,coord,bias)",
"#define SAMPLE_TEXTURE2D_GRAD(tex,samplerTex,coord,ddx,ddy) tex.SampleGrad(samplerTex,coord,ddx,ddy)",
"#define SAMPLE_TEXTURE3D(tex,samplerTex,coord) tex.Sample(samplerTex,coord)",
"#define SAMPLE_TEXTURE3D_LOD(tex,samplerTex,coord,lod) tex.SampleLevel(samplerTex,coord, lod)",
"#define SAMPLE_TEXTURE3D_BIAS(tex,samplerTex,coord,bias) tex.SampleBias(samplerTex,coord,bias)",
"#define SAMPLE_TEXTURE3D_GRAD(tex,samplerTex,coord,ddx,ddy) tex.SampleGrad(samplerTex,coord,ddx,ddy)",
"#define SAMPLE_TEXTURECUBE(tex,samplerTex,coord) tex.Sample(samplerTex,coord)",
"#define SAMPLE_TEXTURECUBE_LOD(tex,samplerTex,coord,lod) tex.SampleLevel(samplerTex,coord, lod)",
"#define SAMPLE_TEXTURECUBE_BIAS(tex,samplerTex,coord,bias) tex.SampleBias(samplerTex,coord,bias)",
"#define SAMPLE_TEXTURECUBE_GRAD(tex,samplerTex,coord,ddx,ddy) tex.SampleGrad(samplerTex,coord,ddx,ddy)",
"#define SAMPLE_TEXTURE2D_ARRAY(tex,samplerTex,coord) tex.Sample(samplerTex,coord)",
"#define SAMPLE_TEXTURE2D_ARRAY_LOD(tex,samplerTex,coord,lod) tex.SampleLevel(samplerTex,coord, lod)",
"#define SAMPLE_TEXTURE2D_ARRAY_BIAS(tex,samplerTex,coord,bias) tex.SampleBias(samplerTex,coord,bias)",
"#define SAMPLE_TEXTURE2D_ARRAY_GRAD(tex,samplerTex,coord,ddx,ddy) tex.SampleGrad(samplerTex,coord,ddx,ddy)",
};
public readonly static string[] CustomASEStandarSamplingMacrosOlder =
{
"#define SAMPLE_TEXTURE2D(tex,samplerTex,coord) tex2D(tex,coord)",
"#define SAMPLE_TEXTURE2D_LOD(tex,samplerTex,coord,lod) tex2Dlod(tex,float4(coord,0,lod))",
"#define SAMPLE_TEXTURE2D_BIAS(tex,samplerTex,coord,bias) tex2Dbias(tex,float4(coord,0,bias))",
"#define SAMPLE_TEXTURE2D_GRAD(tex,samplerTex,coord,ddx,ddy) tex2Dgrad(tex,coord,ddx,ddy)",
"#define SAMPLE_TEXTURE3D(tex,samplerTex,coord) tex3D(tex,coord)",
"#define SAMPLE_TEXTURE3D_LOD(tex,samplerTex,coord,lod) tex3Dlod(tex,float4(coord,lod))",
"#define SAMPLE_TEXTURE3D_BIAS(tex,samplerTex,coord,bias) tex3D(tex,coord)",
"#define SAMPLE_TEXTURE3D_GRAD(tex,samplerTex,coord,ddx,ddy) tex3D(tex,coord)",
"#define SAMPLE_TEXTURECUBE(tex,samplertex,coord) texCUBE(tex,coord)",
"#define SAMPLE_TEXTURECUBE_LOD(tex,samplertex,coord,lod) texCUBElod (tex,half4(coord,lod))",
"#define SAMPLE_TEXTURECUBE_BIAS(tex,samplertex,coord,bias) texCUBE(tex,coord)",
"#define SAMPLE_TEXTURECUBE_GRAD(tex,samplertex,coord,ddx,ddy) texCUBE(tex,coord)",
"#define SAMPLE_TEXTURE2D_ARRAY(tex,samplertex,coord) tex2DArray(tex,coord)",
"#define SAMPLE_TEXTURE2D_ARRAY_LOD(tex,samplertex,coord,lod) tex2DArraylod(tex, float4(coord,lod))",
"#define SAMPLE_TEXTURE2D_ARRAY_BIAS(tex,samplerTex,coord,bias) tex2DArray(tex,coord)",
"#define SAMPLE_TEXTURE2D_ARRAY_GRAD(tex,samplerTex,coord,ddx,ddy) tex2DArray(tex,coord)",
};
public readonly static string[] CustomArraySamplingMacros =
{
"#if defined(UNITY_COMPILER_HLSL2GLSL) || defined(SHADER_TARGET_SURFACE_ANALYSIS)//ASE Array Sampler Macros",
"#define ASE_SAMPLE_TEX2DARRAY_GRAD(tex,coord,dx,dy) UNITY_SAMPLE_TEX2DARRAY (tex,coord)",
"#else//ASE Array Sampler Macros",
"#define ASE_SAMPLE_TEX2DARRAY_GRAD(tex,coord,dx,dy) tex.SampleGrad (sampler##tex,coord,dx,dy)",
"#endif//ASE Array Sampler Macros\n"
};
public readonly static Dictionary<TextureType, string> TexDeclarationStandardMacros = new Dictionary<TextureType, string>
{
{ TextureType.Texture2D,"UNITY_DECLARE_TEX2D({0});"},
{ TextureType.Texture3D,"UNITY_DECLARE_TEX3D({0});"},
{ TextureType.Cube,"UNITY_DECLARE_TEXCUBE({0});"},
{ TextureType.Texture2DArray,"UNITY_DECLARE_TEX2DARRAY({0});"}
};
public readonly static Dictionary<TextureType, string> TexDeclarationNoSamplerStandardMacros = new Dictionary<TextureType, string>
{
{ TextureType.Texture2D,"UNITY_DECLARE_TEX2D_NOSAMPLER({0})"},
{ TextureType.Texture3D,"UNITY_DECLARE_TEX3D_NOSAMPLER({0})"},
{ TextureType.Cube,"UNITY_DECLARE_TEXCUBE_NOSAMPLER({0})"},
{ TextureType.Texture2DArray,"UNITY_DECLARE_TEX2DARRAY_NOSAMPLER({0})"}
};
public readonly static Dictionary<TextureType, string> TexSampleStandardMacros = new Dictionary<TextureType, string>
{
{ TextureType.Texture2D,"UNITY_SAMPLE_TEX2D{0}( {1}, {3} )"},
{ TextureType.Texture3D,"UNITY_SAMPLE_TEX3D{0}( {1}, {3} )"},
{ TextureType.Cube,"UNITY_SAMPLE_TEXCUBE{0}( {1}, {3} )"},
{ TextureType.Texture2DArray,"UNITY_SAMPLE_TEX2DARRAY{0}( {1}, {3} )"}
};
public readonly static Dictionary<TextureType, string> TexSampleSamplerStandardMacros = new Dictionary<TextureType, string>
{
{ TextureType.Texture2D,"SAMPLE_TEXTURE2D{0}( {1}, {2}, {3} )"},
{ TextureType.Texture3D,"SAMPLE_TEXTURE3D{0}( {1}, {2}, {3} )"},
{ TextureType.Cube,"SAMPLE_TEXTURECUBE{0}( {1}, {2}, {3} )"},
{ TextureType.Texture2DArray,"SAMPLE_TEXTURE2D_ARRAY{0}( {1}, {2}, {3} )"}
};
public readonly static Dictionary<TextureType, string> TexSampleStandard = new Dictionary<TextureType, string>
{
{ TextureType.Texture2D,"tex2D{0}( {1}, {2} )"},
{ TextureType.Texture3D,"tex3D{0}( {1}, {2} )"},
{ TextureType.Cube,"texCUBE{0}( {1}, {2} )"},
{ TextureType.Texture2DArray,"tex2DArray{0}( {1}, {2} )"}
};
public readonly static char LineFeedSeparator = '$';
public readonly static char SemiColonSeparator = '@';
public readonly static string AppDataFullName = "appdata_full";
public readonly static string CustomAppDataFullName = "appdata_full_custom";
public readonly static string CustomAppDataFullBody =
"\n\t\tstruct appdata_full_custom\n" +
"\t\t{\n" +
"\t\t\tfloat4 vertex : POSITION;\n" +
"\t\t\tfloat4 tangent : TANGENT;\n" +
"\t\t\tfloat3 normal : NORMAL;\n" +
"\t\t\tfloat4 texcoord : TEXCOORD0;\n" +
"\t\t\tfloat4 texcoord1 : TEXCOORD1;\n" +
"\t\t\tfloat4 texcoord2 : TEXCOORD2;\n" +
"\t\t\tfloat4 texcoord3 : TEXCOORD3;\n" +
"\t\t\tfixed4 color : COLOR;\n" +
"\t\t\tUNITY_VERTEX_INPUT_INSTANCE_ID\n";
public readonly static string IncludeFormat = "#include \"{0}\"";
public readonly static string PragmaFormat = "#pragma {0}";
public readonly static string DefineFormat = "#define {0}";
public readonly static string RenderTypeHelperStr = "RenderType";
public readonly static string RenderQueueHelperStr = "Queue";
public readonly static string DisableBatchingHelperStr = "DisableBatching";
public readonly static string DefaultShaderName = "New Amplify Shader";
public readonly static string UndoReplaceMasterNodeId = "Replacing Master Node";
public readonly static string UnityLightingLib = "Lighting.cginc";
public readonly static string UnityAutoLightLib = "AutoLight.cginc";
public readonly static string UnityBRDFLib = "UnityStandardBRDF.cginc";
public readonly static string LocalValueDecWithoutIdent = "{0} {1} = {2};";
public readonly static string CustomTypeLocalValueDecWithoutIdent = "{0} {1} =({0}){2};";
public readonly static string LocalValueDefWithoutIdent = "{0} {1} {2};";
public readonly static string TilingOffsetFormat = "{0} * {1} + {2}";
public static string InvalidPostProcessDatapath = "__DELETED_GUID_Trash";
//TEMPLATES
public static float PlusMinusButtonLayoutWidth = 15;
public static float NodeButtonSizeX = 16;
public static float NodeButtonSizeY = 16;
public static float NodeButtonDeltaX = 5;
public static float NodeButtonDeltaY = 11;
public readonly static string SafeNormalizeInfoStr = "With Safe Normalize division by 0 is prevented over the normalize operation at the expense of additional instructions on shader.";
public readonly static string ReservedPropertyNameStr = "Property name '{0}' is reserved and cannot be used";
public readonly static string NumericPropertyNameStr = "Property name '{0}' is numeric thus cannot be used";
public readonly static string DeprecatedMessageStr = "Node '{0}' is deprecated. Use node '{1}' instead.";
public readonly static string DeprecatedNoAlternativeMessageStr = "Node '{0}' is deprecated and should be removed.";
public readonly static string UndoChangePropertyTypeNodesId = "Changing Property Types";
public readonly static string UndoChangeTypeNodesId = "Changing Nodes Types";
public readonly static string UndoMoveNodesId = "Moving Nodes";
public readonly static string UndoRegisterFullGrapId = "Register Graph";
public readonly static string UndoAddNodeToCommentaryId = "Add node to Commentary";
public readonly static string UndoRemoveNodeFromCommentaryId = "Remove node from Commentary";
public readonly static string UndoCreateDynamicPortId = "Create Dynamic Port";
public readonly static string UndoDeleteDynamicPortId = "Destroy Dynamic Port";
public readonly static string UndoRegisterNodeId = "Register Object";
public readonly static string UndoUnregisterNodeId = "Unregister Object";
public readonly static string UndoCreateNodeId = "Create Object";
public readonly static string UndoPasteNodeId = "Paste Object";
public readonly static string UndoDeleteNodeId = "Destroy Object";
public readonly static string UndoDeleteConnectionId = "Destroy Connection";
public readonly static string UndoCreateConnectionId = "Create Connection";
public readonly static float MenuDragSpeed = -0.5f;
public readonly static string DefaultCustomInspector = "ASEMaterialInspector";
public readonly static string ReferenceTypeStr = "Mode";
public readonly static string AvailableReferenceStr = "Reference";
public readonly static string InstancePostfixStr = " (Reference) ";
public readonly static string ASEMenuName = "Amplify Shader";
public readonly static string LodCrossFadeOption2017 = "dithercrossfade";
public readonly static string UnityShaderVariables = "UnityShaderVariables.cginc";
public readonly static string UnityCgLibFuncs = "UnityCG.cginc";
public readonly static string UnityStandardUtilsLibFuncs = "UnityStandardUtils.cginc";
public readonly static string UnityPBSLightingLib = "UnityPBSLighting.cginc";
public readonly static string UnityDeferredLightLib = "UnityDeferredLibrary.cginc";
public readonly static string ATSharedLibGUID = "ba242738c4be3324aa88d126f7cc19f9";
#if UNITY_5_6_OR_NEWER
public readonly static string CameraDepthTextureValue = "UNITY_DECLARE_DEPTH_TEXTURE( _CameraDepthTexture );";
#else
public readonly static string CameraDepthTextureValue = "uniform sampler2D _CameraDepthTexture;";
#endif
//public readonly static string CameraDepthTextureSRPVar = "TEXTURE2D(_CameraDepthTexture);";
//public readonly static string CameraDepthTextureSRPSampler = "SAMPLER(sampler_CameraDepthTexture);";
public readonly static string CameraDepthTextureLWEnabler = "REQUIRE_DEPTH_TEXTURE 1";
public readonly static string CameraDepthTextureTexelSize = "uniform float4 _CameraDepthTexture_TexelSize;";
public readonly static string InstanceIdMacro = "UNITY_VERTEX_INPUT_INSTANCE_ID";
public readonly static string InstanceIdVariable = "UNITY_GET_INSTANCE_ID({0})";
public readonly static string HelpURL = "http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor";
//public readonly static string NodeCommonUrl = "http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/Nodes#";
//public readonly static string CommunityNodeCommonUrl = "http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/Community_Nodes#";
public readonly static string NodeCommonUrl = "http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/";
public readonly static string CommunityNodeCommonUrl = "http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/";
public readonly static Color InfiniteLoopColor = Color.red;
public readonly static Color DefaultCategoryColor = new Color( 0.26f, 0.35f, 0.44f, 1.0f );
public readonly static Color NodeBodyColor = new Color( 1f, 1f, 1f, 1.0f );
public readonly static Color ModeTextColor = new Color( 1f, 1f, 1f, 0.25f );
public readonly static Color ModeIconColor = new Color( 1f, 1f, 1f, 0.75f );
public readonly static Color PortTextColor = new Color( 1f, 1f, 1f, 0.5f );
public readonly static Color PortLockedTextColor = new Color( 1f, 1f, 1f, 0.35f );
public readonly static Color BoxSelectionColor = new Color( 0.5f, 0.75f, 1f, 0.33f );
public readonly static Color SpecialRegisterLocalVarSelectionColor = new Color( 0.27f, 0.52f, 1.0f, 1f );
public readonly static Color SpecialGetLocalVarSelectionColor = new Color( 0.2f, 0.8f, 0.4f, 1f );
public readonly static Color NodeSelectedColor = new Color( 0.85f, 0.56f, 0f, 1f );
public readonly static Color NodeDefaultColor = new Color( 1f, 1f, 1f, 1f );
public readonly static Color NodeConnectedColor = new Color( 1.0f, 1f, 0.0f, 1f );
public readonly static Color NodeErrorColor = new Color( 1f, 0.5f, 0.5f, 1f );
public readonly static string NoSpecifiedCategoryStr = "<None>";
public readonly static int MINIMIZE_WINDOW_LOCK_SIZE = 630;
public readonly static int FoldoutMouseId = 0; // Left Mouse Button
public readonly static float SNAP_SQR_DIST = 200f;
public readonly static int INVALID_NODE_ID = -1;
public readonly static float WIRE_WIDTH = 7f;
public readonly static float WIRE_CONTROL_POINT_DIST = 0.7f;
public readonly static float WIRE_CONTROL_POINT_DIST_INV = 1.7f;
public readonly static float IconsLeftRightMargin = 5f;
public readonly static float PropertyPickerWidth = 16f;
public readonly static float PropertyPickerHeight = 16f;
public readonly static float PreviewExpanderWidth = 16f;
public readonly static float PreviewExpanderHeight = 16f;
public readonly static float TextFieldFontSize = 11f;
public readonly static float DefaultFontSize = 15f;
public readonly static float DefaultTitleFontSize = 13f;
public readonly static float PropertiesTitleFontSize = 11f;
public readonly static float MessageFontSize = 40f;
public readonly static float SelectedObjectFontSize = 30f;
public readonly static float PORT_X_ADJUST = 10;
public readonly static float PORT_INITIAL_X = 10;
public readonly static float PORT_INITIAL_Y = 40;
public readonly static float INPUT_PORT_DELTA_Y = 5;
public readonly static float PORT_TO_LABEL_SPACE_X = 5;
public readonly static float NODE_HEADER_HEIGHT = 32;
public readonly static float NODE_HEADER_EXTRA_HEIGHT = 5;
public readonly static float NODE_HEADER_LEFTRIGHT_MARGIN = 10;
public readonly static float MULTIPLE_SELECION_BOX_ALPHA = 0.5f;
public readonly static float RMB_CLICK_DELTA_TIME = 0.1f;
public readonly static float RMB_SCREEN_DIST = 10f;
public readonly static float CAMERA_MAX_ZOOM = 2f;
public readonly static float CAMERA_MIN_ZOOM = 1f;
public readonly static float CAMERA_ZOOM_SPEED = 0.1f;
public readonly static float ALT_CAMERA_ZOOM_SPEED = -0.05f;
public readonly static object INVALID_VALUE = null;
public readonly static float HORIZONTAL_TANGENT_SIZE = 100f;
public readonly static float OUTSIDE_WIRE_MARGIN = 5f;
public readonly static string SubTitleNameFormatStr = "Name( {0} )";
public readonly static string SubTitleSpaceFormatStr = "Space( {0} )";
public readonly static string SubTitleTypeFormatStr = "Type( {0} )";
public readonly static string SubTitleValueFormatStr = "Value( {0} )";
public readonly static string SubTitleConstFormatStr = "Const( {0} )";
public readonly static string SubTitleVarNameFormatStr = "Var( {0} )";
public readonly static string SubTitleRefNameFormatStr = "Ref( {0} )";
public readonly static string CodeWrapper = "( {0} )";
public readonly static string InlineCodeWrapper = "{{\n{0}\n}}";
public readonly static string NodesDumpFormat = "{0}:,{1},{2}\n";
public readonly static string TagFormat = " \"{0}\" = \"{1}\"";
public readonly static string LocalVarIdentation = "\t\t\t";
public readonly static string SimpleLocalValueDec = LocalVarIdentation + "{0} {1};\n";
public readonly static string LocalValueDec = LocalVarIdentation + LocalValueDecWithoutIdent + '\n';
public readonly static string LocalValueDef = LocalVarIdentation + "{0} = {1};\n";
public readonly static string CastHelper = "({0}).{1}";
public readonly static string PropertyLocalVarDec = "{0} {1} = {0}({2});";
public readonly static string[] UniformDec = { "uniform {0} {1};", "{0} {1};" };
public readonly static string PropertyValueLabel = "Value( {0} )";
public readonly static string ConstantsValueLabel = "Const( {0} )";
public readonly static string PropertyFloatFormatLabel = "0.###";
public readonly static string PropertyBigFloatFormatLabel = "0.###e+0";
public readonly static string PropertyIntFormatLabel = "0";
public readonly static string PropertyBigIntFormatLabel = "0e+0";
public readonly static string PropertyVectorFormatLabel = "0.##";
public readonly static string PropertyBigVectorFormatLabel = "0.##e+0";
public readonly static string PropertyMatrixFormatLabel = "0.#";
public readonly static string PropertyBigMatrixFormatLabel = "0.#e+0";
public readonly static string NoPropertiesLabel = "No assigned properties";
public readonly static string ValueLabel = "Value";
public readonly static string DefaultValueLabel = "Default Value";
public readonly static string MaterialValueLabel = "Material Value";
public readonly static GUIContent DefaultValueLabelContent = new GUIContent( "Default Value" );
public readonly static GUIContent MaterialValueLabelContent = new GUIContent( "Material Value" );
public readonly static string InputVarStr = "i";//"input";
public readonly static string OutputVarStr = "o";//"output";
public readonly static string CustomLightOutputVarStr = "s";
public readonly static string CustomLightStructStr = "Custom";
public readonly static string VertexShaderOutputStr = "o";
public readonly static string VertexShaderInputStr = "v";//"vertexData";
public readonly static string VertexDataFunc = "vertexDataFunc";
public readonly static string VirtualCoordNameStr = "vcoord";
public readonly static string VertexVecNameStr = "vertexVec";
public readonly static string VertexVecDecStr = "float3 " + VertexVecNameStr;
public readonly static string VertexVecVertStr = VertexShaderOutputStr + "." + VertexVecNameStr;
public readonly static string NormalVecNameStr = "normalVec";
public readonly static string NormalVecDecStr = "float3 " + NormalVecNameStr;
public readonly static string NormalVecFragStr = InputVarStr + "." + NormalVecNameStr;
public readonly static string NormalVecVertStr = VertexShaderOutputStr + "." + NormalVecNameStr;
public readonly static string IncidentVecNameStr = "incidentVec";
public readonly static string IncidentVecDecStr = "float3 " + IncidentVecNameStr;
public readonly static string IncidentVecDefStr = VertexShaderOutputStr + "." + IncidentVecNameStr + " = normalize( " + VertexVecNameStr + " - _WorldSpaceCameraPos.xyz)";
public readonly static string IncidentVecFragStr = InputVarStr + "." + IncidentVecNameStr;
public readonly static string IncidentVecVertStr = VertexShaderOutputStr + "." + IncidentVecNameStr;
public readonly static string WorldNormalLocalDecStr = "WorldNormalVector( " + Constants.InputVarStr + " , {0}( 0,0,1 ))";
public readonly static string VFaceVariable = "ASEVFace";
public readonly static string VFaceInput = "half ASEVFace : VFACE";
public readonly static string ColorVariable = "vertexColor";
public readonly static string ColorInput = "float4 vertexColor : COLOR";
public readonly static string NoStringValue = "None";
public readonly static string EmptyPortValue = " ";
public readonly static string[] OverallInvalidChars = { "\r", "\n", "\\", " ", ".", ">", ",", "<", "\'", "\"", ";", ":", "[", "{", "]", "}", "=", "+", "`", "~", "/", "?", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "-" };
public readonly static string[] ShaderInvalidChars = { "\r", "\n", "\\", "\'", "\"", };
public readonly static string[] EnumInvalidChars = { "\r", "\n", "\\", ".", ">", ",", "<", "\'", "\"", ";", ":", "[", "{", "]", "}", "=", "+", "`", "~", "/", "?", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "-" };
public readonly static string[] AttrInvalidChars = { "\r", "\n", "\\", ">", "<", "\'", "\"", ";", ":", "[", "{", "]", "}", "=", "+", "`", "~", "/", "?", "!", "@", "#", "$", "%", "^", "&", "*" };
public readonly static string[] HeaderInvalidChars = { "\r", "\n", "\\", ">", ",", "<", "\'", "\"", ";", ":", "[", "{", "]", "}", "=", "+", "`", "~", "/", "?", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "-" };
public readonly static string[] WikiInvalidChars = { "#", "<", ">", "[", "]", "|", "{", "}", "%", "+", "?", "\\", "/", ",", ";", "." };
public readonly static string[,] UrlReplacementStringValues =
{
{ " = ", "Equals" },
{ " == ", "Equals" },
{ " != ", "NotEqual" },
{ " \u2260 ", "NotEqual" },
{ " > ", "Greater" },
{ " \u2265 " , "GreaterOrEqual" },
{ " >= ", "GreaterOrEqual" },
{ " < ", "Less" },
{ " \u2264 ", "LessOrEqual" },
{ " <= ", "LessOrEqual" },
{ " ", "_" },
{ "[", string.Empty },
{ "]", string.Empty }
};
public readonly static int UrlReplacementStringValuesLen = UrlReplacementStringValues.Length / 2;
public readonly static string[,] ReplacementStringValues =
{
{ " = ", "Equals" },
{ " == ", "Equals" },
{ " != ", "NotEqual" },
{ " \u2260 ", "NotEqual" },
{ " > ", "Greater" },
{ " \u2265 ", "GreaterOrEqual" },
{ " >= ", "GreaterOrEqual" },
{ " < ", "Less" },
{ " \u2264 ", "LessOrEqual" },
{ " <= ", "LessOrEqual" }
};
public readonly static int ReplacementStringValuesLen = ReplacementStringValues.Length / 2;
public readonly static string InternalData = "INTERNAL_DATA";
public readonly static string NoMaterialStr = "None";
public readonly static string OptionalParametersSep = " ";
public readonly static string NodeUndoId = "NODE_UNDO_ID";
public readonly static string NodeCreateUndoId = "NODE_CREATE_UNDO_ID";
public readonly static string NodeDestroyUndoId = "NODE_DESTROY_UNDO_ID";
// Custom node tags
//[InPortBegin:Id:Type:Name:InPortEnd]
public readonly static string CNIP = "#IP";
public readonly static float FLOAT_DRAW_HEIGHT_FIELD_SIZE = 16f;
public readonly static float FLOAT_DRAW_WIDTH_FIELD_SIZE = 45f;
public readonly static float FLOAT_WIDTH_SPACING = 3f;
public readonly static Color LockedPortColor = new Color( 0.3f, 0.3f, 0.3f, 0.5f );
#if UNITY_2018_2_OR_NEWER
public readonly static int[] AvailableUVChannels = { 0, 1, 2, 3, 4, 5, 6, 7 };
public readonly static string[] AvailableUVChannelsStr = { "0", "1", "2", "3", "4", "5", "6", "7"};
public readonly static string AvailableUVChannelLabel = "UV Channel";
public readonly static int[] AvailableUVSets = { 0, 1, 2, 3, 4, 5, 6, 7 };
public readonly static string[] AvailableUVSetsStr = { "1", "2", "3", "4","5", "6", "7", "8" };
public readonly static string AvailableUVSetsLabel = "UV Set";
#else
public readonly static int[] AvailableUVChannels = { 0, 1, 2, 3 };
public readonly static string[] AvailableUVChannelsStr = { "0", "1", "2", "3" };
public readonly static string AvailableUVChannelLabel = "UV Channel";
public readonly static int[] AvailableUVSets = { 0, 1, 2, 3 };
public readonly static string[] AvailableUVSetsStr = { "1", "2", "3", "4" };
public readonly static string AvailableUVSetsLabel = "UV Set";
#endif
public readonly static int[] AvailableUVSizes = { 2, 3, 4 };
public readonly static string[] AvailableUVSizesStr = { "Float 2", "Float 3", "Float 4" };
public readonly static string AvailableUVSizesLabel = "Coord Size";
public readonly static string LineSeparator = "________________________________";
public readonly static Vector2 CopyPasteDeltaPos = new Vector2( 40, 40 );
public readonly static string[] VectorSuffixes = { ".x", ".y", ".z", ".w" };
public readonly static string[] ColorSuffixes = { ".r", ".g", ".b", ".a" };
public const string InternalDataLabelStr = "Internal Data";
public const string AttributesLaberStr = "Attributes";
public const string ParameterLabelStr = "Parameters";
public static readonly string[] ReferenceArrayLabels = { "Object", "Reference" };
public static readonly string[] ChannelNamesVector = { "X", "Y", "Z", "W" };
public static readonly string[] ChannelNamesColor = { "R", "G", "B", "A" };
public static readonly string SamplerFormat = "sampler{0}";
public static readonly string SamplerDeclFormat = "SamplerState {0}";
public static readonly string SamplerDeclSRPFormat = "SAMPLER({0})";
}
}

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

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 2206c4bd7f3d18643a6a3452b0c070d1
folderAsset: yes
timeCreated: 1522769470
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,32 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using UnityEditor;
using System;
using AmplifyShaderEditor;
public class ASEBeginDecorator : MaterialPropertyDrawer
{
const int Separator = 2;
public override void OnGUI( Rect position, MaterialProperty prop, String label, MaterialEditor editor )
{
Rect button = position;
button.height = EditorGUIUtility.singleLineHeight;
if( GUI.Button( button, "Open in Shader Editor" ) )
{
Material mat = editor.target as Material;
#if UNITY_2018_3_OR_NEWER
ASEPackageManagerHelper.SetupLateMaterial( mat );
#else
AmplifyShaderEditorWindow.LoadMaterialToASE( mat );
#endif
}
}
public override float GetPropertyHeight( MaterialProperty prop, string label, MaterialEditor editor )
{
return EditorGUIUtility.singleLineHeight + Separator;
}
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 508788a7fa76e1d42ad5fdfb1c941ed2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,36 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using UnityEditor;
using System;
using AmplifyShaderEditor;
public class ASEEndDecorator : MaterialPropertyDrawer
{
bool m_applyNext = false;
public override void OnGUI( Rect position, MaterialProperty prop, String label, MaterialEditor editor )
{
if( prop.applyPropertyCallback == null )
prop.applyPropertyCallback = Testc;
if( GUI.changed || m_applyNext )
{
m_applyNext = false;
Material mat = editor.target as Material;
UIUtils.CopyValuesFromMaterial( mat );
}
}
bool Testc( MaterialProperty prop, int changeMask, object previousValue )
{
m_applyNext = true;
return false;
}
public override float GetPropertyHeight( MaterialProperty prop, string label, MaterialEditor editor )
{
return 0;
}
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fdf2e52babbbbf040b3b9f6df50243f3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,294 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
//
// Donated by BinaryCats
// https://forum.unity.com/threads/best-tool-asset-store-award-amplify-shader-editor-node-based-shader-creation-tool.430959/page-60#post-3414465
//////////////////////
// README / HOW TO USE
//////////////////////
// Examples:
//
// Floats:
//
// x Equals value
// EditableIf( _float1, Equalto, 1)
// This will allow the value to be edited, if the property _float1 is equal to 1. (_float1==1)
// Note: NotEqualTo is also a valid argument which will do the opposite of this example.EditableIf(_float1, NotEqualTo, 1) (NotEqualTo != 1)
//
// x Greater than value
// EditableIf(_Float1,GreaterThan,1)
// This will allow the value to be edited if the property _float1 is Greater than 1. (_float1>1)
//
// x Greater Than Or Equal to value
// EditableIf(_Float1,GreaterThanOrEqualTo,1)
// This will allow the value to be edited if the property _float1 is Greater than or equal to 1. (_float1>=1)
//
//
// x Less Than value
// EditableIf(_Float1,LessThan,1)
// This will allow the value to be edited if the property _float1 is Less than 1. (_float1<1)
//
// x Less Than Or Equal to value
// EditableIf(_Float1,LessThanOrEqualTo,1)
// This will allow the value to be edited if the property _float1 is Less than or equal to 1. (_float1<=1)
//
//
// Colour:
//
// x Equals r,g,b,a
// EditableIf(_Color0,EqualTo,255,255,255,255)
// This will allow the value to be edited, if the property _Color0 R,G,B and A value all Equal 255. (_Color0.R==255 && _Color0.G==255 & _Color0.B == 255 && _Color0.A == 255)
//
// x Equals alpha
// EditableIf(_Color0,EqualTo,null,null,null,255)
// This will allow the value to be edited, if the property _Color0 Alpha value is Equal to 255. (_Color0.A == 255)
//
// a Greater than blue
// EditableIf(_Color0,GreaterThan,null,null,125)
// This will allow the value to be edited, if the property _Color0 Blue value is Greater Than 125. (_Color0.B > 125)
// Note: as I do not want to check the Red or Green Values, i have entered "null" for the parameter
// Note: I have not inputted a value to check for Alpha, as i do not want to check it. Simularly, if I wanted to Only check the Red Value I could have used EditableIf(_Color0,GreaterThan,125)
//
// Like wise with floats GreaterThanOrEqualTo, LessThan, LessThanOrEqualTo
//
// Vector:
// Vector Checks work the same as colour checks
//
// Texture:
// x Does Not have a Texture
// EditableIf(_TextureSample0,Equals,null)
// This will allow the value to be edited, if the property _TextureSample0 does NOT have a texture
//
// x Does have a Texture
// EditableIf(_TextureSample0,NotEqualTo,null)
// This will allow the value to be edited, if the property _TextureSample0 does have a texture
using UnityEngine;
using UnityEditor;
using System;
public enum ComparisonOperators
{
EqualTo, NotEqualTo, GreaterThan, LessThan, EqualsOrGreaterThan, EqualsOrLessThan, ContainsFlags,
DoesNotContainsFlags
}
public class EditableIf : MaterialPropertyDrawer
{
ComparisonOperators op;
string FieldName = "";
object ExpectedValue;
bool InputError;
public EditableIf()
{
InputError = true;
}
public EditableIf( object fieldname, object comparison, object expectedvalue )
{
if( expectedvalue.ToString().ToLower() == "true" )
{
expectedvalue = (System.Single)1;
}
else if( expectedvalue.ToString().ToLower() == "false" )
{
expectedvalue = (System.Single)0;
}
Init( fieldname, comparison, expectedvalue );
}
public EditableIf( object fieldname, object comparison, object expectedvaluex, object expectedvaluey )
{
float? x = expectedvaluex as float?;
float? y = expectedvaluey as float?;
float? z = float.NegativeInfinity;
float? w = float.NegativeInfinity;
x = GetVectorValue( x );
y = GetVectorValue( y );
Init( fieldname, comparison, new Vector4( x.Value, y.Value, z.Value, w.Value ) );
}
public EditableIf( object fieldname, object comparison, object expectedvaluex, object expectedvaluey, object expectedvaluez )
{
float? x = expectedvaluex as float?;
float? y = expectedvaluey as float?;
float? z = expectedvaluez as float?;
float? w = float.NegativeInfinity;
x = GetVectorValue( x );
y = GetVectorValue( y );
z = GetVectorValue( z );
Init( fieldname, comparison, new Vector4( x.Value, y.Value, z.Value, w.Value ) );
}
public EditableIf( object fieldname, object comparison, object expectedvaluex, object expectedvaluey, object expectedvaluez, object expectedvaluew )
{
var x = expectedvaluex as float?;
var y = expectedvaluey as float?;
var z = expectedvaluez as float?;
var w = expectedvaluew as float?;
x = GetVectorValue( x );
y = GetVectorValue( y );
z = GetVectorValue( z );
w = GetVectorValue( w );
Init( fieldname, comparison, new Vector4( x.Value, y.Value, z.Value, w.Value ) );
}
private void Init( object fieldname, object comparison, object expectedvalue )
{
FieldName = fieldname.ToString();
var names = Enum.GetNames( typeof( ComparisonOperators ) );
var name = comparison.ToString().ToLower().Replace( " ", "" );
for( int i = 0; i < names.Length; i++ )
{
if( names[ i ].ToLower() == name )
{
op = (ComparisonOperators)i;
break;
}
}
ExpectedValue = expectedvalue;
}
private static float? GetVectorValue( float? x )
{
if( x.HasValue == false )
{
x = float.NegativeInfinity;
}
return x;
}
// Draw the property inside the given rect
public override void OnGUI( Rect position, MaterialProperty prop, String label, MaterialEditor editor )
{
if( InputError )
{
EditorGUI.LabelField( position, "EditableIf Attribute Error: Input parameters are invalid!" );
return;
}
var LHSprop = MaterialEditor.GetMaterialProperty( prop.targets, FieldName );
if( string.IsNullOrEmpty( LHSprop.name ) )
{
LHSprop = MaterialEditor.GetMaterialProperty( prop.targets, "_" + FieldName.Replace( " ", "" ) );
if( string.IsNullOrEmpty( LHSprop.name ) )
{
EditorGUI.LabelField( position, "EditableIf Attribute Error: " + FieldName + " Does not exist!" );
return;
}
}
object LHSVal = null;
bool test = false;
switch( LHSprop.type )
{
case MaterialProperty.PropType.Color:
case MaterialProperty.PropType.Vector:
LHSVal = LHSprop.type == MaterialProperty.PropType.Color ? (Vector4)LHSprop.colorValue : LHSprop.vectorValue;
var v4 = ExpectedValue as Vector4?;
v4 = v4.HasValue ? v4 : new Vector4( (System.Single)ExpectedValue, float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity );
if( LHSprop.type == MaterialProperty.PropType.Color )
{
test = VectorCheck( (Vector4)LHSVal, op, v4 / 255 );
}
else
test = VectorCheck( (Vector4)LHSVal, op, v4 );
break;
case MaterialProperty.PropType.Range:
case MaterialProperty.PropType.Float:
LHSVal = LHSprop.floatValue;
test = ( Check( LHSVal, op, ExpectedValue ) );
break;
case MaterialProperty.PropType.Texture:
LHSVal = LHSprop.textureValue;
test = ( CheckObject( LHSVal, op, ExpectedValue ) );
break;
}
GUI.enabled = test;
editor.DefaultShaderProperty( position, prop, label );
GUI.enabled = true;
}
private bool VectorCheck( Vector4 LHS, ComparisonOperators op, object expectedValue )
{
var RHS = (Vector4)expectedValue;
if( RHS.x != float.NegativeInfinity )
{
if( !Check( LHS.x, op, RHS.x ) )
return false;
}
if( RHS.y != float.NegativeInfinity )
{
if( !Check( LHS.y, op, RHS.y ) )
return false;
}
if( RHS.z != float.NegativeInfinity )
{
if( !Check( LHS.z, op, RHS.z ) )
return false;
}
if( RHS.w != float.NegativeInfinity )
{
if( !Check( LHS.w, op, RHS.w ) )
return false;
}
return true;
}
protected bool Check( object LHS, ComparisonOperators op, object RHS )
{
if( !( LHS is IComparable ) || !( RHS is IComparable ) )
throw new Exception( "Check using non basic type" );
switch( op )
{
case ComparisonOperators.EqualTo:
return ( (IComparable)LHS ).CompareTo( RHS ) == 0;
case ComparisonOperators.NotEqualTo:
return ( (IComparable)LHS ).CompareTo( RHS ) != 0;
case ComparisonOperators.EqualsOrGreaterThan:
return ( (IComparable)LHS ).CompareTo( RHS ) >= 0;
case ComparisonOperators.EqualsOrLessThan:
return ( (IComparable)LHS ).CompareTo( RHS ) <= 0;
case ComparisonOperators.GreaterThan:
return ( (IComparable)LHS ).CompareTo( RHS ) > 0;
case ComparisonOperators.LessThan:
return ( (IComparable)LHS ).CompareTo( RHS ) < 0;
case ComparisonOperators.ContainsFlags:
return ( (int)LHS & (int)RHS ) != 0; // Dont trust LHS values, it has been casted to a char and then to an int again, first bit will be the sign
case ComparisonOperators.DoesNotContainsFlags:
return ( ( (int)LHS & (int)RHS ) == (int)LHS ); // Dont trust LHS values, it has been casted to a char and then to an int again, first bit will be the sign
default:
break;
}
return false;
}
private bool CheckObject( object LHS, ComparisonOperators comparasonOperator, object RHS )
{
switch( comparasonOperator )
{
case ComparisonOperators.EqualTo:
return ( LHS == null );
case ComparisonOperators.NotEqualTo:
return ( LHS != null );
}
return true;
}
}

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

@ -0,0 +1,25 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using UnityEditor;
using System;
public class NoKeywordToggle : MaterialPropertyDrawer
{
public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor editor) {
bool value = (prop.floatValue != 0.0f);
EditorGUI.BeginChangeCheck();
{
EditorGUI.showMixedValue = prop.hasMixedValue;
value = EditorGUI.Toggle( position, label, value );
EditorGUI.showMixedValue = false;
}
if (EditorGUI.EndChangeCheck())
{
prop.floatValue = value ? 1.0f : 0.0f;
}
}
}

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

@ -0,0 +1,36 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using UnityEditor;
using System;
public class RemapSliders : MaterialPropertyDrawer
{
public override void OnGUI( Rect position, MaterialProperty prop, String label, MaterialEditor editor )
{
EditorGUI.BeginChangeCheck();
Vector4 value = prop.vectorValue;
EditorGUI.showMixedValue = prop.hasMixedValue;
var cacheLabel = EditorGUIUtility.labelWidth;
var cacheField = EditorGUIUtility.fieldWidth;
if( cacheField <= 64 )
{
float total = position.width;
EditorGUIUtility.labelWidth = Mathf.Ceil( 0.45f * total ) - 30;
EditorGUIUtility.fieldWidth = Mathf.Ceil( 0.55f * total ) + 30;
}
EditorGUI.MinMaxSlider(position, label, ref value.x, ref value.y, 0, 1 );
EditorGUIUtility.labelWidth = cacheLabel;
EditorGUIUtility.fieldWidth = cacheField;
EditorGUI.showMixedValue = false;
if( EditorGUI.EndChangeCheck() )
{
prop.vectorValue = value;
}
}
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 314af1bcecbba6c4d92cbb5843c221ba
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,36 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using UnityEditor;
using System;
public class RemapSlidersFull : MaterialPropertyDrawer
{
public override void OnGUI( Rect position, MaterialProperty prop, String label, MaterialEditor editor )
{
EditorGUI.BeginChangeCheck();
Vector4 value = prop.vectorValue;
EditorGUI.showMixedValue = prop.hasMixedValue;
var cacheLabel = EditorGUIUtility.labelWidth;
var cacheField = EditorGUIUtility.fieldWidth;
if( cacheField <= 64 )
{
float total = position.width;
EditorGUIUtility.labelWidth = Mathf.Ceil( 0.45f * total ) - 30;
EditorGUIUtility.fieldWidth = Mathf.Ceil( 0.55f * total ) + 30;
}
EditorGUI.MinMaxSlider( position, label, ref value.x, ref value.y, value.z, value.w );
EditorGUIUtility.labelWidth = cacheLabel;
EditorGUIUtility.fieldWidth = cacheField;
EditorGUI.showMixedValue = false;
if( EditorGUI.EndChangeCheck() )
{
prop.vectorValue = value;
}
}
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9a724dcf5c5ddef40bcef06f0b2c8ec0
MonoImporter:
externalObjects: {}
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>
using UnityEngine;
using UnityEditor;
using System;
public class SingleLineTexture : MaterialPropertyDrawer
{
public override void OnGUI( Rect position, MaterialProperty prop, String label, MaterialEditor editor )
{
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = prop.hasMixedValue;
Texture value = editor.TexturePropertyMiniThumbnail( position, prop, label, string.Empty );
EditorGUI.showMixedValue = false;
if( EditorGUI.EndChangeCheck() )
{
prop.textureValue = value;
}
}
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 85da32683d237ac4f8665251e2ac38dc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,17 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEditor;
using UnityEditor.ProjectWindowCallback;
namespace AmplifyShaderEditor
{
public class DoCreateFunction : EndNameEditAction
{
public override void Action( int instanceId, string pathName, string resourceFile )
{
UnityEngine.Object obj = EditorUtility.InstanceIDToObject( instanceId );
AssetDatabase.CreateAsset( obj, AssetDatabase.GenerateUniqueAssetPath( pathName ) );
AmplifyShaderEditorWindow.LoadShaderFunctionToASE( (AmplifyShaderFunction)obj, false );
}
}
}

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 3f2c950b0ed192943b7484f6b551965f
timeCreated: 1493906087
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 UnityEngine;
using UnityEditor;
using UnityEditor.ProjectWindowCallback;
using System.IO;
namespace AmplifyShaderEditor
{
public class DoCreateStandardShader : EndNameEditAction
{
public override void Action( int instanceId, string pathName, string resourceFile )
{
string uniquePath = AssetDatabase.GenerateUniqueAssetPath( pathName );
string shaderName = Path.GetFileName( uniquePath );
if( IOUtils.AllOpenedWindows.Count > 0 )
{
EditorWindow openedWindow = AmplifyShaderEditorWindow.GetWindow<AmplifyShaderEditorWindow>();
AmplifyShaderEditorWindow currentWindow = AmplifyShaderEditorWindow.CreateTab();
WindowHelper.AddTab( openedWindow, currentWindow );
UIUtils.CurrentWindow = currentWindow;
}
else
{
AmplifyShaderEditorWindow currentWindow = AmplifyShaderEditorWindow.OpenWindow( shaderName, UIUtils.ShaderIcon );
UIUtils.CurrentWindow = currentWindow;
}
Shader shader = UIUtils.CreateNewEmpty( uniquePath, shaderName );
ProjectWindowUtil.ShowCreatedAsset( shader );
}
}
public class DoCreateTemplateShader : EndNameEditAction
{
public override void Action( int instanceId, string pathName, string resourceFile )
{
string uniquePath = AssetDatabase.GenerateUniqueAssetPath( pathName );
string shaderName = Path.GetFileName( uniquePath );
if( !string.IsNullOrEmpty( UIUtils.NewTemplateGUID ) )
{
Shader shader = AmplifyShaderEditorWindow.CreateNewTemplateShader( UIUtils.NewTemplateGUID, uniquePath, shaderName );
ProjectWindowUtil.ShowCreatedAsset( shader );
}
}
}
}

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

@ -0,0 +1,67 @@
using UnityEditor;
namespace AmplifyShaderEditor
{
[System.Serializable]
public class OptionsWindow
{
private AmplifyShaderEditorWindow m_parentWindow = null;
private bool m_coloredPorts = true;
private bool m_multiLinePorts = true;
private const string MultiLineId = "MultiLinePortsDefault";
private const string ColorPortId = "ColoredPortsDefault";
public OptionsWindow( AmplifyShaderEditorWindow parentWindow )
{
m_parentWindow = parentWindow;
//Load ();
}
public void Init()
{
Load();
}
public void Destroy()
{
Save();
}
public void Save()
{
EditorPrefs.SetBool( ColorPortId, ColoredPorts );
EditorPrefs.SetBool( MultiLineId, m_multiLinePorts );
}
public void Load()
{
ColoredPorts = EditorPrefs.GetBool( ColorPortId, true );
m_multiLinePorts = EditorPrefs.GetBool( MultiLineId, true );
}
public bool ColoredPorts
{
get { return m_coloredPorts; }
set
{
if ( m_coloredPorts != value )
EditorPrefs.SetBool( ColorPortId, value );
m_coloredPorts = value;
}
}
public bool MultiLinePorts
{
get { return m_multiLinePorts; }
set
{
if ( m_multiLinePorts != value )
EditorPrefs.SetBool( MultiLineId, value );
m_multiLinePorts = value;
}
}
public AmplifyShaderEditorWindow ParentWindow { get { return m_parentWindow; } set { m_parentWindow = value; } }
}
}

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

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 52f451731ec183e43ab18f0896f7172a
folderAsset: yes
timeCreated: 1481126944
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,283 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace AmplifyShaderEditor
{
public class NodeGrid
{
private bool m_debugGrid = false;
private const float GRID_SIZE_X = 100;
private const float GRID_SIZE_Y = 100;
private const float GRID_AREA_X = 1000;
private const float GRID_AREA_Y = 1000;
private Dictionary<int, Dictionary<int, List<ParentNode>>> m_grid;
private int m_xMin = int.MaxValue;
private int m_yMin = int.MaxValue;
private int m_xMax = int.MinValue;
private int m_yMax = int.MinValue;
public NodeGrid()
{
m_grid = new Dictionary<int, Dictionary<int, List<ParentNode>>>();
}
public void AddNodeToGrid( ParentNode node )
{
Rect pos = node.Position;
if ( Mathf.Abs( pos.width ) < 0.001f || Mathf.Abs( pos.height ) < 0.001f )
{
return;
}
float initialXf = pos.x / GRID_SIZE_X;
float initialYf = pos.y / GRID_SIZE_Y;
int endX = Mathf.CeilToInt( initialXf + pos.width / GRID_SIZE_X );
int endY = Mathf.CeilToInt( initialYf + pos.height / GRID_SIZE_Y );
int initialX = Mathf.FloorToInt( initialXf );
int initialY = Mathf.FloorToInt( initialYf );
if ( initialX < m_xMin )
{
m_xMin = initialX;
}
if ( initialY < m_yMin )
{
m_yMin = initialY;
}
if ( endX > m_xMax )
{
m_xMax = endX;
}
if ( endY > m_yMax )
{
m_yMax = endY;
}
for ( int x = initialX; x < endX; x += 1 )
{
for ( int y = initialY; y < endY; y += 1 )
{
if ( !m_grid.ContainsKey( x ) )
{
m_grid.Add( x, new Dictionary<int, List<ParentNode>>() );
}
if ( !m_grid[ x ].ContainsKey( y ) )
{
m_grid[ x ].Add( y, new List<ParentNode>() );
}
m_grid[ x ][ y ].Add( node );
}
}
node.IsOnGrid = true;
//DebugLimits();
}
public void RemoveNodeFromGrid( ParentNode node, bool useCachedPos )
{
Rect pos = useCachedPos ? node.CachedPos : node.Position;
if ( Mathf.Abs( pos.width ) < 0.001f || Mathf.Abs( pos.height ) < 0.001f )
{
return;
}
float initialXf = pos.x / GRID_SIZE_X;
float initialYf = pos.y / GRID_SIZE_Y;
int endX = Mathf.CeilToInt( initialXf + pos.width / GRID_SIZE_X );
int endY = Mathf.CeilToInt( initialYf + pos.height / GRID_SIZE_Y );
int initialX = Mathf.FloorToInt( initialXf );
int initialY = Mathf.FloorToInt( initialYf );
bool testLimits = false;
int xMinCount = 0;
int xMaxCount = 0;
int yMinCount = 0;
int yMaxCount = 0;
for ( int x = initialX; x < endX; x += 1 )
{
for ( int y = initialY; y < endY; y += 1 )
{
if ( m_grid.ContainsKey( x ) )
{
if ( m_grid[ x ].ContainsKey( y ) )
{
m_grid[ x ][ y ].Remove( node );
node.IsOnGrid = false;
if ( initialX == m_xMin && x == initialX )
{
testLimits = true;
if ( m_grid[ x ][ y ].Count != 0 )
{
xMinCount += 1;
}
}
if ( endX == m_xMax && x == endX )
{
testLimits = true;
if ( m_grid[ x ][ y ].Count != 0 )
{
xMaxCount += 1;
}
}
if ( initialY == m_yMin && y == initialY )
{
testLimits = true;
if ( m_grid[ x ][ y ].Count != 0 )
{
yMinCount += 1;
}
}
if ( endY == m_yMax && y == endY )
{
testLimits = true;
if ( m_grid[ x ][ y ].Count != 0 )
{
yMaxCount += 1;
}
}
}
}
}
}
if ( testLimits )
{
if ( xMinCount == 0 || xMaxCount == 0 || yMinCount == 0 || yMaxCount == 0 )
{
m_xMin = int.MaxValue;
m_yMin = int.MaxValue;
m_xMax = int.MinValue;
m_yMax = int.MinValue;
foreach ( KeyValuePair<int, Dictionary<int, List<ParentNode>>> entryX in m_grid )
{
foreach ( KeyValuePair<int, List<ParentNode>> entryY in entryX.Value )
{
if ( entryY.Value.Count > 0 )
{
if ( entryX.Key < m_xMin )
{
m_xMin = entryX.Key;
}
if ( entryY.Key < m_yMin )
{
m_yMin = entryY.Key;
}
if ( entryX.Key > m_xMax )
{
m_xMax = entryX.Key;
}
if ( entryY.Key > m_yMax )
{
m_yMax = entryY.Key;
}
}
}
}
// The += 1 is to maintain consistence with AddNodeToGrid() ceil op on max values
m_xMax += 1;
m_yMax += 1;
}
}
//DebugLimits();
}
public void DebugLimits()
{
Debug.Log( "[ " + m_xMin + " , " + m_yMin + " ] " + "[ " + m_xMax + " , " + m_yMax + " ] " );
}
//pos must be the transformed mouse position to local canvas coordinates
public List<ParentNode> GetNodesOn( Vector2 pos )
{
int x = Mathf.FloorToInt( pos.x / GRID_SIZE_X );
int y = Mathf.FloorToInt( pos.y / GRID_SIZE_Y );
if ( m_grid.ContainsKey( x ) )
{
if ( m_grid[ x ].ContainsKey( y ) )
{
return m_grid[ x ][ y ];
}
}
return null;
}
public List<ParentNode> GetNodesOn( int x, int y )
{
if ( m_grid.ContainsKey( x ) )
{
if ( m_grid[ x ].ContainsKey( y ) )
{
return m_grid[ x ][ y ];
}
}
return null;
}
public void DrawGrid( DrawInfo drawInfo )
{
if ( m_debugGrid )
{
Handles.CircleHandleCap( 0, drawInfo.InvertedZoom * ( new Vector3( drawInfo.CameraOffset.x, drawInfo.CameraOffset.y, 0f ) ), Quaternion.identity, 5,EventType.Layout );
for ( int x = -( int ) GRID_AREA_X; x < GRID_AREA_X; x += ( int ) GRID_SIZE_X )
{
Handles.DrawLine( drawInfo.InvertedZoom * ( new Vector3( x + drawInfo.CameraOffset.x, drawInfo.CameraOffset.y - GRID_AREA_Y, 0 ) ), drawInfo.InvertedZoom * ( new Vector3( drawInfo.CameraOffset.x + x, drawInfo.CameraOffset.y + GRID_AREA_Y, 0 ) ) );
}
for ( int y = -( int ) GRID_AREA_Y; y < GRID_AREA_X; y += ( int ) GRID_SIZE_Y )
{
Handles.DrawLine( drawInfo.InvertedZoom * ( new Vector3( drawInfo.CameraOffset.x - GRID_AREA_X, drawInfo.CameraOffset.y + y, 0 ) ), drawInfo.InvertedZoom * ( new Vector3( drawInfo.CameraOffset.x + GRID_AREA_X, drawInfo.CameraOffset.y + y, 0 ) ) );
}
}
}
public void Destroy()
{
foreach ( KeyValuePair<int, Dictionary<int, List<ParentNode>>> entryX in m_grid )
{
foreach ( KeyValuePair<int, List<ParentNode>> entryY in entryX.Value )
{
entryY.Value.Clear();
}
entryX.Value.Clear();
}
m_grid.Clear();
}
public float MaxNodeDist
{
get { return Mathf.Max( ( m_xMax - m_xMin )*GRID_SIZE_X, ( m_yMax - m_yMin )*GRID_SIZE_Y ); }
}
}
}

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

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

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 3b28c70161e2aec4787239fba546bd25
folderAsset: yes
timeCreated: 1481126944
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

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

@ -0,0 +1,189 @@
// 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;
using AmplifyShaderEditor;
[Serializable]
public class AmplifyShaderFunction : ScriptableObject
{
[SerializeField]
private string m_functionInfo = string.Empty;
public string FunctionInfo
{
get { return m_functionInfo; }
set { m_functionInfo = value; }
}
[SerializeField]
private string m_functionName = string.Empty;
public string FunctionName
{
get { if( m_functionName.Length == 0 ) return name; else return m_functionName; }
set { m_functionName = value; }
}
[SerializeField]
[TextArea( 5, 15 )]
private string m_description = string.Empty;
public string Description
{
get { return m_description; }
set { m_description = value; }
}
[SerializeField]
private AdditionalIncludesHelper m_additionalIncludes = new AdditionalIncludesHelper();
//public AdditionalIncludesHelper AdditionalIncludes
//{
// get { return m_additionalIncludes; }
// set { m_additionalIncludes = value; }
//}
[SerializeField]
private AdditionalPragmasHelper m_additionalPragmas = new AdditionalPragmasHelper();
//public AdditionalPragmasHelper AdditionalPragmas
//{
// get { return m_additionalPragmas; }
// set { m_additionalPragmas = value; }
//}
[SerializeField]
private TemplateAdditionalDirectivesHelper m_additionalDirectives = new TemplateAdditionalDirectivesHelper( " Additional Directives" );
public TemplateAdditionalDirectivesHelper AdditionalDirectives
{
get { return m_additionalDirectives; }
set { m_additionalDirectives = value; }
}
[SerializeField]
private FunctionNodeCategories m_nodeCategory = FunctionNodeCategories.Functions;
public FunctionNodeCategories NodeCategory
{
get { return m_nodeCategory; }
set { m_nodeCategory = value; }
}
[SerializeField]
private string m_customNodeCategory = string.Empty;
public string CustomNodeCategory
{
get
{
if( m_nodeCategory == FunctionNodeCategories.Custom )
{
if( string.IsNullOrEmpty( m_customNodeCategory ) )
return "Functions";
else
return m_customNodeCategory;
}
else
{
return UIUtils.CategoryPresets[ (int)m_nodeCategory ];
//return new SerializedObject( this ).FindProperty( "m_nodeCategory" ).enumDisplayNames[ (int)m_nodeCategory ];
}
}
}
[SerializeField]
private PreviewLocation m_previewPosition = PreviewLocation.Auto;
public PreviewLocation PreviewPosition
{
get { return m_previewPosition; }
set { m_previewPosition = value; }
}
[SerializeField]
private bool m_hidden = false;
public bool Hidden
{
get { return m_hidden; }
set { m_hidden = value; }
}
public void UpdateDirectivesList()
{
m_additionalDirectives.CleanNullDirectives();
m_additionalDirectives.UpdateDirectivesFromSaveItems();
if( m_additionalIncludes.IncludeList.Count > 0 )
{
m_additionalDirectives.AddItems( AdditionalLineType.Include, m_additionalIncludes.IncludeList );
m_additionalIncludes.IncludeList.Clear();
}
if( m_additionalPragmas.PragmaList.Count > 0 )
{
m_additionalDirectives.AddItems( AdditionalLineType.Pragma, m_additionalPragmas.PragmaList );
m_additionalPragmas.PragmaList.Clear();
}
}
public void ResetDirectivesOrigin()
{
//if( UIUtils.CurrentShaderVersion() < 16807 )
// Although the correct version was 1.6.7 rev 07 this issue was only detected on v1.7.1. rev 00
// So to avoid potential incorrect saves over shader functions, I decided to broaden up the version range
if( UIUtils.CurrentShaderVersion() < 17101 )
{
m_additionalDirectives.ResetDirectivesOrigin();
}
}
}
public class ShaderFunctionDetector : AssetPostprocessor
{
static void OnPostprocessAllAssets( string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths )
{
if( UIUtils.CurrentWindow == null )
return;
bool markForRefresh = false;
AmplifyShaderFunction function = null;
for( int i = 0; i < importedAssets.Length; i++ )
{
function = AssetDatabase.LoadAssetAtPath<AmplifyShaderFunction>( importedAssets[ i ] );
if( function != null )
{
markForRefresh = true;
break;
}
}
if( deletedAssets.Length > 0 )
markForRefresh = true;
for( int i = 0; i < movedAssets.Length; i++ )
{
function = AssetDatabase.LoadAssetAtPath<AmplifyShaderFunction>( movedAssets[ i ] );
if( function != null )
{
markForRefresh = true;
break;
}
}
for( int i = 0; i < movedFromAssetPaths.Length; i++ )
{
function = AssetDatabase.LoadAssetAtPath<AmplifyShaderFunction>( movedFromAssetPaths[ i ] );
if( function != null )
{
markForRefresh = true;
break;
}
}
if( markForRefresh )
{
markForRefresh = false;
if( function != null )
{
IOUtils.UpdateSFandRefreshWindows( function );
}
UIUtils.CurrentWindow.LateRefreshAvailableNodes();
}
}
}

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 78b2425a2284af743826c689403a4924
timeCreated: 1492703397
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 50be8291f9514914aa55c66c49da67cf, type: 3}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,168 @@
using UnityEngine;
using UnityEditor;
using System;
using System.Text.RegularExpressions;
using System.IO;
using System.Collections.Generic;
namespace AmplifyShaderEditor
{
[CustomEditor( typeof( AmplifyShaderFunction ) )]
public class AmplifyShaderFunctionEditor : Editor
{
class FunctionDependency
{
public string AssetName;
public string AssetPath;
public FunctionDependency(string name, string path)
{
AssetName = name;
AssetPath = path;
}
}
AmplifyShaderFunction m_target;
List<FunctionDependency> m_dependencies = new List<FunctionDependency>();
void OnEnable()
{
m_target = ( target as AmplifyShaderFunction );
}
public override void OnInspectorGUI()
{
//base.OnInspectorGUI();
//base.serializedObject.Update();
if( GUILayout.Button( "Open in Shader Editor" ) )
{
#if UNITY_2018_3_OR_NEWER
ASEPackageManagerHelper.SetupLateShaderFunction( m_target );
#else
AmplifyShaderEditorWindow.LoadShaderFunctionToASE( m_target, false );
#endif
}
//EditorGUILayout.Separator();
//m_target.FunctionInfo = EditorGUILayout.TextArea( m_target.FunctionInfo );
if( m_target.Description.Length > 0 )
{
EditorGUILayout.HelpBox( m_target.Description, MessageType.Info );
}
EditorGUILayout.Space();
if( GUILayout.Button( "Search Direct Dependencies" ) )
{
m_dependencies.Clear();
string guid = AssetDatabase.AssetPathToGUID( AssetDatabase.GetAssetPath( m_target ) );
string[] allSFs = AssetDatabase.FindAssets( "t:AmplifyShaderFunction", null );
foreach( string guid1 in allSFs )
{
string sfPath = AssetDatabase.GUIDToAssetPath( guid1 );
bool found = SearchForGUID( guid, sfPath );
if( found )
{
//string n = Regex.Replace( sfPath, @"(\.\w+|[\w\d\/]+\/)", "" );
string n = Regex.Replace( sfPath, @"[\w\d\/]+\/", "" );
m_dependencies.Add(new FunctionDependency( n, sfPath ) );
}
}
string[] allSHs = AssetDatabase.FindAssets( "t:Shader", null );
foreach( string guid1 in allSHs )
{
string shPath = AssetDatabase.GUIDToAssetPath( guid1 );
bool found = SearchForGUID( guid, shPath );
if( found )
{
string n = Regex.Replace( shPath, @"[\w\d\/]+\/", "" );
m_dependencies.Add( new FunctionDependency( n, shPath ) );
}
}
}
EditorGUILayout.Space();
for( int i = 0; i < m_dependencies.Count; i++ )
{
EditorGUILayout.BeginHorizontal();
if( GUILayout.Button( m_dependencies[ i ].AssetName, "minibuttonleft" ) )
{
SelectAtPath( m_dependencies[ i ].AssetPath );
}
if( GUILayout.Button( "edit", "minibuttonright", GUILayout.Width(100) ) )
{
if( m_dependencies[ i ].AssetName.EndsWith( ".asset" ) )
{
var obj = AssetDatabase.LoadAssetAtPath<AmplifyShaderFunction>( m_dependencies[ i ].AssetPath );
AmplifyShaderEditorWindow.LoadShaderFunctionToASE( obj, false );
}
else
{
var obj = AssetDatabase.LoadAssetAtPath<Shader>( m_dependencies[ i ].AssetPath );
AmplifyShaderEditorWindow.ConvertShaderToASE( obj );
}
}
EditorGUILayout.EndHorizontal();
}
if( m_dependencies.Count > 0 )
{
List<string> assetPaths = new List<string>();
for( int i = 0; i < m_dependencies.Count; i++ )
{
assetPaths.Add( m_dependencies[ i ].AssetPath );
}
if( GUILayout.Button( "Open and Save All" ) )
{
bool doit = EditorUtility.DisplayDialog( "Open and Save All", "This will try to open all shader function and shaders that use this shader function and save them in quick succession, this may irreversibly break your files if something goes wrong. Are you sure you want to try?", "Yes, I'll take the risk", "No, I'll do it myself" );
if( doit )
AmplifyShaderEditorWindow.LoadAndSaveList( assetPaths.ToArray() );
}
}
}
public void SelectAtPath( string path )
{
var obj = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>( path );
EditorGUIUtility.PingObject( obj );
}
public static bool SearchForGUID( string guid, string pathName )
{
bool result = false;
int count = 0;
if( !string.IsNullOrEmpty( pathName ) && File.Exists( pathName ) )
{
StreamReader fileReader = null;
try
{
fileReader = new StreamReader( pathName );
string line;
int index = -1;
while( ( line = fileReader.ReadLine() ) != null )
{
index = line.IndexOf( guid );
count++;
if( index > -1 )
{
result = true;
break;
}
}
}
catch( Exception e )
{
Debug.LogException( e );
}
finally
{
if( fileReader != null )
fileReader.Close();
}
}
return result;
}
}
}

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

@ -0,0 +1,94 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
namespace AmplifyShaderEditor
{
public enum AutoPanLocation
{
TOP = 0,
BOTTOM,
LEFT,
RIGHT
}
public class AutoPanData
{
private Rect m_area;
private float m_size;
private Vector2 m_velocity;
private GUIStyle m_style;
private Color m_color = new Color( 1f, 0f, 0f, 0.5f );
private AutoPanLocation m_location;
private float m_adjustWidth = 0;
private float m_adjustInitialX = 0;
public AutoPanData( AutoPanLocation location, float size, Vector2 vel )
{
m_area = new Rect();
m_size = size;
m_velocity = vel;
m_location = location;
}
public bool CheckArea( Vector2 mousePosition, Rect window, bool draw )
{
float totalSize = m_size + m_adjustWidth;
switch ( m_location )
{
case AutoPanLocation.TOP:
{
m_area.x = m_adjustInitialX;
m_area.y = 0;
m_area.width = window.width;
m_area.height = totalSize;
}
break;
case AutoPanLocation.BOTTOM:
{
m_area.x = m_adjustInitialX;
m_area.y = window.height - totalSize;
m_area.width = window.width;
m_area.height = totalSize;
}
break;
case AutoPanLocation.LEFT:
{
m_area.x = m_adjustInitialX;
m_area.y = 0;
m_area.width = totalSize;
m_area.height = window.height;
}
break;
case AutoPanLocation.RIGHT:
{
m_area.x = m_adjustInitialX + window.width - totalSize;
m_area.y = 0;
m_area.width = totalSize;
m_area.height = window.height;
}
break;
}
if ( draw )
{
if ( m_style == null )
{
m_style = UIUtils.Box;
}
Color bufferedColor = GUI.color;
GUI.color = m_color;
GUI.Label( m_area, string.Empty, m_style );
GUI.color = bufferedColor;
}
return m_area.Contains( mousePosition );
}
public float AdjustWidth { set { m_adjustWidth = value; } }
public float AdjustInitialX { set { m_adjustInitialX = value; } }
public Vector2 Velocity { get { return m_velocity; } }
}
}

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

@ -0,0 +1,262 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using UnityEngine;
using System.Collections.Generic;
using UnityEditor;
namespace AmplifyShaderEditor
{
public class ClipboardData
{
public string Data = string.Empty;
public string Connections = string.Empty;
public int OldNodeId = -1;
public int NewNodeId = -1;
public ClipboardData( string data, string connections, int oldNodeId )
{
Data = data;
Connections = connections;
OldNodeId = oldNodeId;
}
public override string ToString()
{
return Data + IOUtils.CLIPBOARD_DATA_SEPARATOR + Connections + IOUtils.CLIPBOARD_DATA_SEPARATOR + OldNodeId + IOUtils.CLIPBOARD_DATA_SEPARATOR + NewNodeId;
}
}
public class Clipboard
{
public const string ClipboardId = "AMPLIFY_CLIPBOARD_ID";
private readonly string[] ClipboardTagId = { "#CLIP_ITEM#" };
private List<ClipboardData> m_clipboardStrData;
private Dictionary<int, ClipboardData> m_clipboardAuxData;
private Dictionary<string, ClipboardData> m_multiPassMasterNodeData;
public Clipboard()
{
m_clipboardStrData = new List<ClipboardData>();
m_clipboardAuxData = new Dictionary<int, ClipboardData>();
m_multiPassMasterNodeData = new Dictionary<string, ClipboardData>();
}
public void ResetMultipassNodesData()
{
m_multiPassMasterNodeData.Clear();
}
public void AddMultiPassNodesToClipboard( List<TemplateMultiPassMasterNode> masterNodes, bool resetList, int lodId )
{
if( resetList )
m_multiPassMasterNodeData.Clear();
int templatesAmount = masterNodes.Count;
for( int i = 0; i < templatesAmount; i++ )
{
if( !masterNodes[ i ].InvalidNode )
{
string data = string.Empty;
string connection = string.Empty;
System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
masterNodes[ i ].FullWriteToString( ref data, ref connection );
System.Threading.Thread.CurrentThread.CurrentCulture = System.Threading.Thread.CurrentThread.CurrentUICulture;
ClipboardData clipboardData = new ClipboardData( data, connection, masterNodes[ i ].UniqueId );
m_multiPassMasterNodeData.Add( masterNodes[ i ].PassUniqueName + lodId, clipboardData );
}
}
}
public void GetMultiPassNodesFromClipboard( List<TemplateMultiPassMasterNode> masterNodes, int lodId )
{
int templatesAmount = masterNodes.Count;
for( int i = 0; i < templatesAmount; i++ )
{
string clipboardDataId = masterNodes[ i ].PassUniqueName + lodId;
if( m_multiPassMasterNodeData.ContainsKey( clipboardDataId ) )
{
ClipboardData nodeData = m_multiPassMasterNodeData[ clipboardDataId ];
string[] nodeParams = nodeData.Data.Split( IOUtils.FIELD_SEPARATOR );
System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
masterNodes[ i ].FullReadFromString( ref nodeParams );
System.Threading.Thread.CurrentThread.CurrentCulture = System.Threading.Thread.CurrentThread.CurrentUICulture;
}
}
for( int i = 0; i < templatesAmount; i++ )
{
string clipboardDataId = masterNodes[ i ].PassUniqueName + lodId;
if( m_multiPassMasterNodeData.ContainsKey( clipboardDataId ) )
{
masterNodes[ i ].SetReadOptions();
masterNodes[ i ].ForceOptionsRefresh();
}
}
}
public void AddToClipboard( List<ParentNode> selectedNodes , Vector3 initialPosition, ParentGraph graph )
{
//m_clipboardStrData.Clear();
//m_clipboardAuxData.Clear();
string clipboardData = IOUtils.Vector3ToString( initialPosition ) + ClipboardTagId[ 0 ];
int masterNodeId = UIUtils.CurrentWindow.CurrentGraph.CurrentMasterNodeId;
int count = selectedNodes.Count;
for ( int i = 0; i < count; i++ )
{
if ( UIUtils.CurrentWindow.IsShaderFunctionWindow || !graph.IsMasterNode( selectedNodes[ i ] ))
{
string nodeData = string.Empty;
string connections = string.Empty;
selectedNodes[ i ].ClipboardFullWriteToString( ref nodeData, ref connections );
clipboardData += nodeData;
if ( !string.IsNullOrEmpty( connections ) )
{
connections = connections.Substring( 0, connections.Length - 1 );
clipboardData += "\n" + connections;
}
if ( i < count - 1 )
clipboardData += ClipboardTagId[ 0 ];
//ClipboardData data = new ClipboardData( nodeData, connections, selectedNodes[ i ].UniqueId );
//m_clipboardStrData.Add( data );
//m_clipboardAuxData.Add( selectedNodes[ i ].UniqueId, data );
}
}
if ( !string.IsNullOrEmpty( clipboardData ) )
{
EditorPrefs.SetString( ClipboardId, clipboardData );
}
//for ( int i = 0; i < selectedNodes.Count; i++ )
//{
// if ( selectedNodes[ i ].UniqueId != masterNodeId )
// {
// WireNode wireNode = selectedNodes[ i ] as WireNode;
// if ( wireNode != null )
// {
// if ( !IsNodeChainValid( selectedNodes[ i ], true ) || !IsNodeChainValid( selectedNodes[ i ], false ) )
// {
// UnityEngine.Debug.Log( "found invalid wire port" );
// }
// }
// }
//}
}
public Vector3 GetDataFromEditorPrefs()
{
Vector3 initialPos = Vector3.zero;
m_clipboardStrData.Clear();
m_clipboardAuxData.Clear();
string clipboardData = EditorPrefs.GetString( ClipboardId, string.Empty );
if ( !string.IsNullOrEmpty( clipboardData ) )
{
string[] clipboardDataArray = clipboardData.Split( ClipboardTagId, StringSplitOptions.None );
initialPos = IOUtils.StringToVector3( clipboardDataArray[0] );
for ( int i = 1; i < clipboardDataArray.Length; i++ )
{
if ( !string.IsNullOrEmpty( clipboardDataArray[ i ] ) )
{
int wiresIndex = clipboardDataArray[ i ].IndexOf( IOUtils.LINE_TERMINATOR );
string nodeData = string.Empty;
string connections = string.Empty;
if ( wiresIndex < 0 )
{
nodeData = clipboardDataArray[ i ];
}
else
{
nodeData = clipboardDataArray[ i ].Substring( 0, wiresIndex );
connections = clipboardDataArray[ i ].Substring( wiresIndex + 1 );
}
string[] nodeDataArr = nodeData.Split( IOUtils.FIELD_SEPARATOR );
if ( nodeDataArr.Length > 2 )
{
int nodeId = Convert.ToInt32( nodeDataArr[ 2 ] );
ClipboardData data = new ClipboardData( nodeData, connections, nodeId );
m_clipboardStrData.Add( data );
m_clipboardAuxData.Add( nodeId, data );
}
}
}
}
return initialPos;
}
public bool IsNodeChainValid( ParentNode currentNode, bool forward )
{
WireNode wireNode = currentNode as WireNode;
if ( wireNode == null )
{
return m_clipboardAuxData.ContainsKey( currentNode.UniqueId );
}
if ( forward )
{
if ( wireNode.InputPorts[ 0 ].ExternalReferences.Count > 0 )
{
int nodeId = wireNode.InputPorts[ 0 ].ExternalReferences[ 0 ].NodeId;
if ( m_clipboardAuxData.ContainsKey( nodeId ) )
{
return IsNodeChainValid( UIUtils.GetNode( nodeId ), forward );
}
}
}
else
{
int nodeId = wireNode.OutputPorts[ 0 ].ExternalReferences[ 0 ].NodeId;
if ( m_clipboardAuxData.ContainsKey( nodeId ) )
{
return IsNodeChainValid( UIUtils.GetNode( nodeId ), forward );
}
}
return false;
}
public void GenerateFullString()
{
string data = string.Empty;
for ( int i = 0; i < m_clipboardStrData.Count; i++ )
{
data += m_clipboardStrData[ i ].ToString();
if ( i < m_clipboardStrData.Count - 1 )
{
data += IOUtils.LINE_TERMINATOR;
}
}
}
public void ClearClipboard()
{
m_clipboardStrData.Clear();
m_clipboardAuxData.Clear();
m_multiPassMasterNodeData.Clear();
}
public ClipboardData GetClipboardData( int oldNodeId )
{
if ( m_clipboardAuxData.ContainsKey( oldNodeId ) )
return m_clipboardAuxData[ oldNodeId ];
return null;
}
public int GeNewNodeId( int oldNodeId )
{
if ( m_clipboardAuxData.ContainsKey( oldNodeId ) )
return m_clipboardAuxData[ oldNodeId ].NewNodeId;
return -1;
}
public List<ClipboardData> CurrentClipboardStrData
{
get { return m_clipboardStrData; }
}
public bool HasCachedMasterNodes { get { return m_multiPassMasterNodeData.Count > 0; } }
}
}

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

@ -0,0 +1,120 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEditor;
using UnityEngine;
namespace AmplifyShaderEditor
{
public class ConfirmationWindow
{
public delegate ShaderLoadResult OnConfirmationSelected( bool value, Shader shader, Material material );
public event OnConfirmationSelected OnConfirmationSelectedEvt;
private const string m_yesStr = "Yes";
private const string m_noStr = "No";
private bool m_isActive = false;
private string m_currentMessage;
private GUIStyle m_areaStyle;
private GUIContent m_content;
private GUIStyle m_buttonStyle;
private GUIStyle m_labelStyle;
private Shader m_shader;
private Material m_material;
private Rect m_area;
private bool m_autoDeactivate = true;
public ConfirmationWindow( float x, float y, float width, float height )
{
m_content = new GUIContent( GUIContent.none );
m_area = new Rect( x, y, width, height );
}
public void Destroy()
{
m_shader = null;
OnConfirmationSelectedEvt = null;
}
public void ActivateConfirmation( Shader shader, Material material, string message, OnConfirmationSelected evt, bool autoDeactivate = true )
{
OnConfirmationSelectedEvt = evt;
m_currentMessage = message;
m_shader = shader;
m_material = material;
m_autoDeactivate = autoDeactivate;
m_isActive = true;
}
public void OnGUI()
{
if ( m_areaStyle == null )
{
m_areaStyle = new GUIStyle( UIUtils.TextArea );
m_areaStyle.stretchHeight = true;
m_areaStyle.stretchWidth = true;
m_areaStyle.fontSize = ( int ) Constants.DefaultTitleFontSize;
}
if ( m_buttonStyle == null )
{
m_buttonStyle = UIUtils.Button;
}
if ( m_labelStyle == null )
{
m_labelStyle = new GUIStyle( UIUtils.Label );
m_labelStyle.alignment = TextAnchor.MiddleCenter;
m_labelStyle.wordWrap = true;
}
m_area.x = ( int ) ( 0.5f * UIUtils.CurrentWindow.CameraInfo.width );
m_area.y = ( int ) ( 0.5f * UIUtils.CurrentWindow.CameraInfo.height );
GUILayout.BeginArea( m_area, m_content, m_areaStyle );
{
EditorGUILayout.BeginVertical();
{
EditorGUILayout.Separator();
EditorGUILayout.LabelField( m_currentMessage, m_labelStyle );
EditorGUILayout.Separator();
EditorGUILayout.Separator();
EditorGUILayout.BeginHorizontal();
{
if ( GUILayout.Button( m_yesStr, m_buttonStyle ) )
{
if ( OnConfirmationSelectedEvt != null )
OnConfirmationSelectedEvt( true, m_shader, m_material );
if ( m_autoDeactivate )
Deactivate();
}
if ( GUILayout.Button( m_noStr, m_buttonStyle ) )
{
if ( OnConfirmationSelectedEvt != null )
OnConfirmationSelectedEvt( false, m_shader, m_material );
if ( m_autoDeactivate )
Deactivate();
}
}
EditorGUILayout.EndHorizontal();
}
EditorGUILayout.EndVertical();
}
GUILayout.EndArea();
}
public void Deactivate()
{
m_isActive = false;
OnConfirmationSelectedEvt = null;
}
public bool IsActive { get { return m_isActive; } }
}
}

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

@ -0,0 +1,309 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace AmplifyShaderEditor
{
[System.Serializable]
public class Toast
{
public MessageSeverity ItemType;
public string ItemMessage;
public double ItemTime;
public int ItemOwnerId;
public Toast( MessageSeverity itemType, string itemMessage, double itemTime,int itemOwnerId )
{
ItemType = itemType;
ItemMessage = itemMessage;
ItemTime = itemTime;
ItemOwnerId = itemOwnerId;
}
}
public class ConsoleLogWindow
{
public const int MAXWIDTH = 400;
public const float FADETIME = 7;
private readonly GUIContent m_boxToggleContent = new GUIContent( "\u2261", "Toggle Message Box" );
private readonly GUIContent m_clearContent = new GUIContent( "\u00D7", "Clear Messages" );
protected AmplifyShaderEditorWindow m_parentWindow = null;
// needs to be serialized
private Vector2 m_currentScrollPos;
int lastCall = -1;
public ConsoleLogWindow( AmplifyShaderEditorWindow parentWindow )
{
m_parentWindow = parentWindow;
}
public void AddMessage( MessageSeverity itemType, string itemMessage , int itemOwnerId )
{
var toast = new Toast( itemType, itemMessage, Time.realtimeSinceStartup, itemOwnerId );
m_parentWindow.Messages.Insert( 0, toast );
m_currentScrollPos.y = Mathf.Infinity;
if( !m_parentWindow.MaximizeMessages )
lastCall = Mathf.Max( (int)itemType, lastCall );
GUIContent gc = new GUIContent( m_parentWindow.Messages.Count + ": " + itemMessage );
float maxWidth = m_parentWindow.MaxMsgWidth;
maxWidth = Mathf.Max( GUIStyle.none.CalcSize( gc ).x + 16, maxWidth );
maxWidth = Mathf.Min( maxWidth, MAXWIDTH );
m_parentWindow.MaxMsgWidth = maxWidth;
}
public void Draw( Rect parentPosition, Vector2 mousePosition, int mouseButtonId, bool hasKeyboadFocus, float rightSide )
{
EventType currentEventType = Event.current.type;
var messages = m_parentWindow.Messages;
var maximize = m_parentWindow.MaximizeMessages;
Rect button = parentPosition;
button.width = 22;
button.height = 22;
button.x = parentPosition.x + parentPosition.width - button.width - rightSide - 8;
button.y = parentPosition.y + parentPosition.height - button.height - ( m_parentWindow.CurrentSelection == ASESelectionMode.Material ? 52 : 8 );
Rect toolbarArea = button;
toolbarArea.y -= 5;
if( maximize )
{
toolbarArea.xMin -= m_parentWindow.MaxMsgWidth;
toolbarArea.yMin -= 66;
}
toolbarArea.x -= 6;
bool needsRepaint = false;
if( maximize )
{
GUIStyle labelStyle = UIUtils.ConsoleLogLabel;
toolbarArea.y -= 16 + 8;
GUILayout.BeginArea( toolbarArea, UIUtils.ConsoleLogMessage );
EditorGUILayout.BeginVertical();
m_currentScrollPos = EditorGUILayout.BeginScrollView( m_currentScrollPos );
{
int count = messages.Count;
for( int i = count - 1; i >= 0; i-- )
{
switch( messages[ i ].ItemType )
{
case MessageSeverity.Error:
labelStyle.normal.textColor = Color.red;
break;
case MessageSeverity.Warning:
labelStyle.normal.textColor = Color.yellow;
break;
default:
case MessageSeverity.Normal:
labelStyle.normal.textColor = Color.white;
break;
}
if( messages[ i ].ItemOwnerId < 0 )
{
if( Event.current.control && Event.current.shift )
{
if( GUILayout.Button( ( count - i ) + ": " + messages[ i ].ItemMessage, labelStyle ) )
{
if( Event.current.button == 1 )
{
EditorGUIUtility.systemCopyBuffer = messages[ i ].ItemMessage;
}
}
}
else
{
GUILayout.Label( ( count - i ) + ": " + messages[ i ].ItemMessage, labelStyle );
}
}
else
{
if( GUILayout.Button( ( count - i ) + ": " + messages[ i ].ItemMessage, labelStyle ) )
{
UIUtils.CurrentWindow.FocusOnNode( messages[ i ].ItemOwnerId, 1, true );
if( Event.current.button == 1 )
{
EditorGUIUtility.systemCopyBuffer = messages[ i ].ItemMessage;
}
}
}
}
}
EditorGUILayout.EndScrollView();
EditorGUILayout.EndVertical();
GUILayout.EndArea();
}
else
{
// draw toaster
int count = messages.Count;
Rect rect = toolbarArea;
rect.xMin -= 200;
float startFade = FADETIME - 1;
for( int i = 0; i < count; i++ )
{
GUIStyle msgstyle = UIUtils.ConsoleLogMessage;
float delta = (float)(Time.realtimeSinceStartup - messages[ i ].ItemTime);
if( delta > FADETIME )
continue;
if( delta < 0.1f )
{
msgstyle.normal.textColor = Color.cyan;
}
else if( delta < startFade )
{
switch( messages[ i ].ItemType )
{
case MessageSeverity.Error:
msgstyle.normal.textColor = Color.red;
break;
case MessageSeverity.Warning:
msgstyle.normal.textColor = Color.yellow;
break;
default:
case MessageSeverity.Normal:
msgstyle.normal.textColor = Color.white;
break;
}
}
else
{
switch( messages[ i ].ItemType )
{
case MessageSeverity.Error:
msgstyle.normal.textColor = new Color( 1, 0, 0, FADETIME - delta );
break;
case MessageSeverity.Warning:
msgstyle.normal.textColor = new Color( 1, 1, 0, FADETIME - delta );
break;
default:
case MessageSeverity.Normal:
msgstyle.normal.textColor = new Color( 1, 1, 1, FADETIME - delta );
break;
}
}
needsRepaint = true;
GUIContent gc = new GUIContent( messages[ i ].ItemMessage );
var sizes = msgstyle.CalcSize( gc );
rect.xMin -= sizes.x - rect.width;
rect.height = sizes.y;
rect.y -= rect.height + 2;
if( messages[ i ].ItemOwnerId < 0 )
{
GUI.Label( rect, gc, msgstyle );
}
else
{
if( GUI.Button( rect, gc, msgstyle ))
{
UIUtils.CurrentWindow.FocusOnNode( messages[ i ].ItemOwnerId, 1, true );
if( Event.current.button == 1 )
{
EditorGUIUtility.systemCopyBuffer = messages[ i ].ItemMessage;
}
}
}
}
}
//GUI.color = cached;
if( needsRepaint )
m_parentWindow.MarkToRepaint();
GUIStyle style = UIUtils.ConsoleLogCircle;
button.size = Vector2.one * 16;
switch( lastCall )
{
case 0:
style.normal.textColor = Color.cyan;
break;
case 1:
style.normal.textColor = Color.yellow;
break;
case 2:
style.normal.textColor = Color.red;
break;
default:
style.normal.textColor = new Color( 1, 1, 1, 0.5f );
break;
}
if( GUI.Button( button, m_boxToggleContent, style ) )
{
maximize = !maximize;
m_parentWindow.MaximizeMessages = maximize;
m_currentScrollPos.y = Mathf.Infinity;
lastCall = -1;
}
style.normal.textColor = new Color( 1, 1, 1, 0.5f );
//GUI.color = cached;
button.x -= button.width + 2;
if( maximize && GUI.Button( button, m_clearContent, style ) )
{
if( messages.Count == 0 )
{
maximize = false;
m_parentWindow.MaximizeMessages = maximize;
}
ClearMessages();
}
button.width += button.width + 2;
bool mouseOnTop = button.Contains( mousePosition );
if( currentEventType == EventType.MouseMove && mouseOnTop )
m_parentWindow.MarkToRepaint();
if( DebugConsoleWindow.DeveloperMode )
{
if( Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Alpha1 )
{
UIUtils.ShowMessage( "This is an info message\nwith two lines" );
}
if( Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Alpha2 )
{
UIUtils.ShowMessage( "This is a warning message", MessageSeverity.Warning );
}
if( Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Alpha3 )
{
UIUtils.ShowMessage( "THIS IS AN ERROR MESSAGE!!", MessageSeverity.Error );
}
}
}
public void ClearMessages()
{
m_parentWindow.Messages.Clear();
m_parentWindow.MaxMsgWidth = 100;
}
public void Toggle()
{
}
public void Destroy()
{
m_parentWindow = null;
}
}
}

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

@ -0,0 +1,81 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using UnityEngine;
namespace AmplifyShaderEditor
{
public class ContextMenuItem
{
private const string PALETTE_NAME_MOD_STR = " ";
private string m_paletteName;
private string m_name;
private string m_tags;
private string m_category;
private string m_description;
private System.Type m_type;
private GUIContent m_guiContent;
private string m_nameWithShortcut;
private AmplifyShaderFunction m_function;
private NodeAttributes m_nodeAttributes;
public ContextMenuItem( NodeAttributes nodeAttributes, System.Type type, string name, string tags, string category, string description, AmplifyShaderFunction function, KeyCode shortcut )
{
m_nodeAttributes = nodeAttributes;
m_name = name;
m_tags = name + ( string.IsNullOrEmpty( tags ) ? "" : " " + tags );
m_tags = m_tags.ToLower();
m_nameWithShortcut = shortcut != KeyCode.None ? ( name + " [ " + UIUtils.KeyCodeToString( shortcut ) + " ]" ) : name;
m_paletteName = PALETTE_NAME_MOD_STR + m_name;
m_type = type;
m_category = category;
m_description = description;
m_function = function;
m_guiContent = new GUIContent( m_nameWithShortcut, m_description );
}
public int CompareTo( ContextMenuItem item , bool useWeights )
{
if ( useWeights && NodeAttributes.SortOrderPriority > -1 && item.NodeAttributes.SortOrderPriority > -1 )
{
if ( NodeAttributes.SortOrderPriority > item.NodeAttributes.SortOrderPriority )
{
return 1;
}
else if ( NodeAttributes.SortOrderPriority == item.NodeAttributes.SortOrderPriority )
{
return m_name.CompareTo( item.Name );
}
else
{
return -1;
}
}
return m_name.CompareTo( item.Name );
}
public string PaletteName { get { return m_paletteName; } }
public string Name { get { return m_name; } }
public string Tags { get { return m_tags; } }
public string NameWithShortcut { get { return m_nameWithShortcut; } }
public string Category { get { return m_category; } }
public string Description { get { return m_description; } }
public AmplifyShaderFunction Function { get { return m_function; } }
public System.Type NodeType { get { return m_type; } }
public GUIContent ItemUIContent { get { return m_guiContent; } }
public NodeAttributes NodeAttributes { get { return m_nodeAttributes; } }
public override string ToString()
{
return m_name + ":" + m_category + ":" + m_description;
}
public void Destroy()
{
m_guiContent = null;
m_nodeAttributes = null;
}
}
}

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

@ -0,0 +1,53 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
//using UnityEditor;
//using UnityEngine;
//namespace AmplifyShaderEditor
//{
// //EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector)
// // this might be a bit nonsense since I could use the GetBuiltinSkin directly but this way will bea easier to change to some custom visuals on some near future
// [System.Serializable]
// public class CustomStylesContainer
// {
// public GUIStyle FoldoutStyle
// {
// get { return EditorStyles.foldout; }
// }
// public GUIStyle Label
// {
// get { return GUI.skin.label; }
// }
// public GUIStyle Button
// {
// get { return GUI.skin.button; }
// }
// public GUIStyle TextArea
// {
// get { return GUI.skin.textArea; }
// }
// public GUIStyle Toggle
// {
// get { return GUI.skin.toggle; }
// }
// public GUIStyle Window
// {
// get { return GUI.skin.window; }
// }
// public GUIStyle Textfield
// {
// get { return GUI.skin.textField; }
// }
// public GUIStyle Box
// {
// get { return GUI.skin.box; }
// }
// }
//}

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

@ -0,0 +1,203 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
//#define ASE_CONSOLE_WINDOW
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
namespace AmplifyShaderEditor
{
public sealed class DebugConsoleWindow : EditorWindow
{
private const float WindowSizeX = 250;
private const float WindowSizeY = 250;
private const float WindowPosX = 5;
private const float WindowPosY = 5;
private Rect m_availableArea;
private bool m_wikiAreaFoldout = true;
private bool m_miscAreaFoldout = true;
private Vector2 m_currentScrollPos;
private int m_minURLNode = 0;
private int m_maxURLNode = -1;
#if ASE_CONSOLE_WINDOW
public readonly static bool DeveloperMode = true;
public static bool UseShaderPanelsInfo = true;
[MenuItem( "Window/Amplify Shader Editor/Open Debug Console" )]
static void OpenMainShaderGraph()
{
OpenWindow();
}
[MenuItem( "Window/Amplify Shader Editor/Create Template Menu Items" )]
public static void CreateTemplateMenuItems()
{
UIUtils.CurrentWindow.TemplatesManagerInstance.CreateTemplateMenuItems();
}
#else
public readonly static bool DeveloperMode = false;
public static bool UseShaderPanelsInfo = false;
#endif
public static DebugConsoleWindow OpenWindow()
{
if ( DeveloperMode )
{
DebugConsoleWindow currentWindow = ( DebugConsoleWindow ) DebugConsoleWindow.GetWindow( typeof( DebugConsoleWindow ), false, "ASE Debug Console" );
currentWindow.titleContent.tooltip = "Debug Options for ASE. Intented only for ASE development team";
currentWindow.minSize = new Vector2( WindowSizeX, WindowSizeY );
currentWindow.maxSize = new Vector2( WindowSizeX, 2 * WindowSizeY ); ;
currentWindow.wantsMouseMove = true;
return currentWindow;
}
return null;
}
void OnGUI()
{
m_availableArea = new Rect( WindowPosX, WindowPosY, position.width - 2 * WindowPosX, position.height - 2 * WindowPosY );
GUILayout.BeginArea( m_availableArea );
{
m_currentScrollPos = EditorGUILayout.BeginScrollView( m_currentScrollPos, GUILayout.Width( 0 ), GUILayout.Height( 0 ) );
{
EditorGUILayout.BeginVertical();
{
AmplifyShaderEditorWindow window = UIUtils.CurrentWindow;
if ( window != null )
{
EditorGUILayout.Separator();
NodeUtils.DrawPropertyGroup( ref m_wikiAreaFoldout, "Wiki Helper", ShowWikiHelperFunctions );
EditorGUILayout.Separator();
NodeUtils.DrawPropertyGroup( ref m_miscAreaFoldout, "Misc", ShowMiscFuntions );
EditorGUILayout.Separator();
}
else
{
EditorGUILayout.LabelField( "Please open an ASE window to access debug options" );
}
}
EditorGUILayout.EndVertical();
}
EditorGUILayout.EndScrollView();
}
GUILayout.EndArea();
}
void ShowWikiHelperFunctions()
{
AmplifyShaderEditorWindow window = UIUtils.CurrentWindow;
EditorGUILayout.Separator();
if ( GUILayout.Button( "Nodes Screen Shots" ) )
{
window.CurrentNodeExporterUtils.ActivateAutoScreenShot( Application.dataPath + "/../NodesInfo/Shots/",0,-1 );
}
GUILayout.BeginHorizontal();
if( GUILayout.Button( "Nodes URLs" ) )
{
window.CurrentNodeExporterUtils.ActivateNodesURL( m_minURLNode, m_maxURLNode );
}
m_minURLNode = EditorGUILayout.IntField( m_minURLNode );
m_maxURLNode = EditorGUILayout.IntField( m_maxURLNode );
GUILayout.EndHorizontal();
EditorGUILayout.Separator();
if( GUILayout.Button( "Nodes Undo Test" ) )
{
window.CurrentNodeExporterUtils.ActivateAutoUndo();
}
EditorGUILayout.Separator();
if ( GUILayout.Button( "Nodes Info" ) )
{
window.CurrentPaletteWindow.DumpAvailableNodes( false, Application.dataPath + "/../NodesInfo/" );
window.CurrentPaletteWindow.DumpAvailableNodes( true, Application.dataPath + "/../NodesInfo/" );
}
EditorGUILayout.Separator();
if ( GUILayout.Button( "Shortcuts Info" ) )
{
window.ShortcutManagerInstance.DumpShortcutsToDisk( Application.dataPath + "/../NodesInfo/" );
}
}
void ShowMiscFuntions()
{
AmplifyShaderEditorWindow window = UIUtils.CurrentWindow;
if ( GUILayout.Button( "Force Example Shader Compilation" ) )
{
UIUtils.ForceExampleShaderCompilation();
}
EditorGUILayout.Separator();
if ( GUILayout.Button( "Refresh Available Nodes" ) )
{
window.RefreshAvaibleNodes();
}
EditorGUILayout.Separator();
if ( GUILayout.Button( "Dump Uniform Names" ) )
{
//window.CurrentPaletteWindow.NewList()
window.DuplicatePrevBufferInstance.DumpUniformNames();
}
EditorGUILayout.Separator();
if ( GUILayout.Button( "Force Palette Update" ) )
{
Debug.Log( UIUtils.CurrentWindow.IsShaderFunctionWindow );
window.CurrentPaletteWindow.ForceUpdate = true;
}
EditorGUILayout.Separator();
if( GUILayout.Button( "Detect Infinite Loops" ) )
{
if( window.IsShaderFunctionWindow )
{
Debug.Log( "Starting infinite loop detection over shader functions" );
List<FunctionOutput> nodes = window.OutsideGraph.FunctionOutputNodes.NodesList;
for( int i = 0; i < nodes.Count; i++ )
{
UIUtils.DetectNodeLoopsFrom( nodes[ i ], new Dictionary<int, int>() );
}
}
else
{
if( window.OutsideGraph.MultiPassMasterNodes.Count > 0 )
{
Debug.Log( "Starting infinite loop detection over shader from template" );
List<TemplateMultiPassMasterNode> nodes = window.OutsideGraph.MultiPassMasterNodes.NodesList;
for( int i = 0; i < nodes.Count; i++ )
{
UIUtils.DetectNodeLoopsFrom( nodes[ i ], new Dictionary<int, int>() );
}
}
else
{
Debug.Log( "Starting infinite loop detection over standard shader" );
UIUtils.DetectNodeLoopsFrom( window.OutsideGraph.CurrentMasterNode, new Dictionary<int, int>() );
}
}
Debug.Log( "End infinite loop detection" );
}
}
}
}

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

@ -0,0 +1,47 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEditor;
using UnityEngine;
namespace AmplifyShaderEditor
{
public class DragAndDropTool
{
public delegate void OnValidDropObject(params UnityEngine.Object[] draggedObjs );
public event OnValidDropObject OnValidDropObjectEvt;
public void Destroy()
{
OnValidDropObjectEvt = null;
}
public void TestDragAndDrop( Rect dropArea )
{
Event currentEvent = Event.current;
EventType currentEventType = currentEvent.type;
switch (currentEventType)
{
case EventType.DragUpdated:
case EventType.DragPerform:
{
if (!dropArea.Contains(currentEvent.mousePosition))
return;
DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
if (currentEvent.type == EventType.DragPerform)
{
DragAndDrop.AcceptDrag();
if (OnValidDropObjectEvt != null)
{
OnValidDropObjectEvt(DragAndDrop.objectReferences);
}
}
}break;
case EventType.DragExited:DragAndDrop.PrepareStartDrag();break;
}
}
}
}

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

@ -0,0 +1,375 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using System.Collections.Generic;
using UnityEngine;
namespace AmplifyShaderEditor
{
[Serializable]
public class DuplicatePreventionBuffer
{
private const string VectorNameStr = "Vector ";
private const string TextureSampleNameStr = "Texture Sample ";
private const string MatrixNameStr = "Matrix ";
private const string IntNameStr = "Int ";
private const string FloatNameStr = "Float ";
private const string ColorNameStr = "Color ";
[SerializeField]
private int[] m_availableUVChannelsArray = { -1, -1, -1, -1 };
private string[] m_availableUVChannelsNamesArray = { "null",
"null",
"null",
"null" };
private Dictionary<string, int> m_availablePropertyNames = new Dictionary<string, int>();
private Dictionary<string, int> m_availableUniformNames = new Dictionary<string, int>();
private Dictionary<string, int> m_availableLocalVariableNames = new Dictionary<string, int>();
public void ReleaseAllUVChannels()
{
for ( int i = 0; i < m_availableUVChannelsArray.Length; i++ )
{
m_availableUVChannelsArray[ i ] = -1;
}
}
public bool RegisterUVChannel( int nodeId, int channelId, string name )
{
if ( channelId < 0 ||
channelId > ( m_availableUVChannelsArray.Length - 1 ) ||
m_availableUVChannelsArray[ channelId ] >= 0 )
{
return false;
}
m_availableUVChannelsArray[ channelId ] = nodeId;
m_availableUVChannelsNamesArray[ channelId ] = name;
return true;
}
public bool ReleaseUVChannel( int nodeId, int channelId )
{
if ( channelId < 0 ||
channelId > ( m_availableUVChannelsArray.Length - 1 ) )
{
return false;
}
if ( m_availableUVChannelsArray[ channelId ] == nodeId )
{
m_availableUVChannelsArray[ channelId ] = -1;
return true;
}
return false;
}
public int RegisterFirstAvailableChannel( int nodeId , string name)
{
for ( int i = 0; i < m_availableUVChannelsArray.Length; i++ )
{
if ( m_availableUVChannelsArray[ i ] == -1 )
{
m_availableUVChannelsArray[ i ] = nodeId;
m_availableUVChannelsNamesArray[ i ] = name;
return i;
}
}
return -1;
}
public bool IsChannelAvailable( int channelId )
{
if ( channelId < 0 ||
channelId > ( m_availableUVChannelsArray.Length - 1 ) )
{
return false;
}
return ( m_availableUVChannelsArray[ channelId ] < 0 );
}
public int GetFirstOccupiedChannel()
{
for ( int i = 0; i < 4; i++ )
{
if ( m_availableUVChannelsArray[ i ] > -1 )
return i;
}
return -1;
}
public string GetChannelName( int channelId )
{
if ( channelId < 0 ||
channelId > ( m_availableUVChannelsArray.Length - 1 ) )
{
return string.Empty;
}
return m_availableUVChannelsNamesArray[ channelId ] ;
}
public void SetChannelName( int channelId , string name )
{
if ( channelId < 0 ||
channelId > ( m_availableUVChannelsArray.Length - 1 ) )
{
return;
}
m_availableUVChannelsNamesArray[ channelId ] = name;
}
public bool RegisterLocalVariableName( int nodeId, string name )
{
if ( name.Length == 0 )
return false;
if ( m_availableLocalVariableNames.ContainsKey( name ) )
{
if ( m_availableLocalVariableNames[ name ] > -1 )
{
return false;
}
else
{
m_availableLocalVariableNames[ name ] = nodeId;
return true;
}
}
m_availableLocalVariableNames.Add( name, nodeId );
return true;
}
public int CheckUniformNameOwner( string name )
{
if ( name.Length == 0 )
return -1;
if ( m_availableUniformNames.ContainsKey( name ) )
{
return m_availableUniformNames[ name ];
}
return -1;
}
public bool RegisterUniformName( int nodeId, string name )
{
if ( name.Length == 0 )
return false;
if ( m_availableUniformNames.ContainsKey( name ) )
{
if ( m_availableUniformNames[ name ] > -1 )
{
return false;
}
else
{
m_availableUniformNames[ name ] = nodeId;
return true;
}
}
m_availableUniformNames.Add( name, nodeId );
return true;
}
public void DumpUniformNames()
{
string val = "CONTENTS\n";
foreach ( KeyValuePair<string, int> kvp in m_availableUniformNames )
{
val += ( "key " + kvp.Key + " : value " + kvp.Value + "\n" );
}
}
public void DumpLocalVariableNames()
{
string val = "CONTENTS\n";
foreach ( KeyValuePair<string, int> kvp in m_availableLocalVariableNames )
{
val += ( "key " + kvp.Key + " : value " + kvp.Value + "\n" );
}
}
public bool ReleaseUniformName( int nodeId, string name )
{
if ( !string.IsNullOrEmpty(name) && name.Length == 0 )
return false;
if ( m_availableUniformNames.ContainsKey( name ) )
{
if ( m_availableUniformNames[ name ] == nodeId )
{
m_availableUniformNames.Remove( name );
return true;
}
}
return false;
}
public bool ReleaseLocalVariableName( int nodeId, string name )
{
if ( name.Length == 0 )
return false;
if ( m_availableLocalVariableNames.ContainsKey( name ) )
{
if ( m_availableLocalVariableNames[ name ] == nodeId )
{
m_availableLocalVariableNames.Remove( name );
return true;
}
}
return false;
}
public void ReleaseAllUniformNames()
{
m_availableUniformNames.Clear();
}
public void ReleaseAllLocalVariableNames()
{
m_availableLocalVariableNames.Clear();
}
public void GetFirstAvailableName( int nodeId, WirePortDataType type , out string outProperty , out string outInspector, bool useCustomPrefix = false, string customPrefix = null)
{
string name = string.Empty;
if ( useCustomPrefix && customPrefix != null )
{
name = customPrefix;
}
else
{
switch ( type )
{
case WirePortDataType.OBJECT:
case WirePortDataType.FLOAT:
{
name = FloatNameStr;
}
break;
case WirePortDataType.INT:
{
name = IntNameStr;
}
break;
case WirePortDataType.FLOAT2:
case WirePortDataType.FLOAT3:
case WirePortDataType.FLOAT4:
{
name = VectorNameStr;
}
break;
case WirePortDataType.FLOAT3x3:
case WirePortDataType.FLOAT4x4:
{
name = MatrixNameStr;
}
break;
case WirePortDataType.COLOR:
{
name = ColorNameStr;
}
break;
}
}
int count = 0;
bool foundName = false;
while ( !foundName )
{
string inspectorName = name + count;
string propertyName = UIUtils.GeneratePropertyName( inspectorName , PropertyType.Property );
if ( IsUniformNameAvailable( propertyName ) )
{
outInspector = inspectorName;
outProperty = propertyName;
RegisterUniformName( nodeId, propertyName );
return;
}
count += 1;
}
outProperty = string.Empty;
outInspector = string.Empty;
UIUtils.ShowMessage( "Could not find a valid name " + MessageSeverity.Warning );
}
public bool IsUniformNameAvailable( string name )
{
if ( m_availableUniformNames.ContainsKey( name ) && m_availableUniformNames[ name ] > -1 )
return false;
return true;
}
public bool IsLocalvariableNameAvailable( string name )
{
if ( m_availableLocalVariableNames.ContainsKey( name ) && m_availableLocalVariableNames[ name ] > -1 )
return false;
return true;
}
public bool GetPropertyName( int nodeId, string name )
{
if ( m_availablePropertyNames.ContainsKey( name ) )
{
if ( m_availablePropertyNames[ name ] > -1 )
{
return false;
}
else
{
m_availablePropertyNames[ name ] = nodeId;
return true;
}
}
m_availablePropertyNames.Add( name, nodeId );
return true;
}
public bool ReleasePropertyName( int nodeId, string name )
{
if ( m_availablePropertyNames.ContainsKey( name ) )
{
if ( m_availablePropertyNames[ name ] == nodeId )
{
m_availablePropertyNames[ name ] = -1;
return true;
}
}
return false;
}
public void ReleaseAllPropertyNames()
{
m_availablePropertyNames.Clear();
}
public bool IsPropertyNameAvailable( string name )
{
if ( m_availablePropertyNames.ContainsKey( name ) && m_availablePropertyNames[ name ] > -1 )
return false;
return true;
}
public void ReleaseAllData()
{
ReleaseAllUVChannels();
ReleaseAllUniformNames();
ReleaseAllPropertyNames();
ReleaseAllLocalVariableNames();
}
}
}

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

@ -0,0 +1,393 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using UnityEditor;
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Reflection;
namespace AmplifyShaderEditor
{
public class ShortcutKeyData
{
public bool IsPressed;
public System.Type NodeType;
public string Name;
public ShortcutKeyData( System.Type type, string name )
{
NodeType = type;
Name = name;
IsPressed = false;
}
}
public class GraphContextMenu
{
private List<ContextMenuItem> m_items;
private List<ContextMenuItem> m_itemFunctions;
private Dictionary<System.Type, NodeAttributes> m_itemsDict;
private Dictionary<System.Type, NodeAttributes> m_deprecatedItemsDict;
private Dictionary<System.Type, System.Type> m_castTypes;
private Dictionary<KeyCode, ShortcutKeyData> m_shortcutTypes;
private KeyCode m_lastKeyPressed;
private ParentGraph m_currentGraph;
private bool m_correctlyLoaded = false;
public GraphContextMenu( ParentGraph currentGraph )
{
m_currentGraph = currentGraph;
m_correctlyLoaded = RefreshNodes( currentGraph );
}
private Type[] GetTypesInNamespace( Assembly assembly, string nameSpace )
{
return assembly.GetTypes().Where( t => String.Equals( t.Namespace, nameSpace, StringComparison.Ordinal ) ).ToArray();
}
public bool RefreshNodes( ParentGraph currentGraph )
{
if( m_items != null )
{
m_items.Clear();
m_items = null;
}
if( m_itemFunctions != null )
{
m_itemFunctions.Clear();
m_itemFunctions = null;
}
m_items = new List<ContextMenuItem>();
m_itemFunctions = new List<ContextMenuItem>();
if( m_itemsDict != null )
m_itemsDict.Clear();
m_itemsDict = new Dictionary<System.Type, NodeAttributes>();
if( m_deprecatedItemsDict != null )
m_deprecatedItemsDict.Clear();
m_deprecatedItemsDict = new Dictionary<System.Type, NodeAttributes>();
if( m_castTypes != null )
m_castTypes.Clear();
m_castTypes = new Dictionary<System.Type, System.Type>();
if( m_shortcutTypes != null )
m_shortcutTypes.Clear();
m_shortcutTypes = new Dictionary<KeyCode, ShortcutKeyData>();
m_lastKeyPressed = KeyCode.None;
// Fetch all available nodes by their attributes
try
{
//IEnumerable<System.Type> availableTypes = AppDomain.CurrentDomain.GetAssemblies().ToList().SelectMany( type => type.GetTypes() );
var mainAssembly = Assembly.GetExecutingAssembly();
Type[] availableTypes = GetTypesInNamespace( mainAssembly, "AmplifyShaderEditor" );
#if UNITY_2017_3_OR_NEWER
try
{
var editorAssembly = Assembly.Load( "Assembly-CSharp-Editor" );
if( mainAssembly != editorAssembly )
{
Type[] extraTypes = GetTypesInNamespace( editorAssembly, "AmplifyShaderEditor" );
availableTypes = availableTypes.Concat<Type>( extraTypes ).ToArray();
}
}
catch( Exception )
{
// quiet catch because we don't care if it fails to find the assembly, we'll just skip it
}
#endif
foreach( System.Type type in availableTypes )
{
foreach( NodeAttributes attribute in Attribute.GetCustomAttributes( type ).OfType<NodeAttributes>() )
{
if( attribute.Available && !attribute.Deprecated )
{
//if ( !UIUtils.CurrentWindow.IsShaderFunctionWindow && attribute.AvailableInFunctionsOnly )
// continue;
if( !UIUtils.HasColorCategory( attribute.Category ) )
{
if( !String.IsNullOrEmpty( attribute.CustomCategoryColor ) )
{
try
{
Color color = new Color();
ColorUtility.TryParseHtmlString( attribute.CustomCategoryColor, out color );
UIUtils.AddColorCategory( attribute.Category, color );
}
catch( Exception e )
{
Debug.LogException( e );
UIUtils.AddColorCategory( attribute.Category, Constants.DefaultCategoryColor );
}
}
//else
//{
// UIUtils.AddColorCategory( attribute.Category, Constants.DefaultCategoryColor );
//}
}
if( attribute.CastType != null && attribute.CastType.Length > 0 && type != null )
{
for( int i = 0; i < attribute.CastType.Length; i++ )
{
m_castTypes.Add( attribute.CastType[ i ], type );
}
}
if( attribute.ShortcutKey != KeyCode.None && type != null )
m_shortcutTypes.Add( attribute.ShortcutKey, new ShortcutKeyData( type, attribute.Name ) );
ContextMenuItem newItem = new ContextMenuItem( attribute, type, attribute.Name, attribute.Tags, attribute.Category, attribute.Description, null, attribute.ShortcutKey );
if( UIUtils.GetNodeAvailabilityInBitArray( attribute.NodeAvailabilityFlags, NodeAvailability.SurfaceShader ) )
m_items.Add( newItem );
else if( UIUtils.GetNodeAvailabilityInBitArray( attribute.NodeAvailabilityFlags, currentGraph.ParentWindow.CurrentNodeAvailability ) )
m_items.Add( newItem );
else if( UIUtils.GetNodeAvailabilityInBitArray( attribute.NodeAvailabilityFlags, currentGraph.CurrentCanvasMode ) )
m_items.Add( newItem );
m_itemsDict.Add( type, attribute );
m_itemFunctions.Add( newItem );
}
else
{
m_deprecatedItemsDict.Add( type, attribute );
}
}
}
}
catch( ReflectionTypeLoadException exception )
{
Debug.LogException( exception );
return false;
}
string[] guids = AssetDatabase.FindAssets( "t:AmplifyShaderFunction" );
List<AmplifyShaderFunction> allFunctions = new List<AmplifyShaderFunction>();
for( int i = 0; i < guids.Length; i++ )
{
allFunctions.Add( AssetDatabase.LoadAssetAtPath<AmplifyShaderFunction>( AssetDatabase.GUIDToAssetPath( guids[ i ] ) ) );
}
int functionCount = allFunctions.Count;
if( functionCount > 0 )
{
m_castTypes.Add( typeof( AmplifyShaderFunction ), typeof( FunctionNode ) );
}
for( int i = 0; i < functionCount; i++ )
{
if( !allFunctions[ i ].Hidden )
{
NodeAttributes attribute = new NodeAttributes( allFunctions[ i ].FunctionName, allFunctions[ i ].CustomNodeCategory, allFunctions[ i ].Description, KeyCode.None, true, 0, int.MaxValue, typeof( AmplifyShaderFunction ) );
System.Type type = typeof( FunctionNode );
ContextMenuItem newItem = new ContextMenuItem( attribute, type, AddSpacesToSentence( attribute.Name ), attribute.Tags, attribute.Category, attribute.Description, allFunctions[ i ], attribute.ShortcutKey );
m_items.Add( newItem );
m_itemFunctions.Add( newItem );
}
}
//Sort out the final list by name
m_items.Sort( ( x, y ) => x.Category.CompareTo( y.Category ) );
m_itemFunctions.Sort( ( x, y ) => x.Category.CompareTo( y.Category ) );
return true;
}
public void Destroy()
{
for( int i = 0; i < m_items.Count; i++ )
{
m_items[ i ].Destroy();
}
for( int i = 0; i < m_itemFunctions.Count; i++ )
{
if( m_itemFunctions[ i ] != null )
m_itemFunctions[ i ].Destroy();
}
m_items.Clear();
m_items = null;
m_itemFunctions.Clear();
m_itemFunctions = null;
m_itemsDict.Clear();
m_itemsDict = null;
m_deprecatedItemsDict.Clear();
m_deprecatedItemsDict = null;
m_castTypes.Clear();
m_castTypes = null;
m_shortcutTypes.Clear();
m_shortcutTypes = null;
}
public static string AddSpacesToSentence( string text )
{
if( string.IsNullOrEmpty( text ) )
return string.Empty;
bool lastIsUpper = char.IsUpper( text, 0 );
bool lastIsLetter = char.IsLetter( text, 0 );
StringBuilder title = new StringBuilder();
title.Append( text[ 0 ] );
for( int i = 1; i < text.Length; i++ )
{
bool currIsUpper = char.IsUpper( text, i );
bool currIsLetter = char.IsLetter( text, i );
if( currIsUpper && !lastIsUpper && lastIsLetter )
{
title.Append( " " );
}
// if current is a number and previous is a letter we space it (ie: Rotation2D = Rotation 2D)
if( lastIsLetter && char.IsNumber( text, i ) )
{
title.Append( " " );
}
// if previous is upper, current is upper and the next two following are lower then we space it (ie: UVDistortion = UV Distortion)
if( i < text.Length - 1 )
{
bool nextIsLower = char.IsLower( text, i + 1 ) && char.IsLetter( text, i + 1 );
bool lastIsLower = i < text.Length - 2 ? char.IsLower( text, i + 2 ) && char.IsLetter( text, i + 2 ) : false;
if( lastIsUpper && currIsUpper && currIsLetter && nextIsLower && lastIsLower )
{
title.Append( " " );
}
}
lastIsUpper = currIsUpper;
lastIsLetter = currIsLetter;
title.Append( text[ i ] );
}
return title.ToString();
}
public NodeAttributes GetNodeAttributesForType( System.Type type )
{
if( type == null )
{
Debug.LogError( "Invalid type detected" );
return null;
}
if( m_itemsDict.ContainsKey( type ) )
return m_itemsDict[ type ];
return null;
}
public NodeAttributes GetDeprecatedNodeAttributesForType( System.Type type )
{
if( m_deprecatedItemsDict.ContainsKey( type ) )
return m_deprecatedItemsDict[ type ];
return null;
}
public void UpdateKeyPress( KeyCode key )
{
if( key == KeyCode.None )
return;
m_lastKeyPressed = key;
if( m_shortcutTypes.ContainsKey( key ) )
{
m_shortcutTypes[ key ].IsPressed = true;
}
}
public void UpdateKeyReleased( KeyCode key )
{
if( key == KeyCode.None )
return;
if( m_shortcutTypes.ContainsKey( key ) )
{
m_shortcutTypes[ key ].IsPressed = false;
}
}
public void ResetShortcutKeyStates()
{
foreach( KeyValuePair<KeyCode, ShortcutKeyData> kvp in m_shortcutTypes )
{
kvp.Value.IsPressed = false;
}
}
public ParentNode CreateNodeFromCastType( System.Type type )
{
if( m_castTypes.ContainsKey( type ) )
{
ParentNode newNode = (ParentNode)ScriptableObject.CreateInstance( m_castTypes[ type ] );
return newNode;
}
return null;
}
public ParentNode CreateNodeFromShortcutKey()
{
if( m_lastKeyPressed == KeyCode.None )
return null;
if( m_shortcutTypes.ContainsKey( m_lastKeyPressed ) && m_shortcutTypes[ m_lastKeyPressed ].IsPressed )
{
ParentNode newNode = (ParentNode)ScriptableObject.CreateInstance( m_shortcutTypes[ m_lastKeyPressed ].NodeType );
return newNode;
}
return null;
}
public bool CheckShortcutKey()
{
if( m_lastKeyPressed == KeyCode.None )
return false;
if( m_shortcutTypes.ContainsKey( m_lastKeyPressed ) && m_shortcutTypes[ m_lastKeyPressed ].IsPressed )
{
return true;
}
return false;
}
public List<ContextMenuItem> MenuItems
{
get
{
if( m_currentGraph.ParentWindow.IsShaderFunctionWindow )
return m_itemFunctions;
else
return m_items;
}
}
public List<ContextMenuItem> ItemFunctions { get { return m_itemFunctions; } }
public KeyCode LastKeyPressed
{
get { return m_lastKeyPressed; }
}
public Dictionary<KeyCode, ShortcutKeyData> NodeShortcuts { get { return m_shortcutTypes; } }
public bool CorrectlyLoaded { get { return m_correctlyLoaded; } }
}
}

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

@ -0,0 +1,451 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using UnityEditor;
namespace AmplifyShaderEditor
{
public enum MenuAnchor
{
TOP_LEFT = 0,
TOP_CENTER,
TOP_RIGHT,
MIDDLE_LEFT,
MIDDLE_CENTER,
MIDDLE_RIGHT,
BOTTOM_LEFT,
BOTTOM_CENTER,
BOTTOM_RIGHT,
NONE
}
public enum MenuAutoSize
{
MATCH_VERTICAL = 0,
MATCH_HORIZONTAL,
NONE
}
public class MenuParent
{
protected AmplifyShaderEditorWindow m_parentWindow = null;
protected const float MinimizeButtonXSpacing = 5;
protected const float MinimizeButtonYSpacing = 5.5f;
protected const float ResizeAreaWidth = 5;
protected const float MinimizeCollisionAdjust = 5;
protected GUIStyle m_style;
protected GUIContent m_content;
protected Rect m_maximizedArea;
protected Rect m_transformedArea;
protected Rect m_resizeArea;
protected MenuAnchor m_anchor;
protected MenuAutoSize m_autoSize;
protected bool m_isActive = true;
protected bool m_isMaximized = true;
protected bool m_lockOnMinimize = false;
protected bool m_preLockState = false;
protected Rect m_minimizedArea;
protected Rect m_minimizeButtonPos;
protected float m_realWidth;
protected GUIStyle m_empty = new GUIStyle();
protected float m_resizeDelta;
protected bool m_isResizing = false;
protected bool m_resizable = false;
protected GUIStyle m_resizeAreaStyle;
protected bool m_isMouseInside = false;
protected Vector2 m_currentScrollPos;
public MenuParent( AmplifyShaderEditorWindow parentWindow, float x, float y, float width, float height, string name, MenuAnchor anchor = MenuAnchor.NONE, MenuAutoSize autoSize = MenuAutoSize.NONE )
{
m_parentWindow = parentWindow;
m_anchor = anchor;
m_autoSize = autoSize;
m_maximizedArea = new Rect( x, y, width, height );
m_content = new GUIContent( GUIContent.none );
m_content.text = name;
m_transformedArea = new Rect();
m_resizeArea = new Rect();
m_resizeArea.width = ResizeAreaWidth;
m_resizeAreaStyle = GUIStyle.none;
m_currentScrollPos = Vector2.zero;
}
public void SetMinimizedArea( float x, float y, float width, float height )
{
m_minimizedArea = new Rect( x, y, width, height );
}
protected void InitDraw( Rect parentPosition, Vector2 mousePosition, int mouseButtonId )
{
if ( m_style == null )
{
m_style = new GUIStyle( UIUtils.TextArea );
#if UNITY_2019_3_OR_NEWER
m_style.normal.background = m_style.normal.scaledBackgrounds[ 0 ];
m_style.normal.scaledBackgrounds = null;
m_style.border = new RectOffset( 4, 4, 4, 4 );
#endif
m_style.stretchHeight = true;
m_style.stretchWidth = true;
m_style.fontSize = ( int ) Constants.DefaultTitleFontSize;
m_style.fontStyle = FontStyle.Normal;
Texture minimizeTex = UIUtils.GetCustomStyle( CustomStyle.MaximizeButton ).normal.background;
m_minimizeButtonPos = new Rect( 0, 0, minimizeTex.width, minimizeTex.height );
}
Rect currentArea = m_isMaximized ? m_maximizedArea : m_minimizedArea;
if ( m_isMaximized )
{
if ( m_resizable )
{
if ( m_isResizing )
{
if ( m_anchor == MenuAnchor.TOP_LEFT )
m_resizeDelta = ( ParentWindow.CurrentEvent.mousePosition.x - m_maximizedArea.width );
else if ( m_anchor == MenuAnchor.TOP_RIGHT )
m_resizeDelta = ParentWindow.CurrentEvent.mousePosition.x - ( parentPosition.width - m_maximizedArea.width);
}
}
m_realWidth = m_maximizedArea.width;
if ( m_resizable )
{
if ( m_anchor == MenuAnchor.TOP_LEFT )
{
currentArea.width += m_resizeDelta;
m_realWidth += m_resizeDelta;
}
else if ( m_anchor == MenuAnchor.TOP_RIGHT )
{
currentArea.width -= m_resizeDelta;
m_realWidth -= m_resizeDelta;
}
}
}
else
{
if ( currentArea.x < 0 )
{
m_realWidth = currentArea.width + currentArea.x;
}
else if ( ( currentArea.x + currentArea.width ) > parentPosition.width )
{
m_realWidth = parentPosition.width - currentArea.x;
}
if ( m_realWidth < 0 )
m_realWidth = 0;
}
switch ( m_anchor )
{
case MenuAnchor.TOP_LEFT:
{
m_transformedArea.x = currentArea.x;
m_transformedArea.y = currentArea.y;
if ( m_isMaximized )
{
m_minimizeButtonPos.x = m_transformedArea.x + m_transformedArea.width - m_minimizeButtonPos.width - MinimizeButtonXSpacing;
m_minimizeButtonPos.y = m_transformedArea.y + MinimizeButtonYSpacing;
m_resizeArea.x = m_transformedArea.x + m_transformedArea.width;
m_resizeArea.y = m_minimizeButtonPos.y;
m_resizeArea.height = m_transformedArea.height;
}
else
{
float width = ( m_transformedArea.width - m_transformedArea.x );
m_minimizeButtonPos.x = m_transformedArea.x + width * 0.5f - m_minimizeButtonPos.width * 0.5f;
m_minimizeButtonPos.y = m_transformedArea.height * 0.5f - m_minimizeButtonPos.height * 0.5f;
}
}
break;
case MenuAnchor.TOP_CENTER:
{
m_transformedArea.x = parentPosition.width * 0.5f + currentArea.x;
m_transformedArea.y = currentArea.y;
}
break;
case MenuAnchor.TOP_RIGHT:
{
m_transformedArea.x = parentPosition.width - currentArea.x - currentArea.width;
m_transformedArea.y = currentArea.y;
if ( m_isMaximized )
{
m_minimizeButtonPos.x = m_transformedArea.x + MinimizeButtonXSpacing;
m_minimizeButtonPos.y = m_transformedArea.y + MinimizeButtonYSpacing;
m_resizeArea.x = m_transformedArea.x - ResizeAreaWidth;
m_resizeArea.y = m_minimizeButtonPos.y;
m_resizeArea.height = m_transformedArea.height;
}
else
{
float width = ( parentPosition.width - m_transformedArea.x );
m_minimizeButtonPos.x = m_transformedArea.x + width * 0.5f - m_minimizeButtonPos.width * 0.5f;
m_minimizeButtonPos.y = m_transformedArea.height * 0.5f - m_minimizeButtonPos.height * 0.5f;
}
}
break;
case MenuAnchor.MIDDLE_LEFT:
{
m_transformedArea.x = currentArea.x;
m_transformedArea.y = parentPosition.height * 0.5f + currentArea.y;
}
break;
case MenuAnchor.MIDDLE_CENTER:
{
m_transformedArea.x = parentPosition.width * 0.5f + currentArea.x;
m_transformedArea.y = parentPosition.height * 0.5f + currentArea.y;
}
break;
case MenuAnchor.MIDDLE_RIGHT:
{
m_transformedArea.x = parentPosition.width - currentArea.x - currentArea.width;
m_transformedArea.y = parentPosition.height * 0.5f + currentArea.y;
}
break;
case MenuAnchor.BOTTOM_LEFT:
{
m_transformedArea.x = currentArea.x;
m_transformedArea.y = parentPosition.height - currentArea.y - currentArea.height;
}
break;
case MenuAnchor.BOTTOM_CENTER:
{
m_transformedArea.x = parentPosition.width * 0.5f + currentArea.x;
m_transformedArea.y = parentPosition.height - currentArea.y - currentArea.height;
}
break;
case MenuAnchor.BOTTOM_RIGHT:
{
m_transformedArea.x = parentPosition.width - currentArea.x - currentArea.width;
m_transformedArea.y = parentPosition.height - currentArea.y - currentArea.height;
}
break;
case MenuAnchor.NONE:
{
m_transformedArea.x = currentArea.x;
m_transformedArea.y = currentArea.y;
}
break;
}
switch ( m_autoSize )
{
case MenuAutoSize.MATCH_HORIZONTAL:
{
m_transformedArea.width = parentPosition.width - m_transformedArea.x;
m_transformedArea.height = currentArea.height;
}
break;
case MenuAutoSize.MATCH_VERTICAL:
{
m_transformedArea.width = currentArea.width;
m_transformedArea.height = parentPosition.height - m_transformedArea.y;
}
break;
case MenuAutoSize.NONE:
{
m_transformedArea.width = currentArea.width;
m_transformedArea.height = currentArea.height;
}
break;
}
}
public virtual void Draw( Rect parentPosition, Vector2 mousePosition, int mouseButtonId, bool hasKeyboadFocus )
{
InitDraw( parentPosition, mousePosition, mouseButtonId );
if ( ParentWindow.CurrentEvent.type == EventType.MouseDrag && ParentWindow.CurrentEvent.button > 0 /*catches both middle and right mouse button*/ )
{
m_isMouseInside = IsInside( mousePosition );
if ( m_isMouseInside )
{
m_currentScrollPos.x += Constants.MenuDragSpeed * ParentWindow.CurrentEvent.delta.x;
if ( m_currentScrollPos.x < 0 )
m_currentScrollPos.x = 0;
m_currentScrollPos.y += Constants.MenuDragSpeed * ParentWindow.CurrentEvent.delta.y;
if ( m_currentScrollPos.y < 0 )
m_currentScrollPos.y = 0;
}
}
}
public void PostDraw()
{
if ( !m_isMaximized )
{
m_transformedArea.height = 35;
GUI.Label( m_transformedArea, m_content, m_style );
}
Color colorBuffer = GUI.color;
GUI.color = EditorGUIUtility.isProSkin ? Color.white : Color.black;
bool guiEnabledBuffer = GUI.enabled;
GUI.enabled = !m_lockOnMinimize;
Rect buttonArea = m_minimizeButtonPos;
buttonArea.x -= MinimizeCollisionAdjust;
buttonArea.width += 2 * MinimizeCollisionAdjust;
buttonArea.y -= MinimizeCollisionAdjust;
buttonArea.height += 2 * MinimizeCollisionAdjust;
if ( m_parentWindow.CameraDrawInfo.CurrentEventType == EventType.Repaint )
GUI.Label( m_minimizeButtonPos, string.Empty, UIUtils.GetCustomStyle( m_isMaximized ? CustomStyle.MinimizeButton : CustomStyle.MaximizeButton ) );
if( m_parentWindow.CameraDrawInfo.CurrentEventType == EventType.MouseDown && buttonArea.Contains( m_parentWindow.CameraDrawInfo.MousePosition ) )
//if ( GUI.Button( buttonArea, string.Empty, m_empty ) )
{
m_isMaximized = !m_isMaximized;
m_resizeDelta = 0;
}
if ( m_resizable && m_isMaximized )
{
EditorGUIUtility.AddCursorRect( m_resizeArea, MouseCursor.ResizeHorizontal );
if ( !m_isResizing && GUI.RepeatButton( m_resizeArea, string.Empty, m_resizeAreaStyle ) )
{
m_isResizing = true;
}
else
{
if ( m_isResizing )
{
if ( ParentWindow.CurrentEvent.isMouse && ParentWindow.CurrentEvent.type != EventType.MouseDrag )
{
m_isResizing = false;
}
}
}
if ( m_realWidth < buttonArea.width )
{
// Auto-minimize
m_isMaximized = false;
m_resizeDelta = 0;
m_isResizing = false;
}
else
{
float halfSizeWindow = 0.5f * ParentWindow.position.width;
if ( m_realWidth > halfSizeWindow )
{
m_realWidth = 0.5f * ParentWindow.position.width;
if ( m_resizeDelta > 0 )
{
m_resizeDelta = m_realWidth - m_maximizedArea.width;
}
else
{
m_resizeDelta = m_maximizedArea.width - m_realWidth;
}
}
}
}
GUI.enabled = guiEnabledBuffer;
GUI.color = colorBuffer;
}
public void OnLostFocus()
{
if ( m_isResizing )
{
m_isResizing = false;
}
}
virtual public void Destroy()
{
m_empty = null;
m_resizeAreaStyle = null;
}
public float InitialX
{
get { return m_maximizedArea.x; }
set { m_maximizedArea.x = value; }
}
public float Width
{
get { return m_maximizedArea.width; }
set { m_maximizedArea.width = value; }
}
public float RealWidth
{
get { return m_realWidth; }
}
public float Height
{
get { return m_maximizedArea.height; }
set { m_maximizedArea.height = value; }
}
public Rect Size
{
get { return m_maximizedArea; }
}
public virtual bool IsInside( Vector2 position )
{
if ( !m_isActive )
return false;
return m_transformedArea.Contains( position );
}
public bool IsMaximized
{
get { return m_isMaximized; }
set { m_isMaximized = value; }
}
public Rect TransformedArea
{
get { return m_transformedArea; }
}
public bool Resizable { set { m_resizable = value; } }
public bool IsResizing { get { return m_isResizing; } }
public bool LockOnMinimize
{
set
{
if ( m_lockOnMinimize == value )
return;
m_lockOnMinimize = value;
if ( value )
{
m_preLockState = m_isMaximized;
m_isMaximized = false;
}
else
{
m_isMaximized = m_preLockState;
}
}
}
public bool IsActive
{
get { return m_isActive; }
}
public AmplifyShaderEditorWindow ParentWindow { get { return m_parentWindow; } set { m_parentWindow = value; } }
}
}

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

@ -0,0 +1,557 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
using UnityEditorInternal;
namespace AmplifyShaderEditor
{
public sealed class NodeParametersWindow : MenuParent
{
private int m_lastSelectedNode = -1;
private const string TitleStr = "Node Properties";
private GUIStyle m_nodePropertiesStyle;
private GUIContent m_dummyContent = new GUIContent();
private GUIStyle m_propertyAdjustment;
private ReorderableList m_functionInputsReordableList = null;
private int m_functionInputsLastCount = 0;
private ReorderableList m_functionSwitchesReordableList = null;
private int m_functionSwitchesLastCount = 0;
private ReorderableList m_functionOutputsReordableList = null;
private int m_functionOutputsLastCount = 0;
private ReorderableList m_propertyReordableList = null;
private int m_lastCount = 0;
private bool m_forceUpdate = false;
[SerializeField]
private List<PropertyNode> m_propertyReordableNodes = new List<PropertyNode>();
// width and height are between [0,1] and represent a percentage of the total screen area
public NodeParametersWindow( AmplifyShaderEditorWindow parentWindow ) : base( parentWindow, 0, 0, 285, 0, string.Empty, MenuAnchor.TOP_LEFT, MenuAutoSize.MATCH_VERTICAL )
{
SetMinimizedArea( -225, 0, 260, 0 );
}
public void OnShaderFunctionLoad()
{
m_functionInputsReordableList = null;
m_functionSwitchesReordableList = null;
m_functionOutputsReordableList = null;
}
public bool Draw( Rect parentPosition, ParentNode selectedNode, Vector2 mousePosition, int mouseButtonId, bool hasKeyboardFocus )
{
bool changeCheck = false;
base.Draw( parentPosition, mousePosition, mouseButtonId, hasKeyboardFocus );
if ( m_nodePropertiesStyle == null )
{
m_nodePropertiesStyle = UIUtils.GetCustomStyle( CustomStyle.NodePropertiesTitle );
m_nodePropertiesStyle.normal.textColor = m_nodePropertiesStyle.active.textColor = EditorGUIUtility.isProSkin ? new Color( 1f, 1f, 1f ) : new Color( 0f, 0f, 0f );
}
if ( m_isMaximized )
{
KeyCode key = Event.current.keyCode;
if ( m_isMouseInside || hasKeyboardFocus )
{
if ( key == ShortcutsManager.ScrollUpKey )
{
m_currentScrollPos.y -= 10;
if ( m_currentScrollPos.y < 0 )
{
m_currentScrollPos.y = 0;
}
Event.current.Use();
}
if ( key == ShortcutsManager.ScrollDownKey )
{
m_currentScrollPos.y += 10;
Event.current.Use();
}
}
if( m_forceUpdate )
{
if( m_propertyReordableList != null )
m_propertyReordableList.ReleaseKeyboardFocus();
m_propertyReordableList = null;
if ( m_functionInputsReordableList != null )
m_functionInputsReordableList.ReleaseKeyboardFocus();
m_functionInputsReordableList = null;
if( m_functionSwitchesReordableList != null )
m_functionSwitchesReordableList.ReleaseKeyboardFocus();
m_functionSwitchesReordableList = null;
if ( m_functionOutputsReordableList != null )
m_functionOutputsReordableList.ReleaseKeyboardFocus();
m_functionOutputsReordableList = null;
m_forceUpdate = false;
}
GUILayout.BeginArea( m_transformedArea, m_content, m_style );
{
//Draw selected node parameters
if ( selectedNode != null )
{
// this hack is need because without it the several FloatFields/Textfields/... would show wrong values ( different from the ones they were assigned to show )
if ( m_lastSelectedNode != selectedNode.UniqueId )
{
m_lastSelectedNode = selectedNode.UniqueId;
GUI.FocusControl( "" );
}
EditorGUILayout.BeginVertical();
{
EditorGUILayout.Separator();
if ( selectedNode.UniqueId == ParentWindow.CurrentGraph.CurrentMasterNodeId )
{
m_dummyContent.text = "Output Node";
}
else
{
if ( selectedNode.Attributes != null )
{
m_dummyContent.text = selectedNode.Attributes.Name;
}
else if ( selectedNode is CommentaryNode )
{
m_dummyContent.text = "Commentary";
}
else
{
m_dummyContent.text = TitleStr;
}
}
EditorGUILayout.LabelField( m_dummyContent, m_nodePropertiesStyle );
EditorGUILayout.Separator();
//UIUtils.RecordObject( selectedNode , "Changing properties on node " + selectedNode.UniqueId);
m_currentScrollPos = EditorGUILayout.BeginScrollView( m_currentScrollPos, GUILayout.Width( 0 ), GUILayout.Height( 0 ) );
float labelWidth = EditorGUIUtility.labelWidth;
//if( selectedNode.TextLabelWidth > 0 )
// EditorGUIUtility.labelWidth = selectedNode.TextLabelWidth;
//else
EditorGUIUtility.labelWidth = TransformedArea.width * 0.42f;
changeCheck = selectedNode.SafeDrawProperties();
EditorGUIUtility.labelWidth = labelWidth;
EditorGUILayout.EndScrollView();
}
EditorGUILayout.EndVertical();
if ( changeCheck )
{
if ( selectedNode.ConnStatus == NodeConnectionStatus.Connected )
ParentWindow.SetSaveIsDirty();
}
}
else
{
//Draw Graph Params
EditorGUILayout.BeginVertical();
{
EditorGUILayout.Separator();
EditorGUILayout.LabelField( "Graph Properties", m_nodePropertiesStyle );
EditorGUILayout.Separator();
m_currentScrollPos = EditorGUILayout.BeginScrollView( m_currentScrollPos, GUILayout.Width( 0 ), GUILayout.Height( 0 ) );
float labelWidth = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = 90;
bool generalIsVisible = m_parentWindow.InnerWindowVariables.ExpandedGeneralShaderOptions;
NodeUtils.DrawPropertyGroup( ref generalIsVisible, " General", DrawGeneralFunction );
m_parentWindow.InnerWindowVariables.ExpandedGeneralShaderOptions = generalIsVisible;
AmplifyShaderFunction function = ParentWindow.CurrentGraph.CurrentShaderFunction;
if( function != null )
{
//function.AdditionalIncludes.Draw( ParentWindow.CurrentGraph.CurrentOutputNode );
//function.AdditionalPragmas.Draw( ParentWindow.CurrentGraph.CurrentOutputNode );
function.AdditionalDirectives.Draw( ParentWindow.CurrentGraph.CurrentOutputNode );
}
bool inputIsVisible = m_parentWindow.InnerWindowVariables.ExpandedFunctionInputs;
NodeUtils.DrawPropertyGroup( ref inputIsVisible, " Function Inputs", DrawFunctionInputs );
m_parentWindow.InnerWindowVariables.ExpandedFunctionInputs = inputIsVisible;
bool swicthIsVisible = m_parentWindow.InnerWindowVariables.ExpandedFunctionSwitches;
NodeUtils.DrawPropertyGroup( ref swicthIsVisible, " Function Switches", DrawFunctionSwitches );
m_parentWindow.InnerWindowVariables.ExpandedFunctionSwitches = swicthIsVisible;
bool outputIsVisible = m_parentWindow.InnerWindowVariables.ExpandedFunctionOutputs;
NodeUtils.DrawPropertyGroup( ref outputIsVisible, " Function Outputs", DrawFunctionOutputs );
m_parentWindow.InnerWindowVariables.ExpandedFunctionOutputs = outputIsVisible;
bool properties = ParentWindow.InnerWindowVariables.ExpandedProperties;
NodeUtils.DrawPropertyGroup( ref properties, " Material Properties", DrawFunctionProperties );
ParentWindow.InnerWindowVariables.ExpandedProperties = properties;
EditorGUIUtility.labelWidth = labelWidth;
EditorGUILayout.EndScrollView();
}
EditorGUILayout.EndVertical();
}
}
// Close window area
GUILayout.EndArea();
}
PostDraw();
return changeCheck;
}
public void DrawGeneralFunction()
{
AmplifyShaderFunction function = ParentWindow.CurrentGraph.CurrentShaderFunction;
if ( function == null )
return;
float cacheWidth = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = 115;
SerializedObject serializedObject = new UnityEditor.SerializedObject( function );
if ( serializedObject != null )
{
SerializedProperty temo = serializedObject.FindProperty( "m_description" );
EditorGUILayout.PropertyField( temo, new GUIContent( " Description" ) );
SerializedProperty cat = serializedObject.FindProperty( "m_nodeCategory" );
SerializedProperty ppos = serializedObject.FindProperty( "m_previewPosition" );
EditorGUILayout.PropertyField( ppos, new GUIContent( "Preview Position" ) );
cat.intValue = ParentWindow.CurrentGraph.CurrentOutputNode.EditorGUILayoutPopup( "Category", cat.intValue, UIUtils.CategoryPresets );
if( cat.enumValueIndex == 0 )
{
SerializedProperty custCat = serializedObject.FindProperty( "m_customNodeCategory" );
EditorGUILayout.PropertyField( custCat, new GUIContent( "Custom" ) );
}
SerializedProperty hidden = serializedObject.FindProperty( "m_hidden" );
EditorGUILayout.PropertyField( hidden, new GUIContent( "Hidden" ) );
serializedObject.ApplyModifiedProperties();
}
EditorGUIUtility.labelWidth = cacheWidth;
}
public void DrawFunctionInputs()
{
List<FunctionInput> functionInputNodes = UIUtils.FunctionInputList();
if ( m_functionInputsReordableList == null || functionInputNodes.Count != m_functionInputsLastCount )
{
functionInputNodes.Sort( ( x, y ) => { return x.OrderIndex.CompareTo( y.OrderIndex ); } );
m_functionInputsReordableList = new ReorderableList( functionInputNodes, typeof( FunctionInput ), true, false, false, false );
m_functionInputsReordableList.headerHeight = 0;
m_functionInputsReordableList.footerHeight = 0;
m_functionInputsReordableList.showDefaultBackground = false;
m_functionInputsReordableList.drawElementCallback = ( Rect rect, int index, bool isActive, bool isFocused ) =>
{
EditorGUI.LabelField( rect, functionInputNodes[ index ].InputName );
};
m_functionInputsReordableList.onChangedCallback = ( list ) =>
{
//for ( int i = 0; i < functionInputNodes.Count; i++ )
//{
// functionInputNodes[ i ].OrderIndex = i;
//}
ForceInputReorder( ref functionInputNodes );
};
m_functionInputsLastCount = m_functionInputsReordableList.count;
}
if ( m_functionInputsReordableList != null )
{
if ( m_propertyAdjustment == null )
{
m_propertyAdjustment = new GUIStyle();
m_propertyAdjustment.padding.left = 17;
}
EditorGUILayout.BeginVertical( m_propertyAdjustment );
m_functionInputsReordableList.DoLayoutList();
EditorGUILayout.EndVertical();
}
}
public void ForceInputReorder( ref List<FunctionInput> functionInputNodes )
{
for( int i = 0; i < functionInputNodes.Count; i++ )
{
functionInputNodes[ i ].OrderIndex = i;
}
}
public void DrawFunctionSwitches()
{
List<FunctionSwitch> functionSwitchNodes = UIUtils.FunctionSwitchList();
if( m_functionSwitchesReordableList == null || functionSwitchNodes.Count != m_functionSwitchesLastCount )
{
functionSwitchNodes.Sort( ( x, y ) => { return x.OrderIndex.CompareTo( y.OrderIndex ); } );
UIUtils.UpdateFunctionSwitchArr();
m_functionSwitchesReordableList = new ReorderableList( functionSwitchNodes, typeof( FunctionSwitch ), true, false, false, false );
m_functionSwitchesReordableList.headerHeight = 0;
m_functionSwitchesReordableList.footerHeight = 0;
m_functionSwitchesReordableList.showDefaultBackground = false;
m_functionSwitchesReordableList.drawElementCallback = ( Rect rect, int index, bool isActive, bool isFocused ) =>
{
EditorGUI.LabelField( rect, functionSwitchNodes[ index ].OptionLabel );
};
m_functionSwitchesReordableList.onChangedCallback = ( list ) =>
{
ForceSwitchesReorder(ref functionSwitchNodes );
};
m_functionSwitchesLastCount = m_functionSwitchesReordableList.count;
}
if( m_functionSwitchesReordableList != null )
{
if( m_propertyAdjustment == null )
{
m_propertyAdjustment = new GUIStyle();
m_propertyAdjustment.padding.left = 17;
}
EditorGUILayout.BeginVertical( m_propertyAdjustment );
m_functionSwitchesReordableList.DoLayoutList();
EditorGUILayout.EndVertical();
}
}
public void ForceSwitchesReorder( ref List<FunctionSwitch> functionSwitchNodes )
{
for( int i = 0; i < functionSwitchNodes.Count; i++ )
{
functionSwitchNodes[ i ].OrderIndex = i;
}
UIUtils.UpdateFunctionSwitchArr();
}
public void DrawFunctionOutputs()
{
List<FunctionOutput> functionOutputNodes = UIUtils.FunctionOutputList();
if ( m_functionOutputsReordableList == null || functionOutputNodes.Count != m_functionOutputsLastCount )
{
functionOutputNodes.Sort( ( x, y ) => { return x.OrderIndex.CompareTo( y.OrderIndex ); } );
m_functionOutputsReordableList = new ReorderableList( functionOutputNodes, typeof( FunctionOutput ), true, false, false, false );
m_functionOutputsReordableList.headerHeight = 0;
m_functionOutputsReordableList.footerHeight = 0;
m_functionOutputsReordableList.showDefaultBackground = false;
m_functionOutputsReordableList.drawElementCallback = ( Rect rect, int index, bool isActive, bool isFocused ) =>
{
EditorGUI.LabelField( rect, functionOutputNodes[ index ].OutputName );
};
m_functionOutputsReordableList.onChangedCallback = ( list ) =>
{
for ( int i = 0; i < functionOutputNodes.Count; i++ )
{
functionOutputNodes[ i ].OrderIndex = i;
}
};
m_functionOutputsLastCount = m_functionOutputsReordableList.count;
}
if ( m_functionOutputsReordableList != null )
{
if ( m_propertyAdjustment == null )
{
m_propertyAdjustment = new GUIStyle();
m_propertyAdjustment.padding.left = 17;
}
EditorGUILayout.BeginVertical( m_propertyAdjustment );
m_functionOutputsReordableList.DoLayoutList();
EditorGUILayout.EndVertical();
}
}
private void RefreshVisibleList( ref List<PropertyNode> allNodes )
{
// temp reference for lambda expression
List<PropertyNode> nodes = allNodes;
m_propertyReordableNodes.Clear();
for( int i = 0; i < nodes.Count; i++ )
{
ReordenatorNode rnode = nodes[ i ] as ReordenatorNode;
if( ( rnode == null || !rnode.IsInside ) && ( !m_propertyReordableNodes.Exists( x => x.PropertyName.Equals( nodes[ i ].PropertyName ) ) ) )
m_propertyReordableNodes.Add( nodes[ i ] );
}
m_propertyReordableNodes.Sort( ( x, y ) => { return x.OrderIndex.CompareTo( y.OrderIndex ); } );
}
public void DrawFunctionProperties()
{
List<PropertyNode> nodes = UIUtils.PropertyNodesList();
if( nodes.Count != m_lastCount )
{
RefreshVisibleList( ref nodes );
m_lastCount = nodes.Count;
}
if( m_propertyReordableList == null )
{
m_propertyReordableList = new ReorderableList( m_propertyReordableNodes, typeof( PropertyNode ), true, false, false, false )
{
headerHeight = 0,
footerHeight = 0,
showDefaultBackground = false,
drawElementCallback = ( Rect rect, int index, bool isActive, bool isFocused ) =>
{
var first = rect;
first.width *= 0.60f;
EditorGUI.LabelField( first, m_propertyReordableNodes[ index ].PropertyInspectorName );
var second = rect;
second.width *= 0.4f;
second.x += first.width;
if( GUI.Button( second, m_propertyReordableNodes[ index ].PropertyName, new GUIStyle( "AssetLabel Partial" ) ) )
{
UIUtils.FocusOnNode( m_propertyReordableNodes[ index ], 1, false );
}
},
onReorderCallback = ( list ) =>
{
ReorderList( ref nodes );
}
};
ReorderList( ref nodes );
}
if( m_propertyReordableList != null )
{
if( m_propertyAdjustment == null )
{
m_propertyAdjustment = new GUIStyle();
m_propertyAdjustment.padding.left = 17;
}
EditorGUILayout.BeginVertical( m_propertyAdjustment );
m_propertyReordableList.DoLayoutList();
EditorGUILayout.EndVertical();
}
}
public void ForceReordering()
{
List<PropertyNode> nodes = UIUtils.PropertyNodesList();
ReorderList( ref nodes );
List<FunctionInput> functionInputNodes = UIUtils.FunctionInputList();
ForceInputReorder( ref functionInputNodes );
List<FunctionSwitch> functionSwitchNodes = UIUtils.FunctionSwitchList();
ForceSwitchesReorder( ref functionSwitchNodes );
//RecursiveLog();
}
private void RecursiveLog()
{
List<PropertyNode> nodes = UIUtils.PropertyNodesList();
nodes.Sort( ( x, y ) => { return x.OrderIndex.CompareTo( y.OrderIndex ); } );
for( int i = 0; i < nodes.Count; i++ )
{
if( ( nodes[ i ] is ReordenatorNode ) )
( nodes[ i ] as ReordenatorNode ).RecursiveLog();
else
Debug.Log( nodes[ i ].OrderIndex + " " + nodes[ i ].PropertyName );
}
}
private void ReorderList( ref List<PropertyNode> nodes )
{
// clear lock list before reordering because of multiple sf being used
for( int i = 0; i < nodes.Count; i++ )
{
ReordenatorNode rnode = nodes[ i ] as ReordenatorNode;
if ( rnode != null )
rnode.RecursiveClear();
}
int propoffset = 0;
int count = 0;
for ( int i = 0; i < m_propertyReordableNodes.Count; i++ )
{
ReordenatorNode renode = m_propertyReordableNodes[ i ] as ReordenatorNode;
if ( renode != null )
{
if ( !renode.IsInside )
{
m_propertyReordableNodes[ i ].OrderIndex = count + propoffset;
if ( renode.PropertyListCount > 0 )
{
propoffset += renode.RecursiveCount();
// the same reordenator can exist multiple times, apply ordering to all of them
for( int j = 0; j < nodes.Count; j++ )
{
ReordenatorNode pnode = ( nodes[ j ] as ReordenatorNode );
if ( pnode != null && pnode.PropertyName.Equals( renode.PropertyName ) )
{
pnode.OrderIndex = renode.RawOrderIndex;
pnode.RecursiveSetOrderOffset( renode.RawOrderIndex, true );
}
}
}
else
{
count++;
}
}
else
{
m_propertyReordableNodes[ i ].OrderIndex = 0;
}
}
else
{
m_propertyReordableNodes[ i ].OrderIndex = count + propoffset;
count++;
}
}
}
public override void Destroy()
{
base.Destroy();
m_functionInputsReordableList = null;
m_functionOutputsReordableList = null;
m_propertyReordableList = null;
}
public bool ForceUpdate
{
get { return m_forceUpdate; }
set { m_forceUpdate = value; }
}
}
}

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

@ -0,0 +1,56 @@
using UnityEngine;
namespace AmplifyShaderEditor
{
public class NodeWireReferencesUtils
{
public WireReference InputPortReference = new WireReference();
public WireReference SwitchPortReference = new WireReference();
public WireReference OutputPortReference = new WireReference();
public Vector2 SnapPosition = Vector2.zero;
public bool SnapEnabled = false;
public WireReference SnapPort = new WireReference();
public bool ValidReferences()
{
return ( InputPortReference.IsValid || OutputPortReference.IsValid );
}
public void InvalidateReferences()
{
InputPortReference.Invalidate();
OutputPortReference.Invalidate();
SnapPort.Invalidate();
SnapEnabled = false;
}
public void SetOutputReference( int nodeId, int portId, WirePortDataType dataType, bool typeLocked )
{
if( InputPortReference.IsValid )
InputPortReference.Invalidate();
OutputPortReference.SetReference( nodeId, portId, dataType, typeLocked );
}
public void SetInputReference( int nodeId, int portId, WirePortDataType dataType, bool typeLocked )
{
if( OutputPortReference.IsValid )
OutputPortReference.Invalidate();
InputPortReference.SetReference( nodeId, portId, dataType, typeLocked );
}
public void ActivateSnap( Vector2 position, WirePort port )
{
SnapPort.SetReference( port );
SnapEnabled = true;
SnapPosition = position;
}
public void DeactivateSnap()
{
SnapEnabled = false;
SnapPort.Invalidate();
}
}
}

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

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: a89b03eb735b82a4da19a8381846935f
folderAsset: yes
timeCreated: 1481126946
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,101 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using System.Collections.Generic;
using System;
namespace AmplifyShaderEditor
{
public sealed class ContextPalette : PaletteParent
{
private Vector3 m_position;
private Vector2 m_startDropPosition;
public ContextPalette( AmplifyShaderEditorWindow parentWindow ) : base( parentWindow, 0, 0, 250, 250, string.Empty, MenuAnchor.NONE, MenuAutoSize.NONE )
{
m_isActive = false;
OnPaletteNodeCreateEvt += OnOptionSelected;
m_searchFilterControl += "CONTEXTPALETTE";
}
public override void OnEnterPressed(int index = 0)
{
if ( m_searchFilter.Length > 0 && m_currentItems.Count > 0 )
{
FireNodeCreateEvent( m_currentItems[ index ].NodeType, m_currentItems[ index ].Name, m_currentItems[ index ].Function );
}
else
{
Disable();
}
}
public override void OnEscapePressed()
{
Disable();
if ( m_parentWindow.WireReferenceUtils.ValidReferences() )
{
m_parentWindow.WireReferenceUtils.InvalidateReferences();
}
}
public override void Draw( Rect parentPosition, Vector2 mousePosition, int mouseButtonId, bool hasKeyboadFocus )
{
//if ( !_isActive )
// return;
if ( Event.current.type == EventType.MouseDown && !IsInside( Event.current.mousePosition ) )
{
Disable();
return;
}
base.Draw( parentPosition, mousePosition, mouseButtonId, hasKeyboadFocus );
}
public void Show( Vector2 position, Rect cameraInfo )
{
m_startDropPosition = position;
m_maximizedArea.x = ( position.x + m_maximizedArea.width ) > cameraInfo.width ? ( cameraInfo.width - 1.1f * m_maximizedArea.width ) : position.x;
m_maximizedArea.y = ( position.y + m_maximizedArea.height ) > cameraInfo.height ? ( cameraInfo.height - 1.1f * m_maximizedArea.height ) : position.y;
m_position = new Vector3( m_maximizedArea.x, m_maximizedArea.y, 0f );
m_isActive = true;
m_focusOnSearch = true;
}
// This override is removing focus from our window ... need to figure out a workaround before re-using it
//public override bool CheckButton( GUIContent content, GUIStyle style, int buttonId )
//{
// if ( buttonId != m_validButtonId )
// return false;
// return GUILayout.Button( content, style );
//}
void OnOptionSelected( System.Type type, string name, AmplifyShaderFunction function )
{
Disable();
}
public void Disable()
{
m_isActive = false;
}
public Vector2 StartDropPosition
{
get { return m_startDropPosition; }
}
public Vector3 CurrentPosition
{
get { return m_position; }
}
public Vector2 CurrentPosition2D
{
get { return new Vector2( m_position.x, m_position.y ); }
}
}
}

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

@ -0,0 +1,573 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using System.Collections.Generic;
using UnityEditor;
using System;
using System.Text.RegularExpressions;
namespace AmplifyShaderEditor
{
public class PaletteFilterData
{
public bool Visible;
public bool HasCommunityData;
public List<ContextMenuItem> Contents;
public PaletteFilterData( bool visible )
{
Visible = visible;
Contents = new List<ContextMenuItem>();
}
}
public class PaletteParent : MenuParent
{
private const float ItemSize = 18;
public delegate void OnPaletteNodeCreate( System.Type type, string name, AmplifyShaderFunction function );
public event OnPaletteNodeCreate OnPaletteNodeCreateEvt;
private string m_searchFilterStr = "Search";
protected string m_searchFilterControl = "SHADERNAMETEXTFIELDCONTROLNAME";
protected bool m_focusOnSearch = false;
protected bool m_defaultCategoryVisible = false;
//protected List<ContextMenuItem> m_allItems;
protected List<ContextMenuItem> m_currentItems;
protected Dictionary<string, PaletteFilterData> m_currentCategories;
private bool m_forceUpdate = true;
protected string m_searchFilter = string.Empty;
private float m_searchLabelSize = -1;
private GUIStyle m_buttonStyle;
private GUIStyle m_foldoutStyle;
protected bool m_previousWindowIsFunction = false;
protected int m_validButtonId = 0;
protected int m_initialSeparatorAmount = 1;
private Vector2 m_currScrollBarDims = new Vector2( 1, 1 );
public PaletteParent( AmplifyShaderEditorWindow parentWindow, float x, float y, float width, float height, string name, MenuAnchor anchor = MenuAnchor.NONE, MenuAutoSize autoSize = MenuAutoSize.NONE ) : base( parentWindow, x, y, width, height, name, anchor, autoSize )
{
m_searchFilter = string.Empty;
m_currentCategories = new Dictionary<string, PaletteFilterData>();
//m_allItems = items;
m_currentItems = new List<ContextMenuItem>();
}
public virtual void OnEnterPressed( int index = 0 ) { }
public virtual void OnEscapePressed() { }
public void FireNodeCreateEvent( System.Type type, string name, AmplifyShaderFunction function )
{
OnPaletteNodeCreateEvt( type, name, function );
}
public override void Draw( Rect parentPosition, Vector2 mousePosition, int mouseButtonId, bool hasKeyboadFocus )
{
base.Draw( parentPosition, mousePosition, mouseButtonId, hasKeyboadFocus );
if( m_previousWindowIsFunction != ParentWindow.IsShaderFunctionWindow )
{
m_forceUpdate = true;
}
m_previousWindowIsFunction = ParentWindow.IsShaderFunctionWindow;
List<ContextMenuItem> allItems = ParentWindow.ContextMenuInstance.MenuItems;
if( m_searchLabelSize < 0 )
{
m_searchLabelSize = GUI.skin.label.CalcSize( new GUIContent( m_searchFilterStr ) ).x;
}
if( m_foldoutStyle == null )
{
m_foldoutStyle = new GUIStyle( GUI.skin.GetStyle( "foldout" ) );
m_foldoutStyle.fontStyle = FontStyle.Bold;
}
if( m_buttonStyle == null )
{
m_buttonStyle = UIUtils.Label;
}
Event currenEvent = Event.current;
GUILayout.BeginArea( m_transformedArea, m_content, m_style );
{
for( int i = 0; i < m_initialSeparatorAmount; i++ )
{
EditorGUILayout.Separator();
}
if( currenEvent.type == EventType.KeyDown )
{
KeyCode key = currenEvent.keyCode;
//if ( key == KeyCode.Return || key == KeyCode.KeypadEnter )
// OnEnterPressed();
if( ( currenEvent.keyCode == KeyCode.KeypadEnter || currenEvent.keyCode == KeyCode.Return ) && currenEvent.type == EventType.KeyDown )
{
int index = m_currentItems.FindIndex( x => GUI.GetNameOfFocusedControl().Equals( x.ItemUIContent.text + m_resizable ) );
if( index > -1 )
OnEnterPressed( index );
else
OnEnterPressed();
}
if( key == KeyCode.Escape )
OnEscapePressed();
if( m_isMouseInside || hasKeyboadFocus )
{
if( key == ShortcutsManager.ScrollUpKey )
{
m_currentScrollPos.y -= 10;
if( m_currentScrollPos.y < 0 )
{
m_currentScrollPos.y = 0;
}
currenEvent.Use();
}
if( key == ShortcutsManager.ScrollDownKey )
{
m_currentScrollPos.y += 10;
currenEvent.Use();
}
}
}
float width = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = m_searchLabelSize;
EditorGUI.BeginChangeCheck();
{
GUI.SetNextControlName( m_searchFilterControl + m_resizable );
m_searchFilter = EditorGUILayout.TextField( m_searchFilterStr, m_searchFilter );
if( m_focusOnSearch )
{
m_focusOnSearch = false;
EditorGUI.FocusTextInControl( m_searchFilterControl + m_resizable );
}
}
if( EditorGUI.EndChangeCheck() )
m_forceUpdate = true;
EditorGUIUtility.labelWidth = width;
bool usingSearchFilter = ( m_searchFilter.Length == 0 );
m_currScrollBarDims.x = m_transformedArea.width;
m_currScrollBarDims.y = m_transformedArea.height - 2 - 16 - 2 - 7 * m_initialSeparatorAmount - 2;
m_currentScrollPos = EditorGUILayout.BeginScrollView( m_currentScrollPos/*, GUILayout.Width( 242 ), GUILayout.Height( 250 - 2 - 16 - 2 - 7 - 2) */);
{
if( m_forceUpdate )
{
m_forceUpdate = false;
//m_currentItems.Clear();
m_currentCategories.Clear();
if( usingSearchFilter )
{
for( int i = 0; i < allItems.Count; i++ )
{
//m_currentItems.Add( allItems[ i ] );
if( !m_currentCategories.ContainsKey( allItems[ i ].Category ) )
{
m_currentCategories.Add( allItems[ i ].Category, new PaletteFilterData( m_defaultCategoryVisible ) );
//m_currentCategories[ allItems[ i ].Category ].HasCommunityData = allItems[ i ].NodeAttributes.FromCommunity || m_currentCategories[ allItems[ i ].Category ].HasCommunityData;
}
m_currentCategories[ allItems[ i ].Category ].Contents.Add( allItems[ i ] );
}
}
else
{
for( int i = 0; i < allItems.Count; i++ )
{
var searchList = m_searchFilter.Trim( ' ' ).ToLower().Split(' ');
int matchesFound = 0;
for( int k = 0; k < searchList.Length; k++ )
{
MatchCollection wordmatch = Regex.Matches( allItems[ i ].Tags, "\\b"+searchList[ k ] );
if( wordmatch.Count > 0 )
matchesFound++;
else
break;
}
if( searchList.Length == matchesFound )
{
//m_currentItems.Add( allItems[ i ] );
if( !m_currentCategories.ContainsKey( allItems[ i ].Category ) )
{
m_currentCategories.Add( allItems[ i ].Category, new PaletteFilterData( m_defaultCategoryVisible ) );
//m_currentCategories[ allItems[ i ].Category ].HasCommunityData = allItems[ i ].NodeAttributes.FromCommunity || m_currentCategories[ allItems[ i ].Category ].HasCommunityData;
}
m_currentCategories[ allItems[ i ].Category ].Contents.Add( allItems[ i ] );
}
}
}
var categoryEnumerator = m_currentCategories.GetEnumerator();
while( categoryEnumerator.MoveNext() )
{
categoryEnumerator.Current.Value.Contents.Sort( ( x, y ) => x.CompareTo( y, usingSearchFilter ) );
}
//sort current list respecting categories
m_currentItems.Clear();
foreach( var item in m_currentCategories )
{
for( int i = 0; i < item.Value.Contents.Count; i++ )
{
m_currentItems.Add( item.Value.Contents[ i ] );
}
}
}
string watching = string.Empty;
// unselect the main search field so it can focus list elements next
if( ( currenEvent.keyCode == KeyCode.DownArrow || currenEvent.keyCode == KeyCode.UpArrow ) && m_searchFilter.Length > 0 )
{
if( GUI.GetNameOfFocusedControl().Equals( m_searchFilterControl + m_resizable ) )
{
EditorGUI.FocusTextInControl( null );
}
}
if( currenEvent.keyCode == KeyCode.DownArrow && currenEvent.type == EventType.KeyDown )
{
currenEvent.Use();
int nextIndex = m_currentItems.FindIndex( x => GUI.GetNameOfFocusedControl().Equals( x.ItemUIContent.text + m_resizable ) ) + 1;
if( nextIndex == m_currentItems.Count )
nextIndex = 0;
watching = m_currentItems[ nextIndex ].ItemUIContent.text + m_resizable;
GUI.FocusControl( watching );
}
if( currenEvent.keyCode == KeyCode.UpArrow && currenEvent.type == EventType.KeyDown )
{
currenEvent.Use();
int nextIndex = m_currentItems.FindIndex( x => GUI.GetNameOfFocusedControl().Equals( x.ItemUIContent.text + m_resizable ) ) - 1;
if( nextIndex < 0 )
nextIndex = m_currentItems.Count - 1;
watching = m_currentItems[ nextIndex ].ItemUIContent.text + m_resizable;
GUI.FocusControl( watching );
}
if( currenEvent.keyCode == KeyCode.Tab )
{
ContextMenuItem item = m_currentItems.Find( x => GUI.GetNameOfFocusedControl().Equals( x.ItemUIContent.text + m_resizable ) );
if( item != null )
{
watching = item.ItemUIContent.text + m_resizable;
}
}
float currPos = 0;
var enumerator = m_currentCategories.GetEnumerator();
float cache = EditorGUIUtility.labelWidth;
while( enumerator.MoveNext() )
{
var current = enumerator.Current;
bool visible = GUILayout.Toggle( current.Value.Visible, current.Key, m_foldoutStyle );
if( m_validButtonId == mouseButtonId )
{
current.Value.Visible = visible;
}
currPos += ItemSize;
if( m_searchFilter.Length > 0 || current.Value.Visible )
{
for( int i = 0; i < current.Value.Contents.Count; i++ )
{
//if ( !IsItemVisible( currPos ) )
//{
// // Invisible
// GUILayout.Space( ItemSize );
//}
//else
{
currPos += ItemSize;
// Visible
EditorGUILayout.BeginHorizontal();
GUILayout.Space( 16 );
//if ( m_isMouseInside )
//{
// //GUI.SetNextControlName( current.Value.Contents[ i ].ItemUIContent.text );
// if ( CheckButton( current.Value.Contents[ i ].ItemUIContent, m_buttonStyle, mouseButtonId ) )
// {
// int controlID = GUIUtility.GetControlID( FocusType.Passive );
// GUIUtility.hotControl = controlID;
// OnPaletteNodeCreateEvt( current.Value.Contents[ i ].NodeType, current.Value.Contents[ i ].Name, current.Value.Contents[ i ].Function );
// }
//}
//else
{
Rect thisRect = EditorGUILayout.GetControlRect( false, 16f, EditorStyles.label );
//if ( m_resizable )
{
if( GUI.RepeatButton( thisRect, string.Empty, EditorStyles.label ) )
{
int controlID = GUIUtility.GetControlID( FocusType.Passive );
GUIUtility.hotControl = controlID;
OnPaletteNodeCreateEvt( current.Value.Contents[ i ].NodeType, current.Value.Contents[ i ].Name, current.Value.Contents[ i ].Function );
//unfocus to make it focus the next text field correctly
GUI.FocusControl( null );
}
}
GUI.SetNextControlName( current.Value.Contents[ i ].ItemUIContent.text + m_resizable );
//EditorGUI.SelectableLabel( thisRect, current.Value.Contents[ i ].ItemUIContent.text, EditorStyles.label );
//float cache = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = thisRect.width;
EditorGUI.Toggle( thisRect, current.Value.Contents[ i ].ItemUIContent.text, false, EditorStyles.label );
EditorGUIUtility.labelWidth = cache;
if( watching == current.Value.Contents[ i ].ItemUIContent.text + m_resizable )
{
bool boundBottom = currPos - m_currentScrollPos.y > m_currScrollBarDims.y;
bool boundTop = currPos - m_currentScrollPos.y - 4 <= 0;
if( boundBottom )
m_currentScrollPos.y = currPos - m_currScrollBarDims.y + 2;
else if( boundTop )
m_currentScrollPos.y = currPos - 18;
//else if ( boundBottom && !downDirection )
// m_currentScrollPos.y = currPos - m_currScrollBarDims.y + 2;
//else if ( boundTop && downDirection )
// m_currentScrollPos.y = currPos - 18;
}
}
EditorGUILayout.EndHorizontal();
}
//currPos += ItemSize;
}
}
}
EditorGUIUtility.labelWidth = cache;
}
EditorGUILayout.EndScrollView();
}
GUILayout.EndArea();
}
public void CheckCommunityNodes()
{
var enumerator = m_currentCategories.GetEnumerator();
while( enumerator.MoveNext() )
{
var current = enumerator.Current;
current.Value.HasCommunityData = false;
int count = current.Value.Contents.Count;
for( int i = 0; i < count; i++ )
{
if( current.Value.Contents[ i ].NodeAttributes.FromCommunity )
{
current.Value.HasCommunityData = true;
break;
}
}
}
}
public void DumpAvailableNodes( bool fromCommunity, string pathname )
{
string noTOCHeader = "__NOTOC__\n";
string nodesHeader = "== Available Node Categories ==\n";
string InitialCategoriesFormat = "[[#{0}|{0}]]<br>\n";
string InitialCategories = string.Empty;
string CurrentCategoryFormat = "\n== {0} ==\n\n";
//string NodesFootFormat = "[[Unity Products:Amplify Shader Editor/{0} | Learn More]] -\n[[#Top|Back to Categories]]\n";
string NodesFootFormatSep = "[[#Top|Back to Top]]\n----\n";
string OverallFoot = "[[Category:Nodes]]";
string NodeInfoBeginFormat = "<div class=\"nodecard\">\n";
string nodeInfoBodyFormat = "{{| id=\"{2}\" class=\"wikitable\" |\n" +
"|- \n" +
"| <div>[[Unity Products:Amplify Shader Editor/{1}|<img class=\"responsive-img\" src=\"http://amplify.pt/Nodes/{0}.jpg\">]]</div>\n" +
"<div>\n" +
"{{| style=\"width: 100%; height: 150px;\"\n" +
"|-\n" +
"| [[Unity Products:Amplify Shader Editor/{1}|'''{2}''']]\n" +
"|- style=\"vertical-align:top; height: 100%;\" |\n" +
"|<p class=\"cardtext\">{3}</p>\n" +
"|- style=\"text-align:right;\" |\n" +
"|{4}[[Unity Products:Amplify Shader Editor/{1} | Learn More]]\n" +
"|}}</div>\n" +
"|}}\n";
string NodeInfoEndFormat = "</div>\n";
//string NodeInfoBeginFormat = "<span style=\"color:#c00;display:block;\">This page is under construction!</span>\n\n";
//string nodeInfoBodyFormat = "<img style=\"float:left; margin-right:10px;\" src=\"http://amplify.pt/Nodes/{0}.jpg\">\n[[Unity Products:Amplify Shader Editor/{1}|'''{2}''']]\n\n{3}";
//string NodeInfoEndFormat = "\n\n[[Unity_Products:Amplify_Shader_Editor/Nodes | Back to Node List ]]\n[[Category:Nodes]][[Category:{0}]]\n\n\n";
//string NodeInfoBeginFormat = "{| cellpadding=\"10\"\n";
//string nodeInfoBodyFormat = "|- style=\"vertical-align:top;\"\n| http://amplify.pt/Nodes/{0}.jpg\n| [[Unity Products:Amplify Shader Editor/{1} | <span style=\"font-size: 120%;\"><span id=\"{2}\"></span>'''{2}'''<span> ]] <br> {3}\n";
//string NodeInfoEndFormat = "|}\n";
string nodesInfo = string.Empty;
BuildFullList( true );
CheckCommunityNodes();
var enumerator = m_currentCategories.GetEnumerator();
while( enumerator.MoveNext() )
{
var current = enumerator.Current;
if( fromCommunity && current.Value.HasCommunityData || !fromCommunity )
{
InitialCategories += string.Format( InitialCategoriesFormat, current.Key );
nodesInfo += string.Format( CurrentCategoryFormat, current.Key );
int count = current.Value.Contents.Count;
for( int i = 0; i < count; i++ )
{
if( ( fromCommunity && current.Value.Contents[ i ].NodeAttributes.FromCommunity )
|| !fromCommunity
//|| ( !fromCommunity && !current.Value.Contents[ i ].NodeAttributes.FromCommunity )
)
{
string nodeFullName = current.Value.Contents[ i ].Name;
string pictureFilename = UIUtils.ReplaceInvalidStrings( nodeFullName );
string pageFilename = UIUtils.RemoveWikiInvalidCharacters( pictureFilename );
pictureFilename = UIUtils.RemoveInvalidCharacters( pictureFilename );
string nodeDescription = current.Value.Contents[ i ].ItemUIContent.tooltip;
string communityText = string.Empty;
if( current.Value.Contents[ i ].NodeAttributes.FromCommunity )
communityText = "<small class=\"cardauthor\">( originally by "+ current.Value.Contents[ i ].NodeAttributes.Community + " )</small> ";
string nodeInfoBody = string.Format( nodeInfoBodyFormat, pictureFilename, pageFilename, nodeFullName, nodeDescription, communityText );
//string nodeInfoFoot = string.Format( NodesFootFormat, pageFilename );
nodesInfo += ( NodeInfoBeginFormat + nodeInfoBody + NodeInfoEndFormat );
//nodesInfo += ( NodeInfoBeginFormat + nodeInfoBody + string.Format( NodeInfoEndFormat, current.Key ) );
//if ( i != ( count - 1 ) )
//{
// nodesInfo += NodesFootFormatSep;
//}
}
}
nodesInfo += NodesFootFormatSep;
}
}
string finalText = noTOCHeader + nodesHeader + InitialCategories + nodesInfo + OverallFoot;
if( !System.IO.Directory.Exists( pathname ) )
{
System.IO.Directory.CreateDirectory( pathname );
}
// Save file
string nodesPathname = pathname + ( fromCommunity ? "AvailableNodesFromCommunity.txt" : "AvailableNodes.txt" );
Debug.Log( " Creating nodes file at " + nodesPathname );
IOUtils.SaveTextfileToDisk( finalText, nodesPathname, false );
BuildFullList( false );
}
public virtual bool CheckButton( GUIContent content, GUIStyle style, int buttonId )
{
if( buttonId != m_validButtonId )
{
GUILayout.Label( content, style );
return false;
}
return GUILayout.RepeatButton( content, style );
}
public void FillList( ref List<ContextMenuItem> list, bool forceAllItems )
{
List<ContextMenuItem> allList = forceAllItems ? ParentWindow.ContextMenuInstance.ItemFunctions : ParentWindow.ContextMenuInstance.MenuItems;
list.Clear();
int count = allList.Count;
for( int i = 0; i < count; i++ )
{
list.Add( allList[ i ] );
}
}
public Dictionary<string, PaletteFilterData> BuildFullList( bool forceAllNodes = false )
{
//Only need to build if search filter is active and list is set according to it
if( m_searchFilter.Length > 0 || !m_isActive || m_currentCategories.Count == 0 )
{
m_currentItems.Clear();
m_currentCategories.Clear();
List<ContextMenuItem> allItems = forceAllNodes ? ParentWindow.ContextMenuInstance.ItemFunctions : ParentWindow.ContextMenuInstance.MenuItems;
for( int i = 0; i < allItems.Count; i++ )
{
if( allItems[ i ].Name.IndexOf( m_searchFilter, StringComparison.InvariantCultureIgnoreCase ) >= 0 ||
allItems[ i ].Category.IndexOf( m_searchFilter, StringComparison.InvariantCultureIgnoreCase ) >= 0
)
{
m_currentItems.Add( allItems[ i ] );
if( !m_currentCategories.ContainsKey( allItems[ i ].Category ) )
{
m_currentCategories.Add( allItems[ i ].Category, new PaletteFilterData( m_defaultCategoryVisible ) );
//m_currentCategories[ allItems[ i ].Category ].HasCommunityData = allItems[ i ].NodeAttributes.FromCommunity || m_currentCategories[ allItems[ i ].Category ].HasCommunityData;
}
m_currentCategories[ allItems[ i ].Category ].Contents.Add( allItems[ i ] );
}
}
var categoryEnumerator = m_currentCategories.GetEnumerator();
while( categoryEnumerator.MoveNext() )
{
categoryEnumerator.Current.Value.Contents.Sort( ( x, y ) => x.CompareTo( y, false ) );
}
//mark to force update and take search filter into account
m_forceUpdate = true;
}
return m_currentCategories;
}
private bool IsItemVisible( float currPos )
{
if( ( currPos < m_currentScrollPos.y && ( currPos + ItemSize ) < m_currentScrollPos.y ) ||
( currPos > ( m_currentScrollPos.y + m_currScrollBarDims.y ) &&
( currPos + ItemSize ) > ( m_currentScrollPos.y + m_currScrollBarDims.y ) ) )
{
return false;
}
return true;
}
public override void Destroy()
{
base.Destroy();
//m_allItems = null;
m_currentItems.Clear();
m_currentItems = null;
m_currentCategories.Clear();
m_currentCategories = null;
OnPaletteNodeCreateEvt = null;
m_buttonStyle = null;
m_foldoutStyle = null;
}
//public void Clear() {
// m_allItems.Clear();
// m_allItems = new List<ContextMenuItem>();
//}
public bool ForceUpdate { get { return m_forceUpdate; } set { m_forceUpdate = value; } }
}
}

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

@ -0,0 +1,73 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
namespace AmplifyShaderEditor
{
public class PalettePopUp
{
private const int DeltaX = 5;
private Rect m_areaSettings;
private Vector2 m_mouseDeltaPos = new Vector2( 10, -10 );
private bool m_isActive = false;
private GUIContent m_content;
private GUIStyle m_style;
private GUIStyle m_fontStyle;
private GUIContent m_labelContent;
public PalettePopUp()
{
m_content = new GUIContent( GUIContent.none );
m_areaSettings = new Rect( 0, 0, 100, 30 );
m_labelContent = new GUIContent( "Test Label" );
}
public void Activate( string label )
{
m_labelContent.text = label;
m_areaSettings.width = -1;
m_isActive = true;
}
public void Deactivate()
{
m_isActive = false;
}
public void Draw( Vector2 mousePos )
{
if ( m_style == null )
{
m_style = UIUtils.TextArea;
}
if ( m_fontStyle == null )
{
m_fontStyle = new GUIStyle( UIUtils.Label );
m_fontStyle.fontSize = 15;
}
if ( m_areaSettings.width < 0 )
{
m_areaSettings.width = m_fontStyle.CalcSize( m_labelContent ).x + 2 * DeltaX;
}
m_areaSettings.position = mousePos + m_mouseDeltaPos;
GUI.Label( m_areaSettings, m_content, m_style );
m_areaSettings.position += new Vector2( DeltaX,DeltaX);
GUI.Label( m_areaSettings, m_labelContent, m_fontStyle );
}
public void Destroy()
{
m_content = null;
m_style = null;
}
public bool IsActive
{
get { return m_isActive; }
}
}
}

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: bc4f137f15efe1d42b7bcbf984ec1545
timeCreated: 1481126958
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.Collections.Generic;
using UnityEngine;
namespace AmplifyShaderEditor
{
public sealed class PaletteWindow : PaletteParent
{
public PaletteWindow( AmplifyShaderEditorWindow parentWindow ) : base( parentWindow, 0, 0, 250, 0, string.Empty, MenuAnchor.TOP_RIGHT, MenuAutoSize.MATCH_VERTICAL )
{
m_searchFilterControl += "PALETTEWINDOW";
m_initialSeparatorAmount = 4;
SetMinimizedArea( -225, 0, 260, 0 );
}
public override void Draw( Rect parentPosition, Vector2 mousePosition, int mouseButtonId, bool hasKeyboadFocus )
{
if ( m_isMaximized )
{
base.Draw( parentPosition, mousePosition, mouseButtonId, hasKeyboadFocus );
}
else
{
InitDraw( parentPosition, mousePosition, mouseButtonId );
}
PostDraw();
}
}
}

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

Loading…
Cancel
Save