init assets and filemgt

This commit is contained in:
2022-03-07 18:33:30 +02:00
parent 62585ef143
commit 813cd0c451
1274 changed files with 346654 additions and 249 deletions

View File

@@ -0,0 +1,184 @@
// Fantasy Adventure Environment
// Copyright Staggart Creations
// staggart.xyz
using System;
using UnityEngine;
using System.Collections;
using UnityEditor;
namespace FAE
{
[CustomEditor(typeof(CliffAppearance))]
public class CliffAppearanceInspector : Editor
{
CliffAppearance ca;
private bool showHelp = false;
public SerializedProperty targetMaterials;
public SerializedProperty objectColor;
public SerializedProperty roughness;
public SerializedProperty detailNormalMap;
public SerializedProperty detailNormalStrength;
public SerializedProperty globalColorMap;
public SerializedProperty globalColor;
public SerializedProperty globalTiling;
public SerializedProperty useCoverageShader;
public SerializedProperty coverageColorMap;
public SerializedProperty coverageNormalMap;
public SerializedProperty coverageAmount;
public SerializedProperty coverageTiling;
public SerializedProperty coverageMap;
#if UNITY_EDITOR
void OnEnable()
{
ca = (CliffAppearance)target;
targetMaterials = serializedObject.FindProperty("targetMaterials");
objectColor = serializedObject.FindProperty("objectColor");
roughness = serializedObject.FindProperty("roughness");
detailNormalMap = serializedObject.FindProperty("detailNormalMap");
detailNormalStrength = serializedObject.FindProperty("detailNormalStrength");
globalColorMap = serializedObject.FindProperty("globalColorMap");
globalColor = serializedObject.FindProperty("globalColor");
globalTiling = serializedObject.FindProperty("globalTiling");
useCoverageShader = serializedObject.FindProperty("useCoverageShader");
coverageColorMap = serializedObject.FindProperty("coverageColorMap");
coverageNormalMap = serializedObject.FindProperty("coverageNormalMap");
coverageAmount = serializedObject.FindProperty("coverageAmount");
coverageTiling = serializedObject.FindProperty("coverageTiling");
coverageMap = serializedObject.FindProperty("coverageMap");
Undo.undoRedoPerformed += OnUndoRedo;
}
private void OnDisable()
{
Undo.undoRedoPerformed -= OnUndoRedo;
}
private void OnUndoRedo()
{
ca.Apply();
}
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUI.BeginChangeCheck();
if (ca.cliffShader == null) EditorGUILayout.HelpBox("Cliff shader could not be found!", MessageType.Error);
if (ca.cliffCoverageShader == null) EditorGUILayout.HelpBox("Cliff Coverage shader could not be found!", MessageType.Error);
DrawFields();
if (EditorGUI.EndChangeCheck())
{
serializedObject.ApplyModifiedProperties();
ca.Apply();
}
}
private void DrawFields()
{
DoHeader();
EditorGUILayout.PropertyField(targetMaterials, true);
EditorGUILayout.Space();
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
EditorGUILayout.LabelField("Coverage", EditorStyles.boldLabel);
EditorGUILayout.Space();
EditorGUILayout.PropertyField(useCoverageShader, new GUIContent("Enable"));
if (showHelp) EditorGUILayout.HelpBox("Covers the objects from the Y-axis", MessageType.Info);
if (ca.useCoverageShader)
{
EditorGUILayout.HelpBox("Currently this feature requires you to have the PigmentMapGenerator script on your terrain", MessageType.Info);
EditorGUILayout.PropertyField(coverageMap, new GUIContent("Coverage map"));
if (showHelp) EditorGUILayout.HelpBox("This grayscale map represents the coverage amount on the terrain \n\nThe bottom left of the texture equals the pivot point of the terrain", MessageType.Info);
EditorGUILayout.PropertyField(coverageColorMap, new GUIContent("Albedo"));
EditorGUILayout.PropertyField(coverageNormalMap, new GUIContent("Normals"));
EditorGUILayout.PropertyField(coverageAmount, new GUIContent("Amount"));
EditorGUILayout.PropertyField(coverageTiling, new GUIContent("Tiling"));
}
EditorGUILayout.Space();
EditorGUILayout.EndVertical();
EditorGUILayout.Space();
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
EditorGUILayout.LabelField("Object", EditorStyles.boldLabel);
EditorGUILayout.Space();
EditorGUILayout.PropertyField(objectColor);
EditorGUILayout.PropertyField(roughness);
EditorGUILayout.Space();
EditorGUILayout.EndVertical();
EditorGUILayout.Space();
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
EditorGUILayout.LabelField("Detail", EditorStyles.boldLabel);
EditorGUILayout.Space();
if (showHelp) EditorGUILayout.HelpBox("Normal details visible up close", MessageType.Info);
EditorGUILayout.PropertyField(detailNormalMap, new GUIContent("Detail normal map"));
EditorGUILayout.PropertyField(detailNormalStrength, new GUIContent("Normal strength"));
EditorGUILayout.Space();
EditorGUILayout.EndVertical();
EditorGUILayout.Space();
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
EditorGUILayout.LabelField("Global", EditorStyles.boldLabel);
EditorGUILayout.Space();
if (showHelp) EditorGUILayout.HelpBox("A tri-planar projected color map which tiles across all the objects seamlessly", MessageType.Info);
EditorGUILayout.PropertyField(globalColorMap, new GUIContent("Global color map"));
EditorGUILayout.PropertyField(globalColor, new GUIContent("Color"));
EditorGUILayout.PropertyField(globalTiling, new GUIContent("Tiling"));
EditorGUILayout.Space();
EditorGUILayout.EndVertical();
GUIHelper.DrawFooter();
}
private void DoHeader()
{
EditorGUILayout.BeginHorizontal();
showHelp = GUILayout.Toggle(showHelp, "Toggle help", "Button");
GUILayout.Label("FAE Cliff Appearance", GUIHelper.Header);
EditorGUILayout.EndHorizontal();
if (showHelp) EditorGUILayout.HelpBox("This script allows you to edit multiple materials that use the FAE/Cliff shader. When it's loaded, the settings will be applied to them, so it acts as a sort of preset loader", MessageType.Info);
}
#endif
}
}

View File

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

View File

@@ -0,0 +1,346 @@
// Fantasy Adventure Environment
// Staggart Creations
// http://staggart.xyz
using UnityEngine;
using System.IO;
using UnityEditor;
using System.Collections.Generic;
using System.Linq;
namespace FAE
{
public class FAE_Core : Editor
{
public const string ASSET_NAME = "Fantasy Adventure Environment";
public const string ASSET_ABRV = "FAE";
public const string ASSET_ID = "70354";
public const string PACKAGE_VERSION = "20174";
public static string INSTALLED_VERSION = "1.5.5";
public const string MIN_UNITY_VERSION = "2019.3";
public static string DOC_URL = "http://staggart.xyz/unity/fantasy-adventure-environment/fae-documentation/";
public static string FORUM_URL = "https://forum.unity3d.com/threads/486102";
#if UNITY_2019_3_OR_NEWER
private const string UniversalShaderPackageGUID = "7c884420a5dfbaa4db9afe42d366b843";
#endif
public static void OpenStorePage()
{
Application.OpenURL("com.unity3d.kharma:content/" + ASSET_ID);
}
public static string PACKAGE_ROOT_FOLDER
{
get { return SessionState.GetString(ASSET_ABRV + "_BASE_FOLDER", string.Empty); }
set { SessionState.SetString(ASSET_ABRV + "_BASE_FOLDER", value); }
}
public static string GetRootFolder()
{
//Get script path
string[] scriptGUID = AssetDatabase.FindAssets("FAE_Core t:script");
string scriptFilePath = AssetDatabase.GUIDToAssetPath(scriptGUID[0]);
//Truncate to get relative path
PACKAGE_ROOT_FOLDER = scriptFilePath.Replace("/Editor/FAE_Core.cs", string.Empty);
#if FAE_DEV
Debug.Log("<b>Package root</b> " + PACKAGE_ROOT_FOLDER);
#endif
return PACKAGE_ROOT_FOLDER;
}
#if UNITY_2019_3_OR_NEWER
public enum ShaderInstallation
{
BuiltIn,
UniversalRP
}
public class RunOnImport : AssetPostprocessor
{
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
{
foreach (string str in importedAssets)
{
if (str.Contains("FAE_Core.cs"))
{
GetRootFolder();
string urpFolder = FAE_Core.PACKAGE_ROOT_FOLDER + "/Shaders/URP/";
var info = new DirectoryInfo(urpFolder);
FileInfo[] fileInfo = info.GetFiles();
//Only one file in the folder, shaders not yet unpacked
if (fileInfo.Length <= 2 && UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset != null)
{
if (EditorUtility.DisplayDialog("Fantasy Adventure Environment", "The Universal Render Pipeline is in use.\n\nURP compatible shaders can be unpacked and materials upgraded through the \"Help\" window after importing has finished\n\nErrors about _GrabTexture can safely be ignored.", "OK"))
{
}
}
}
}
}
}
private const string urpName = "Universal Render Pipeline";
//Look up table to finding pipeline shader variants
private static Dictionary<string, string> ShaderRelations = new Dictionary<string, string>
{
//Peartickles
//Since 7.4.1, the legacy particle shaders will work
//{ "Legacy Shaders/Particles/Alpha Blended", urpName + "/Particles/Simple Lit" },
//No longer needed to convert particle materials. Barely works, so particle materials are now packaged for URP
//{ "Particles/Alpha Blended", urpName + "/Particles/Simple Lit" },
//{ "Mobile/Particles/Alpha Blended", urpName + "/Particles/Simple Lit" },
//{ "Particles/Standard Surface", urpName + "/Particles/Simple Lit" },
//{ "Particles/Standard Unlit", urpName + "/Particles/Unlit" },
{ "Standard", urpName + "/Lit" },
{ "Skybox/Cubemap","Skybox/Cubemap" },
{ "Nature/Terrain/Standard", urpName + "/Terrain/Lit" },
{ "FAE/Fog sheet", urpName + "/FAE/FAE_FogSheet" },
{ "FAE/Sunshaft", urpName + "/FAE/FAE_Sunshaft" },
//{ "FAE/Sunshaft particle", urpName + "/FAE/FAE_SunshaftParticle" },
{ "FAE/Cliff", urpName + "/FAE/FAE_Cliff" },
{ "FAE/Cliff coverage", urpName + "/FAE/FAE_Cliff_Coverage" },
{ "FAE/Water", urpName + "/FAE/FAE_Water" },
{ "FAE/Waterfall", urpName + "/FAE/FAE_Waterfall" },
{ "FAE/Waterfall foam", urpName + "/FAE/FAE_WaterfallFoam" },
{ "FAE/Foliage", urpName+ "/FAE/FAE_Foliage" },
{ "FAE/Tree Branch", urpName+ "/FAE/FAE_TreeBranch" },
{ "FAE/Tree Trunk", urpName+ "/FAE/FAE_TreeTrunk" },
{ "FAE/Tree Billboard", urpName+ "/FAE/FAE_TreeBillboard" }
};
[MenuItem("Edit/Render Pipeline/Fantasy Adventure Environment/Revert to Built-in")]
public static void InstallBuiltIn()
{
InstallShaders(ShaderInstallation.BuiltIn);
}
[MenuItem("Edit/Render Pipeline/Fantasy Adventure Environment/Convert to URP")]
public static void InstallURP()
{
#if UNITY_2019_3_OR_NEWER && FAE_DEV
SwitchRenderPipeline.SetPipeline(ShaderInstallation.UniversalRP);
#endif
if (UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset == null)
{
if (EditorUtility.DisplayDialog("Fantasy Adventure Environment", "No URP asset has been assigned in the Graphics settings. URP should be set up, before converting the package.", "Show me", "Cancel"))
{
SettingsService.OpenProjectSettings("Project/Graphics");
return;
}
}
InstallShaders(ShaderInstallation.UniversalRP);
}
public static void InstallShaders(ShaderInstallation config)
{
string guid = UniversalShaderPackageGUID;
string packagePath = AssetDatabase.GUIDToAssetPath(guid);
GetRootFolder();
//TODO: Package up current shaders
if (config == ShaderInstallation.BuiltIn)
{
//AssetDatabase.ExportPackage(PACKAGE_ROOT_FOLDER + "/Shaders/URP", packagePath, ExportPackageOptions.Default | ExportPackageOptions.Recurse);
UpgradeMaterials(config);
}
else
{
if (packagePath == string.Empty)
{
Debug.LogError("URP Shader/material package with the GUID: " + guid + ". Could not be found in the project, was it changed or not imported? It should be located in <i>" + PACKAGE_ROOT_FOLDER + "/Shaders/URP</i>");
return;
}
AssetDatabase.ImportPackage(packagePath, false);
AssetDatabase.importPackageCompleted += new AssetDatabase.ImportPackageCallback(ImportURPCallback);
}
#if UNITY_2019_3_OR_NEWER && FAE_DEV
SwitchRenderPipeline.SetPipeline(config);
#endif
}
static void ImportURPCallback(string packageName)
{
AssetDatabase.Refresh();
UpgradeMaterials(ShaderInstallation.UniversalRP);
AssetDatabase.importPackageCompleted -= ImportURPCallback;
}
public static void UpgradeMaterials(ShaderInstallation config)
{
string[] GUIDs = AssetDatabase.FindAssets("t: material", new string[] { PACKAGE_ROOT_FOLDER });
int count = 0;
if (GUIDs.Length > 0)
{
Material[] mats = new Material[GUIDs.Length];
for (int i = 0; i < mats.Length; i++)
{
EditorUtility.DisplayProgressBar("Material configuration", "Converting FAE materials for " + config, (float)i / mats.Length);
string path = AssetDatabase.GUIDToAssetPath(GUIDs[i]);
mats[i] = (Material)AssetDatabase.LoadAssetAtPath(path, typeof(Material));
string dest = string.Empty;
string source = mats[i].shader.name;
bool matched = ShaderRelations.TryGetValue(source, out dest);
if (config == ShaderInstallation.BuiltIn)
{
//Get key by value (inverse lookup)
dest = ShaderRelations.FirstOrDefault(x => x.Value == source).Key;
matched = dest != null;
}
if (config == ShaderInstallation.UniversalRP)
{
//Set grass to foliage shader
if (source == "FAE/Grass")
{
dest = urpName + "/FAE/FAE_Foliage";
matched = true;
}
}
if (config == ShaderInstallation.BuiltIn)
{
//Set foliage to grass shader
if (mats[i].name.Contains("Grass"))
{
dest = "FAE/Grass";
matched = true;
}
}
if (source == null && dest == null) continue;
if (string.Equals(dest, source)) continue;
if (matched)
{
if (config == ShaderInstallation.UniversalRP)
{
Texture mainTex = null;
if (mats[i].HasProperty("_MainTex")) mainTex = mats[i].GetTexture("_MainTex");
if (mats[i].HasProperty("_Color")) mats[i].SetColor("_BaseColor", mats[i].GetColor("_Color"));
if (mats[i].HasProperty("_TintColor")) mats[i].SetColor("_BaseColor", mats[i].GetColor("_TintColor"));
//Grass to foliage switch
if (mats[i].HasProperty("_ColorTop")) mats[i].SetColor("_Color", mats[i].GetColor("_ColorTop"));
if (mats[i].HasProperty("_MainTex"))
{
mats[i].SetTexture("_BaseMap", mainTex);
}
if (mats[i].name.Contains("Grass"))
{
mats[i].SetFloat("_MaxWindStrength", 0.2f);
mats[i].SetFloat("_AmbientOcclusion", 0.15f);
}
mats[i].shader = Shader.Find(dest);
if (mainTex) mats[i].SetTexture("_BaseMap", mainTex);
}
if (mats[i].HasProperty("_TransmissionAmount"))
{
mats[i].SetFloat("_TransmissionAmount", Mathf.Clamp(mats[i].GetFloat("_TransmissionAmount"), 0, 10));
}
//Debug.Log("src: " + source + " dst:" + dest);
mats[i].shader = Shader.Find(dest);
EditorUtility.SetDirty(mats[i]);
count++;
}
else
{
#if FAE_DEV
Debug.LogError("No matching " + config + " shader could be found for " + mats[i].shader.name);
#endif
}
}
EditorUtility.ClearProgressBar();
Debug.Log(count + " materials were configured for the " + config + " render pipeline");
AssetDatabase.Refresh();
AssetDatabase.SaveAssets();
if (config == ShaderInstallation.UniversalRP)
{
delayTime = (float)EditorApplication.timeSinceStartup + renameDelaySec;
EditorApplication.update += PostURPConversion;
}
}
}
private static float delayTime;
private const float renameDelaySec = 1f;
private static void PostURPConversion()
{
//Wait 1s
if (EditorApplication.timeSinceStartup >= delayTime)
{
EditorApplication.update -= PostURPConversion;
//If any controllers are present in the open scene, these need to be nudged to apply the correct shaders
CliffAppearance[] cliffControllers = GameObject.FindObjectsOfType<CliffAppearance>();
for (int i = 0; i < cliffControllers.Length; i++)
{
cliffControllers[i].OnEnable();
}
string[] shaderFileGUIDS = AssetDatabase.FindAssets("t: Shader", new[] {PACKAGE_ROOT_FOLDER + "/Shaders/URP"});
//Force a re-import of the Shader Graphs, depending on the angle of the sun, and the orbit of Jupiter, they fail to reference the FAE.hlsl file if imported last
for (int i = 0; i < shaderFileGUIDS.Length; i++)
{
AssetDatabase.ImportAsset(AssetDatabase.GUIDToAssetPath(shaderFileGUIDS[i]));
}
if (EditorUtility.DisplayDialog("Fantasy Adventure Environment", "Ensure the Depth/Opaque Texture options are enabled in your pipeline settings, otherwise the water isn't visible in the game view", "Show me", "OK"))
{
Selection.activeObject = UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset;
}
AssetDatabase.SaveAssets();
}
}
#endif
}
}//namespace

View File

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

View File

