summaryrefslogtreecommitdiff
path: root/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient')
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogAndAmbientColorsNode.cs126
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogAndAmbientColorsNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogParamsNode.cs32
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogParamsNode.cs.meta12
4 files changed, 182 insertions, 0 deletions
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogAndAmbientColorsNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogAndAmbientColorsNode.cs
new file mode 100644
index 00000000..2af78f78
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogAndAmbientColorsNode.cs
@@ -0,0 +1,126 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+using UnityEngine;
+using UnityEditor;
+using System;
+
+namespace AmplifyShaderEditor
+{
+ public enum BuiltInFogAndAmbientColors
+ {
+ UNITY_LIGHTMODEL_AMBIENT = 0,
+ unity_AmbientSky,
+ unity_AmbientEquator,
+ unity_AmbientGround,
+ unity_FogColor
+ }
+
+ [Serializable]
+ [NodeAttributes( "Fog And Ambient Colors", "Light", "Fog and Ambient colors" )]
+ public sealed class FogAndAmbientColorsNode : ShaderVariablesNode
+ {
+ private const string ColorLabelStr = "Color";
+ private readonly string[] ColorValuesStr = {
+ "Ambient light ( Legacy )",
+ "Sky ambient light",
+ "Equator ambient light",
+ "Ground ambient light",
+ "Fog"
+ };
+
+ [SerializeField]
+ private BuiltInFogAndAmbientColors m_selectedType = BuiltInFogAndAmbientColors.UNITY_LIGHTMODEL_AMBIENT;
+
+ private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper();
+
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ ChangeOutputProperties( 0, ColorValuesStr[ ( int ) m_selectedType ], WirePortDataType.COLOR );
+ m_textLabelWidth = 50;
+ m_autoWrapProperties = true;
+ m_hasLeftDropdown = true;
+ m_previewShaderGUID = "937c7bde062f0f942b600d9950d2ebb2";
+ }
+
+ public override void AfterCommonInit()
+ {
+ base.AfterCommonInit();
+ if( PaddingTitleLeft == 0 )
+ {
+ PaddingTitleLeft = Constants.PropertyPickerWidth + Constants.IconsLeftRightMargin;
+ if( PaddingTitleRight == 0 )
+ PaddingTitleRight = Constants.PropertyPickerWidth + Constants.IconsLeftRightMargin;
+ }
+ }
+
+ public override void SetPreviewInputs()
+ {
+ base.SetPreviewInputs();
+ m_previewMaterialPassId = (int)m_selectedType;
+ }
+
+ public override void Destroy()
+ {
+ base.Destroy();
+ m_upperLeftWidget = null;
+ }
+
+ public override void Draw( DrawInfo drawInfo )
+ {
+ base.Draw( drawInfo );
+ EditorGUI.BeginChangeCheck();
+ m_selectedType = (BuiltInFogAndAmbientColors)m_upperLeftWidget.DrawWidget( this, (int)m_selectedType, ColorValuesStr );
+ if( EditorGUI.EndChangeCheck() )
+ {
+ ChangeOutputName( 0, ColorValuesStr[ (int)m_selectedType ] );
+ }
+ }
+
+ public override void DrawProperties()
+ {
+ base.DrawProperties();
+ EditorGUI.BeginChangeCheck();
+ m_selectedType = ( BuiltInFogAndAmbientColors ) EditorGUILayoutPopup( ColorLabelStr, ( int ) m_selectedType, ColorValuesStr );
+
+ if ( EditorGUI.EndChangeCheck() )
+ {
+ ChangeOutputName( 0, ColorValuesStr[ ( int ) m_selectedType ] );
+ }
+ }
+
+ public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
+ {
+ base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
+ if( dataCollector.IsTemplate && dataCollector.CurrentSRPType == TemplateSRPType.HD )
+ {
+ switch( m_selectedType )
+ {
+ case BuiltInFogAndAmbientColors.unity_AmbientSky:
+ return "_Ambient_ColorSky";
+ case BuiltInFogAndAmbientColors.unity_AmbientEquator:
+ return "_Ambient_Equator";
+ case BuiltInFogAndAmbientColors.unity_AmbientGround:
+ return "_Ambient_Ground";
+ case BuiltInFogAndAmbientColors.unity_FogColor:
+ return "_FogColor";
+ }
+ }
+ return m_selectedType.ToString();
+ }
+
+ public override void ReadFromString( ref string[] nodeParams )
+ {
+ base.ReadFromString( ref nodeParams );
+ m_selectedType = ( BuiltInFogAndAmbientColors ) Enum.Parse( typeof( BuiltInFogAndAmbientColors ), GetCurrentParam( ref nodeParams ) );
+ ChangeOutputName( 0, ColorValuesStr[ ( int ) m_selectedType ] );
+ }
+
+ public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
+ {
+ base.WriteToString( ref nodeInfo, ref connectionsInfo );
+ IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedType );
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogAndAmbientColorsNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogAndAmbientColorsNode.cs.meta
new file mode 100644
index 00000000..f2ab7d02
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogAndAmbientColorsNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: e2bdfc2fa6fcd0640b01a8b7448a1a11
+timeCreated: 1481126959
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogParamsNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogParamsNode.cs
new file mode 100644
index 00000000..63a635d1
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogParamsNode.cs
@@ -0,0 +1,32 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+using System;
+namespace AmplifyShaderEditor
+{
+ [Serializable]
+ [NodeAttributes( "Fog Params", "Light", "Parameters for fog calculation" )]
+ public sealed class FogParamsNode : ConstVecShaderVariable
+ {
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ ChangeOutputName( 1, "Density/Sqrt(Ln(2))" );
+ ChangeOutputName( 2, "Density/Ln(2)" );
+ ChangeOutputName( 3, "-1/(End-Start)" );
+ ChangeOutputName( 4, "End/(End-Start))" );
+ m_value = "unity_FogParams";
+ m_previewShaderGUID = "42abde3281b1848438c3b53443c91a1e";
+ }
+
+ public override void RefreshExternalReferences()
+ {
+ base.RefreshExternalReferences();
+ if( !m_outputPorts[ 0 ].IsConnected )
+ {
+ m_outputPorts[ 0 ].Visible = false;
+ m_sizeIsDirty = true;
+ }
+ }
+ }
+}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogParamsNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogParamsNode.cs.meta
new file mode 100644
index 00000000..ccc0df5e
--- /dev/null
+++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogParamsNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: a3d8c31159e07bc419a7484ab5e894ed
+timeCreated: 1481126958
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: