[Add] All in one shader

This commit is contained in:
2026-02-23 22:01:07 +07:00
parent ec0aa86ac2
commit 4f942cd7c0
806 changed files with 401510 additions and 33 deletions
@@ -0,0 +1,104 @@
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;
namespace AllIn13DShader
{
[ExecuteInEditMode]
[DisallowMultipleComponent]
[AddComponentMenu("AllIn13DShader/AddAllIn13DShader")]
public class AllIn13DShaderComponent : MonoBehaviour
{
public Renderer currRenderer;
public Material currMaterial
{
get
{
return currRenderer.sharedMaterial;
}
set
{
currRenderer.sharedMaterial = value;
}
}
#if UNITY_EDITOR
public void NewCleanMaterial(Shader shader, Material matPreset)
{
Material previousMat = currMaterial;
currMaterial = new Material(shader);
currMaterial.CopyMatchingPropertiesFromMaterial(matPreset);
string materialName = currMaterial.name;
int nameStartIndex = materialName.LastIndexOf("/");
if(nameStartIndex >= 0)
{
materialName = materialName.Substring(nameStartIndex + 1);
}
currMaterial.name = $"MAT_{materialName}";
}
public void CleanMaterial()
{
currMaterial = new Material(Shader.Find(ConstantsRuntime.STANDARD_SHADER_NAME));
}
public bool CheckValidComponent()
{
bool res = true;
bool dirty = false;
if (currRenderer == null || currMaterial == null)
{
res = res && TryGetComponent<Renderer>(out currRenderer);
dirty = true;
}
if (dirty && res)
{
currRenderer = GetComponent<Renderer>();
EditorUtility.SetDirty(this);
if(currMaterial != null)
{
EditorUtility.SetDirty(currMaterial);
}
}
return res;
}
public void ApplyMaterialToChildren()
{
ApplyMaterialRecursively(transform, currMaterial);
}
public Material DuplicateCurrentMaterial()
{
currMaterial = new Material(currMaterial);
return currMaterial;
}
private void ApplyMaterialRecursively(Transform tr, Material mat)
{
bool existsMeshRenderer = tr.TryGetComponent<Renderer>(out currRenderer);
if (existsMeshRenderer)
{
currRenderer.sharedMaterial = mat;
}
int childCount = tr.childCount;
for(int i = 0; i < childCount; i++)
{
ApplyMaterialRecursively(tr.GetChild(i), mat);
}
}
#endif
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 09fb2c5f145047846ac8e94ce0994dbb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 316173
packageName: All In 1 3D-Shader
packageVersion: 2.72
assetPath: Assets/Plugins/AllIn13DShader/Scripts/AllIn13DShaderComponent.cs
uploadId: 865720
@@ -0,0 +1,24 @@
using UnityEngine;
namespace AllIn13DShader
{
[ExecuteInEditMode]
public class AllIn13DShaderRandomTimeSeed : MonoBehaviour
{
[SerializeField] private float minSeedValue = 0;
[SerializeField] private float maxSeedValue = 100f;
private void Start()
{
RefreshTimingSeed();
}
[ContextMenu("Refresh Timing Seed")]
private void RefreshTimingSeed()
{
MaterialPropertyBlock properties = new MaterialPropertyBlock();
properties.SetFloat("_TimingSeed", Random.Range(minSeedValue, maxSeedValue));
GetComponent<Renderer>().SetPropertyBlock(properties);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 8302f7da0ee1d6848bcadb44b88c6626
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 316173
packageName: All In 1 3D-Shader
packageVersion: 2.72
assetPath: Assets/Plugins/AllIn13DShader/Scripts/AllIn13DShaderRandomTimeSeed.cs
uploadId: 865720
@@ -0,0 +1,26 @@
using UnityEngine;
namespace AllIn13DShader
{
[CreateAssetMenu(menuName = "AllIn13DShader/Others/Depth Coloring Properties", fileName = "DepthColoringProperties.asset")]
public class AllIn1DepthColoringProperties : ScriptableObject
{
public float depthColoringMinDepth;
[Range(0.1f, 1.5f)] public float fallOff;
public Texture2D depthColoringGradientTex;
public float depthZoneLength;
private readonly int globalMinDepth = Shader.PropertyToID("global_MinDepth");
private readonly int globalDepthZoneLength = Shader.PropertyToID("global_DepthZoneLength");
private readonly int globalDepthGradient = Shader.PropertyToID("global_DepthGradient");
private readonly int globalDepthGradientFallOff = Shader.PropertyToID("global_DepthGradientFallOff");
public void ApplyValues()
{
Shader.SetGlobalFloat(globalMinDepth, depthColoringMinDepth);
Shader.SetGlobalFloat(globalDepthZoneLength, depthZoneLength);
Shader.SetGlobalFloat(globalDepthGradientFallOff, fallOff);
Shader.SetGlobalTexture(globalDepthGradient, depthColoringGradientTex);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 550a4f83cc82e43499a5efe7e94a4f5a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 316173
packageName: All In 1 3D-Shader
packageVersion: 2.72
assetPath: Assets/Plugins/AllIn13DShader/Scripts/AllIn1DepthColoringProperties.cs
uploadId: 865720
@@ -0,0 +1,23 @@
namespace AllIn13DShader
{
public static class ConstantsRuntime
{
//Special Properties
public const string GLOBAL_PROPERTY_GLOBAL_TIME = "allIn13DShader_globalTime";
#if UNITY_EDITOR
public const string SESSION_KEY_ROOT_PLUGIN_PATH = "AllIn13DShader_sessionKey_rootPluginPath";
//Standard Shader
#if ALLIN13DSHADER_BIRP
public const string STANDARD_SHADER_NAME = "Standard";
#elif ALLIN13DSHADER_URP
public const string STANDARD_SHADER_NAME = "Universal Render Pipeline/Lit";
#else
public const string STANDARD_SHADER_NAME = "Standard";
#endif
#endif
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 3ea460bdd0e63b64e8d01c3ed5f2d97e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 316173
packageName: All In 1 3D-Shader
packageVersion: 2.72
assetPath: Assets/Plugins/AllIn13DShader/Scripts/ConstantsRuntime.cs
uploadId: 865720
@@ -0,0 +1,39 @@
using UnityEngine;
namespace AllIn13DShader
{
[ExecuteInEditMode]
public class DepthColoringCamera : MonoBehaviour
{
public Camera cam;
public AllIn1DepthColoringProperties depthColoringProperties;
private void OnEnable()
{
if(depthColoringProperties != null)
{
depthColoringProperties.ApplyValues();
}
}
#if UNITY_EDITOR
private void Update()
{
Update_Editor();
}
private void Reset()
{
cam = GetComponent<Camera>();
}
private void Update_Editor()
{
if(cam != null)
{
cam.depthTextureMode = DepthTextureMode.Depth;
}
}
#endif
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: bb429cb35d67af14c998db9b8ff58396
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 316173
packageName: All In 1 3D-Shader
packageVersion: 2.72
assetPath: Assets/Plugins/AllIn13DShader/Scripts/DepthColoringCamera.cs
uploadId: 865720
@@ -0,0 +1,62 @@
using System.IO;
using UnityEngine;
namespace AllIn13DShader
{
[ExecuteInEditMode]
public class FastLightConfigurator : MonoBehaviour
{
private readonly int global_lightDirection = Shader.PropertyToID("global_lightDirection");
private readonly int global_lightColor = Shader.PropertyToID("global_lightColor");
public Color lightColor = Color.white;
private void Update()
{
Shader.SetGlobalVector(global_lightDirection, -transform.forward);
Shader.SetGlobalColor(global_lightColor, lightColor);
}
#if UNITY_EDITOR
private void OnDrawGizmos()
{
string gizmosFolderPath = UnityEditor.SessionState.GetString(ConstantsRuntime.SESSION_KEY_ROOT_PLUGIN_PATH, string.Empty);
if (!string.IsNullOrEmpty(gizmosFolderPath))
{
string iconPath = Path.Combine(gizmosFolderPath, "Editor\\Gizmos\\Fast_Light_Icon.png");
iconPath = iconPath.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
Gizmos.DrawIcon(transform.position, iconPath, false, lightColor);
}
}
private void OnDrawGizmosSelected()
{
Color rayColor = lightColor;
rayColor.a = 0.25f;
int numRays = 12;
float angle = 360f / numRays;
float radius = 0.5f;
float rayLength = 3f;
Vector3 rayInit = transform.position + transform.up * radius;
Gizmos.color = rayColor;
for (int i = 0; i < numRays; i++)
{
Gizmos.DrawRay(rayInit, transform.forward * rayLength);
Vector3 vec = rayInit - transform.position;
Vector3 rotatedVec = Quaternion.AngleAxis(angle, transform.forward) * vec;
rayInit = transform.position + rotatedVec;
}
}
private void Reset()
{
Light thisLight = GetComponent<Light>();
if(thisLight != null) lightColor = thisLight.color;
}
#endif
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: bd4409434c8db9244bf9b01281077df9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 316173
packageName: All In 1 3D-Shader
packageVersion: 2.72
assetPath: Assets/Plugins/AllIn13DShader/Scripts/FastLightConfigurator.cs
uploadId: 865720
@@ -0,0 +1,20 @@
using UnityEngine;
namespace AllIn13DShader
{
[ExecuteInEditMode]
public class ShaderGlobalTimeController : MonoBehaviour
{
private readonly int globalTimePropertyID = Shader.PropertyToID(ConstantsRuntime.GLOBAL_PROPERTY_GLOBAL_TIME);
private Vector4 timeVector;
private void Update()
{
timeVector.x = Time.unscaledTime / 20f;
timeVector.y = Time.unscaledTime;
timeVector.z = Time.unscaledTime * 2f;
timeVector.w = Time.unscaledTime * 3f;
Shader.SetGlobalVector(globalTimePropertyID, timeVector);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 736e2efc20149b14183cb7af7a304732
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 316173
packageName: All In 1 3D-Shader
packageVersion: 2.72
assetPath: Assets/Plugins/AllIn13DShader/Scripts/ShaderGlobalTimeController.cs
uploadId: 865720
@@ -0,0 +1,24 @@
using UnityEngine;
namespace AllIn13DShader
{
[ExecuteInEditMode]
public class ShadowsConfigurator : MonoBehaviour
{
public Color shadowColor = Color.black;
private readonly int shadowColorPropID = Shader.PropertyToID("global_shadowColor");
#if UNITY_EDITOR
public void Update()
{
SetupShadowColor();
}
#endif
public void SetupShadowColor()
{
Shader.SetGlobalColor(shadowColorPropID, shadowColor);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 74c2a9bafe054594dba7f6110a0e0fa3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 316173
packageName: All In 1 3D-Shader
packageVersion: 2.72
assetPath: Assets/Plugins/AllIn13DShader/Scripts/ShadowsConfigurator.cs
uploadId: 865720
@@ -0,0 +1,102 @@
using UnityEngine;
namespace AllIn13DShader
{
[ExecuteInEditMode]
public class WindController : MonoBehaviour
{
private readonly int MATPROP_GLOBAL_WIND_NOISE_TEX = Shader.PropertyToID("global_windNoiseTex");
private readonly int MATPROP_GLOBAL_WIND_FORCE = Shader.PropertyToID("global_windForce");
private readonly int MATPROP_GLOBAL_NOISE_SPEED = Shader.PropertyToID("global_noiseSpeed");
private readonly int MATPROP_GLOBAL_WIND_DIR = Shader.PropertyToID("global_windDir");
private readonly int MATPROP_GLOBAL_USE_WIND_DIR = Shader.PropertyToID("global_useWindDir");
private readonly int MATPROP_GLOBAL_MIN_WIND_VALUE = Shader.PropertyToID("global_minWindValue");
private readonly int MATPROP_GLOBAL_MAX_WIND_VALUE = Shader.PropertyToID("global_maxWindValue");
private readonly int MATPROP_GLOBAL_WIND_WORLD_SIZE = Shader.PropertyToID("global_windWorldSize");
[Header("General")]
[Tooltip("Overall strength of the wind effect. Higher values create stronger wind displacement.")]
[Range(0f, 3f)] public float windForce = 1f;
[Tooltip("Speed of noise texture scrolling (X,Y). Higher values create faster wind movement.")]
public Vector2 noiseSpeed = new Vector2(12f, 6f);
[Tooltip("When enabled, wind can push objects in both positive and negative directions. When disabled, wind only pushes in the positive direction.")]
public bool bidirectionalWind = true;
[Tooltip("When enabled, wind direction is determined by this GameObject's forward direction. When disabled, wind affects all directions equally.")]
public bool useWindDir = false;
[Header("World Size")]
[Tooltip("Scale of the noise texture in world space. Larger values spread the wind pattern across a bigger area.")]
public float worldSize = 50f;
[Header("Noise")]
[Tooltip("Texture used to generate wind displacement patterns. RGB channels control displacement in respective directions.")]
public Texture2D windNoise;
public void Update()
{
ApplyWindValues();
}
public void ApplyWindValues()
{
if(windNoise != null)
{
Shader.SetGlobalTexture(MATPROP_GLOBAL_WIND_NOISE_TEX, windNoise);
}
Shader.SetGlobalFloat(MATPROP_GLOBAL_WIND_FORCE, windForce);
Shader.SetGlobalVector(MATPROP_GLOBAL_NOISE_SPEED, noiseSpeed);
Vector3 correctedWindDir = useWindDir ? transform.forward : Vector3.one;
float useWindDirFloat = useWindDir ? 1f : 0f;
Shader.SetGlobalFloat(MATPROP_GLOBAL_USE_WIND_DIR, useWindDirFloat);
Shader.SetGlobalVector(MATPROP_GLOBAL_WIND_DIR, correctedWindDir);
float minWindValue = bidirectionalWind ? -1f : 0f;
Shader.SetGlobalFloat(MATPROP_GLOBAL_MIN_WIND_VALUE, minWindValue);
Shader.SetGlobalFloat(MATPROP_GLOBAL_MAX_WIND_VALUE, 1f);
Shader.SetGlobalFloat(MATPROP_GLOBAL_WIND_WORLD_SIZE, worldSize);
}
#if UNITY_EDITOR
public void OnDrawGizmos()
{
string gizmosFolderPath = UnityEditor.SessionState.GetString(ConstantsRuntime.SESSION_KEY_ROOT_PLUGIN_PATH, string.Empty);
if (!string.IsNullOrEmpty(gizmosFolderPath))
{
string iconPath = System.IO.Path.Combine(gizmosFolderPath, "Editor\\Gizmos\\GizmoIcon_Wind.png");
iconPath = iconPath.Replace(System.IO.Path.DirectorySeparatorChar, System.IO.Path.AltDirectorySeparatorChar);
Gizmos.DrawIcon(transform.position, iconPath, false, Color.cyan);
}
}
private void OnDrawGizmosSelected()
{
if(!useWindDir) { return; }
Color rayColor = Color.cyan;
rayColor.a = 0.25f;
int numRays = 12;
float angle = 360f / numRays;
float radius = 0.5f;
float rayLength = 3f;
Vector3 rayInit = transform.position + transform.up * radius;
Gizmos.color = rayColor;
for (int i = 0; i < numRays; i++)
{
Gizmos.DrawRay(rayInit, transform.forward * rayLength);
Vector3 vec = rayInit - transform.position;
Vector3 rotatedVec = Quaternion.AngleAxis(angle, transform.forward) * vec;
rayInit = transform.position + rotatedVec;
}
}
#endif
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 0fc862a3a3f744b41ae4abebf6a3bd81
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 316173
packageName: All In 1 3D-Shader
packageVersion: 2.72
assetPath: Assets/Plugins/AllIn13DShader/Scripts/WindController.cs
uploadId: 865720