@@ -0,0 +1,230 @@
// Fantasy Adventure Environment
// Copyright Staggart Creations
// staggart.xyz
using UnityEngine;
using UnityEditor;
using System.Collections;
namespace FAE
{
public class FoliageShaderGUI : ShaderGUI
{
MaterialProperty _MaskClipValue;
//Main maps
MaterialProperty _MainTex;
MaterialProperty _BumpMap;
MaterialProperty _Color;
//Color
MaterialProperty _WindTint;
MaterialProperty _AmbientOcclusion;
MaterialProperty _TransmissionSize;
MaterialProperty _TransmissionAmount;
//Animation
MaterialProperty _MaxWindStrength;
MaterialProperty _GlobalWindMotion;
MaterialProperty _LeafFlutter;
MaterialProperty _WindAmplitudeMultiplier;
MaterialProperty _WindSwinging;
MaterialProperty _BendingInfluence;
MaterialEditor m_MaterialEditor;
private Material targetMat;
//Meta
bool showHelp;
bool showHelpColor;
bool showHelpAnimation;
bool hasWindController;
WindController windController;
GUIContent mainTexName = new GUIContent("Diffuse", "Diffuse (RGB) and Transparency (A)");
GUIContent normalMapName = new GUIContent("Normal Map");
private bool visualizeVectors;
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
{
if (windController == null) LocateWindController();
//Receive
visualizeVectors = WindController._visualizeVectors;
this.m_MaterialEditor = materialEditor;
targetMat = (Material)materialEditor.target;
this.FindProperties(props);
//Style similar to Standard shader
m_MaterialEditor.SetDefaultGUIWidths();
m_MaterialEditor.UseDefaultMargins();
EditorGUIUtility.labelWidth = 0f;
#if UNITY_2019_3_OR_NEWER
if (UnityEngine.Rendering.GraphicsSettings.currentRenderPipeline != null &&
!targetMat.shader.name.Contains("Universal Render Pipeline"))
{
EditorGUILayout.HelpBox("A render pipeline is in use, but this material is using a shader for the Built-in render pipeline.\n\nShaders and materials can be converted through the Help window", MessageType.Error);
EditorGUILayout.Space();
}
#endif
EditorGUI.BeginChangeCheck();
//Draw fields
DoHeader();
DoMapsArea();
DoColorArea();
DoAnimationArea();
if (EditorGUI.EndChangeCheck())
{
//Send
WindController.VisualizeVectors(visualizeVectors);
}
GUIHelper.DrawExtraFields(m_MaterialEditor);
GUIHelper.DrawFooter();
}
void DoHeader()
{
EditorGUILayout.BeginHorizontal();
showHelp = GUILayout.Toggle(showHelp, "Toggle help", "Button");
GUILayout.Label("FAE Foliage Shader", GUIHelper.Header);
EditorGUILayout.EndHorizontal();
if (showHelp) EditorGUILayout.HelpBox("Please bear in mind, when using custom meshes, that most shader feature require the tips of the mesh to be vertex colored.\n\nBaking Ambient Occlusion into the vertex colors will yield correct results.", MessageType.Warning);
}
void DoMapsArea()
{
GUILayout.Label("Main maps", EditorStyles.boldLabel);
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel(_MaskClipValue.displayName);
_MaskClipValue.floatValue = EditorGUILayout.Slider(_MaskClipValue.floatValue, 0f, 1f);
EditorGUILayout.EndHorizontal();
this.m_MaterialEditor.TexturePropertySingleLine(mainTexName, this._MainTex);
if(targetMat.HasProperty("_BumpMap"))this.m_MaterialEditor.TexturePropertySingleLine(normalMapName, this._BumpMap);
EditorGUILayout.Space();
}
void DoColorArea()
{
EditorGUILayout.BeginHorizontal();
showHelpColor = GUILayout.Toggle(showHelpColor, "?", "Button", GUILayout.Width(25f)); GUILayout.Label("Color", EditorStyles.boldLabel);
EditorGUILayout.EndHorizontal();
m_MaterialEditor.ShaderProperty(_Color, _Color.displayName);
m_MaterialEditor.ShaderProperty(_AmbientOcclusion, _AmbientOcclusion.displayName);
if (showHelpColor) EditorGUILayout.HelpBox("Darkens the areas of the mesh where vertex colors are applied", MessageType.None);
m_MaterialEditor.ShaderProperty(_TransmissionAmount, _TransmissionAmount.displayName);
if (showHelpColor) EditorGUILayout.HelpBox("Simulates light passing through the material. This will have no effect on short grass.", MessageType.None);
m_MaterialEditor.ShaderProperty(_TransmissionSize, _TransmissionSize.displayName);
EditorGUILayout.Space();
}
void DoAnimationArea()
{
EditorGUILayout.BeginHorizontal();
showHelpAnimation = GUILayout.Toggle(showHelpAnimation, "?", "Button", GUILayout.Width(25f)); GUILayout.Label("Wind animation", EditorStyles.boldLabel);
EditorGUILayout.EndHorizontal();
#if UNITY_2019_3_OR_NEWER
if (UnityEngine.Rendering.GraphicsSettings.currentRenderPipeline == null)
{
#endif
visualizeVectors = EditorGUILayout.Toggle("Visualize wind", visualizeVectors);
#if UNITY_2019_3_OR_NEWER
}
#endif
#if !VEGETATION_STUDIO_PRO //VS Pro has an FAE wind controller
if (!hasWindController)
{
EditorGUILayout.HelpBox("No \"WindController\" component was found in your scene. Please add this script to an empty GameObject\n\nA prefab can be found in the Prefabs/Effects folder.", MessageType.Warning);
EditorGUI.BeginDisabledGroup(true);
}
#else
EditorGUI.BeginDisabledGroup(false);
#endif
if (showHelpAnimation) EditorGUILayout.HelpBox("Toggle a visualisation of the wind vectors on all the objects that use FAE shaders featuring wind.\n\nThis allows you to more clearly see the effects of the settings.", MessageType.None);
m_MaterialEditor.ShaderProperty(_MaxWindStrength, _MaxWindStrength.displayName);
if (showHelpAnimation) EditorGUILayout.HelpBox("Determines how much influence the wind has on the object", MessageType.None);
m_MaterialEditor.ShaderProperty(_GlobalWindMotion, _GlobalWindMotion.displayName);
if (showHelpAnimation) EditorGUILayout.HelpBox("Back and forth motion", MessageType.None);
m_MaterialEditor.ShaderProperty(_LeafFlutter, _LeafFlutter.displayName);
if (showHelpAnimation) EditorGUILayout.HelpBox("Local wind turbulence", MessageType.None);
m_MaterialEditor.ShaderProperty(_WindAmplitudeMultiplier, _WindAmplitudeMultiplier.displayName);
if (showHelpAnimation) EditorGUILayout.HelpBox("Multiply the wind amplitude for this material.Essentally this is the size of the wind waves.", MessageType.None);
m_MaterialEditor.ShaderProperty(_WindSwinging, _WindSwinging.displayName);
if (showHelpAnimation) EditorGUILayout.HelpBox("Higher values mean the object always sways back against the wind direction", MessageType.None);
if (targetMat.HasProperty("_WindTint"))
{
m_MaterialEditor.ShaderProperty(_WindTint, _WindTint.displayName);
if (showHelpAnimation)
EditorGUILayout.HelpBox("Vizualises the wind by adding a slight tint, either dark (<0) or light (>0)", MessageType.None);
}
if (showHelpAnimation) EditorGUILayout.HelpBox("Multiply the wind amplitude for this material. Essentally this is the size of the wind waves.", MessageType.None);
if (!hasWindController)
{
EditorGUI.EndDisabledGroup();
}
m_MaterialEditor.ShaderProperty(_BendingInfluence, _BendingInfluence.displayName);
if (showHelpAnimation) EditorGUILayout.HelpBox("Determines how much influence the FoliageBender script has on the object", MessageType.None);
if (hasWindController && showHelpAnimation)
{
GUIHelper.DrawWindInfo();
}
EditorGUILayout.Space();
}
void LocateWindController()
{
//Debug.Log("Searching scene for WindController script");
windController = GameObject.FindObjectOfType<WindController>();
hasWindController = (windController) ? true : false;
}
public void FindProperties(MaterialProperty[] props)
{
//Rendering
#if UNITY_2017_1_OR_NEWER
_MaskClipValue = FindProperty("_Cutoff", props);
#else
_MaskClipValue = FindProperty("_Cutoff", props);
#endif
//Main maps
_MainTex = FindProperty("_MainTex", props);
if(targetMat.HasProperty("_BumpMap")) _BumpMap = FindProperty("_BumpMap", props);
//Color
if(targetMat.HasProperty("_WindTint")) _WindTint = FindProperty("_WindTint", props);
_Color = FindProperty("_Color", props);
_AmbientOcclusion = FindProperty("_AmbientOcclusion", props);
_TransmissionSize = FindProperty("_TransmissionSize", props);
_TransmissionAmount = FindProperty("_TransmissionAmount", props);
//Animation
_MaxWindStrength = FindProperty("_MaxWindStrength", props);
_GlobalWindMotion = FindProperty("_GlobalWindMotion", props);
_LeafFlutter = FindProperty("_LeafFlutter", props);
_WindAmplitudeMultiplier = FindProperty("_WindAmplitudeMultiplier", props);
_WindSwinging = FindProperty("_WindSwinging", props);
_BendingInfluence = FindProperty("_BendingInfluence", props);
}
}
}

View File

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

View File

@@ -0,0 +1,75 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
namespace FAE
{
/// <summary>
/// Helper class to centralize commonly used fields and styles used in inspectors
/// </summary>
public class GUIHelper : Editor
{
/// <summary>Draws the Staggart Creations footer</summary>
public static void DrawFooter()
{
GUILayout.Label("- Staggart Creations -", new GUIStyle(EditorStyles.centeredGreyMiniLabel)
{
alignment = TextAnchor.MiddleCenter,
wordWrap = true,
fontSize = 12
});
}
/// <summary>Displays a box with the wind values from the current WindController</summary>
public static void DrawWindInfo()
{
EditorGUILayout.Space();
EditorGUILayout.LabelField("Global wind settings", EditorStyles.boldLabel);
GUIHelper.ProgressBar(WindController._windStrength, 1f, "Strength");
GUIHelper.ProgressBar(WindController._windAmplitude, 32f, "Amplitude");
EditorGUILayout.Space();
}
private static void ProgressBar(float value, float maxValue, string label)
{
Rect rect = GUILayoutUtility.GetRect(6, 18, "TextField");
EditorGUI.ProgressBar(rect, value / maxValue, label + " (" + value + " / " + maxValue + ")");
}
/// <summary>If the supported Unity version is used, a field for setting the Render Queue and GPU Instancing options is drawn</summary>
public static void DrawExtraFields(MaterialEditor m_MaterialEditor)
{
#if UNITY_5_5_OR_NEWER
m_MaterialEditor.RenderQueueField();
#endif
#if UNITY_5_6_OR_NEWER
m_MaterialEditor.EnableInstancingField();
#endif
}
//Styles
private static GUIStyle _Header;
public static GUIStyle Header
{
get
{
if (_Header == null)
{
_Header = new GUIStyle(EditorStyles.centeredGreyMiniLabel)
{
alignment = TextAnchor.MiddleCenter,
wordWrap = true,
fontSize = 12
};
}
return _Header;
}
}
}
}

View File

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

View File

@@ -0,0 +1,352 @@
// Fantasy Adventure Environment
// Copyright Staggart Creations
// staggart.xyz
using UnityEngine;
using UnityEditor;
using System.Collections;
namespace FAE
{
[ExecuteInEditMode]
public class GrassShaderGUI : ShaderGUI
{
MaterialProperty _MaskClipValue;
//Main maps
MaterialProperty _MainTex;
MaterialProperty _BumpMap;
//Color
MaterialProperty _ColorTop;
MaterialProperty _ColorBottom;
MaterialProperty _ColorVariation;
MaterialProperty _AmbientOcclusion;
MaterialProperty _TransmissionSize;
MaterialProperty _TransmissionAmount;
//Animation
MaterialProperty _MaxWindStrength;
MaterialProperty _WindSwinging;
MaterialProperty _WindAmplitudeMultiplier;
MaterialProperty _BendingInfluence;
//VS Touch Bend
#if TOUCH_REACT
MaterialProperty _VS_TOUCHBEND;
MaterialProperty _BendingTint;
#endif
//Heightmap
MaterialProperty _HeightmapInfluence;
MaterialProperty _MinHeight;
MaterialProperty _MaxHeight;
//Pigment map
MaterialProperty _PigmentMapInfluence;
MaterialProperty _PigmentMapHeight;
MaterialEditor m_MaterialEditor;
//Meta
bool showHelp;
bool showHelpColor;
bool showHelpAnimation;
bool showHelpBending;
bool showHelpHeightmap;
bool showHelpPigmentmap;
#if UNITY_5_5_OR_NEWER
bool hasPigmentMap = true;
#endif
bool hasWindController;
WindController windController;
GUIContent mainTexName = new GUIContent("Diffuse", "Diffuse (RGB) and Transparency (A)");
GUIContent normalMapName = new GUIContent("Normal Map");
private bool visualizeVectors;
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
{
if (windController == null) LocateWindController();
this.FindProperties(props);
//Receive
visualizeVectors = WindController._visualizeVectors;
this.m_MaterialEditor = materialEditor;
//Style similar to Standard shader
m_MaterialEditor.SetDefaultGUIWidths();
m_MaterialEditor.UseDefaultMargins();
EditorGUIUtility.labelWidth = 0f;
//GetGlobalTexture is only available since Unity 5.5
#if UNITY_5_5_OR_NEWER
hasPigmentMap = (Shader.GetGlobalTexture("_PigmentMap")) ? true : false;
#endif
EditorGUI.BeginChangeCheck();
//Draw fields
DoHeader();
DoMapsArea();
DoColorArea();
DoAnimationArea();
DoBendingArea();
DoHeightmapArea();
DoPigmentMapArea();
if (EditorGUI.EndChangeCheck())
{
//Send
WindController.VisualizeVectors(visualizeVectors);
}
GUIHelper.DrawExtraFields(m_MaterialEditor);
GUIHelper.DrawFooter();
}
void DoHeader()
{
EditorGUILayout.BeginHorizontal();
showHelp = GUILayout.Toggle(showHelp, "Toggle help", "Button");
GUILayout.Label("FAE Grass Shader", GUIHelper.Header);
EditorGUILayout.EndHorizontal();
if (showHelp) EditorGUILayout.HelpBox("Please bear in mind, when using custom meshes, that most shader feature require the top of the mesh to be vertex colored.", MessageType.Warning);
}
void DoMapsArea()
{
GUILayout.Label("Main maps", EditorStyles.boldLabel);
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel(_MaskClipValue.displayName);
_MaskClipValue.floatValue = EditorGUILayout.Slider(_MaskClipValue.floatValue, 0f, 1f);
EditorGUILayout.EndHorizontal();
this.m_MaterialEditor.TexturePropertySingleLine(mainTexName, this._MainTex);
this.m_MaterialEditor.TexturePropertySingleLine(normalMapName, this._BumpMap);
EditorGUILayout.Space();
}
void DoColorArea()
{
EditorGUILayout.BeginHorizontal();
showHelpColor = GUILayout.Toggle(showHelpColor, "?", "Button", GUILayout.Width(25f)); GUILayout.Label("Color", EditorStyles.boldLabel);
EditorGUILayout.EndHorizontal();
EditorGUI.BeginDisabledGroup(_PigmentMapInfluence.floatValue == 1);
m_MaterialEditor.ShaderProperty(_ColorTop, "Top");
m_MaterialEditor.ShaderProperty(_ColorBottom, "Bottom");
EditorGUI.EndDisabledGroup();
if (_PigmentMapInfluence.floatValue == 1)
{
EditorGUILayout.HelpBox("These colors are disabled because the pigment map influence value is set to 1, so they would have no effect", MessageType.None);
}
m_MaterialEditor.ShaderProperty(_ColorVariation, _ColorVariation.displayName);
if (showHelpColor) EditorGUILayout.HelpBox("Vizualises the wind by adding a slight white tint. When the wind strength is set 0, this effect doesn't appear", MessageType.None);
m_MaterialEditor.ShaderProperty(_AmbientOcclusion, _AmbientOcclusion.displayName);
if (showHelpColor) EditorGUILayout.HelpBox("Darkens the areas of the mesh where vertex colors are applied", MessageType.None);
m_MaterialEditor.ShaderProperty(_TransmissionAmount, _TransmissionAmount.displayName);
if (showHelpColor) EditorGUILayout.HelpBox("Simulates light passing through the material. This will have no effect on short grass.", MessageType.None);
m_MaterialEditor.ShaderProperty(_TransmissionSize, _TransmissionSize.displayName);
EditorGUILayout.Space();
}
void DoAnimationArea()
{
EditorGUILayout.BeginHorizontal();
showHelpAnimation = GUILayout.Toggle(showHelpAnimation, "?", "Button", GUILayout.Width(25f)); GUILayout.Label("Wind animation", EditorStyles.boldLabel);
EditorGUILayout.EndHorizontal();
visualizeVectors = EditorGUILayout.Toggle("Visualize wind", visualizeVectors);
#if !VEGETATION_STUDIO_PRO //VS Pro has an FAE wind controller
if (!hasWindController)
{
EditorGUILayout.HelpBox("No \"WindController\" component was found in your scene. Please add this script to an empty GameObject\n\nA prefab can be found in the Prefabs/Effects folder.", MessageType.Warning);
EditorGUI.BeginDisabledGroup(true);
}
#else
EditorGUI.BeginDisabledGroup(false);
#endif
if (showHelpAnimation) EditorGUILayout.HelpBox("Toggle a visualisation of the wind vectors on all the objects that use FAE shaders featuring wind.\n\nThis allows you to more clearly see the effects of the settings.", MessageType.None);
m_MaterialEditor.ShaderProperty(_MaxWindStrength, _MaxWindStrength.displayName);
if (showHelpAnimation) EditorGUILayout.HelpBox("Determines how much influence the wind has on the object", MessageType.None);
m_MaterialEditor.ShaderProperty(_WindSwinging, _WindSwinging.displayName);
if (showHelpAnimation) EditorGUILayout.HelpBox("Higher values mean the object always sways back against the wind direction", MessageType.None);
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField(_WindAmplitudeMultiplier.displayName);
_WindAmplitudeMultiplier.floatValue = EditorGUILayout.FloatField(_WindAmplitudeMultiplier.floatValue, GUILayout.Width(65f));
EditorGUILayout.EndHorizontal();
if (showHelpAnimation) EditorGUILayout.HelpBox("Multiply the wind amplitude for this material. Essentally this is the size of the wind waves.", MessageType.None);
if (!hasWindController)
{
EditorGUI.EndDisabledGroup();
}
if (hasWindController && showHelpAnimation)
{
GUIHelper.DrawWindInfo();
}
EditorGUILayout.Space();
}
void DoBendingArea()
{
EditorGUILayout.BeginHorizontal();
showHelpBending = GUILayout.Toggle(showHelpBending, "?", "Button", GUILayout.Width(25f)); GUILayout.Label("Bending", EditorStyles.boldLabel);
EditorGUILayout.EndHorizontal();
#if TOUCH_REACT
m_MaterialEditor.ShaderProperty(_VS_TOUCHBEND, new GUIContent("Use Vegetation Studio TouchBend"));
if (showHelpBending) EditorGUILayout.HelpBox("Utilize Vegetation Studio's TouchBendSystem", MessageType.None);
if (_VS_TOUCHBEND.floatValue == 1)
{
m_MaterialEditor.ShaderProperty(_BendingTint, _BendingTint.displayName);
if (showHelpBending) EditorGUILayout.HelpBox("Darken the grass where it is bending", MessageType.None);
}
else
#endif
{
m_MaterialEditor.ShaderProperty(_BendingInfluence, _BendingInfluence.displayName);
if (showHelpBending) EditorGUILayout.HelpBox("Determines how much influence the FoliageBender script has on the object", MessageType.None);
}
EditorGUILayout.Space();
}
void LocateWindController()
{
//Debug.Log("Searching scene for WindController script");
windController = GameObject.FindObjectOfType<WindController>();
hasWindController = (windController) ? true : false;
}
void DoHeightmapArea()
{
EditorGUILayout.BeginHorizontal();
showHelpHeightmap = GUILayout.Toggle(showHelpHeightmap, "?", "Button", GUILayout.Width(25f)); GUILayout.Label("Heightmap", EditorStyles.boldLabel);
EditorGUILayout.EndHorizontal();
#if UNITY_5_5_OR_NEWER
if(!hasPigmentMap)
{
EditorGUILayout.HelpBox("No height map was found, please add the PigmentMapGenerator script to your terrain to enable these features", MessageType.Warning);
_HeightmapInfluence.floatValue = 0;
EditorGUI.BeginDisabledGroup(true);
}
#endif
if (showHelpHeightmap) EditorGUILayout.HelpBox("The heightmap is generated through the PigmentMapGenerator script on your terrain", MessageType.None);
m_MaterialEditor.ShaderProperty(_HeightmapInfluence, "Influence");
if (showHelpHeightmap) EditorGUILayout.HelpBox("Determines the influence the heightmap has on the object", MessageType.None);
m_MaterialEditor.ShaderProperty(_MinHeight, _MinHeight.displayName);
if (showHelpHeightmap) EditorGUILayout.HelpBox("Minimum grass height", MessageType.None);
m_MaterialEditor.ShaderProperty(_MaxHeight, _MaxHeight.displayName);
if (showHelpHeightmap) EditorGUILayout.HelpBox("Maximum grass height", MessageType.None);
EditorGUILayout.Space();
#if UNITY_5_5_OR_NEWER
if (!hasPigmentMap)
{
EditorGUI.EndDisabledGroup();
}
#endif
}
void DoPigmentMapArea()
{
EditorGUILayout.BeginHorizontal();
showHelpPigmentmap = GUILayout.Toggle(showHelpPigmentmap, "?", "Button", GUILayout.Width(25f)); GUILayout.Label("Pigment map", EditorStyles.boldLabel);
EditorGUILayout.EndHorizontal();
#if UNITY_5_5_OR_NEWER
if(!hasPigmentMap)
{
EditorGUILayout.HelpBox("No pigment map was found, please add the PigmentMapGenerator script to your terrain to enable these features", MessageType.Warning);
_PigmentMapInfluence.floatValue = 0;
EditorGUI.BeginDisabledGroup(true);
}
#endif
if (showHelpPigmentmap) EditorGUILayout.HelpBox("The pigment map is generated through the PigmentMapGenerator script on your terrain. It colors the grass by the terrain's color.", MessageType.None);
m_MaterialEditor.ShaderProperty(_PigmentMapInfluence, "Influence");
if (showHelpPigmentmap) EditorGUILayout.HelpBox("Determines how much the object should be colored through the pigment map", MessageType.None);
m_MaterialEditor.ShaderProperty(_PigmentMapHeight, "Height");
if (showHelpPigmentmap) EditorGUILayout.HelpBox("With this parameter you can choose to only color the base of the grass", MessageType.None);
EditorGUILayout.Space();
if (showHelpPigmentmap) EditorGUILayout.HelpBox("If your grass is completely white, bring the Influence parameter to 0. Or add the PigmentmapGenerator script to your terrain.", MessageType.Info);
#if UNITY_5_4 && !UNITY_5_5_OR_NEWER
if (showHelpPigmentmap) EditorGUILayout.HelpBox("In versions older than Unity 5.5, it is possible for your grass to still be colored by the last pigment map generated", MessageType.Info);
#endif
EditorGUILayout.Space();
#if UNITY_5_5_OR_NEWER
if (!hasPigmentMap)
{
EditorGUI.EndDisabledGroup();
}
#endif
}
public void FindProperties(MaterialProperty[] props)
{
//Rendering
_MaskClipValue = FindProperty("_Cutoff", props);
//Main maps
_MainTex = FindProperty("_MainTex", props);
_BumpMap = FindProperty("_BumpMap", props);
//Color
_ColorTop = FindProperty("_ColorTop", props);
_ColorBottom = FindProperty("_ColorBottom", props);
_ColorVariation = FindProperty("_ColorVariation", props);
_AmbientOcclusion = FindProperty("_AmbientOcclusion", props);
_TransmissionSize = FindProperty("_TransmissionSize", props);
_TransmissionAmount = FindProperty("_TransmissionAmount", props);
//Animation
_MaxWindStrength = FindProperty("_MaxWindStrength", props);
_WindSwinging = FindProperty("_WindSwinging", props);
_WindAmplitudeMultiplier = FindProperty("_WindAmplitudeMultiplier", props);
_BendingInfluence = FindProperty("_BendingInfluence", props);
#if TOUCH_REACT
//TouchBend
_VS_TOUCHBEND = FindProperty("_VS_TOUCHBEND", props);
_BendingTint = FindProperty("_BendingTint", props);
#endif
//Heightmap
_HeightmapInfluence = FindProperty("_HeightmapInfluence", props);
_MinHeight = FindProperty("_MinHeight", props);
_MaxHeight = FindProperty("_MaxHeight", props);
//Pigment map
_PigmentMapInfluence = FindProperty("_PigmentMapInfluence", props);
_PigmentMapHeight = FindProperty("_PigmentMapHeight", props);
}
}
}

View File

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

View File

@@ -0,0 +1,342 @@
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace FAE
{
public class HelpWindow : EditorWindow
{
//Window properties
private static int width = 440;
private static int height = 300;
private bool isTabInstallation = true;
private bool isTabGettingStarted = false;
private bool isTabSupport = false;
[MenuItem("Help/Fantasy Adventure Environment", false, 0)]
public static void ShowWindow()
{
EditorWindow editorWindow = EditorWindow.GetWindow<HelpWindow>(false, "About", true);
editorWindow.titleContent = new GUIContent("Help " + FAE_Core.INSTALLED_VERSION);
editorWindow.autoRepaintOnSceneChange = true;
//Open somewhat in the center of the screen
editorWindow.position = new Rect((Screen.width) / 2f, (Screen.height) / 2f, width, height);
//Fixed size
editorWindow.maxSize = new Vector2(width, height);
editorWindow.minSize = new Vector2(width, 200);
Init();
editorWindow.Show();
}
private void SetWindowHeight(float height)
{
this.maxSize = new Vector2(width, height);
this.minSize = new Vector2(width, height);
}
//Store values in the volatile SessionState
static void Init()
{
FAE_Core.GetRootFolder();
}
void OnGUI()
{
DrawHeader();
GUILayout.Space(5);
DrawTabs();
GUILayout.Space(5);
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
if (isTabInstallation) DrawInstallation();
if (isTabGettingStarted) DrawGettingStarted();
if (isTabSupport) DrawSupport();
//DrawActionButtons();
EditorGUILayout.EndVertical();
DrawFooter();
}
void DrawHeader()
{
EditorGUILayout.Space();
EditorGUILayout.LabelField("<b><size=24>Fantasy Adventure Environment</size></b>", Header);
GUILayout.Label("Version: " + FAE_Core.INSTALLED_VERSION, Footer);
EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
}
void DrawTabs()
{
EditorGUILayout.BeginHorizontal();
if (GUILayout.Toggle(isTabInstallation, "Installation", Tab))
{
isTabInstallation = true;
isTabGettingStarted = false;
isTabSupport = false;
}
if (GUILayout.Toggle(isTabGettingStarted, "Getting started", Tab))
{
isTabInstallation = false;
isTabGettingStarted = true;
isTabSupport = false;
}
if (GUILayout.Toggle(isTabSupport, "Support", Tab))
{
isTabInstallation = false;
isTabGettingStarted = false;
isTabSupport = true;
}
EditorGUILayout.EndHorizontal();
}
void DrawInstallation()
{
SetWindowHeight(335);
EditorGUILayout.LabelField("Render pipeline conversion", EditorStyles.boldLabel);
#if !UNITY_2019_3_OR_NEWER
EditorGUILayout.HelpBox("Universal Render Pipeline support requires Unity 2019.3.7f1 or newer", MessageType.Info);
#else
if (UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset == null)
{
EditorGUILayout.HelpBox("No Scriptable Render Pipeline is currently active", MessageType.Warning);
}
#if FAE_DEV
EditorGUILayout.BeginHorizontal();
{
if (GUILayout.Button("<b><size=16>Built-in</size></b>\n<i>Amplify Shader Editor shaders</i>", Button))
{
FAE_Core.InstallShaders(FAE_Core.ShaderInstallation.BuiltIn);
}
#endif
using (new EditorGUI.DisabledGroupScope(UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset == null))
{
if (GUILayout.Button("<b><size=16>Universal Render Pipeline</size></b>\n<i>Unpack Shader Graph shaders and URP materials</i>", Button))
{
FAE_Core.InstallShaders(FAE_Core.ShaderInstallation.UniversalRP);
}
}
#if FAE_DEV
}
EditorGUILayout.EndHorizontal();
#endif
EditorGUILayout.Space();
using (new EditorGUILayout.HorizontalScope())
{
EditorGUILayout.HelpBox("Note: Grass shader for the URP is available on the Asset Store", MessageType.Info);
if (GUILayout.Button("Open Asset Store", GUILayout.Height(40f), GUILayout.Width(120f)))
{
Application.OpenURL("com.unity3d.kharma:content/143830");
}
}
#endif
}
void DrawGettingStarted()
{
SetWindowHeight(335);
EditorGUILayout.HelpBox("Please view the documentation for further details about this package and its workings.", MessageType.Info);
EditorGUILayout.Space();
if (GUILayout.Button("<b><size=16>Online documentation</size></b>\n<i>Set up, best practices and troubleshooting</i>", Button))
{
Application.OpenURL(FAE_Core.DOC_URL + "#getting-started-3");
}
}
void DrawSupport()
{
SetWindowHeight(350f);
EditorGUILayout.BeginVertical(); //Support box
EditorGUILayout.HelpBox("If you have any questions, or ran into issues, please get in touch!", MessageType.Info);
EditorGUILayout.Space();
//Buttons box
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("<b><size=12>Email</size></b>\n<i>Contact</i>", Button))
{
Application.OpenURL("mailto:contact@staggart.xyz");
}
if (GUILayout.Button("<b><size=12>Twitter</size></b>\n<i>Follow developments</i>", Button))
{
Application.OpenURL("https://twitter.com/search?q=staggart%20creations");
}
if (GUILayout.Button("<b><size=12>Forum</size></b>\n<i>Join the discussion</i>", Button))
{
Application.OpenURL(FAE_Core.FORUM_URL);
}
EditorGUILayout.EndHorizontal();//Buttons box
EditorGUILayout.EndVertical(); //Support box
}
private void DrawActionButtons()
{
EditorGUILayout.Space();
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("<size=12>Rate</size>", Button))
Application.OpenURL("https://www.assetstore.unity3d.com/en/#!/account/downloads/search=");
if (GUILayout.Button("<size=12>Review</size>", Button))
Application.OpenURL("");
EditorGUILayout.EndHorizontal();
EditorGUILayout.Space();
}
private void DrawFooter()
{
//EditorGUILayout.Space();
EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
EditorGUILayout.Space();
GUILayout.Label("- Staggart Creations -", Footer);
}
#region Styles
private static GUIStyle _Footer;
public static GUIStyle Footer
{
get
{
if (_Footer == null)
{
_Footer = new GUIStyle(EditorStyles.centeredGreyMiniLabel)
{
alignment = TextAnchor.MiddleCenter,
wordWrap = true,
fontSize = 12
};
}
return _Footer;
}
}
private static GUIStyle _Button;
public static GUIStyle Button
{
get
{
if (_Button == null)
{
_Button = new GUIStyle(GUI.skin.button)
{
alignment = TextAnchor.MiddleLeft,
stretchWidth = true,
richText = true,
wordWrap = true,
padding = new RectOffset()
{
left = 14,
right = 14,
top = 8,
bottom = 8
}
};
}
return _Button;
}
}
private static GUIStyle _Header;
public static GUIStyle Header
{
get
{
if (_Header == null)
{
_Header = new GUIStyle(GUI.skin.label)
{
richText = true,
alignment = TextAnchor.MiddleCenter,
wordWrap = true,
fontSize = 18,
fontStyle = FontStyle.Bold
};
}
return _Header;
}
}
private static Texture _HelpIcon;
public static Texture HelpIcon
{
get
{
if (_HelpIcon == null)
{
_HelpIcon = EditorGUIUtility.FindTexture("d_UnityEditor.InspectorWindow");
}
return _HelpIcon;
}
}
private static GUIStyle _Tab;
public static GUIStyle Tab
{
get
{
if (_Tab == null)
{
_Tab = new GUIStyle(EditorStyles.miniButtonMid)
{
alignment = TextAnchor.MiddleCenter,
stretchWidth = true,
richText = true,
wordWrap = true,
fontSize = 12,
fixedHeight = 30f,
fontStyle = FontStyle.Bold,
padding = new RectOffset()
{
left = 14,
right = 14,
top = 8,
bottom = 8
}
};
}
return _Tab;
}
}
#endregion //Stylies
}//Window Class
}

View File

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

View File

@@ -0,0 +1,451 @@
// Fantasy Adventure Environment
// Copyright Staggart Creations
// staggart.xyz
using UnityEngine;
using System.Collections;
using UnityEditor;
using UnityEditor.Callbacks;
using FAE;
using System;
namespace FAE
{
[CustomEditor(typeof(PigmentMapGenerator))]
public class PigmentMapGeneratorInspector : Editor
{
PigmentMapGenerator pmg;
new SerializedObject serializedObject;
SerializedProperty isMultiTerrain;
SerializedProperty isMegaSplat;
SerializedProperty terrainObjects;
SerializedProperty manualInput;
SerializedProperty resIdx;
SerializedProperty useCustomPigmentMap;
SerializedProperty inputPigmentMap;
SerializedProperty layerMask;
public static string[] reslist = new string[] { "64x64", "128x128", "256x256", "512x512", "1024x1024", "2048x2048", "4096x4096" };
// Use this for initialization
void OnEnable()
{
pmg = (PigmentMapGenerator)target;
GetProperties();
}
private void GetProperties()
{
serializedObject = new SerializedObject(pmg);
isMultiTerrain = serializedObject.FindProperty("isMultiTerrain");
isMegaSplat = serializedObject.FindProperty("isMegaSplat");
terrainObjects = serializedObject.FindProperty("terrainObjects");
manualInput = serializedObject.FindProperty("manualInput");
resIdx = serializedObject.FindProperty("resIdx");
useCustomPigmentMap = serializedObject.FindProperty("useCustomPigmentMap");
inputPigmentMap = serializedObject.FindProperty("customPigmentMap");
layerMask = serializedObject.FindProperty("layerMask");
}
//Meta
private string terrainInfo;
private bool showHelp;
public override void OnInspectorGUI()
{
DoHeader();
#if UNITY_2019_3_OR_NEWER
if (UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset)
{
EditorGUILayout.HelpBox("Not available in the Universal Render Pipeline.\n\nThe Stylized Grass Shader package is URP compatible", MessageType.Warning);
GUILayout.Space(-32);
using (new EditorGUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
if (GUILayout.Button("Open Asset Store", GUILayout.Width(120)))
{
Application.OpenURL("com.unity3d.kharma:content/143830");
}
GUILayout.Space(8);
}
GUILayout.Space(11);
}
#endif
EditorGUI.BeginChangeCheck();
serializedObject.Update();
DrawTerrainInfo();
EditorGUILayout.PropertyField(useCustomPigmentMap, new GUIContent("Custom pigment map"));
if (showHelp) EditorGUILayout.HelpBox("This option allows you to assign a custom pigment map, rather than rendering one.", MessageType.Info);
EditorGUILayout.Space();
//Custom pigment map
if (useCustomPigmentMap.boolValue)
{
EditorGUILayout.PropertyField(inputPigmentMap, new GUIContent("Input"));
if (showHelp) EditorGUILayout.HelpBox("Grass heightmap should be stored in the alpha channel.", MessageType.Info);
if (pmg.customPigmentMap)
{
//Check if input heightmap is readable
try
{
pmg.customPigmentMap.GetPixel(0, 0);
}
catch (UnityException e)
{
if (e.Message.StartsWith("Texture '" + pmg.customPigmentMap.name + "' is not readable"))
{
EditorGUILayout.HelpBox("Please enable the Read/Write option on texture \"" + pmg.customPigmentMap.name + "\"\n\nIt accessed be read otherwise.", MessageType.Error);
}
}
}
EditorGUILayout.Space();
}
//If terrain list is empty, expand it
if (isMultiTerrain.boolValue && terrainObjects.arraySize == 0 && !manualInput.boolValue)
{
terrainObjects.isExpanded = true;
}
DoTerrainList();
EditorGUILayout.Space();
if (!useCustomPigmentMap.boolValue)
{
//Safety check, required for preventing errors when updating from 1.1.2 to 1.2.0
//if (pmg.terrains == null || pmg.terrains.Length == 0) return;
//If single terrain without any textures
if (!isMegaSplat.boolValue)
{
#if UNITY_2018_3_OR_NEWER
if (!isMultiTerrain.boolValue && pmg.workflow == TerrainUVUtil.Workflow.Terrain && pmg.terrains[0].terrainData.terrainLayers.Length == 0)
#else
if (!isMultiTerrain.boolValue && pmg.workflow == TerrainUVUtil.Workflow.Terrain && pmg.terrains[0].terrainData.splatPrototypes.Length == 0)
#endif
{
EditorGUILayout.HelpBox("Assign at least one texture to your terrain", MessageType.Error);
return;
}
}
DoHeightMap();
DoTexTransforms();
DoRenderer();
}
EditorGUILayout.Space();
//Button
//If multi terrain, with no objects assigned, don't show Generate button
if (isMultiTerrain.boolValue && terrainObjects.arraySize == 0 && !manualInput.boolValue)
{
EditorGUILayout.HelpBox("Assign at least one terrain object", MessageType.Error);
}
EditorGUI.BeginDisabledGroup(isMultiTerrain.boolValue && terrainObjects.arraySize == 0 && !manualInput.boolValue);
string buttonLabel = (useCustomPigmentMap.boolValue) ? "Assign" : "Generate";
if (GUILayout.Button(buttonLabel, GUILayout.Height(40f)))
{
pmg.Generate();
}
EditorGUI.EndDisabledGroup();
EditorGUILayout.Space();
DoPreview();
//GUIHelper.DrawFooter();
serializedObject.ApplyModifiedProperties();
if (GUI.changed || EditorGUI.EndChangeCheck())
{
EditorUtility.SetDirty((PigmentMapGenerator)target);
EditorUtility.SetDirty(this);
}
}
private void DoHeader()
{
EditorGUILayout.BeginHorizontal();
showHelp = GUILayout.Toggle(showHelp, "Toggle help", "Button");
GUILayout.Label("FAE Pigmentmap Generator", GUIHelper.Header);
EditorGUILayout.EndHorizontal();
if (showHelp) EditorGUILayout.HelpBox("This renders a color map from your terrain, which is used by the \"FAE/Grass\" shader to blend the grass color with the terrain.", MessageType.Info);
if (showHelp) EditorGUILayout.HelpBox("If you'd like some objects to be included, like cliffs, parent them under your terrain object.", MessageType.Info);
if (showHelp) EditorGUILayout.HelpBox("For a multi-terrain setup, add this script to the parent object of your terrain tiles/chunks.", MessageType.Info);
EditorGUILayout.Space();
}
private void DrawTerrainInfo()
{
EditorGUILayout.PropertyField(manualInput, new GUIContent("Manual input"));
if (showHelp) EditorGUILayout.HelpBox("Allows you to manually set the terrain's size, center and corner values. Particularly useful if your terrain(s) sits in a different scene.", MessageType.Info);
if (manualInput.boolValue)
{
pmg.targetCenterPosition = EditorGUILayout.Vector3Field("Center", pmg.targetCenterPosition);
pmg.targetSize = EditorGUILayout.Vector3Field("Size", pmg.targetSize);
pmg.targetOriginPosition = EditorGUILayout.Vector3Field("Corner/Origin", pmg.targetOriginPosition);
EditorGUILayout.Space();
using (new EditorGUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
if (GUILayout.Button("Apply", EditorStyles.miniButton))
{
Shader.SetGlobalVector("_TerrainUV", new Vector4(pmg.targetSize.x, pmg.targetSize.z, Mathf.Abs(pmg.targetOriginPosition.x), Mathf.Abs(pmg.targetOriginPosition.z)));
}
}
return;
}
terrainInfo = string.Format("Size: ({0},{1},{2}) \nCenter: ({3},{4}) \nCorner: ({5},{6})",
Mathf.Round(pmg.targetSize.x),
Mathf.Round(pmg.targetSize.y),
Mathf.Round(pmg.targetSize.z),
Mathf.Round(pmg.targetCenterPosition.x),
Mathf.Round(pmg.targetCenterPosition.z),
Mathf.Round(pmg.targetOriginPosition.x),
Mathf.Round(pmg.targetOriginPosition.z)
);
EditorGUILayout.HelpBox(terrainInfo, MessageType.Info);
GUILayout.Space(-32);
using (new EditorGUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
pmg.showArea = GUILayout.Toggle(pmg.showArea, new GUIContent(" Show area", EditorGUIUtility.IconContent("Prefab Icon").image), "Button", GUILayout.MaxHeight(17f));
GUILayout.Space(8);
}
GUILayout.Space(11);
}
private void DoTerrainList()
{
if (isMultiTerrain.boolValue && !manualInput.boolValue)
{
EditorGUILayout.PropertyField(terrainObjects, new GUIContent("Terrain objects"), true);
if (terrainObjects.isExpanded)
{
EditorGUILayout.HelpBox("The first object in the array must be the corner chunk, where the terrain continues on the postive X and Z axis", MessageType.Warning);
using (new EditorGUILayout.HorizontalScope())
{
if (GUILayout.Button("Assign all child objects"))
{
pmg.GetChildTerrainObjects(pmg.transform);
}
if (GUILayout.Button("Add active terrains"))
{
AssignActiveTerrains();
}
}
}
}
else
{
//Single terrain, don't show array
}
}
private void DoHeightMap()
{
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
//If is single terrain
if (!isMultiTerrain.boolValue && pmg.workflow == TerrainUVUtil.Workflow.Terrain && !isMegaSplat.boolValue && !manualInput.boolValue)
{
EditorGUILayout.LabelField("Grass heightmap", EditorStyles.boldLabel);
EditorGUILayout.Space();
pmg.heightmapChannel = (PigmentMapGenerator.HeightmapChannel)EditorGUILayout.EnumPopup("Height source material", pmg.heightmapChannel);
if (showHelp) EditorGUILayout.HelpBox("This is the texture whose painted weight will determine the grass height \n\nThe effect can be controlled through the \"Heightmap influence\" parameter on the FAE/Grass shader", MessageType.None);
/*
if (pmg.heightmapChannel > 0)
{
using (new EditorGUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
EditorGUILayout.LabelField(pmg.terrains[0].terrainData.splatPrototypes[(int)pmg.heightmapChannel - 1].texture.name);
}
}
*/
}
//If mesh or multi terrain
else
{
//Field to assign heightmap texture
EditorGUILayout.LabelField("Input grass heightmap (optional)", EditorStyles.boldLabel);
EditorGUILayout.Space();
pmg.inputHeightmap = EditorGUILayout.ObjectField("Heightmap", pmg.inputHeightmap, typeof(Texture2D), false) as Texture2D;
if (showHelp) EditorGUILayout.HelpBox("This information is used in the \"FAE/Grass\" shader to make the grass shorter where desired", MessageType.Info);
if (pmg.inputHeightmap)
{
//Check if input heightmap is readable
try
{
pmg.inputHeightmap.GetPixel(0, 0);
}
catch (UnityException e)
{
if (e.Message.StartsWith("Texture '" + pmg.inputHeightmap.name + "' is not readable"))
{
EditorGUILayout.HelpBox("Please enable Read/Write on texture \"" + pmg.inputHeightmap.name + "\"", MessageType.Error);
}
}
}
}
EditorGUILayout.Space();
EditorGUILayout.EndVertical();
}
private void DoTexTransforms()
{
if (pmg.workflow == TerrainUVUtil.Workflow.Terrain) return;
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
EditorGUILayout.LabelField("Texture transformation", EditorStyles.boldLabel);
EditorGUILayout.Space();
if (showHelp) EditorGUILayout.HelpBox("The UV's of your mesh terrain may differ, so these options allow you to compensate for this.", MessageType.Info);
pmg.flipHortizontally = EditorGUILayout.Toggle("Flip horizontally", pmg.flipHortizontally);
pmg.flipVertically = EditorGUILayout.Toggle("Flip vertically", pmg.flipVertically);
pmg.textureRotation = (PigmentMapGenerator.TextureRotation)EditorGUILayout.EnumPopup("Rotation", pmg.textureRotation);
EditorGUILayout.Space();
EditorGUILayout.EndVertical();
}
private void DoRenderer()
{
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
EditorGUILayout.LabelField("Renderer", EditorStyles.boldLabel);
EditorGUILayout.Space();
if (manualInput.boolValue)
{
EditorGUILayout.PropertyField(layerMask, new GUIContent("Layer mask"));
EditorGUILayout.HelpBox("Manual input mode requires terrains to be on a dedicated layer", MessageType.None);
}
resIdx.intValue = EditorGUILayout.Popup("Resolution", resIdx.intValue, reslist, new GUILayoutOption[0]);
pmg.useAlternativeRenderer = EditorGUILayout.ToggleLeft("Using third-party terrain shader", pmg.useAlternativeRenderer);
if (showHelp) EditorGUILayout.HelpBox("Some third-party terrain shaders require you to use this, otherwise the result may be black.", MessageType.Info);
if (pmg.useAlternativeRenderer) pmg.renderLightBrightness = EditorGUILayout.Slider("Brightness adjustment", pmg.renderLightBrightness, 0f, 1f);
if (pmg.useAlternativeRenderer && showHelp) EditorGUILayout.HelpBox("To compensate for any shader variations on the terrain, you can use this to increase the brightness of the pigment map, in case it turns out too dark/bright.", MessageType.Info);
EditorGUILayout.Space();
EditorGUILayout.EndVertical();
}
private void DoPreview()
{
if (!useCustomPigmentMap.boolValue)
{
//Pigment map preview
if (!pmg.pigmentMap) return;
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField(string.Format("Output pigment map ({0}x{0})", pmg.pigmentMap.height), EditorStyles.boldLabel);
EditorGUILayout.EndHorizontal();
Rect cRect = EditorGUILayout.GetControlRect();
using (new EditorGUILayout.HorizontalScope())
{
EditorGUI.DrawPreviewTexture(new Rect(cRect.x, cRect.y, 150f, 150f), pmg.pigmentMap, null, ScaleMode.ScaleAndCrop);
}
GUILayout.Space(140f);
//Single terrain
if (!isMultiTerrain.boolValue)
{
if (pmg.workflow == TerrainUVUtil.Workflow.Terrain)
{
if (pmg.hasTerrainData)
{
EditorGUILayout.LabelField("The output texture file is stored next to the TerrainData asset", EditorStyles.helpBox);
}
else
{
EditorGUILayout.LabelField("The output texture file is stored next to the scene file", EditorStyles.helpBox);
}
}
else if (pmg.workflow == TerrainUVUtil.Workflow.Mesh)
{
EditorGUILayout.LabelField("The output texture file is stored next to the material file", EditorStyles.helpBox);
}
}
//Multi terrain
else
{
if (pmg.workflow == TerrainUVUtil.Workflow.Terrain)
{
EditorGUILayout.LabelField("The output texture file is stored next to the scene file", EditorStyles.helpBox);
}
else if (pmg.workflow == TerrainUVUtil.Workflow.Mesh)
{
EditorGUILayout.LabelField("The output texture file is stored next to the material file", EditorStyles.helpBox);
}
}
}
}
private void AssignActiveTerrains()
{
Terrain[] terrains = Terrain.activeTerrains;
pmg.terrainObjects = new GameObject[terrains.Length];
for (int i = 0; i < terrains.Length; i++)
{
pmg.terrainObjects[i] = terrains[i].gameObject;
}
}
}
}

View File

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

View File

@@ -0,0 +1,229 @@
// Fantasy Adventure Environment
// Copyright Staggart Creations
// staggart.xyz
using UnityEngine;
using UnityEditor;
using System.Collections;
namespace FAE
{
public class TreeBranchShaderGUI : ShaderGUI
{
MaterialProperty _MaskClipValue;
MaterialProperty _UseSpeedTreeWind;
//Main maps
MaterialProperty _MainTex;
MaterialProperty _BumpMap;
//Color
MaterialProperty _Color;
MaterialProperty _HueVariation;
MaterialProperty _AmbientOcclusion;
MaterialProperty _TransmissionColor;
MaterialProperty _GradientBrightness;
MaterialProperty _Smoothness;
MaterialProperty _FlatLighting;
//Animation
MaterialProperty _MaxWindStrength;
MaterialProperty _WindAmplitudeMultiplier;
MaterialEditor m_MaterialEditor;
//Meta
bool showHelp;
bool showHelpColor;
bool showHelpAnimation;
bool hasWindController;
WindController windController;
GUIContent mainTexName = new GUIContent("Diffuse", "Diffuse (RGB) and Transparency (A)");
GUIContent normalMapName = new GUIContent("Normal Map");
private Material targetMat;
private bool visualizeVectors;
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
{
if (windController == null) LocateWindController();
//Receive
visualizeVectors = WindController._visualizeVectors;
this.m_MaterialEditor = materialEditor;
targetMat = (Material)materialEditor.target;
this.FindProperties(props);
//Style similar to Standard shader
m_MaterialEditor.SetDefaultGUIWidths();
m_MaterialEditor.UseDefaultMargins();
EditorGUIUtility.labelWidth = 0f;
#if UNITY_2019_3_OR_NEWER
if (UnityEngine.Rendering.GraphicsSettings.currentRenderPipeline != null &&
!targetMat.shader.name.Contains("Universal Render Pipeline"))
{
EditorGUILayout.HelpBox("A render pipeline is in use, but this material is using a shader for the Built-in render pipeline.\n\nShaders and materials can be converted through the Help window", MessageType.Error);
EditorGUILayout.Space();
}
#endif
EditorGUI.BeginChangeCheck();
//Draw fields
DoHeader();
DoMapsArea();
DoColorArea();
DoAnimationArea();
if (EditorGUI.EndChangeCheck())
{
//Send
WindController.VisualizeVectors(visualizeVectors);
}
GUILayout.Label("Advanced Options", EditorStyles.boldLabel);
GUIHelper.DrawExtraFields(m_MaterialEditor);
GUIHelper.DrawFooter();
}
void DoHeader()
{
EditorGUILayout.BeginHorizontal();
showHelp = GUILayout.Toggle(showHelp, "Toggle help", "Button");
GUILayout.Label("FAE Tree Branch Shader", GUIHelper.Header);
EditorGUILayout.EndHorizontal();
if (showHelp) EditorGUILayout.HelpBox("Please bear in mind, when using custom meshes, that most shader features require the Ambient Occlusion to be baked into the RGB vertex colors.", MessageType.Warning);
}
void DoMapsArea()
{
GUILayout.Label("Main maps", EditorStyles.boldLabel);
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel(_MaskClipValue.displayName);
_MaskClipValue.floatValue = EditorGUILayout.Slider(_MaskClipValue.floatValue, 0f, 1f);
EditorGUILayout.EndHorizontal();
this.m_MaterialEditor.TexturePropertySingleLine(mainTexName, this._MainTex, this._Color);
if(targetMat.HasProperty("_BumpMap")) this.m_MaterialEditor.TexturePropertySingleLine(normalMapName, this._BumpMap);
EditorGUILayout.Space();
}
void DoColorArea()
{
EditorGUILayout.BeginHorizontal();
showHelpColor = GUILayout.Toggle(showHelpColor, "?", "Button", GUILayout.Width(25f)); GUILayout.Label("Color", EditorStyles.boldLabel);
EditorGUILayout.EndHorizontal();
m_MaterialEditor.ShaderProperty(_HueVariation, _HueVariation.displayName);
if (showHelpColor) EditorGUILayout.HelpBox("Uses the object's world-space position to add a color variation. This effect is controlled through the alpha channel.\n\n Note: Does not work with meshes that are batched or combined", MessageType.None);
m_MaterialEditor.ShaderProperty(_AmbientOcclusion, _AmbientOcclusion.displayName);
if (showHelpColor) EditorGUILayout.HelpBox("Darkens the areas of the mesh where red vertex colors are applied", MessageType.None);
m_MaterialEditor.ShaderProperty(_TransmissionColor, new GUIContent("Translucency"));
if (showHelpColor) EditorGUILayout.HelpBox("Simulates light passing through the material. The alpha channel controls the intensity. This effect is controlled through the blue channel.", MessageType.None);
m_MaterialEditor.ShaderProperty(_GradientBrightness, _GradientBrightness.displayName);
if (showHelpColor) EditorGUILayout.HelpBox("Adds a gradient to the branch mesh from bottom to top. This information is stored in the alpha vertex color channel.\n\nWithout this information, the parameter will have no effect.", MessageType.None);
m_MaterialEditor.ShaderProperty(_Smoothness, _Smoothness.displayName);
if (showHelpColor) EditorGUILayout.HelpBox("Determines the shininess of the material", MessageType.None);
m_MaterialEditor.ShaderProperty(_FlatLighting, _FlatLighting.displayName);
if (showHelpColor) EditorGUILayout.HelpBox("A value of 1 makes the mesh normals point upwards. For some trees this is necessary to achieve the best visual result.", MessageType.None);
EditorGUILayout.Space();
}
void DoAnimationArea()
{
EditorGUILayout.BeginHorizontal();
showHelpAnimation = GUILayout.Toggle(showHelpAnimation, "?", "Button", GUILayout.Width(25f)); GUILayout.Label("Wind animation", EditorStyles.boldLabel);
EditorGUILayout.EndHorizontal();
#if !VEGETATION_STUDIO_PRO //VS Pro has an FAE wind controller
if (!hasWindController)
{
EditorGUILayout.HelpBox("No \"WindController\" component was found in your scene. Please add this script to an empty GameObject\n\nGo to GameObject->3D Object to create one", MessageType.Warning);
EditorGUI.BeginDisabledGroup(true);
}
#else
EditorGUI.BeginDisabledGroup(false);
#endif
#if UNITY_2019_3_OR_NEWER
if (UnityEngine.Rendering.GraphicsSettings.currentRenderPipeline == null)
{
#endif
visualizeVectors = EditorGUILayout.Toggle("Visualize wind", visualizeVectors);
#if UNITY_2019_3_OR_NEWER
}
#endif
if (showHelpAnimation) EditorGUILayout.HelpBox("Toggle a visualisation of the wind vectors on all the objects that use FAE shaders featuring wind.\n\nThis allows you to more clearly see the effects of the settings.", MessageType.None);
m_MaterialEditor.ShaderProperty(_UseSpeedTreeWind, new GUIContent("Sample SpeedTree wind"));
if (showHelpAnimation) EditorGUILayout.HelpBox("If this is a tree created using the Unity SpeedTree Modeler, this toggle will make the shader read the wind information as stored by SpeedTree.", MessageType.None);
m_MaterialEditor.ShaderProperty(_MaxWindStrength, new GUIContent("Max wind strength"));
if (showHelpAnimation) EditorGUILayout.HelpBox("Determines how much influence the wind has on the branches", MessageType.None);
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField(new GUIContent("Wind Amplitude Multiplier"));
_WindAmplitudeMultiplier.floatValue = EditorGUILayout.FloatField(_WindAmplitudeMultiplier.floatValue, GUILayout.Width(65f));
EditorGUILayout.EndHorizontal();
//m_MaterialEditor.ShaderProperty(_WindAmplitudeMultiplier, _WindAmplitudeMultiplier.displayName);
if (showHelpAnimation) EditorGUILayout.HelpBox("Multiply the wind amplitude for this material. Essentally this is the size of the wind waves.", MessageType.None);
if (hasWindController && showHelpAnimation)
{
GUIHelper.DrawWindInfo();
}
EditorGUI.EndDisabledGroup();
EditorGUILayout.Space();
}
void LocateWindController()
{
//Debug.Log("Searching scene for WindController script");
windController = GameObject.FindObjectOfType<WindController>();
hasWindController = (windController) ? true : false;
}
public void FindProperties(MaterialProperty[] props)
{
//Rendering
_MaskClipValue = FindProperty("_Cutoff", props);
_UseSpeedTreeWind = FindProperty("_UseSpeedTreeWind", props);
//Main maps
_Color = FindProperty("_Color", props);
_MainTex = FindProperty("_MainTex", props);
if(targetMat.HasProperty("_BumpMap")) _BumpMap = FindProperty("_BumpMap", props);
//Color
_HueVariation = FindProperty("_HueVariation", props);
_AmbientOcclusion = FindProperty("_AmbientOcclusion", props);
_TransmissionColor = FindProperty("_TransmissionColor", props);
_GradientBrightness = FindProperty("_GradientBrightness", props);
_Smoothness = FindProperty("_Smoothness", props);
_FlatLighting = FindProperty("_FlatLighting", props);
//Animation
_MaxWindStrength = FindProperty("_MaxWindStrength", props);
_WindAmplitudeMultiplier = FindProperty("_WindAmplitudeMultiplier", props);
}
}
}

View File

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

View File

@@ -0,0 +1,132 @@
// Fantasy Adventure Environment
// Copyright Staggart Creations
// staggart.xyz
using UnityEngine;
using UnityEditor;
using System.Collections;
namespace FAE
{
public class TreeTrunkShaderGUI : ShaderGUI
{
//Main maps
MaterialProperty _MainTex;
MaterialProperty _BumpMap;
MaterialProperty _UseSpeedTreeWind;
//Color
MaterialProperty _AmbientOcclusion;
MaterialProperty _GradientBrightness;
MaterialProperty _Smoothness;
MaterialEditor m_MaterialEditor;
#if UNITY_2019_3_OR_NEWER
private Material targetMat;
#endif
//Meta
bool showHelp;
GUIContent mainTexName = new GUIContent("Diffuse", "Diffuse (RGB) and Transparency (A)");
GUIContent normalMapName = new GUIContent("Normal Map");
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
{
this.m_MaterialEditor = materialEditor;
#if UNITY_2019_3_OR_NEWER
targetMat = materialEditor.target as Material;
#endif
this.FindProperties(props);
//Style similar to Standard shader
m_MaterialEditor.SetDefaultGUIWidths();
m_MaterialEditor.UseDefaultMargins();
EditorGUIUtility.labelWidth = 0f;
#if UNITY_2019_3_OR_NEWER
if (UnityEngine.Rendering.GraphicsSettings.currentRenderPipeline != null &&
!targetMat.shader.name.Contains("Universal Render Pipeline"))
{
EditorGUILayout.HelpBox("Universal Render Pipeline is in use, but this material is using a shader for the Built-in render pipeline.\n\nShaders and materials can be converted through the Help window", MessageType.Error);
EditorGUILayout.Space();
}
#endif
EditorGUI.BeginChangeCheck();
//Draw fields
DoHeader();
DoMapsArea();
DoColorArea();
if (EditorGUI.EndChangeCheck())
{
//Apply changes
}
GUILayout.Label("Advanced Options", EditorStyles.boldLabel);
GUIHelper.DrawExtraFields(m_MaterialEditor);
m_MaterialEditor.ShaderProperty(_UseSpeedTreeWind, new GUIContent("Sample SpeedTree wind"));
if (showHelp) EditorGUILayout.HelpBox("If this is a tree created using the SpeedTree Unity Modeler, this toggle will make the shader read the wind information as stored by SpeedTree.", MessageType.None);
if(showHelp) GUIHelper.DrawWindInfo();
GUIHelper.DrawFooter();
}
void DoHeader()
{
EditorGUILayout.BeginHorizontal();
showHelp = GUILayout.Toggle(showHelp, "Toggle help", "Button");
GUILayout.Label("FAE Tree Trunk Shader", GUIHelper.Header);
EditorGUILayout.EndHorizontal();
if (showHelp) EditorGUILayout.HelpBox("Tree trunk shader, featuring global wind motion", MessageType.Info);
}
void DoMapsArea()
{
GUILayout.Label("Main maps", EditorStyles.boldLabel);
this.m_MaterialEditor.TexturePropertySingleLine(mainTexName, this._MainTex);
this.m_MaterialEditor.TexturePropertySingleLine(normalMapName, this._BumpMap);
EditorGUILayout.Space();
}
void DoColorArea()
{
m_MaterialEditor.ShaderProperty(_AmbientOcclusion, _AmbientOcclusion.displayName);
if (showHelp) EditorGUILayout.HelpBox("Darkens the areas of the mesh where red vertex colors are applied", MessageType.None);
m_MaterialEditor.ShaderProperty(_GradientBrightness, _GradientBrightness.displayName);
if (showHelp) EditorGUILayout.HelpBox("Adds a gradient to the branch mesh from bottom to top. This information is stored in the alpha vertex color channel.\n\nWithout this information, the parameter will have no effect.", MessageType.None);
m_MaterialEditor.ShaderProperty(_Smoothness, _Smoothness.displayName);
if (showHelp) EditorGUILayout.HelpBox("Multiplies the value of the texture's alpha channel to decrease the roughness amount", MessageType.None);
EditorGUILayout.Space();
}
public void FindProperties(MaterialProperty[] props)
{
_UseSpeedTreeWind = FindProperty("_UseSpeedTreeWind", props);
//Main maps
_MainTex = FindProperty("_MainTex", props);
_BumpMap = FindProperty("_BumpMap", props);
//Color
_AmbientOcclusion = FindProperty("_AmbientOcclusion", props);
_GradientBrightness = FindProperty("_GradientBrightness", props);
_Smoothness = FindProperty("_Smoothness", props);
}
}
}

View File

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

View File

@@ -0,0 +1,173 @@
using UnityEngine;
using System.Collections;
using UnityEditor;
namespace FAE
{
[CustomEditor(typeof(WindController))]
public class WindControllerInspector : Editor
{
WindController wc;
private bool showHelp = false;
private bool visualizeVectors;
new SerializedObject serializedObject;
SerializedProperty listenToWindZone;
SerializedProperty windZone;
SerializedProperty windVectors;
SerializedProperty windSpeed;
SerializedProperty windStrength;
SerializedProperty windAmplitude;
SerializedProperty trunkWindSpeed;
SerializedProperty trunkWindWeight;
SerializedProperty trunkWindSwinging;
void OnEnable()
{
wc = (WindController)target;
serializedObject = new SerializedObject(target);
listenToWindZone = serializedObject.FindProperty("listenToWindZone");
windZone = serializedObject.FindProperty("windZone");
windVectors = serializedObject.FindProperty("windVectors");
windSpeed = serializedObject.FindProperty("windSpeed");
windStrength = serializedObject.FindProperty("windStrength");
windAmplitude = serializedObject.FindProperty("windAmplitude");
trunkWindSpeed = serializedObject.FindProperty("trunkWindSpeed");
trunkWindWeight = serializedObject.FindProperty("trunkWindWeight");
trunkWindSwinging = serializedObject.FindProperty("trunkWindSwinging");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUI.BeginChangeCheck();
//Sync inspector var to static class var
visualizeVectors = WindController._visualizeVectors;
Undo.RecordObject(this, "Component");
Undo.RecordObject(wc, "WindController");
DrawFields();
serializedObject.ApplyModifiedProperties();
if (GUI.changed || EditorGUI.EndChangeCheck())
{
EditorUtility.SetDirty((WindController)target);
wc.Apply();
//Set the static var
WindController.VisualizeVectors(visualizeVectors);
}
}
private void DrawFields()
{
DoHeader();
EditorGUILayout.Space();
EditorGUILayout.PropertyField(windVectors);
if (!windVectors.objectReferenceValue)
{
EditorGUILayout.HelpBox("Assign a wind vector map for wind to function", MessageType.Error);
return;
}
EditorGUILayout.PropertyField(listenToWindZone, new GUIContent("Listen to Wind Zone"));
if (showHelp) EditorGUILayout.HelpBox("When a Wind Zone is assigned, the wind strength and tree trunk weight values are divided by it's \"Main\" parameter value.\n\nThis allows you to use weather systems such as Enviro", MessageType.Info);
if (listenToWindZone.boolValue)
{
EditorGUILayout.PropertyField(windZone, new GUIContent("Wind Zone"));
}
EditorGUILayout.Space();
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
EditorGUILayout.LabelField("Wind settings", EditorStyles.toolbarButton);
EditorGUILayout.Space();
EditorGUILayout.PropertyField(windSpeed, new GUIContent("Speed"));
if (showHelp) EditorGUILayout.HelpBox("The overall speed of the wind.", MessageType.Info);
EditorGUILayout.PropertyField(windStrength, new GUIContent("Strength"));
if (showHelp) EditorGUILayout.HelpBox("The overall strength of the wind.", MessageType.Info);
EditorGUILayout.PropertyField(windAmplitude, new GUIContent("Amplitude"));
if (showHelp) EditorGUILayout.HelpBox("The overall amplitude of the wind, essentially the size of wind waves.\n\nThe shader have a \"WindAmplitudeMultiplier\" parameter which multiplies this value in the material.", MessageType.Info);
EditorGUILayout.Space();
EditorGUILayout.EndVertical();
EditorGUILayout.Space();
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
EditorGUILayout.LabelField("Tree trunks", EditorStyles.toolbarButton);
EditorGUILayout.Space();
EditorGUILayout.PropertyField(trunkWindSpeed, new GUIContent("Speed"));
if (showHelp) EditorGUILayout.HelpBox("The speed by which the tree moves.", MessageType.Info);
EditorGUILayout.PropertyField(trunkWindWeight, new GUIContent("Weight"));
if (showHelp) EditorGUILayout.HelpBox("The amount of influence the wind has on a tree.", MessageType.Info);
EditorGUILayout.PropertyField(trunkWindSwinging, new GUIContent("Swinging"));
if (showHelp) EditorGUILayout.HelpBox("A value higher than 0 means the trees will also move against the wind direction.", MessageType.Info);
EditorGUILayout.Space();
EditorGUILayout.EndVertical();
visualizeVectors = EditorGUILayout.Toggle("Visualize wind", visualizeVectors);
if (showHelp) EditorGUILayout.HelpBox("Toggle a visualisation of the wind vectors on all the objects that use FAE shaders featuring wind.\n\nThis allows you to more clearly see the effects of the settings.", MessageType.Info);
GUIHelper.DrawFooter();
}
private void DoHeader()
{
EditorGUILayout.BeginHorizontal();
showHelp = GUILayout.Toggle(showHelp, "Toggle help", "Button");
GUILayout.Label("FAE Wind Controller", GUIHelper.Header);
EditorGUILayout.EndHorizontal();
if (showHelp) EditorGUILayout.HelpBox("This script drives the wind parameters of the Foliage, Grass, Tree Branch and Tree Trunk shaders.", MessageType.Info);
}
[MenuItem("GameObject/3D Object/FAE Wind Controller")]
private static void NewMenuOption()
{
WindController currentWindController = GameObject.FindObjectOfType<WindController>();
if (currentWindController != null)
{
if (EditorUtility.DisplayDialog("FAE Wind Controller", "A WindController object already exists in your scene", "Create anyway", "Cancel"))
{
CreateNewWindController();
}
}
else
{
CreateNewWindController();
}
}
private static void CreateNewWindController()
{
GameObject newWindController = new GameObject()
{
name = "Wind Controller"
};
newWindController.AddComponent<WindController>();
Selection.activeGameObject = newWindController;
Undo.RegisterCreatedObjectUndo(newWindController, "Created Wind Controller");
}
}
}

View File

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

View File

@@ -0,0 +1,31 @@
{
"name": "sc.fae.editor",
"references": [
"GUID:8c4644ab61e3e7d4d8f26823347fc459",
"GUID:15fc0a57446b3144c949da3e2b9737a9"
],
"includePlatforms": [],
"excludePlatforms": [
"Android",
"iOS",
"LinuxStandalone64",
"Lumin",
"macOSStandalone",
"PS4",
"Stadia",
"Switch",
"tvOS",
"WSA",
"WebGL",
"WindowsStandalone32",
"WindowsStandalone64",
"XboxOne"
],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

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