111
This commit is contained in:
1
Packages/NBPostProcessing/.gitignore
vendored
Normal file
1
Packages/NBPostProcessing/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
Runtime/.idea
|
||||
@@ -11,7 +11,7 @@ using Unity.Cinemachine;
|
||||
using System;
|
||||
// using Unity.Properties;
|
||||
|
||||
[CustomEditor(typeof(NBPostProcessingController))]
|
||||
[CustomEditor(typeof(PostProcessingController))]
|
||||
public class PostProcessingControllerGUI : Editor
|
||||
{
|
||||
private SerializedProperty _managerProperty;
|
||||
@@ -21,7 +21,7 @@ public class PostProcessingControllerGUI : Editor
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
NBPostProcessingController ppController = (NBPostProcessingController)target;
|
||||
PostProcessingController ppController = (PostProcessingController)target;
|
||||
serializedObject.Update();
|
||||
|
||||
_managerProperty = serializedObject.FindProperty("_manager");
|
||||
@@ -252,7 +252,9 @@ public class PostProcessingControllerGUI : Editor
|
||||
EditorGUILayout.PropertyField(flashContrastProp, new GUIContent("对比度"));
|
||||
// ppController.flashColor = EditorGUILayout.ColorField("闪颜色", ppController.flashColor);
|
||||
SerializedProperty flashColorProp = serializedObject.FindProperty("flashColor");
|
||||
EditorGUILayout.PropertyField(flashColorProp, new GUIContent("闪颜色"));
|
||||
EditorGUILayout.PropertyField(flashColorProp, new GUIContent("亮部闪颜色"));
|
||||
SerializedProperty blackFlashColorProp = serializedObject.FindProperty("blackFlashColor");
|
||||
EditorGUILayout.PropertyField(blackFlashColorProp, new GUIContent("暗部闪颜色"));
|
||||
});
|
||||
|
||||
SerializedProperty vignetteToggleProp = serializedObject.FindProperty("vignetteToggle");
|
||||
@@ -340,10 +342,10 @@ public class PostProcessingControllerGUI : Editor
|
||||
if (isIndentBlock) EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
void ReflectMethod(string methodName,NBPostProcessingController controller)
|
||||
void ReflectMethod(string methodName,PostProcessingController controller)
|
||||
{
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
MethodInfo privateMethod = typeof(NBPostProcessingController).GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
MethodInfo privateMethod = typeof(PostProcessingController).GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
if (privateMethod != null)
|
||||
{
|
||||
privateMethod.Invoke(controller, null);
|
||||
|
||||
@@ -4,26 +4,26 @@ using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Reflection;
|
||||
|
||||
[CustomEditor(typeof(NBPostProcessingManager))]
|
||||
[CustomEditor(typeof(PostProcessingManager))]
|
||||
public class PostProcessingManagerGUI : Editor
|
||||
{
|
||||
private NBPostProcessingManager _ppManager;
|
||||
private PostProcessingManager _ppManager;
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
|
||||
_ppManager = (NBPostProcessingManager)target;
|
||||
_ppManager = (PostProcessingManager)target;
|
||||
serializedObject.Update();
|
||||
DrawToggle("controllerIndexFlags","_controllerIndexFlags");
|
||||
DrawToggle("色散开关",NBPostProcessingManager.chromaticAberrationToggles);
|
||||
DrawToggle("径向扭曲开关",NBPostProcessingManager.distortSpeedToggles);
|
||||
DrawToggle("径向模糊开关",NBPostProcessingManager.radialBlurToggles);
|
||||
DrawToggle("色散开关",PostProcessingManager.chromaticAberrationToggles);
|
||||
DrawToggle("径向扭曲开关",PostProcessingManager.distortSpeedToggles);
|
||||
DrawToggle("径向模糊开关",PostProcessingManager.radialBlurToggles);
|
||||
#if CINIMACHINE_3_0
|
||||
DrawToggle("震屏开关",PostProcessingManager.cameraShakeToggles);
|
||||
#endif
|
||||
DrawToggle("肌理开关",NBPostProcessingManager.overlayTextureToggles);
|
||||
DrawToggle("黑白闪开关",NBPostProcessingManager.flashToggles);
|
||||
DrawToggle("暗角开关",NBPostProcessingManager.vignetteToggles);
|
||||
DrawToggle32("ShaderFlags", NBPostProcessingManager.material.GetInteger(NBPostProcessFlags.FlagsId));
|
||||
DrawToggle("肌理开关",PostProcessingManager.overlayTextureToggles);
|
||||
DrawToggle("黑白闪开关",PostProcessingManager.flashToggles);
|
||||
DrawToggle("暗角开关",PostProcessingManager.vignetteToggles);
|
||||
DrawToggle32("ShaderFlags", PostProcessingManager.material.GetInteger(NBPostProcessFlags.FlagsId));
|
||||
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class PostProcessingManagerGUI : Editor
|
||||
int ReflectIntValue(string propertyName)
|
||||
{
|
||||
|
||||
FieldInfo privateField = typeof(NBPostProcessingManager).GetField(propertyName, BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
FieldInfo privateField = typeof(PostProcessingManager).GetField(propertyName, BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
if (privateField != null)
|
||||
{
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace MhRender.RendererFeatures
|
||||
// Shader shader = Shader.Find("XuanXuan/Postprocess/NBPostProcessUber");
|
||||
NBPostProcessMaterial = CoreUtils.CreateEngineMaterial(Shader.Find("XuanXuan/Postprocess/NBPostProcessUber"));
|
||||
|
||||
NBPostProcessingManager.InitMat();
|
||||
PostProcessingManager.InitMat();
|
||||
|
||||
// if (Application.isPlaying)
|
||||
// {
|
||||
@@ -349,23 +349,25 @@ namespace MhRender.RendererFeatures
|
||||
using (new ProfilingScope(cmd, _profilingSampler))
|
||||
{
|
||||
context.DrawRenderers(renderingData.cullResults, ref DisturbanceDraw, ref _Filtering);
|
||||
|
||||
|
||||
#if UNIVERSAL_RP_13_1_2_OR_NEWER
|
||||
_renderMaskMat.SetTexture(CameraTexture, _DisturbanceMaskRTHandle);
|
||||
cmd.SetRenderTarget((RenderTargetIdentifier)_DownRT);
|
||||
|
||||
switch (_downSampling)
|
||||
{
|
||||
case Downsampling._2xBilinear:
|
||||
Blitter.BlitTexture(cmd, _DisturbanceMaskRTHandle, _DownRT, _renderMaskMat, 0);
|
||||
Blitter.BlitTexture(cmd, _DisturbanceMaskRTHandle, Vector2.one, _renderMaskMat, 0);
|
||||
break;
|
||||
case Downsampling._4xBilinear:
|
||||
Blitter.BlitTexture(cmd, _DisturbanceMaskRTHandle, _DownRT, _renderMaskMat, 0);
|
||||
Blitter.BlitTexture(cmd, _DisturbanceMaskRTHandle, Vector2.one, _renderMaskMat, 0);
|
||||
break;
|
||||
case Downsampling._4xBox:
|
||||
_renderMaskMat.SetFloat(SampleOffset, 2);
|
||||
Blitter.BlitTexture(cmd, _DisturbanceMaskRTHandle, _DownRT, _renderMaskMat, 1);
|
||||
Blitter.BlitTexture(cmd, _DisturbanceMaskRTHandle, Vector2.one, _renderMaskMat, 1);
|
||||
break;
|
||||
default:
|
||||
Blitter.BlitTexture(cmd, _DisturbanceMaskRTHandle, _DownRT, _renderMaskMat, 0);
|
||||
Blitter.BlitTexture(cmd, _DisturbanceMaskRTHandle, Vector2.one, _renderMaskMat, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -439,7 +441,7 @@ namespace MhRender.RendererFeatures
|
||||
public static Material _material;
|
||||
public Mesh _fullScreenMesh;
|
||||
|
||||
public NBPostProcessFlags _shaderFlag => NBPostProcessingManager.flags;
|
||||
public NBPostProcessFlags _shaderFlag => PostProcessingManager.flags;
|
||||
|
||||
private Vector4 _lastOutlineProps;
|
||||
public Vector4 outLinePorps = Vector4.one;
|
||||
|
||||
@@ -5,7 +5,7 @@ public class NBPostProcessFlags: ShaderFlagsBase
|
||||
public const string FlagsName = "_NBPostProcessFlags";
|
||||
public static int FlagsId = Shader.PropertyToID(FlagsName);
|
||||
|
||||
protected override int GetShaderFlagsId(int index = 0)
|
||||
public override int GetShaderFlagsId(int index = 0)
|
||||
{
|
||||
return FlagsId;
|
||||
}
|
||||
|
||||
@@ -13,14 +13,14 @@ using UnityEditor;
|
||||
|
||||
|
||||
[ExecuteInEditMode]
|
||||
public class NBPostProcessingController : MonoBehaviour
|
||||
public class PostProcessingController : MonoBehaviour
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
public AnimBool[] AnimBools = new AnimBool[10];
|
||||
#endif
|
||||
// [ShowInInspector][ReadOnly]
|
||||
[SerializeField]
|
||||
private NBPostProcessingManager _manager;
|
||||
private PostProcessingManager _manager;
|
||||
|
||||
public int index
|
||||
{
|
||||
@@ -199,6 +199,7 @@ public class NBPostProcessingController : MonoBehaviour
|
||||
// [LabelText("对比度")] [ToggleGroup("flashToggle")]
|
||||
public float flashContrast = 1f;
|
||||
public Color flashColor = new Color(1f,1f,1f,1f);
|
||||
public Color blackFlashColor = new Color(0f,0f,0f,1f);
|
||||
|
||||
// [ToggleGroup("vignetteToggle", "暗角")]
|
||||
// [OnValueChanged("InitAllSettings")]
|
||||
@@ -225,7 +226,7 @@ public class NBPostProcessingController : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
_manager = NBPostProcessingManager.Instance;
|
||||
_manager = PostProcessingManager.Instance;
|
||||
|
||||
_manager.InitController(this);
|
||||
InitAllSettings();
|
||||
@@ -245,30 +246,30 @@ public class NBPostProcessingController : MonoBehaviour
|
||||
|
||||
void SetScreenCenterPos()
|
||||
{
|
||||
NBPostProcessingManager.customScreenCenterPos = customScreenCenterPos;
|
||||
PostProcessingManager.customScreenCenterPos = customScreenCenterPos;
|
||||
_lastCustomScreenCenterPos = customScreenCenterPos;
|
||||
}
|
||||
|
||||
void SetUVFromDistort()
|
||||
{
|
||||
NBPostProcessingManager.isDistortScreenUVMode = distortScreenUVMode;
|
||||
NBPostProcessingManager.isCaByDistort = caFromDistort;
|
||||
NBPostProcessingManager.isRadialBlurByDistort = radialBlurFromDistort;
|
||||
PostProcessingManager.isDistortScreenUVMode = distortScreenUVMode;
|
||||
PostProcessingManager.isCaByDistort = caFromDistort;
|
||||
PostProcessingManager.isRadialBlurByDistort = radialBlurFromDistort;
|
||||
}
|
||||
|
||||
private void SetTexture()
|
||||
{
|
||||
if(NBPostProcessingManager.material == null) return;
|
||||
if(PostProcessingManager.material == null) return;
|
||||
if (distortSpeedToggle)
|
||||
{
|
||||
if (distortSpeedTexture != null)
|
||||
{
|
||||
NBPostProcessingManager.material.SetTexture(_distortSpeedTextureID, distortSpeedTexture);
|
||||
NBPostProcessingManager.distortTextureMidValue = distortTextureMidValue;
|
||||
PostProcessingManager.material.SetTexture(_distortSpeedTextureID, distortSpeedTexture);
|
||||
PostProcessingManager.distortTextureMidValue = distortTextureMidValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
NBPostProcessingManager.material.SetTexture(_distortSpeedTextureID, null);
|
||||
PostProcessingManager.material.SetTexture(_distortSpeedTextureID, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,34 +277,34 @@ public class NBPostProcessingController : MonoBehaviour
|
||||
{
|
||||
if (overlayTexturePolarCoordMode)
|
||||
{
|
||||
NBPostProcessingManager.flags.SetFlagBits(NBPostProcessFlags.FLAG_BIT_OVERLAYTEXTURE_POLLARCOORD);
|
||||
PostProcessingManager.flags.SetFlagBits(NBPostProcessFlags.FLAG_BIT_OVERLAYTEXTURE_POLLARCOORD);
|
||||
}
|
||||
else
|
||||
{
|
||||
NBPostProcessingManager.flags.ClearFlagBits(NBPostProcessFlags.FLAG_BIT_OVERLAYTEXTURE_POLLARCOORD);
|
||||
PostProcessingManager.flags.ClearFlagBits(NBPostProcessFlags.FLAG_BIT_OVERLAYTEXTURE_POLLARCOORD);
|
||||
}
|
||||
|
||||
if (overlayTexture)
|
||||
{
|
||||
Debug.Log("SetOverlayTexture");
|
||||
NBPostProcessingManager.material.SetTexture(_overlayTextureID,overlayTexture);
|
||||
PostProcessingManager.material.SetTexture(_overlayTextureID,overlayTexture);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("ClearOverlayTexture");
|
||||
NBPostProcessingManager.material.SetTexture(_overlayTextureID,null);
|
||||
PostProcessingManager.material.SetTexture(_overlayTextureID,null);
|
||||
}
|
||||
|
||||
if (overlayMaskTexture)
|
||||
{
|
||||
Debug.Log("SetOverlayMaskTexture");
|
||||
NBPostProcessingManager.material.SetTexture(_textureOverlayMaskProperty,overlayMaskTexture);
|
||||
NBPostProcessingManager.flags.SetFlagBits(NBPostProcessFlags.FLAG_BIT_OVERLAYTEXTURE_MASKMAP);
|
||||
PostProcessingManager.material.SetTexture(_textureOverlayMaskProperty,overlayMaskTexture);
|
||||
PostProcessingManager.flags.SetFlagBits(NBPostProcessFlags.FLAG_BIT_OVERLAYTEXTURE_MASKMAP);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("ClearOverlayMaskTexture");
|
||||
NBPostProcessingManager.flags.ClearFlagBits(NBPostProcessFlags.FLAG_BIT_OVERLAYTEXTURE_MASKMAP);
|
||||
PostProcessingManager.flags.ClearFlagBits(NBPostProcessFlags.FLAG_BIT_OVERLAYTEXTURE_MASKMAP);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,15 +312,15 @@ public class NBPostProcessingController : MonoBehaviour
|
||||
|
||||
private void SetToggles()
|
||||
{
|
||||
SetBit(ref NBPostProcessingManager.chromaticAberrationToggles,index,chromaticAberrationToggle);
|
||||
SetBit(ref NBPostProcessingManager.distortSpeedToggles,index,distortSpeedToggle);
|
||||
SetBit(ref PostProcessingManager.chromaticAberrationToggles,index,chromaticAberrationToggle);
|
||||
SetBit(ref PostProcessingManager.distortSpeedToggles,index,distortSpeedToggle);
|
||||
#if CINIMACHINE_3_0
|
||||
SetBit(ref PostProcessingManager.cameraShakeToggles,index,cameraShakeToggle);
|
||||
#endif
|
||||
SetBit(ref NBPostProcessingManager.overlayTextureToggles,index,overlayTextureToggle);
|
||||
SetBit(ref NBPostProcessingManager.flashToggles,index,flashToggle);
|
||||
SetBit(ref NBPostProcessingManager.radialBlurToggles,index,radialBlurToggle);
|
||||
SetBit(ref NBPostProcessingManager.vignetteToggles,index,vignetteToggle);
|
||||
SetBit(ref PostProcessingManager.overlayTextureToggles,index,overlayTextureToggle);
|
||||
SetBit(ref PostProcessingManager.flashToggles,index,flashToggle);
|
||||
SetBit(ref PostProcessingManager.radialBlurToggles,index,radialBlurToggle);
|
||||
SetBit(ref PostProcessingManager.vignetteToggles,index,vignetteToggle);
|
||||
|
||||
#if UNITY_EDITOR
|
||||
SetTexture();
|
||||
@@ -329,15 +330,15 @@ public class NBPostProcessingController : MonoBehaviour
|
||||
|
||||
private void ClearToggles()
|
||||
{
|
||||
SetBit(ref NBPostProcessingManager.chromaticAberrationToggles,index,false);
|
||||
SetBit(ref NBPostProcessingManager.distortSpeedToggles,index,false);
|
||||
SetBit(ref PostProcessingManager.chromaticAberrationToggles,index,false);
|
||||
SetBit(ref PostProcessingManager.distortSpeedToggles,index,false);
|
||||
#if CINIMACHINE_3_0
|
||||
SetBit(ref PostProcessingManager.cameraShakeToggles,index,false);
|
||||
#endif
|
||||
SetBit(ref NBPostProcessingManager.overlayTextureToggles,index,false);
|
||||
SetBit(ref NBPostProcessingManager.flashToggles,index,false);
|
||||
SetBit(ref NBPostProcessingManager.radialBlurToggles,index,false);
|
||||
SetBit(ref NBPostProcessingManager.vignetteToggles,index,false);
|
||||
SetBit(ref PostProcessingManager.overlayTextureToggles,index,false);
|
||||
SetBit(ref PostProcessingManager.flashToggles,index,false);
|
||||
SetBit(ref PostProcessingManager.radialBlurToggles,index,false);
|
||||
SetBit(ref PostProcessingManager.vignetteToggles,index,false);
|
||||
}
|
||||
|
||||
private bool _lastChormaticAberrationToggle = false;
|
||||
@@ -455,7 +456,7 @@ public class NBPostProcessingController : MonoBehaviour
|
||||
isFirstUpdate = false;
|
||||
return;
|
||||
}
|
||||
if(!NBPostProcessingManager.material) return;
|
||||
if(!PostProcessingManager.material) return;
|
||||
//#if UNITY_EDITOR
|
||||
//Odin的ToggleGroup和OnValueChange功能冲突,导致不一定生效。不好调试。所以用手动的方式更新。
|
||||
bool isToggleChanged = false;
|
||||
@@ -482,35 +483,35 @@ public class NBPostProcessingController : MonoBehaviour
|
||||
|
||||
if (chromaticAberrationToggle)
|
||||
{
|
||||
NBPostProcessingManager.chromaticAberrationIntensity =
|
||||
Mathf.Max(NBPostProcessingManager.chromaticAberrationIntensity, chromaticAberrationIntensity);
|
||||
NBPostProcessingManager.chromaticAberrationPos =
|
||||
Mathf.Max(NBPostProcessingManager.chromaticAberrationPos, chromaticAberrationPos);
|
||||
NBPostProcessingManager.chromaticAberrationRange =
|
||||
Mathf.Max(NBPostProcessingManager.chromaticAberrationRange, chromaticAberrationRange);
|
||||
PostProcessingManager.chromaticAberrationIntensity =
|
||||
Mathf.Max(PostProcessingManager.chromaticAberrationIntensity, chromaticAberrationIntensity);
|
||||
PostProcessingManager.chromaticAberrationPos =
|
||||
Mathf.Max(PostProcessingManager.chromaticAberrationPos, chromaticAberrationPos);
|
||||
PostProcessingManager.chromaticAberrationRange =
|
||||
Mathf.Max(PostProcessingManager.chromaticAberrationRange, chromaticAberrationRange);
|
||||
}
|
||||
|
||||
if (distortSpeedToggle)
|
||||
{
|
||||
if (index == NBPostProcessingManager.laseUpdateControllerIndex)
|
||||
if (index == PostProcessingManager.laseUpdateControllerIndex)
|
||||
{
|
||||
//只有这里才会更新Scale
|
||||
NBPostProcessingManager.material.SetVector(_distortSpeedTextureStID, distortSpeedTexSt);
|
||||
PostProcessingManager.material.SetVector(_distortSpeedTextureStID, distortSpeedTexSt);
|
||||
}
|
||||
|
||||
NBPostProcessingManager.distortSpeedIntensity =
|
||||
Mathf.Max(NBPostProcessingManager.distortSpeedIntensity, distortSpeedIntensity);
|
||||
NBPostProcessingManager.distortSpeedPosition =
|
||||
Mathf.Max(NBPostProcessingManager.distortSpeedPosition, distortSpeedPosition);
|
||||
NBPostProcessingManager.distortSpeedRange =
|
||||
Mathf.Max(NBPostProcessingManager.distortSpeedRange, distortSpeedRange);
|
||||
NBPostProcessingManager.distortSpeedMoveSpeedX =
|
||||
Mathf.Abs(NBPostProcessingManager.distortSpeedMoveSpeedX) > Mathf.Abs(distortSpeedMoveSpeedX)
|
||||
? NBPostProcessingManager.distortSpeedMoveSpeedX
|
||||
PostProcessingManager.distortSpeedIntensity =
|
||||
Mathf.Max(PostProcessingManager.distortSpeedIntensity, distortSpeedIntensity);
|
||||
PostProcessingManager.distortSpeedPosition =
|
||||
Mathf.Max(PostProcessingManager.distortSpeedPosition, distortSpeedPosition);
|
||||
PostProcessingManager.distortSpeedRange =
|
||||
Mathf.Max(PostProcessingManager.distortSpeedRange, distortSpeedRange);
|
||||
PostProcessingManager.distortSpeedMoveSpeedX =
|
||||
Mathf.Abs(PostProcessingManager.distortSpeedMoveSpeedX) > Mathf.Abs(distortSpeedMoveSpeedX)
|
||||
? PostProcessingManager.distortSpeedMoveSpeedX
|
||||
: distortSpeedMoveSpeedX;
|
||||
NBPostProcessingManager.distortSpeedMoveSpeedY =
|
||||
Mathf.Abs(NBPostProcessingManager.distortSpeedMoveSpeedY) > Mathf.Abs(distortSpeedMoveSpeed)
|
||||
? NBPostProcessingManager.distortSpeedMoveSpeedY
|
||||
PostProcessingManager.distortSpeedMoveSpeedY =
|
||||
Mathf.Abs(PostProcessingManager.distortSpeedMoveSpeedY) > Mathf.Abs(distortSpeedMoveSpeed)
|
||||
? PostProcessingManager.distortSpeedMoveSpeedY
|
||||
: distortSpeedMoveSpeed;
|
||||
}
|
||||
|
||||
@@ -525,47 +526,48 @@ public class NBPostProcessingController : MonoBehaviour
|
||||
|
||||
if (overlayTextureToggle)
|
||||
{
|
||||
if (index == NBPostProcessingManager.laseUpdateControllerIndex)
|
||||
if (index == PostProcessingManager.laseUpdateControllerIndex)
|
||||
{
|
||||
NBPostProcessingManager.material.SetVector(_overlayTextureStID, overlayTextureSt);
|
||||
NBPostProcessingManager.material.SetVector(_textureOverlayMaskStProperty, overlayMaskTextureSt);
|
||||
NBPostProcessingManager.material.SetVector(_textureOverlayAnimProperty,overlayTextureAnim);
|
||||
PostProcessingManager.material.SetVector(_overlayTextureStID, overlayTextureSt);
|
||||
PostProcessingManager.material.SetVector(_textureOverlayMaskStProperty, overlayMaskTextureSt);
|
||||
PostProcessingManager.material.SetVector(_textureOverlayAnimProperty,overlayTextureAnim);
|
||||
}
|
||||
|
||||
NBPostProcessingManager.overlayTextureIntensity = Mathf.Max(NBPostProcessingManager.overlayTextureIntensity,
|
||||
PostProcessingManager.overlayTextureIntensity = Mathf.Max(PostProcessingManager.overlayTextureIntensity,
|
||||
overlayTextureIntensity);
|
||||
}
|
||||
|
||||
if (flashToggle)
|
||||
{
|
||||
NBPostProcessingManager.flashDesaturateIntensity =
|
||||
Mathf.Max(NBPostProcessingManager.flashDesaturateIntensity, flashDeSaturateIntensity);
|
||||
NBPostProcessingManager.flashInvertIntensity =
|
||||
Mathf.Max(NBPostProcessingManager.flashInvertIntensity, flashInvertIntensity);
|
||||
NBPostProcessingManager.flashContrast =
|
||||
Mathf.Max(NBPostProcessingManager.flashContrast, flashContrast);
|
||||
NBPostProcessingManager.flashColor = flashColor;
|
||||
PostProcessingManager.flashDesaturateIntensity =
|
||||
Mathf.Max(PostProcessingManager.flashDesaturateIntensity, flashDeSaturateIntensity);
|
||||
PostProcessingManager.flashInvertIntensity =
|
||||
Mathf.Max(PostProcessingManager.flashInvertIntensity, flashInvertIntensity);
|
||||
PostProcessingManager.flashContrast =
|
||||
Mathf.Max(PostProcessingManager.flashContrast, flashContrast);
|
||||
PostProcessingManager.flashColor = flashColor;
|
||||
PostProcessingManager.blackFlashColor = blackFlashColor;
|
||||
}
|
||||
|
||||
if (radialBlurToggle)
|
||||
{
|
||||
NBPostProcessingManager.radialBlurIntensity =
|
||||
Mathf.Max(NBPostProcessingManager.radialBlurIntensity, radialBlurIntensity);
|
||||
NBPostProcessingManager.radialBlurSampleCount = Mathf.Max(NBPostProcessingManager.radialBlurSampleCount,
|
||||
PostProcessingManager.radialBlurIntensity =
|
||||
Mathf.Max(PostProcessingManager.radialBlurIntensity, radialBlurIntensity);
|
||||
PostProcessingManager.radialBlurSampleCount = Mathf.Max(PostProcessingManager.radialBlurSampleCount,
|
||||
radialBlurSampleCount);
|
||||
NBPostProcessingManager.radialBlurPos = Mathf.Max(NBPostProcessingManager.radialBlurPos, radialBlurPos);
|
||||
NBPostProcessingManager.radialBlurRange = Mathf.Max(NBPostProcessingManager.radialBlurRange, radialBlurRange);
|
||||
PostProcessingManager.radialBlurPos = Mathf.Max(PostProcessingManager.radialBlurPos, radialBlurPos);
|
||||
PostProcessingManager.radialBlurRange = Mathf.Max(PostProcessingManager.radialBlurRange, radialBlurRange);
|
||||
}
|
||||
|
||||
if (vignetteToggle)
|
||||
{
|
||||
NBPostProcessingManager.vignetteIntensity =
|
||||
Mathf.Max(NBPostProcessingManager.vignetteIntensity, vignetteIntensity);
|
||||
NBPostProcessingManager.vignetteRoundness = Mathf.Max(NBPostProcessingManager.vignetteRoundness, vignetteRoundness);
|
||||
NBPostProcessingManager.vignetteSmothness = Mathf.Max(NBPostProcessingManager.vignetteSmothness, vignetteSmothness);
|
||||
if (index == NBPostProcessingManager.laseUpdateControllerIndex)
|
||||
PostProcessingManager.vignetteIntensity =
|
||||
Mathf.Max(PostProcessingManager.vignetteIntensity, vignetteIntensity);
|
||||
PostProcessingManager.vignetteRoundness = Mathf.Max(PostProcessingManager.vignetteRoundness, vignetteRoundness);
|
||||
PostProcessingManager.vignetteSmothness = Mathf.Max(PostProcessingManager.vignetteSmothness, vignetteSmothness);
|
||||
if (index == PostProcessingManager.laseUpdateControllerIndex)
|
||||
{
|
||||
NBPostProcessingManager.material.SetColor(_vignetteColorID,vignetteColor);
|
||||
PostProcessingManager.material.SetColor(_vignetteColorID,vignetteColor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -586,7 +588,7 @@ public class NBPostProcessingController : MonoBehaviour
|
||||
{
|
||||
GameObject Effect = new GameObject();
|
||||
Effect.name = "NBPostprocessController";
|
||||
NBPostProcessingController controller = Effect.AddComponent<NBPostProcessingController>();
|
||||
PostProcessingController controller = Effect.AddComponent<PostProcessingController>();
|
||||
|
||||
UnityEditor.Selection.activeObject = Effect;
|
||||
}
|
||||
@@ -17,26 +17,26 @@ using MhRender.RendererFeatures;
|
||||
|
||||
|
||||
[ExecuteAlways]
|
||||
public class NBPostProcessingManager : MonoBehaviour
|
||||
public class PostProcessingManager : MonoBehaviour
|
||||
{
|
||||
//单例实现
|
||||
private static NBPostProcessingManager _instance = null;
|
||||
private static PostProcessingManager _instance = null;
|
||||
|
||||
public static NBPostProcessingManager Instance
|
||||
public static PostProcessingManager Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
#if UNITY_2022_1_OR_NEWER
|
||||
_instance = FindFirstObjectByType<NBPostProcessingManager>();
|
||||
#else
|
||||
_instance = FindObjectOfType<PostProcessingManager>();
|
||||
#endif
|
||||
// #if UNITY_2022_1_OR_NEWER
|
||||
// _instance = FindFirstObjectByType<PostProcessingManager>();
|
||||
// #else
|
||||
_instance = FindObjectOfType<PostProcessingManager>();//因为兼容性因素,保留较慢版本
|
||||
// #endif
|
||||
if (_instance == null)
|
||||
{
|
||||
GameObject singletonObj = new GameObject();
|
||||
_instance = singletonObj.AddComponent<NBPostProcessingManager>();
|
||||
_instance = singletonObj.AddComponent<PostProcessingManager>();
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
singletonObj.name = "NBPostProcessManager";
|
||||
@@ -88,7 +88,7 @@ public class NBPostProcessingManager : MonoBehaviour
|
||||
|
||||
public static void InitMat()
|
||||
{
|
||||
flags.SetMaterial(NBPostProcessingManager.material);
|
||||
flags.SetMaterial(PostProcessingManager.material);
|
||||
if (_instance)
|
||||
{
|
||||
_instance.ResetEffect();
|
||||
@@ -197,7 +197,7 @@ public class NBPostProcessingManager : MonoBehaviour
|
||||
return count;
|
||||
}
|
||||
//每次Controller触发Play都会触发Init
|
||||
public void InitController(NBPostProcessingController controller)
|
||||
public void InitController(PostProcessingController controller)
|
||||
{
|
||||
#if CINIMACHINE_3_0
|
||||
if (controller.cinemachineCamera != null)
|
||||
@@ -210,7 +210,7 @@ public class NBPostProcessingManager : MonoBehaviour
|
||||
controller.SetIndex(GetControllerIndex());
|
||||
}
|
||||
|
||||
public void EndController(NBPostProcessingController controller)
|
||||
public void EndController(PostProcessingController controller)
|
||||
{
|
||||
#if CINIMACHINE_3_0
|
||||
if (currentVirtualCamera == controller.cinemachineCamera)
|
||||
@@ -629,11 +629,13 @@ public class NBPostProcessingManager : MonoBehaviour
|
||||
public static float flashContrast = 0;
|
||||
|
||||
public static Color flashColor = new Color(1, 1, 1, 1);
|
||||
public static Color blackFlashColor = new Color(0, 0, 0, 1);
|
||||
|
||||
private readonly int _flashDesaturateProperty = Shader.PropertyToID("_DeSaturateIntensity");
|
||||
private readonly int _flashInvertProperty = Shader.PropertyToID("_InvertIntensity");
|
||||
private readonly int _flashContrastProperty = Shader.PropertyToID("_Contrast");
|
||||
private readonly int _flashColorProperty = Shader.PropertyToID("_FlashColor");
|
||||
private readonly int _blackFlashColorProperty = Shader.PropertyToID("_BlackFlashColor");
|
||||
|
||||
private void InitFlash()
|
||||
{
|
||||
@@ -646,6 +648,7 @@ public class NBPostProcessingManager : MonoBehaviour
|
||||
material.SetFloat(_flashInvertProperty, flashInvertIntensity);
|
||||
material.SetFloat(_flashContrastProperty, flashContrast);
|
||||
material.SetColor(_flashColorProperty,flashColor);
|
||||
material.SetColor(_blackFlashColorProperty,blackFlashColor);
|
||||
flashDesaturateIntensity = 0;
|
||||
flashInvertIntensity = 0;
|
||||
flashContrast = 0;
|
||||
@@ -132,20 +132,22 @@ namespace MhRender.RendererFeatures
|
||||
#if UNIVERSAL_RP_13_1_2_OR_NEWER
|
||||
|
||||
_material.SetTexture(CameraTexture, _screenColorHandle);
|
||||
cmd.SetRenderTarget((RenderTargetIdentifier)_tempRTHandle);
|
||||
switch (_downSampling)
|
||||
{
|
||||
case Downsampling._2xBilinear:
|
||||
Blitter.BlitTexture(cmd, _screenColorHandle, _tempRTHandle, _material, 0);
|
||||
|
||||
Blitter.BlitTexture(cmd, _screenColorHandle, Vector2.one, _material, 0);
|
||||
break;
|
||||
case Downsampling._4xBilinear:
|
||||
Blitter.BlitTexture(cmd, _screenColorHandle, _tempRTHandle, _material, 0);
|
||||
Blitter.BlitTexture(cmd, _screenColorHandle, Vector2.one, _material, 0);
|
||||
break;
|
||||
case Downsampling._4xBox:
|
||||
_material.SetFloat(SampleOffset,2);
|
||||
Blitter.BlitTexture(cmd, _screenColorHandle, _tempRTHandle, _material, 1);
|
||||
Blitter.BlitTexture(cmd, _screenColorHandle, Vector2.one, _material, 1);
|
||||
break;
|
||||
default:
|
||||
Blitter.BlitTexture(cmd, _screenColorHandle, _tempRTHandle, _material, 0);
|
||||
Blitter.BlitTexture(cmd, _screenColorHandle, Vector2.one, _material, 0);
|
||||
break;
|
||||
}
|
||||
#else
|
||||
|
||||
@@ -16,6 +16,7 @@ Shader "XuanXuan/Postprocess/NBPostProcessUber"
|
||||
_DeSaturateIntensity("饱和度强度",Float) = 0
|
||||
_Contrast("对比度",Float) = 1
|
||||
_FlashColor("闪颜色", Vector) = (1, 1, 1, 1)
|
||||
_BlackFlashColor("闪黑颜色", Vector) = (0, 0, 0, 1)
|
||||
|
||||
|
||||
[HideInInspector] _NBPostProcessFlags("_NBPostProcessFlags", Integer) = 0
|
||||
@@ -85,7 +86,7 @@ Shader "XuanXuan/Postprocess/NBPostProcessUber"
|
||||
TEXTURE2D(_TextureOverlayMask);
|
||||
SAMPLER(sampler_TextureOverlayMask);
|
||||
|
||||
#if UNITY_VERSION < 202210
|
||||
#if UNITY_VERSION < 202220
|
||||
SAMPLER(sampler_LinearClamp);
|
||||
#endif
|
||||
|
||||
@@ -104,6 +105,7 @@ Shader "XuanXuan/Postprocess/NBPostProcessUber"
|
||||
half _DeSaturateIntensity;
|
||||
half _Contrast;
|
||||
half3 _FlashColor;
|
||||
half3 _BlackFlashColor;
|
||||
|
||||
half4 _ChromaticAberrationVec;
|
||||
half4 _CustomScreenCenter;
|
||||
@@ -330,17 +332,18 @@ Shader "XuanXuan/Postprocess/NBPostProcessUber"
|
||||
UNITY_BRANCH
|
||||
if(CheckLocalFlags(FLAG_BIT_FLASH))
|
||||
{
|
||||
|
||||
// //因为颜色空间的特殊原因,这里的转换运算可能会造成性能热点,后续考虑优化。
|
||||
// half3 invertColor = SRGBToLinear(1- LinearToSRGB(color.xyz));
|
||||
// color.rgb = lerp(color.rgb,invertColor,_InvertIntensity);
|
||||
|
||||
half3 endColor = lerp(_BlackFlashColor,_FlashColor,luminance(color.rgb));
|
||||
color.rgb = lerp(color.rgb,endColor,_InvertIntensity);
|
||||
|
||||
color.xyz = RgbToHsv(color.rgb);
|
||||
half3 colorHSV = color.xyz;
|
||||
color.y *= _DeSaturateIntensity;
|
||||
color.rgb = HsvToRgb(color.xyz);
|
||||
|
||||
//因为颜色空间的特殊原因,这里的转换运算可能会造成性能热点,后续考虑优化。
|
||||
half3 invertColor = SRGBToLinear(1- LinearToSRGB(color.xyz));
|
||||
color.rgb = lerp(color.rgb,invertColor,_InvertIntensity);
|
||||
|
||||
half3 endColor = lerp(color,_FlashColor,luminance(color.rgb));
|
||||
color.rgb = lerp(color.rgb,endColor,_InvertIntensity);
|
||||
|
||||
color.rgb = lerp(half3(0.5,0.5,0.5),color.rgb,_Contrast);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,9 +18,13 @@ public class W9ParticleShaderFlags: ShaderFlagsBase
|
||||
|
||||
public const string foldOutFlagName1 = "_W9ParticleShaderGUIFoldToggle1";
|
||||
public static int foldOutFlagId1 = Shader.PropertyToID(foldOutFlagName1);
|
||||
|
||||
|
||||
protected override int GetShaderFlagsId(int index = 0)
|
||||
public const string foldOutFlagName2 = "_W9ParticleShaderGUIFoldToggle2";
|
||||
public static int foldOutFlagId2 = Shader.PropertyToID(foldOutFlagName2);
|
||||
|
||||
public const string colorChannelFlagName = "_W9ParticleShaderColorChannelFlag";
|
||||
public static int colorChannelFlagId = Shader.PropertyToID(colorChannelFlagName);
|
||||
public override int GetShaderFlagsId(int index = 0)
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
@@ -33,11 +37,18 @@ public class W9ParticleShaderFlags: ShaderFlagsBase
|
||||
case 2:
|
||||
return WrapFlagsId;
|
||||
|
||||
//FoldOut必须要紧挨着,因为按照Index去拿AnimBool
|
||||
case 3:
|
||||
return foldOutFlagId;
|
||||
|
||||
case 4:
|
||||
return foldOutFlagId1;
|
||||
|
||||
case 5:
|
||||
return foldOutFlagId2;
|
||||
|
||||
case 6:
|
||||
return colorChannelFlagId;
|
||||
|
||||
default:
|
||||
return FlagsId;
|
||||
@@ -62,6 +73,9 @@ public class W9ParticleShaderFlags: ShaderFlagsBase
|
||||
|
||||
case 4:
|
||||
return foldOutFlagName1;
|
||||
|
||||
case 5:
|
||||
return colorChannelFlagName;
|
||||
|
||||
default:
|
||||
return FlagsName;
|
||||
@@ -88,7 +102,7 @@ public class W9ParticleShaderFlags: ShaderFlagsBase
|
||||
public const int FLAG_BIT_PARTICLE_LINEARTOGAMMA_ON = 1 << 10;
|
||||
public const int FLAG_BIT_PARTICLE_FRESNEL_ON = 1 << 11;
|
||||
public const int FLAG_BIT_PARTICLE_NOISEMAP_NORMALIZEED_ON = 1 << 12;
|
||||
public const int FLAG_BIT_PARTICLE_CUSTOMDATA1Z_DISSOLVE_ON = 1 << 13;
|
||||
public const int FLAG_BIT_PARTICLE_FRESNEL_COLOR_AFFETCT_BY_ALPHA = 1 << 13;
|
||||
public const int FLAG_BIT_PARTICLE_UIEFFECT_ON = 1 << 14;
|
||||
public const int FLAG_BIT_PARTICLE_UNSCALETIME_ON = 1 << 15;
|
||||
public const int FLAG_BIT_PARTICLE_SCRIPTABLETIME_ON = 1 << 16;
|
||||
@@ -96,27 +110,26 @@ public class W9ParticleShaderFlags: ShaderFlagsBase
|
||||
public const int FLAG_BIT_PARTICLE_FRESNEL_INVERT_ON = 1 << 18;
|
||||
public const int FLAG_BIT_HUESHIFT_ON = 1 << 19;
|
||||
public const int FLAG_BIT_PARTICLE_CUSTOMDATA2_ON = 1 << 20;
|
||||
public const int FLAG_BIT_PARTICLE_CUSTOMDATA1X_MAINTEXOFFSETX = 1 << 21;
|
||||
public const int FLAG_BIT_PARTICLE_CUSTOMDATA1Y_MAINTEXOFFSETY = 1 << 22;
|
||||
|
||||
public const int FLAG_BIT_PARTICLE_CUSTOMDATA1W_HUESHIFT = 1 << 23;
|
||||
public const int FLAG_BIT_PARTICLE_CUSTOMDATA2X_MASKMAPOFFSETX = 1 << 24;
|
||||
public const int FLAG_BIT_PARTICLE_CUSTOMDATA2Y_MASKMAPOFFSETY = 1 << 25;
|
||||
public const int FLAG_BIT_PARTICLE_CUSTOMDATA2Z_FRESNELOFFSET = 1 << 26;
|
||||
public const int FLAG_BIT_PARTICLE_NORMALMAP_MASK_MODE = 1 << 21;
|
||||
public const int FLAG_BIT_PARTICLE_COLOR_BLEND_FOLLOW_MAINTEX_UV = 1 << 22;
|
||||
public const int FLAG_BIT_PARTICLE_RAMP_COLOR_MAP_MODE_ON = 1 << 23;
|
||||
public const int FLAG_BIT_PARTICLE_RAMP_COLOR_BLEND_ADD= 1 << 24;
|
||||
public const int FLAG_BIT_PARTICLE_COLOR_BLEND_ALPHA_MULTIPLY_MODE = 1 << 25;
|
||||
public const int FLAG_BIT_PARTICLE_DISSOLVE_RAMP_MAP = 1 << 26;
|
||||
public const int FLAG_BIT_PARTICLE_DISSOLVE_MASK = 1 << 27;
|
||||
public const int FLAG_BIT_PARTICLE_BACKCOLOR = 1 << 28;
|
||||
public const int FLAG_BIT_PARTICLE_PC_ONLYSPECIALFUNC = 1 << 29;
|
||||
public const int FLAG_BIT_PARTICLE_EMISSION_FOLLOW_MAINTEX_UV= 1 << 29;
|
||||
public const int FLAG_BIT_PARTICLE_VERTEX_OFFSET_ON = 1 << 30;
|
||||
public const int FLAG_BIT_PARTICLE_VERTEX_OFFSET_NORMAL_DIR= 1 << 31;
|
||||
|
||||
public const int FLAG_BIT_PARTICLE_1_DEPTH_OUTLINE= 1 << 0;
|
||||
public const int FLAG_BIT_PARTICLE_1_PARALLAX_MAPPING= 1 << 1;
|
||||
public const int FLAG_BIT_PARTICLE_CUSTOMDATA1X_DISSOLVETEXOFFSETX= 1 << 2;
|
||||
public const int FLAG_BIT_PARTICLE_CUSTOMDATA1Y_DISSOLVETEXOFFSETY = 1 << 3;
|
||||
public const int FLAG_BIT_PARTICLE_CUSTOMDATA1Z_NOISE_INTENSITY = 1 << 4;
|
||||
public const int FLAG_BIT_PARTICLE_CUSTOMDATA1W_SATURATE = 1 << 5;
|
||||
public const int FLAG_BIT_PARTICLE_CUSTOMDATA2X_VERTEXOFFSETX = 1 << 6;
|
||||
public const int FLAG_BIT_PARTICLE_CUSTOMDATA2Y_VERTEXOFFSETY = 1 << 7;
|
||||
public const int FLAG_BIT_PARTICLE_1_MASKMAP_GRADIENT= 1 << 2;
|
||||
public const int FLAG_BIT_PARTICLE_1_MASKMAP_2_GRADIENT = 1 << 3;
|
||||
public const int FLAG_BIT_PARTICLE_1_MASKMAP_3_GRADIENT = 1 << 4;
|
||||
public const int FLAG_BIT_PARTICLE_1_DISSOLVE_LINE_MASK = 1 << 5;
|
||||
public const int FLAG_BIT_PARTICLE_1_DISSOLVE_RAMP_MULITPLY = 1 << 6;
|
||||
public const int FLAG_BIT_PARTICLE_1_MASK_REFINE = 1 << 7;
|
||||
public const int FLAG_BIT_PARTICLE_CUSTOMDATA2W_CHORATICABERRAT_INTENSITY = 1 << 8;
|
||||
public const int FLAG_BIT_PARTICLE_1_IGNORE_VERTEX_COLOR = 1 << 9;
|
||||
public const int FLAG_BIT_PARTICLE_1_DISSOVLE_VORONOI = 1 << 10;
|
||||
@@ -137,6 +150,9 @@ public class W9ParticleShaderFlags: ShaderFlagsBase
|
||||
public const int FLAG_BIT_PARTICLE_1_VERTEXOFFSET_START_FROM_ZERO= 1 << 25;
|
||||
public const int FLAG_BIT_PARTICLE_1_VERTEXOFFSET_MASKMAP= 1 << 26;
|
||||
public const int FLAG_BIT_PARTICLE_1_MAINTEX_COLOR_REFINE= 1 << 27;
|
||||
public const int FLAG_BIT_PARTICLE_1_BUMP_TEX_UV_FOLLOW_MAINTEX= 1 << 28;
|
||||
public const int FLAG_BIT_PARTICLE_1_SIXWAY_RAMPMAP= 1 << 29;
|
||||
public const int FLAG_BIT_PARTICLE_1_MATCAP_MULTY_MODE= 1 << 30;
|
||||
|
||||
|
||||
public const int FLAG_BIT_WRAPMODE_BASEMAP= 1 << 0;
|
||||
@@ -153,6 +169,8 @@ public class W9ParticleShaderFlags: ShaderFlagsBase
|
||||
public const int FLAG_BIT_WRAPMODE_MASKMAP3= 1 << 11;
|
||||
public const int FLAG_BIT_WRAPMODE_NOISE_MASKMAP= 1 << 12;
|
||||
public const int FLAG_BIT_WRAPMODE_VERTEXOFFSET_MASKMAP= 1 << 13;
|
||||
public const int FLAG_BIT_WRAPMODE_BUMPTEX= 1 << 14;
|
||||
public const int FLAG_BIT_WRAPMODE_RAMP_COLOR_MAP= 1 << 15; //很快就要超支了。。。
|
||||
|
||||
public const int foldOutBitMeshOption = 1 << 0;
|
||||
public const int foldOutBitMainTexOption = 1 << 1;
|
||||
@@ -185,39 +203,48 @@ public class W9ParticleShaderFlags: ShaderFlagsBase
|
||||
public const int foldOutDepthOutline= 1 << 28;
|
||||
public const int foldOutVertexOffset= 1 << 29;
|
||||
public const int foldOutParallexMapping= 1 << 30;
|
||||
// public const int foldOutPortal= 1 << 31;
|
||||
// public const int foldOutBit1Portal= 1 << 31;
|
||||
|
||||
|
||||
|
||||
|
||||
public const int foldOutBit2UVModeMainTex = 1 << 0;
|
||||
public const int foldOutBit2UVModeMaskMap= 1 << 1;
|
||||
public const int foldOutBit2UVModeMaskMap2= 1 << 2;
|
||||
public const int foldOutBit2UVModeMaskMap3= 1 << 3;
|
||||
public const int foldOutBit2UVModeNoiseMap = 1 << 4;
|
||||
public const int foldOutBit2UVModeNoiseMaskMap = 1 << 5;
|
||||
public const int foldOutBit2UVModeEmissionMap = 1 << 6;
|
||||
public const int foldOutBit2UVModeDissolveMap = 1 << 7;
|
||||
public const int foldOutBit2UVModeDissolveMaskMap = 1 << 8;
|
||||
public const int foldOutBit2UVModeColorBlendMap = 1 << 9;
|
||||
public const int foldOutBit2UVModeVertexOffsetMap = 1 << 10;
|
||||
public const int foldOutBit2UVModeVertexOffsetMaskMap = 1 << 11;
|
||||
public const int foldOutBit1UVModeMainTex = 1 << 0;
|
||||
public const int foldOutBit1UVModeMaskMap= 1 << 1;
|
||||
public const int foldOutBit1UVModeMaskMap2= 1 << 2;
|
||||
public const int foldOutBit1UVModeMaskMap3= 1 << 3;
|
||||
public const int foldOutBit1UVModeNoiseMap = 1 << 4;
|
||||
public const int foldOutBit1UVModeNoiseMaskMap = 1 << 5;
|
||||
public const int foldOutBit1UVModeEmissionMap = 1 << 6;
|
||||
public const int foldOutBit1UVModeDissolveMap = 1 << 7;
|
||||
public const int foldOutBit1UVModeDissolveMaskMap = 1 << 8;
|
||||
public const int foldOutBit1UVModeColorBlendMap = 1 << 9;
|
||||
public const int foldOutBit1UVModeVertexOffsetMap = 1 << 10;
|
||||
public const int foldOutBit1UVModeVertexOffsetMaskMap = 1 << 11;
|
||||
public const int foldOutBit1UVModeBumpTex = 1 << 12;
|
||||
public const int foldOutBit1UVModeRampColorMap = 1 << 13;
|
||||
|
||||
//留一些位置给以后可能会增加的贴图。
|
||||
public const int foldOutPortal= 1 << 20;
|
||||
public const int foldOutZOffset= 1 << 21;
|
||||
public const int foldOutCustomStencilTest= 1 << 22;
|
||||
public const int foldOutTaOption = 1 << 23;
|
||||
public const int foldOutMianTexContrast= 1 << 24;
|
||||
public const int foldOutVertexOffsetMask= 1 << 25;
|
||||
public const int foldOutMainTexColorRefine= 1 << 26;
|
||||
public const int foldOutBit1Portal= 1 << 20;
|
||||
public const int foldOutBit1ZOffset= 1 << 21;
|
||||
public const int foldOutBit1CustomStencilTest= 1 << 22;
|
||||
public const int foldOutBit1TaOption = 1 << 23;
|
||||
public const int foldOutBit1MianTexContrast= 1 << 24;
|
||||
public const int foldOutBit1VertexOffsetMask= 1 << 25;
|
||||
public const int foldOutBit1MainTexColorRefine= 1 << 26;
|
||||
public const int foldOutBit1LightOption= 1 << 27;
|
||||
public const int foldOutBit1ShaderKeyword= 1 << 28;
|
||||
public const int foldOutBit1BumpTex= 1 << 29;
|
||||
|
||||
public const int foldOutBit2BumpTexToggle= 1 << 0;
|
||||
public const int foldOutBit2MatCapToggle= 1 << 1;
|
||||
public const int foldOutBit2RampColor= 1 << 2;
|
||||
public const int foldOutBit2DissolveLine= 1 << 3;
|
||||
public const int foldOutBit2BaseBackColor= 1 << 4;
|
||||
public const int foldOutBit2MaskRefine= 1 << 5;
|
||||
|
||||
|
||||
#region CustomDataCodes
|
||||
|
||||
|
||||
|
||||
|
||||
public const string CustomDataFlag0Name = "_W9ParticleCustomDataFlag0";
|
||||
public const string CustomDataFlag1Name = "_W9ParticleCustomDataFlag1";
|
||||
public const string CustomDataFlag2Name = "_W9ParticleCustomDataFlag2";
|
||||
@@ -238,6 +265,7 @@ public class W9ParticleShaderFlags: ShaderFlagsBase
|
||||
CustomData2Y,
|
||||
CustomData2Z,
|
||||
CustomData2W,
|
||||
UnKnownOrMixed = -1
|
||||
}
|
||||
|
||||
public const int FLAGBIT_POS_0_CUSTOMDATA_MAINTEX_OFFSET_X = 0 * 4;
|
||||
@@ -486,33 +514,6 @@ public class W9ParticleShaderFlags: ShaderFlagsBase
|
||||
isCustomData1On |= CheckCustomData(1, 2);
|
||||
isCustomData1On |= CheckCustomData(1, 3);
|
||||
return isCustomData1On;
|
||||
|
||||
// int prop0Flag = material.GetInteger(CustomDataFlag0Id);
|
||||
//
|
||||
// int i = 0;
|
||||
// while (i<8)
|
||||
// {
|
||||
// int bit = prop0Flag >> (4 * i);
|
||||
// if ((bit & 0b_1000) > 0 && (bit & 0b_0100) > 0)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// i += 1;
|
||||
// }
|
||||
//
|
||||
// i = 0;
|
||||
// int prop1Flag = material.GetInteger(CustomDataFlag1Id);
|
||||
// while (i<8)
|
||||
// {
|
||||
// int bit = prop1Flag >> (4 * i);
|
||||
// if ((bit & 0b_1000) > 0 && (bit & 0b_0100) > 0)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// i += 1;
|
||||
// }
|
||||
// return false;
|
||||
}
|
||||
|
||||
public bool IsCustomData2On()
|
||||
@@ -527,32 +528,7 @@ public class W9ParticleShaderFlags: ShaderFlagsBase
|
||||
isCustomData1On |= CheckCustomData(2, 2);
|
||||
isCustomData1On |= CheckCustomData(2, 3);
|
||||
return isCustomData1On;
|
||||
// int prop0Flag = material.GetInteger(CustomDataFlag0Id);
|
||||
//
|
||||
// int i = 0;
|
||||
// while (i<8)
|
||||
// {
|
||||
// int bit = prop0Flag >> (4 * i);
|
||||
// if ((bit & 0b_1000) > 0 && (bit & 0b_0100) == 0)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// i += 1;
|
||||
// }
|
||||
//
|
||||
// i = 0;
|
||||
// int prop1Flag = material.GetInteger(CustomDataFlag1Id);
|
||||
// while (i<8)
|
||||
// {
|
||||
// int bit = prop1Flag >> (4 * i);
|
||||
// if ((bit & 0b_1000) > 0 && (bit & 0b_0100) == 0)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// i += 1;
|
||||
// }
|
||||
// return false;
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -575,17 +551,10 @@ public class W9ParticleShaderFlags: ShaderFlagsBase
|
||||
DefaultUVChannel, //0 0b_00
|
||||
SpecialUVChannel, //1 0b_01
|
||||
PolarOrTwirl, //2 0b_10
|
||||
Cylinder //3 0b_11
|
||||
Cylinder, //3 0b_11
|
||||
UnknownOrMixed = -1
|
||||
}
|
||||
|
||||
// public enum MeshSourceMode
|
||||
// {
|
||||
// ParticleSystem,
|
||||
// Mesh,
|
||||
// RawImage,
|
||||
// Sprite
|
||||
// }
|
||||
|
||||
public const int FLAG_BIT_UVMODE_POS_0_MAINTEX = 0 * 2;
|
||||
public const int FLAG_BIT_UVMODE_POS_0_MASKMAP = 1 * 2;
|
||||
public const int FLAG_BIT_UVMODE_POS_0_MASKMAP_2 = 2 * 2;
|
||||
@@ -598,6 +567,8 @@ public class W9ParticleShaderFlags: ShaderFlagsBase
|
||||
public const int FLAG_BIT_UVMODE_POS_0_COLOR_BLEND_MAP = 9 * 2;
|
||||
public const int FLAG_BIT_UVMODE_POS_0_VERTEX_OFFSET_MAP = 10 * 2;
|
||||
public const int FLAG_BIT_UVMODE_POS_0_VERTEX_OFFSET_MASKMAP = 11 * 2;
|
||||
public const int FLAG_BIT_UVMODE_POS_0_BUMPMAP = 12 * 2;
|
||||
public const int FLAG_BIT_UVMODE_POS_0_RAMP_COLOR_MAP = 13 * 2;
|
||||
|
||||
public int GetUVModeFlagPropID(int flagIndex)
|
||||
{
|
||||
@@ -646,10 +617,6 @@ public class W9ParticleShaderFlags: ShaderFlagsBase
|
||||
{
|
||||
uint checkBit = uvModeFlag0 >> (i * 2);
|
||||
checkBit = checkBit & 0b_11;
|
||||
// Debug.Log("i:"+i);
|
||||
// Debug.Log("uvModeFlag0:"+Convert.ToString(uvModeFlag0,2));
|
||||
// Debug.Log("checkBit:"+Convert.ToString(checkBit,2));
|
||||
// Debug.Log("uvModeBit:"+Convert.ToString(uvModeBit,2));
|
||||
if (checkBit == uvModeBit)
|
||||
{
|
||||
isUvMode = true;
|
||||
@@ -659,6 +626,45 @@ public class W9ParticleShaderFlags: ShaderFlagsBase
|
||||
return isUvMode;
|
||||
}
|
||||
|
||||
public const int FLAG_BIT_COLOR_CHANNEL_POS_0_MAINTEX_ALPHA = 0 * 2;
|
||||
public const int FLAG_BIT_COLOR_CHANNEL_POS_0_MASKMAP1 = 1 * 2;
|
||||
public const int FLAG_BIT_COLOR_CHANNEL_POS_0_MASKMAP2 = 2 * 2;
|
||||
public const int FLAG_BIT_COLOR_CHANNEL_POS_0_MASKMAP3 = 3 * 2;
|
||||
public const int FLAG_BIT_COLOR_CHANNEL_POS_0_NOISE_MASK = 4 * 2;
|
||||
public const int FLAG_BIT_COLOR_CHANNEL_POS_0_DISSOLVE_MAP = 5 * 2;
|
||||
public const int FLAG_BIT_COLOR_CHANNEL_POS_0_DISSOLVE_MASK_MAP = 6 * 2;
|
||||
public const int FLAG_BIT_COLOR_CHANNEL_POS_0_RAMP_COLOR_MAP = 7 * 2;
|
||||
|
||||
|
||||
public enum ColorChannel
|
||||
{
|
||||
X,
|
||||
Y,
|
||||
Z,
|
||||
W,
|
||||
UnKnownOrMixedValue
|
||||
}
|
||||
|
||||
public void SetColorChanel(ColorChannel channel, int colorChannelFlagPos)
|
||||
{
|
||||
int colorChannelFlag = material.GetInteger(colorChannelFlagId);
|
||||
|
||||
int clearFlag = 0b_11 << colorChannelFlagPos;
|
||||
clearFlag = ~ clearFlag;
|
||||
|
||||
colorChannelFlag &= clearFlag;
|
||||
int channelBit = (int)channel << colorChannelFlagPos;
|
||||
colorChannelFlag |= channelBit;
|
||||
|
||||
material.SetInteger(colorChannelFlagId,colorChannelFlag);
|
||||
}
|
||||
|
||||
public ColorChannel GetColorChanel(int colorChannelFlagPos)
|
||||
{
|
||||
int colorChannelFlag = material.GetInteger(colorChannelFlagId);
|
||||
colorChannelFlag = colorChannelFlag >> colorChannelFlagPos;
|
||||
colorChannelFlag &= 0b_11;
|
||||
return (ColorChannel)colorChannelFlag;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#define FLAG_BIT_PARTICLE_LINEARTOGAMMA_ON (1 << 10)
|
||||
#define FLAG_BIT_PARTICLE_FRESNEL_ON (1 << 11)
|
||||
#define FLAG_BIT_PARTICLE_NOISEMAP_NORMALIZEED_ON (1 << 12)
|
||||
#define FLAG_BIT_PARTICLE_CUSTOMDATA1Z_DISSOLVE_ON (1 << 13)
|
||||
#define FLAG_BIT_PARTICLE_FRESNEL_COLOR_AFFETCT_BY_ALPHA (1 << 13)
|
||||
#define FLAG_BIT_PARTICLE_UIEFFECT_ON (1 << 14)
|
||||
#define FLAG_BIT_PARTICLE_UNSCALETIME_ON (1 << 15)
|
||||
#define FLAG_BIT_PARTICLE_SCRIPTABLETIME_ON (1 << 16)
|
||||
@@ -22,27 +22,27 @@
|
||||
#define FLAG_BIT_PARTICLE_FRESNEL_INVERT_ON (1 << 18)
|
||||
#define FLAG_BIT_HUESHIFT_ON (1 << 19)
|
||||
#define FLAG_BIT_PARTICLE_CUSTOMDATA2_ON (1 << 20)
|
||||
#define FLAG_BIT_PARTICLE_CUSTOMDATA1X_MAINTEXOFFSETX (1 << 21)
|
||||
#define FLAG_BIT_PARTICLE_CUSTOMDATA1Y_MAINTEXOFFSETY (1 << 22)
|
||||
#define FLAG_BIT_PARTICLE_CUSTOMDATA1W_HUESHIFT (1 << 23)
|
||||
#define FLAG_BIT_PARTICLE_CUSTOMDATA2X_MASKMAPOFFSETX (1 << 24)
|
||||
#define FLAG_BIT_PARTICLE_CUSTOMDATA2Y_MASKMAPOFFSETY (1 << 25)
|
||||
#define FLAG_BIT_PARTICLE_CUSTOMDATA2Z_FRESNELOFFSET (1 << 26)
|
||||
#define FLAG_BIT_PARTICLE_NORMALMAP_MASK_MODE (1 << 21)
|
||||
#define FLAG_BIT_PARTICLE_COLOR_BLEND_FOLLOW_MAINTEX_UV (1 << 22)
|
||||
#define FLAG_BIT_PARTICLE_RAMP_COLOR_MAP_MODE_ON (1 << 23)
|
||||
#define FLAG_BIT_PARTICLE_RAMP_COLOR_BLEND_ADD (1 << 24)
|
||||
#define FLAG_BIT_PARTICLE_COLOR_BLEND_ALPHA_MULTIPLY_MODE (1 << 25)
|
||||
#define FLAG_BIT_PARTICLE_DISSOLVE_RAMP_MAP (1 << 26)
|
||||
#define FLAG_BIT_PARTICLE_DISSOLVE_MASK (1 << 27)
|
||||
#define FLAG_BIT_PARTICLE_BACKCOLOR (1 << 28)
|
||||
#define FLAG_BIT_PARTICLE_PC_ONLYSPECIALFUNC (1 << 29)
|
||||
#define FLAG_BIT_PARTICLE_EMISSION_FOLLOW_MAINTEX_UV (1 << 29)
|
||||
#define FLAG_BIT_PARTICLE_VERTEX_OFFSET_ON (1 << 30)
|
||||
#define FLAG_BIT_PARTICLE_VERTEX_OFFSET_NORMAL_DIR (1 << 31)
|
||||
// uint _W9ParticleShaderFlags;
|
||||
|
||||
#define FLAG_BIT_PARTICLE_1_DEPTH_OUTLINE (1 << 0)
|
||||
#define FLAG_BIT_PARTICLE_1_PARALLAX_MAPPING (1 << 1)
|
||||
#define FLAG_BIT_PARTICLE_CUSTOMDATA1X_DISSOLVETEXOFFSETX (1 << 2)
|
||||
#define FLAG_BIT_PARTICLE_CUSTOMDATA1Y_DISSOLVETEXOFFSETY (1 << 3)
|
||||
#define FLAG_BIT_PARTICLE_CUSTOMDATA1Z_NOISE_INTENSITY (1 << 4)
|
||||
#define FLAG_BIT_PARTICLE_CUSTOMDATA1W_SATURATE (1 << 5)
|
||||
#define FLAG_BIT_PARTICLE_CUSTOMDATA2X_VERTEXOFFSETX (1 << 6)
|
||||
#define FLAG_BIT_PARTICLE_CUSTOMDATA2Y_VERTEXOFFSETY (1 << 7)
|
||||
#define FLAG_BIT_PARTICLE_1_MASKMAP_GRADIENT (1 << 2)
|
||||
#define FLAG_BIT_PARTICLE_1_MASKMAP_2_GRADIENT (1 << 3)
|
||||
#define FLAG_BIT_PARTICLE_1_MASKMAP_3_GRADIENT (1 << 4)
|
||||
#define FLAG_BIT_PARTICLE_1_DISSOLVE_LINE_MASK (1 << 5)
|
||||
#define FLAG_BIT_PARTICLE_1_DISSOLVE_RAMP_MULITPLY (1 << 6)
|
||||
#define FLAG_BIT_PARTICLE_1_MASK_REFINE (1 << 7)
|
||||
#define FLAG_BIT_PARTICLE_CUSTOMDATA2W_CHORATICABERRAT_INTENSITY (1 << 8)
|
||||
#define FLAG_BIT_PARTICLE_1_IGNORE_VERTEX_COLOR (1 << 9)
|
||||
#define FLAG_BIT_PARTICLE_1_DISSOVLE_VORONOI (1 << 10)
|
||||
@@ -63,6 +63,9 @@
|
||||
#define FLAG_BIT_PARTICLE_1_VERTEXOFFSET_START_FROM_ZERO (1 << 25)
|
||||
#define FLAG_BIT_PARTICLE_1_VERTEXOFFSET_MASKMAP (1 << 26)
|
||||
#define FLAG_BIT_PARTICLE_1_MAINTEX_COLOR_REFINE (1 << 27)
|
||||
#define FLAG_BIT_PARTICLE_1_BUMP_TEX_UV_FOLLOW_MAINTEX (1 << 28)
|
||||
#define FLAG_BIT_PARTICLE_1_SIXWAY_RAMPMAP (1 << 29)
|
||||
#define FLAG_BIT_PARTICLE_1_MATCAP_MULTY_MODE (1 << 30)
|
||||
|
||||
|
||||
//WrapMode不能够超过16位(因为会占用x和x+16两个bit位)
|
||||
@@ -80,6 +83,8 @@
|
||||
#define FLAG_BIT_WRAPMODE_MASKMAP3 (1 << 11)
|
||||
#define FLAG_BIT_WRAPMODE_NOISE_MASKMAP (1 << 12)
|
||||
#define FLAG_BIT_WRAPMODE_VERTEXOFFSET_MASKMAP (1 << 13)
|
||||
#define FLAG_BIT_WRAPMODE_BUMPTEX (1 << 14)
|
||||
#define FLAG_BIT_WRAPMODE_RAMP_COLOR_MAP (1 << 15)
|
||||
|
||||
#define FLAGBIT_POS_0_CUSTOMDATA_MAINTEX_OFFSET_X (0*4)
|
||||
#define FLAGBIT_POS_0_CUSTOMDATA_MAINTEX_OFFSET_Y (1*4)
|
||||
@@ -128,6 +133,17 @@
|
||||
#define FLAG_BIT_UVMODE_POS_0_COLOR_BLEND_MAP (9*2)
|
||||
#define FLAG_BIT_UVMODE_POS_0_VERTEX_OFFSET_MAP (10*2)
|
||||
#define FLAG_BIT_UVMODE_POS_0_VERTEX_OFFSET_MASKMAP (11*2)
|
||||
#define FLAG_BIT_UVMODE_POS_0_BUMPTEX (12*2)
|
||||
#define FLAG_BIT_UVMODE_POS_0_RAMP_COLOR_MAP (13*2)
|
||||
|
||||
#define FLAG_BIT_COLOR_CHANNEL_POS_0_MAINTEX_ALPHA (0*2)
|
||||
#define FLAG_BIT_COLOR_CHANNEL_POS_0_MASKMAP1 (1*2)
|
||||
#define FLAG_BIT_COLOR_CHANNEL_POS_0_MASKMAP2 (2*2)
|
||||
#define FLAG_BIT_COLOR_CHANNEL_POS_0_MASKMAP3 (3*2)
|
||||
#define FLAG_BIT_COLOR_CHANNEL_POS_0_NOISE_MASK (4*2)
|
||||
#define FLAG_BIT_COLOR_CHANNEL_POS_0_DISSOLVE_MAP (5*2)
|
||||
#define FLAG_BIT_COLOR_CHANNEL_POS_0_DISSOLVE_MASK_MAP (6*2)
|
||||
#define FLAG_BIT_COLOR_CHANNEL_POS_0_RAMP_COLOR_MAP (7*2)
|
||||
|
||||
float GetCustomData(uint flagProperty,int flagPos,float orignValue,half4 cutstomData1,half4 customData2)
|
||||
{
|
||||
@@ -224,4 +240,9 @@
|
||||
return baseUVs.cylinderUV;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,90 +1,8 @@
|
||||
#ifndef PARTICLESUNLITFORWARDPASS
|
||||
#define PARTICLESUNLITFORWARDPASS
|
||||
#include "HLSL/ParticlesUnlitInputNew.hlsl"
|
||||
#include "HLSL/SixWaySmokeLit.hlsl"
|
||||
|
||||
struct AttributesParticle//即URP语境下的appdata
|
||||
{
|
||||
float4 vertex: POSITION;
|
||||
float3 normalOS: NORMAL;
|
||||
half4 color: COLOR;
|
||||
#if defined(_FLIPBOOKBLENDING_ON)
|
||||
float4 texcoords: TEXCOORD0; //texcoords.zw就是粒子那边新建的UV2
|
||||
float3 texcoordBlend: TEXCOORD3;//注意,假如需要UI支持,則Canvas要開放相關Channel
|
||||
#else
|
||||
float4 texcoords: TEXCOORD0;
|
||||
#endif
|
||||
|
||||
#ifdef _PARALLAX_MAPPING
|
||||
float4 tangentOS : TANGENT;
|
||||
#endif
|
||||
|
||||
float4 Custom1: TEXCOORD1;
|
||||
float4 Custom2: TEXCOORD2;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct VaryingsParticle//即URP语境下的v2f
|
||||
{
|
||||
float4 clipPos: SV_POSITION;
|
||||
|
||||
half4 color: COLOR;
|
||||
float4 texcoord: TEXCOORD0; // 主帖图 和 mask
|
||||
|
||||
#if defined (_EMISSION) || defined(_COLORMAPBLEND)
|
||||
float4 emissionColorBlendTexcoord: TEXCOORD1; // 流光
|
||||
#endif
|
||||
|
||||
#ifdef _NOISEMAP
|
||||
float4 noisemapTexcoord:TEXCOORD2;//Noise
|
||||
#endif
|
||||
|
||||
#if defined(_DISSOLVE)
|
||||
|
||||
float4 dissolveTexcoord:TEXCOORD15;
|
||||
float4 dissolveNoiseTexcoord: TEXCOORD5;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
float4 positionWS: TEXCOORD3;
|
||||
float4 positionOS: TEXCOORD12;
|
||||
|
||||
float4 texcoord2AndSpecialUV: TEXCOORD6; // UV2和SpecialUV
|
||||
|
||||
float4 positionNDC: TEXCOORD7;
|
||||
|
||||
|
||||
float4 VaryingsP_Custom1: TEXCOORD8;
|
||||
float4 VaryingsP_Custom2: TEXCOORD9;
|
||||
|
||||
|
||||
float4 normalWSAndAnimBlend: TEXCOORD10;
|
||||
|
||||
float3 fresnelViewDir :TEXCOORD11;
|
||||
|
||||
float3 viewDirWS :TEXCOORD13;
|
||||
float4 texcoordMaskMap2 : TEXCOORD14;
|
||||
|
||||
#ifdef _PARALLAX_MAPPING
|
||||
half3 tangentViewDir : TEXCOORD16;
|
||||
#endif
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
bool isProcessUVInFrag()
|
||||
{
|
||||
if(CheckLocalFlags(FLAG_BIT_PARTICLE_POLARCOORDINATES_ON) || CheckLocalFlags(FLAG_BIT_PARTICLE_UTWIRL_ON))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#if defined(_DEPTH_DECAL) || defined(_PARALLAX_MAPPING) || defined(_SCREEN_DISTORT_MODE)
|
||||
return true;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Vertex and Fragment functions //
|
||||
@@ -152,6 +70,33 @@
|
||||
|
||||
output.viewDirWS = GetWorldSpaceNormalizeViewDir(output.positionWS.xyz);
|
||||
output.normalWSAndAnimBlend.xyz = TransformObjectToWorldNormal(input.normalOS.xyz);
|
||||
|
||||
#if defined(_NORMALMAP)||defined(_FX_LIGHT_MODE_SIX_WAY)
|
||||
real sign = input.tangentOS.w * GetOddNegativeScale();
|
||||
half3 tangentWS = TransformObjectToWorldDir(input.tangentOS.xyz);
|
||||
output.tangentWS = half4(tangentWS,sign);
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef _FX_LIGHT_MODE_UNLIT
|
||||
#ifdef _FX_LIGHT_MODE_SIX_WAY
|
||||
float3 bitangent = sign * cross(output.normalWSAndAnimBlend.xyz, output.tangentWS.xyz);
|
||||
// GetSixWayBakeDiffuseLight(output.normalWSAndAnimBlend.xyz,output.tangentWS,bitangent,
|
||||
// output.bakeDiffuseLighting0,output.bakeDiffuseLighting1,output.bakeDiffuseLighting2,
|
||||
// output.backBakeDiffuseLighting0,output.backBakeDiffuseLighting1,output.backBakeDiffuseLighting2);
|
||||
|
||||
GetSixWayBakeDiffuseLight(output.normalWSAndAnimBlend.xyz,output.tangentWS,bitangent,
|
||||
output.bakeDiffuseLighting0,output.bakeDiffuseLighting1,output.bakeDiffuseLighting2,
|
||||
output.backBakeDiffuseLighting0,output.backBakeDiffuseLighting1,output.backBakeDiffuseLighting2);
|
||||
|
||||
#else
|
||||
OUTPUT_SH(output.normalWSAndAnimBlend.xyz, output.vertexSH);
|
||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||
output.vertexLight = VertexLighting(output.positionWS.xyz, output.normalWSAndAnimBlend.xyz);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
UNITY_FLATTEN
|
||||
@@ -192,6 +137,12 @@
|
||||
|
||||
output.texcoordMaskMap2.xy = particleUVs.maskMap2UV;
|
||||
output.texcoordMaskMap2.zw = particleUVs.maskMap3UV;
|
||||
#if defined (_NORMALMAP) || defined(_COLOR_RAMP)
|
||||
output.bumpTexAndColorRampMapTexcoord.xy = particleUVs.bumpTexUV;
|
||||
output.bumpTexAndColorRampMapTexcoord.zw = particleUVs.colorRampMapUV;
|
||||
|
||||
#endif
|
||||
|
||||
#if defined (_EMISSION) || defined(_COLORMAPBLEND)
|
||||
output.emissionColorBlendTexcoord.xy = particleUVs.emissionUV;
|
||||
output.emissionColorBlendTexcoord.zw = particleUVs.colorBlendUV;
|
||||
@@ -307,6 +258,8 @@
|
||||
float2 dissolve_uv;
|
||||
float2 dissolve_mask_uv;
|
||||
float4 dissolve_noise_uv;
|
||||
float2 BumpTex_uv;
|
||||
float2 colorRamp_uv;
|
||||
|
||||
//如果同时在粒子系统里开启序列帧融帧和特殊UV通道模式。
|
||||
|
||||
@@ -334,13 +287,20 @@
|
||||
noiseMap_uv = particleUVs.noiseMapUV;
|
||||
noiseMaskMap_uv = particleUVs.noiseMaskMapUV;
|
||||
dissolve_noise_uv = float4(particleUVs.dissolve_noise1_UV,particleUVs.dissolve_noise2_UV);
|
||||
|
||||
BumpTex_uv = particleUVs.bumpTexUV;
|
||||
colorRamp_uv = particleUVs.colorRampMapUV;
|
||||
}
|
||||
else
|
||||
{
|
||||
MaskMapuv = input.texcoord.zw;
|
||||
MaskMapuv2 = input.texcoordMaskMap2.xy;
|
||||
MaskMapuv3 = input.texcoordMaskMap2.zw;
|
||||
|
||||
#if defined (_NORMALMAP)||defined(_COLOR_RAMP)
|
||||
BumpTex_uv = input.bumpTexAndColorRampMapTexcoord.xy;
|
||||
colorRamp_uv = input.bumpTexAndColorRampMapTexcoord.zw;
|
||||
#endif
|
||||
|
||||
#ifdef _NOISEMAP
|
||||
noiseMap_uv = input.noisemapTexcoord.xy;
|
||||
noiseMaskMap_uv = input.noisemapTexcoord.zw;
|
||||
@@ -374,11 +334,12 @@
|
||||
{
|
||||
cum_noise = cum_noise * 2 - 1;
|
||||
}
|
||||
noiseMask *= noiseSample.a;
|
||||
UNITY_BRANCH
|
||||
if(CheckLocalFlags1(FLAG_BIT_PARTICLE_1_NOISE_MASKMAP))
|
||||
{
|
||||
noiseMask= SampleTexture2DWithWrapFlags(_NoiseMaskMap,noiseMaskMap_uv,FLAG_BIT_WRAPMODE_NOISE_MASKMAP).r;
|
||||
noiseMask *= noiseSample.a;
|
||||
half4 noiseMaskSample = SampleTexture2DWithWrapFlags(_NoiseMaskMap,noiseMaskMap_uv,FLAG_BIT_WRAPMODE_NOISE_MASKMAP);
|
||||
noiseMask *= GetColorChannel(noiseMaskSample,FLAG_BIT_COLOR_CHANNEL_POS_0_NOISE_MASK);
|
||||
}
|
||||
_TexDistortion_intensity = GetCustomData(_W9ParticleCustomDataFlag1,FLAGBIT_POS_1_CUSTOMDATA_NOISE_INTENSITY,_TexDistortion_intensity,input.VaryingsP_Custom1,input.VaryingsP_Custom2);
|
||||
|
||||
@@ -392,14 +353,15 @@
|
||||
|
||||
float2 mainTexNoise = cum_noise * noiseMask * _TexDistortion_intensity * _DistortionDirection.xy;
|
||||
uv.xy += mainTexNoise;//主贴图纹理扭曲
|
||||
blendUv.xy += mainTexNoise;
|
||||
blendUv.xy += mainTexNoise;
|
||||
#endif
|
||||
|
||||
|
||||
// SampleAlbedo--------------------
|
||||
half4 albedo = 0;
|
||||
#if defined(_SCREEN_DISTORT_MODE)
|
||||
albedo = half4(cum_noise_xy, 1.0, noiseMask);
|
||||
#else
|
||||
|
||||
UNITY_FLATTEN
|
||||
if(CheckLocalFlags(FLAG_BIT_PARTICLE_BACKCOLOR))
|
||||
{
|
||||
@@ -414,7 +376,6 @@
|
||||
#else
|
||||
baseMap = _BaseMap;
|
||||
#endif
|
||||
|
||||
|
||||
UNITY_BRANCH
|
||||
if (CheckLocalFlags(FLAG_BIT_PARTICLE_UIEFFECT_ON) & !CheckLocalFlags1(FLAG_BIT_PARTICLE_1_UIEFFECT_BASEMAP_MODE))
|
||||
@@ -430,18 +391,25 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
albedo = BlendTexture(baseMap, uv, blendUv,FLAG_BIT_WRAPMODE_BASEMAP);
|
||||
|
||||
}
|
||||
|
||||
albedo.a = GetColorChannel(albedo,FLAG_BIT_COLOR_CHANNEL_POS_0_MAINTEX_ALPHA);
|
||||
|
||||
albedo *= _BaseColor ;
|
||||
albedo.rgb *= _BaseColorIntensityForTimeline;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
half alpha = albedo.a;
|
||||
half3 result = albedo.rgb;
|
||||
|
||||
#ifdef _FX_LIGHT_MODE_SIX_WAY
|
||||
float4 rigRTBkSample = BlendTexture(_RigRTBk, uv, blendUv,FLAG_BIT_WRAPMODE_BASEMAP);
|
||||
float4 rigLBtFSample = BlendTexture(_RigLBtF, uv, blendUv,FLAG_BIT_WRAPMODE_BASEMAP);
|
||||
#endif
|
||||
|
||||
UNITY_BRANCH
|
||||
if(CheckLocalFlags(FLAG_BIT_HUESHIFT_ON))
|
||||
@@ -466,13 +434,132 @@
|
||||
result.rgb = lerp(colorA,colorB,_BaseMapColorRefine.w);
|
||||
}
|
||||
|
||||
half3 normalTS = half3(0, 0, 1);//TODO
|
||||
|
||||
if (CheckLocalFlags1(FLAG_BIT_PARTICLE_1_BUMP_TEX_UV_FOLLOW_MAINTEX))
|
||||
{
|
||||
BumpTex_uv = uv;
|
||||
}
|
||||
|
||||
half metallic = 1;
|
||||
half smoothness = 1;
|
||||
#ifdef _NORMALMAP
|
||||
|
||||
half4 normalMapSample = SampleTexture2DWithWrapFlags(_BumpTex,BumpTex_uv,FLAG_BIT_WRAPMODE_BUMPTEX);
|
||||
if (CheckLocalFlags(FLAG_BIT_PARTICLE_NORMALMAP_MASK_MODE))
|
||||
{
|
||||
normalTS = UnpackNormalRGB(half4(normalMapSample.xy,0,1),_BumpScale);
|
||||
metallic *= normalMapSample.z;
|
||||
smoothness *= normalMapSample.w;
|
||||
}
|
||||
else
|
||||
{
|
||||
normalTS = UnpackNormalScale(half4(normalMapSample),_BumpScale);
|
||||
}
|
||||
|
||||
#endif
|
||||
//光照模式
|
||||
#ifndef _FX_LIGHT_MODE_UNLIT
|
||||
|
||||
InputData inputData;
|
||||
InitializeInputData(input, normalTS, inputData);
|
||||
metallic *= _MaterialInfo.x;
|
||||
half3 specular = 0;
|
||||
smoothness *= _MaterialInfo.y;
|
||||
half occlusion = 1;
|
||||
half3 pbrEmission = 0;
|
||||
// return half4(inputData.bakedGI,1);
|
||||
#if defined (_FX_LIGHT_MODE_BLINN_PHONG) || defined(_FX_LIGHT_MODE_HALF_LAMBERT)
|
||||
half4 specularGloss = _SpecularColor;
|
||||
#ifdef _FX_LIGHT_MODE_BLINN_PHONG
|
||||
half4 blinnPhong = UniversalFragmentBlinnPhong(inputData,result.rgb, specularGloss, smoothness, pbrEmission, alpha,normalTS);
|
||||
#else //_FX_LIGHT_MODE_HALF_LAMBERT
|
||||
half4 blinnPhong = UniversalFragmentHalfLambert(inputData,result.rgb, specularGloss, smoothness, pbrEmission, alpha,normalTS);
|
||||
#endif
|
||||
result = blinnPhong.rgb;
|
||||
alpha = blinnPhong.a;
|
||||
#elif _FX_LIGHT_MODE_PBR
|
||||
half4 pbr = UniversalFragmentPBR(inputData,result.rgb, metallic, specular, smoothness, occlusion, pbrEmission, alpha);
|
||||
result = pbr.rgb;
|
||||
alpha = pbr.a;
|
||||
#elif _FX_LIGHT_MODE_SIX_WAY
|
||||
BSDFData bsdfData = (BSDFData)0;
|
||||
bsdfData.absorptionRange = GetAbsorptionRange(_SixWayInfo.x);
|
||||
bsdfData.diffuseColor = albedo;
|
||||
bsdfData.normalWS = inputData.normalWS;
|
||||
bsdfData.tangentWS = input.tangentWS;//Check this
|
||||
bsdfData.rigRTBk = rigRTBkSample.xyz * INV_PI;//AccordingTo SixWayForwardPass
|
||||
bsdfData.rigLBtF = rigLBtFSample.xyz * INV_PI;//AccordingTo SixWayForwardPass
|
||||
bsdfData.bakeDiffuseLighting0 = input.bakeDiffuseLighting0;
|
||||
bsdfData.bakeDiffuseLighting1 = input.bakeDiffuseLighting1;
|
||||
bsdfData.bakeDiffuseLighting2 = input.bakeDiffuseLighting2;
|
||||
bsdfData.backBakeDiffuseLighting0 = input.backBakeDiffuseLighting0;
|
||||
bsdfData.backBakeDiffuseLighting1 = input.backBakeDiffuseLighting1;
|
||||
bsdfData.backBakeDiffuseLighting2 = input.backBakeDiffuseLighting2;
|
||||
bsdfData.emissionInput = rigLBtFSample.a;
|
||||
GetSixWayEmission(bsdfData,_SixWayEmissionRamp,_SixWayEmissionColor,CheckLocalFlags1(FLAG_BIT_PARTICLE_1_SIXWAY_RAMPMAP));//Init Emission
|
||||
bsdfData.alpha = rigRTBkSample.a * _BaseColor.a;
|
||||
|
||||
ModifyBakedDiffuseLighting(bsdfData,inputData.bakedGI);
|
||||
|
||||
half4 sixWay = UniversalFragmentSixWay(inputData,bsdfData);
|
||||
|
||||
|
||||
// half3 dir = _MainLightPosition.xyz;
|
||||
// dir = TransformToLocalFrame(dir, bsdfData);
|
||||
// return half4(dir,1);
|
||||
|
||||
result = sixWay.rgb;
|
||||
alpha = sixWay.a;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||
result.rgb *= input.vertexLight;
|
||||
#endif
|
||||
|
||||
input.normalWSAndAnimBlend.xyz = inputData.normalWS;
|
||||
|
||||
#else
|
||||
#ifdef _NORMALMAP
|
||||
float sgn = input.tangentWS.w; // should be either +1 or -1
|
||||
float3 bitangent = sgn * cross(input.normalWSAndAnimBlend.xyz, input.tangentWS.xyz);
|
||||
half3x3 tangentToWorld = half3x3(input.tangentWS.xyz, bitangent.xyz, input.normalWSAndAnimBlend.xyz);
|
||||
input.normalWSAndAnimBlend.xyz = TransformTangentToWorld(normalTS, tangentToWorld);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _MATCAP
|
||||
// URP
|
||||
half3 normalVS = mul(input.normalWSAndAnimBlend.xyz, (float3x3)UNITY_MATRIX_I_V); // 逆转置矩阵
|
||||
half3 positionVS = TransformWorldToView(input.positionWS);
|
||||
|
||||
|
||||
float3 r = reflect(positionVS, normalVS);
|
||||
r = normalize(r);
|
||||
float m = 2.828427f * sqrt(r.z + 1.0);
|
||||
float2 matCapUV = r.xy / m + 0.5;
|
||||
half3 matCapSample = SAMPLE_TEXTURE2D(_MatCapTex,sampler_linear_clamp,matCapUV);
|
||||
|
||||
matCapSample *= _MatCapColor.rgb;
|
||||
|
||||
half3 matCapMutilResult = result * matCapSample;
|
||||
half3 matAddResult = result + matCapSample;
|
||||
half3 matCapResult = lerp(matAddResult,matCapMutilResult,_MatCapInfo.x);
|
||||
|
||||
result = lerp(result,matCapResult,_MatCapColor.a);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//流光部分
|
||||
half4 emission = half4(0, 0, 0,1);
|
||||
#if defined(_EMISSION)
|
||||
#ifdef _NOISEMAP
|
||||
if (!CheckLocalFlags(FLAG_BIT_PARTICLE_EMISSION_FOLLOW_MAINTEX_UV))
|
||||
{
|
||||
emission_uv += cum_noise * _Emi_Distortion_intensity;
|
||||
}
|
||||
#endif
|
||||
// emission = tex2D_TryLinearizeWithoutAlphaFX(_EmissionMap,emission_uv);
|
||||
emission = SampleTexture2DWithWrapFlags(_EmissionMap,emission_uv,FLAG_BIT_WRAPMODE_EMISSIONMAP);
|
||||
@@ -484,6 +571,55 @@
|
||||
|
||||
result += emission;
|
||||
|
||||
|
||||
#if defined(_COLOR_RAMP)
|
||||
half rampValue = 0;
|
||||
if (CheckLocalFlags(FLAG_BIT_PARTICLE_RAMP_COLOR_MAP_MODE_ON))
|
||||
{
|
||||
half4 RampColorSample = SampleTexture2DWithWrapFlags(_RampColorMap,colorRamp_uv,FLAG_BIT_WRAPMODE_RAMP_COLOR_MAP);
|
||||
rampValue = GetColorChannel(RampColorSample,FLAG_BIT_COLOR_CHANNEL_POS_0_RAMP_COLOR_MAP);
|
||||
}
|
||||
else
|
||||
{
|
||||
const int rampColorWrapMode = CheckLocalWrapFlags(FLAG_BIT_WRAPMODE_RAMP_COLOR_MAP);
|
||||
if (rampColorWrapMode == 0 || rampColorWrapMode == 2)
|
||||
{
|
||||
rampValue = frac(colorRamp_uv.x);
|
||||
}
|
||||
else
|
||||
{
|
||||
rampValue = saturate(colorRamp_uv.x);
|
||||
}
|
||||
}
|
||||
|
||||
half3 colorRampColorArr[] = {_RampColor0.rgb,_RampColor1.rgb,_RampColor2.rgb,_RampColor3.rgb,_RampColor4.rgb,_RampColor5.rgb};
|
||||
half colorRampColorTimeArr[] = {_RampColor0.a,_RampColor1.a,_RampColor2.a,_RampColor3.a,_RampColor4.a,_RampColor5.a};
|
||||
int colorRampColorCount = _RampColorCount & 0xFFFF;
|
||||
|
||||
half colorRampAlphaArr[] = {_RampColorAlpha0.x,_RampColorAlpha0.z,_RampColorAlpha1.x,_RampColorAlpha1.z,_RampColorAlpha2.x,_RampColorAlpha2.z};
|
||||
half colorRampAlphaTimeArr[] = {_RampColorAlpha0.y,_RampColorAlpha0.w,_RampColorAlpha1.y,_RampColorAlpha1.w,_RampColorAlpha2.y,_RampColorAlpha2.w};
|
||||
int colorRampAlphaCount = _RampColorCount >> 16;
|
||||
|
||||
half4 rampColor;
|
||||
rampColor.rgb = GetGradientColorValue(colorRampColorArr,colorRampColorTimeArr,colorRampColorCount,rampValue);
|
||||
rampColor.a = GetGradientAlphaValue(colorRampAlphaArr,colorRampAlphaTimeArr,colorRampAlphaCount,rampValue);
|
||||
|
||||
rampColor *= _RampColorBlendColor;
|
||||
|
||||
if (CheckLocalFlags(FLAG_BIT_PARTICLE_RAMP_COLOR_BLEND_ADD))
|
||||
{
|
||||
result += rampColor;
|
||||
alpha += rampColor.a;
|
||||
}
|
||||
else
|
||||
{
|
||||
result *= rampColor;
|
||||
alpha *= rampColor.a;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//溶解部分
|
||||
#if defined(_DISSOLVE)
|
||||
#ifdef _NOISEMAP
|
||||
@@ -495,9 +631,10 @@
|
||||
dissolve_mask_uv += cum_noise * _DissolveOffsetRotateDistort.w;
|
||||
}
|
||||
#endif
|
||||
half dissolveValue;
|
||||
|
||||
dissolveValue = SampleTexture2DWithWrapFlags(_DissolveMap,dissolve_uv,FLAG_BIT_WRAPMODE_DISSOLVE_MAP);
|
||||
half4 dissolveMapSample = SampleTexture2DWithWrapFlags(_DissolveMap,dissolve_uv,FLAG_BIT_WRAPMODE_DISSOLVE_MAP);
|
||||
|
||||
half dissolveValue = GetColorChannel(dissolveMapSample,FLAG_BIT_COLOR_CHANNEL_POS_0_DISSOLVE_MAP);
|
||||
|
||||
UNITY_BRANCH
|
||||
if(CheckLocalFlags1(FLAG_BIT_PARTICLE_1_DISSOVLE_VORONOI))
|
||||
@@ -518,53 +655,124 @@
|
||||
|
||||
}
|
||||
|
||||
dissolveValue = SimpleSmoothstep(_Dissolve_Vec2.x,_Dissolve_Vec2.y,dissolveValue);
|
||||
// dissolveValue = SimpleSmoothstep(_Dissolve_Vec2.x,_Dissolve_Vec2.y,dissolveValue);
|
||||
dissolveValue = pow(dissolveValue,_Dissolve.y);
|
||||
|
||||
#ifdef _DISSOLVE_EDITOR_TEST //后续Test类的关键字要找机会排除
|
||||
return half4(dissolveValue.rrr,1);
|
||||
#endif
|
||||
|
||||
|
||||
half dissolveMaskValue = 0;
|
||||
|
||||
UNITY_BRANCH
|
||||
if(CheckLocalFlags(FLAG_BIT_PARTICLE_DISSOLVE_MASK))
|
||||
{
|
||||
dissolveMaskValue = SampleTexture2DWithWrapFlags(_DissolveMaskMap,dissolve_mask_uv,FLAG_BIT_WRAPMODE_DISSOLVE_MASKMAP);
|
||||
half dissolveMaskValue = 0;
|
||||
half4 dissolveMaskSample = SampleTexture2DWithWrapFlags(_DissolveMaskMap,dissolve_mask_uv,FLAG_BIT_WRAPMODE_DISSOLVE_MASKMAP);
|
||||
dissolveMaskValue = GetColorChannel(dissolveMaskSample,FLAG_BIT_COLOR_CHANNEL_POS_0_DISSOLVE_MASK_MAP);
|
||||
_Dissolve.z += GetCustomData(_W9ParticleCustomDataFlag1,FLAGBIT_POS_1_CUSTOMDATA_DISSOLVE_MASK_INTENSITY,0,input.VaryingsP_Custom1,input.VaryingsP_Custom2);
|
||||
dissolveMaskValue *= _Dissolve.z;
|
||||
dissolveValue = lerp(dissolveValue,1.01,dissolveMaskValue);
|
||||
dissolveMaskValue += _Dissolve.z;
|
||||
// dissolveValue = dissolveMaskValue*dissolveValue;
|
||||
//
|
||||
// half mixedDisolveValue ;
|
||||
// Blend_HardLight_half(dissolveValue,dissolveMaskValue,mixedDisolveValue);
|
||||
// dissolveValue = mixedDisolveValue;
|
||||
|
||||
dissolveValue = (dissolveValue +dissolveMaskValue)*0.5;//Smart Way By Panda
|
||||
}
|
||||
half originDissolve = dissolveValue;
|
||||
|
||||
_Dissolve.x += GetCustomData(_W9ParticleCustomDataFlag0,FLAGBIT_POS_0_CUSTOMDATA_DISSOLVE_INTENSITY,0,input.VaryingsP_Custom1,input.VaryingsP_Custom2);
|
||||
#ifdef _DISSOLVE_EDITOR_TEST //后续Test类的关键字要找机会排除
|
||||
return half4(dissolveValue.rrr,1);
|
||||
#endif
|
||||
half dissolveStrenth = _Dissolve.x + GetCustomData(_W9ParticleCustomDataFlag0,FLAGBIT_POS_0_CUSTOMDATA_DISSOLVE_INTENSITY,0,input.VaryingsP_Custom1,input.VaryingsP_Custom2);
|
||||
|
||||
dissolveValue = dissolveValue-_Dissolve.x;
|
||||
half dissolveValueBeforeSoftStep = dissolveValue;
|
||||
half softStep = _Dissolve.w;
|
||||
dissolveValue = SimpleSmoothstep(0,softStep,(dissolveValue));
|
||||
half invSoftStep = 1/_Dissolve.w;
|
||||
half dissolveValueBeforeSoftStep = dissolveValue - ((dissolveStrenth)*(invSoftStep + 1)-1)*_Dissolve.w ;
|
||||
dissolveValue = dissolveValue*invSoftStep -(1+invSoftStep)*dissolveStrenth +1;
|
||||
// dissolveValue = smoothstep(dissolveStrenth-_Dissolve.w,dissolveStrenth,dissolveValue);//Smart Way By Panda
|
||||
dissolveValue = saturate(dissolveValue);
|
||||
|
||||
|
||||
|
||||
alpha *= dissolveValue;
|
||||
if(CheckLocalFlags1(FLAG_BIT_PARTICLE_1_DISSOVLE_USE_RAMP))
|
||||
{
|
||||
half rampRange = 1-dissolveValueBeforeSoftStep ;
|
||||
// half rampRange = (dissolveValueBeforeSoftStep - _Dissolve_Vec2.x)*_Dissolve_Vec2.y;
|
||||
half rampRange = dissolveValueBeforeSoftStep;
|
||||
rampRange = rampRange * _DissolveRampMap_ST.x +_DissolveRampMap_ST.z;
|
||||
|
||||
half4 rampSample = SampleTexture2DWithWrapFlags(_DissolveRampMap,half2(rampRange,0.5),FLAG_BIT_WRAPMODE_DISSOLVE_RAMPMAP);
|
||||
result = lerp(result,rampSample.rgb*_DissolveRampColor.rgb,rampSample.a*_DissolveRampColor.a);
|
||||
|
||||
half4 rampSample ;
|
||||
if (CheckLocalFlags(FLAG_BIT_PARTICLE_DISSOLVE_RAMP_MAP))
|
||||
{
|
||||
rampSample = SampleTexture2DWithWrapFlags(_DissolveRampMap,half2(rampRange,0.5),FLAG_BIT_WRAPMODE_DISSOLVE_RAMPMAP);
|
||||
}
|
||||
else
|
||||
{
|
||||
half3 dissolveRampColorArr[] = {_DissolveRampColor0.rgb,_DissolveRampColor1.rgb,_DissolveRampColor2.rgb,_DissolveRampColor3.rgb,_DissolveRampColor4.rgb,_DissolveRampColor5.rgb};
|
||||
half dissolveRampColorTimeArr[] = {_DissolveRampColor0.a,_DissolveRampColor1.a,_DissolveRampColor2.a,_DissolveRampColor3.a,_DissolveRampColor4.a,_DissolveRampColor5.a};
|
||||
int dissolveRampColorCount = _DissolveRampCount & 0xFFFF;
|
||||
|
||||
half dissolveRampAlphaArr[] = {_DissolveRampAlpha0.x,_DissolveRampAlpha0.z,_DissolveRampAlpha1.x,_DissolveRampAlpha1.z,_DissolveRampAlpha2.x,_DissolveRampAlpha2.z};
|
||||
half dissolveRampAlphaTimeArr[] = {_DissolveRampAlpha0.y,_DissolveRampAlpha0.w,_DissolveRampAlpha1.y,_DissolveRampAlpha1.w,_DissolveRampAlpha2.y,_DissolveRampAlpha2.w};
|
||||
int dissolveRampAlphaCount = _DissolveRampCount >> 16;
|
||||
|
||||
const int rampWrapMode = CheckLocalWrapFlags(FLAG_BIT_WRAPMODE_DISSOLVE_RAMPMAP);
|
||||
if (rampWrapMode == 0 || rampWrapMode == 2)
|
||||
{
|
||||
rampRange = frac(rampRange);
|
||||
}
|
||||
else
|
||||
{
|
||||
rampRange = saturate(rampRange);
|
||||
}
|
||||
|
||||
|
||||
rampSample.rgb = GetGradientColorValue(dissolveRampColorArr,dissolveRampColorTimeArr,dissolveRampColorCount,rampRange);
|
||||
rampSample.a = GetGradientAlphaValue(dissolveRampAlphaArr,dissolveRampAlphaTimeArr,dissolveRampAlphaCount,rampRange);
|
||||
}
|
||||
|
||||
if (CheckLocalFlags1(FLAG_BIT_PARTICLE_1_DISSOLVE_RAMP_MULITPLY))
|
||||
{
|
||||
result = result * lerp(1,rampSample.rgb*_DissolveRampColor.rgb,rampSample.a*_DissolveRampColor.a);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = lerp(result,rampSample.rgb*_DissolveRampColor.rgb,rampSample.a*_DissolveRampColor.a);
|
||||
}
|
||||
}
|
||||
|
||||
half lineMask = 1 - smoothstep(0,softStep,alpha * (dissolveValueBeforeSoftStep - _Dissolve.y));
|
||||
result = lerp(result,_DissolveLineColor.rgb,lineMask*_DissolveLineColor.a);
|
||||
|
||||
|
||||
|
||||
if (CheckLocalFlags1(FLAG_BIT_PARTICLE_1_DISSOLVE_LINE_MASK))
|
||||
{
|
||||
half lineMask = dissolveValueBeforeSoftStep;//SmoothStep要优化
|
||||
lineMask = saturate(NB_Remap01(lineMask,_Dissolve_Vec2.x-_Dissolve_Vec2.y,_Dissolve_Vec2 + _Dissolve_Vec2.y));
|
||||
lineMask = 1- lineMask;
|
||||
|
||||
result = lerp(result,_DissolveLineColor.rgb,lineMask*_DissolveLineColor.a);
|
||||
}
|
||||
//
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
//颜色渐变
|
||||
#ifdef _COLORMAPBLEND
|
||||
#if defined(_NOISEMAP)
|
||||
if (!CheckLocalFlags(FLAG_BIT_PARTICLE_COLOR_BLEND_FOLLOW_MAINTEX_UV))
|
||||
{
|
||||
colorBlendMap_uv += cum_noise * _ColorBlendVec.x; //加入扭曲效果
|
||||
}
|
||||
#endif
|
||||
half4 colorBlend = SampleTexture2DWithWrapFlags(_ColorBlendMap,colorBlendMap_uv,FLAG_BIT_WRAPMODE_COLORBLENDMAP);
|
||||
colorBlend.rgb = colorBlend.rgb * _ColorBlendColor.rgb;
|
||||
result.rgb = lerp(result.rgb,result.rgb * colorBlend.rgb,_ColorBlendColor.a);
|
||||
colorBlend.a = lerp(1,colorBlend.a*_ColorBlendColor.a,_ColorBlendVec.z);
|
||||
if (CheckLocalFlags(FLAG_BIT_PARTICLE_COLOR_BLEND_ALPHA_MULTIPLY_MODE))
|
||||
{
|
||||
result *= colorBlend.rgb;
|
||||
alpha *= colorBlend.a;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.rgb = lerp(result.rgb,result.rgb * colorBlend.rgb,colorBlend.a);
|
||||
}
|
||||
#endif
|
||||
|
||||
//菲涅
|
||||
@@ -583,7 +791,8 @@
|
||||
|
||||
_FresnelUnit.x += GetCustomData(_W9ParticleCustomDataFlag0,FLAGBIT_POS_0_CUSTOMDATA_FRESNEL_OFFSET,0,input.VaryingsP_Custom1,input.VaryingsP_Custom2);;
|
||||
|
||||
fresnelValue = NB_Remap(fresnelValue,_FresnelUnit.x,1,0,1);
|
||||
// half fresnelHardness = - _FresnelUnit.w*0.5 +0.5;
|
||||
fresnelValue = NB_Remap(fresnelValue,_FresnelUnit.x,_FresnelUnit.x + 1.01 - _FresnelUnit.w,0,1);
|
||||
UNITY_BRANCH
|
||||
if(!CheckLocalFlags(FLAG_BIT_PARTICLE_FRESNEL_INVERT_ON))
|
||||
{
|
||||
@@ -591,9 +800,8 @@
|
||||
}
|
||||
fresnelValue = pow(fresnelValue,_FresnelUnit.y);
|
||||
|
||||
half fresnelHardness = (1 - _FresnelUnit.w)*0.5;
|
||||
|
||||
fresnelValue = smoothstep(0.5-fresnelHardness,0.5+fresnelHardness,fresnelValue);
|
||||
// fresnelValue = smoothstep(0.5-fresnelHardness,0.5+fresnelHardness,fresnelValue);
|
||||
}
|
||||
|
||||
UNITY_BRANCH
|
||||
@@ -602,7 +810,10 @@
|
||||
float fresnelColorIntensity = fresnelValue*_FresnelColor.a*_FresnelUnit.z;
|
||||
|
||||
result = lerp(result,_FresnelColor.rgb,fresnelColorIntensity);
|
||||
alpha = max(alpha,fresnelColorIntensity);//颜色要不要不被主贴图Alpha影响呢?
|
||||
if (!CheckLocalFlags(FLAG_BIT_PARTICLE_FRESNEL_COLOR_AFFETCT_BY_ALPHA))
|
||||
{
|
||||
alpha = max(alpha,fresnelColorIntensity);//颜色要不要不被主贴图Alpha影响呢?
|
||||
}
|
||||
}
|
||||
|
||||
UNITY_BRANCH
|
||||
@@ -635,28 +846,104 @@
|
||||
#if defined(_NOISEMAP)
|
||||
MaskMapuv += cum_noise * _MaskDistortion_intensity; //加入扭曲效果
|
||||
#endif
|
||||
half4 maskmap1 = SampleTexture2DWithWrapFlags(_MaskMap, MaskMapuv,FLAG_BIT_WRAPMODE_MASKMAP);
|
||||
|
||||
half mask1 = 1;
|
||||
if (CheckLocalFlags1(FLAG_BIT_PARTICLE_1_MASKMAP_GRADIENT))
|
||||
{
|
||||
const int maskMapWrapMode = CheckLocalWrapFlags(FLAG_BIT_WRAPMODE_MASKMAP);
|
||||
half maskMapTimeValue;
|
||||
if (maskMapWrapMode == 0 || maskMapWrapMode == 2)
|
||||
{
|
||||
maskMapTimeValue = frac(MaskMapuv.x);
|
||||
}
|
||||
else
|
||||
{
|
||||
maskMapTimeValue = saturate(MaskMapuv.x);
|
||||
}
|
||||
|
||||
half maskMapAlphaArr[] = {_MaskMapGradientFloat0.x,_MaskMapGradientFloat0.z,_MaskMapGradientFloat1.x,_MaskMapGradientFloat1.z,_MaskMapGradientFloat2.x,_MaskMapGradientFloat2.z};
|
||||
half maskMapAlphaTimeArr[] = {_MaskMapGradientFloat0.y,_MaskMapGradientFloat0.w,_MaskMapGradientFloat1.y,_MaskMapGradientFloat1.w,_MaskMapGradientFloat2.y,_MaskMapGradientFloat2.w};
|
||||
int maskMapAlphaCount = _MaskMapGradientCount;
|
||||
mask1 = GetGradientAlphaValue(maskMapAlphaArr,maskMapAlphaTimeArr,maskMapAlphaCount,maskMapTimeValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
half4 maskmap1Sample = SampleTexture2DWithWrapFlags(_MaskMap, MaskMapuv,FLAG_BIT_WRAPMODE_MASKMAP);
|
||||
mask1 = GetColorChannel(maskmap1Sample,FLAG_BIT_COLOR_CHANNEL_POS_0_MASKMAP1);
|
||||
|
||||
}
|
||||
|
||||
UNITY_BRANCH
|
||||
if(CheckLocalFlags1(FLAG_BIT_PARTICLE_1_MASK_MAP2))
|
||||
{
|
||||
half maskMap2 = SampleTexture2DWithWrapFlags(_MaskMap2, MaskMapuv2,FLAG_BIT_WRAPMODE_MASKMAP2).r;
|
||||
maskmap1 *= maskMap2;
|
||||
half mask2 = 1;
|
||||
if (CheckLocalFlags1(FLAG_BIT_PARTICLE_1_MASKMAP_2_GRADIENT))
|
||||
{
|
||||
const int maskMap2WrapMode = CheckLocalWrapFlags(FLAG_BIT_WRAPMODE_MASKMAP2);
|
||||
half maskMap2TimeValue;
|
||||
if (maskMap2WrapMode == 0 || maskMap2WrapMode == 3)
|
||||
{
|
||||
maskMap2TimeValue = frac(MaskMapuv2.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
maskMap2TimeValue = saturate(MaskMapuv2.y);
|
||||
}
|
||||
|
||||
half maskMap2AlphaArr[] = {_MaskMap2GradientFloat0.x,_MaskMap2GradientFloat0.z,_MaskMap2GradientFloat1.x,_MaskMap2GradientFloat1.z,_MaskMap2GradientFloat2.x,_MaskMap2GradientFloat2.z};
|
||||
half maskMap2AlphaTimeArr[] = {_MaskMap2GradientFloat0.y,_MaskMap2GradientFloat0.w,_MaskMap2GradientFloat1.y,_MaskMap2GradientFloat1.w,_MaskMap2GradientFloat2.y,_MaskMap2GradientFloat2.w};
|
||||
int maskMap2AlphaCount = _MaskMap2GradientCount;
|
||||
mask2 = GetGradientAlphaValue(maskMap2AlphaArr,maskMap2AlphaTimeArr,maskMap2AlphaCount,maskMap2TimeValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
half4 maskMap2Sample = SampleTexture2DWithWrapFlags(_MaskMap2, MaskMapuv2,FLAG_BIT_WRAPMODE_MASKMAP2);
|
||||
mask2 = GetColorChannel(maskMap2Sample,FLAG_BIT_COLOR_CHANNEL_POS_0_MASKMAP2);
|
||||
}
|
||||
mask1 *= mask2;
|
||||
}
|
||||
|
||||
UNITY_BRANCH
|
||||
if(CheckLocalFlags1(FLAG_BIT_PARTICLE_1_MASK_MAP3))
|
||||
{
|
||||
half maskMap3 = SampleTexture2DWithWrapFlags(_MaskMap3, MaskMapuv3,FLAG_BIT_WRAPMODE_MASKMAP3).r;
|
||||
maskmap1 *= maskMap3;
|
||||
half mask3 = 1;
|
||||
if (CheckLocalFlags1(FLAG_BIT_PARTICLE_1_MASKMAP_3_GRADIENT))
|
||||
{
|
||||
const int maskMap3WrapMode = CheckLocalWrapFlags(FLAG_BIT_WRAPMODE_MASKMAP3);
|
||||
half maskMap3TimeValue;
|
||||
if (maskMap3WrapMode == 0 || maskMap3WrapMode == 2)
|
||||
{
|
||||
maskMap3TimeValue = frac(MaskMapuv3.x);
|
||||
}
|
||||
else
|
||||
{
|
||||
maskMap3TimeValue = saturate(MaskMapuv3.x);
|
||||
}
|
||||
|
||||
half maskMap3AlphaArr[] = {_MaskMap3GradientFloat0.x,_MaskMap3GradientFloat0.z,_MaskMap3GradientFloat1.x,_MaskMap3GradientFloat1.z,_MaskMap3GradientFloat2.x,_MaskMap3GradientFloat2.z};
|
||||
half maskMap3AlphaTimeArr[] = {_MaskMap3GradientFloat0.y,_MaskMap3GradientFloat0.w,_MaskMap3GradientFloat1.y,_MaskMap3GradientFloat1.w,_MaskMap3GradientFloat2.y,_MaskMap3GradientFloat2.w};
|
||||
int maskMap3AlphaCount = _MaskMap3GradientCount;
|
||||
mask3 = GetGradientAlphaValue(maskMap3AlphaArr,maskMap3AlphaTimeArr,maskMap3AlphaCount,maskMap3TimeValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
half4 maskMap3Sample = SampleTexture2DWithWrapFlags(_MaskMap3, MaskMapuv3,FLAG_BIT_WRAPMODE_MASKMAP3);
|
||||
mask3 = GetColorChannel(maskMap3Sample,FLAG_BIT_COLOR_CHANNEL_POS_0_MASKMAP3);
|
||||
}
|
||||
mask1 *= mask3;
|
||||
}
|
||||
|
||||
maskmap1.rgb = lerp(1,maskmap1.rgb,_MaskMapVec.x);
|
||||
maskmap1.rgb = saturate(maskmap1.rgb);
|
||||
if (CheckLocalFlags1(FLAG_BIT_PARTICLE_1_MASK_REFINE))
|
||||
{
|
||||
mask1 = pow(mask1,_MaskRefineVec.x);
|
||||
mask1 = mask1 * _MaskRefineVec.y;
|
||||
mask1 += _MaskRefineVec.z;
|
||||
}
|
||||
|
||||
mask1 = lerp(1,mask1,_MaskMapVec.x);
|
||||
mask1 = saturate(mask1);
|
||||
|
||||
maskmap1.rgb *= maskmap1.a;//预乘
|
||||
|
||||
alpha *= maskmap1.r; //mask边缘
|
||||
alpha *= mask1; //mask边缘
|
||||
#endif
|
||||
|
||||
|
||||
@@ -714,28 +1001,36 @@
|
||||
half3 beforeFogResult = result;
|
||||
result = MixFog(result,input.positionWS.w);
|
||||
result = lerp(beforeFogResult, result, _fogintensity);
|
||||
|
||||
|
||||
|
||||
#ifndef _SCREEN_DISTORT_MODE
|
||||
result.rgb = result.rgb * alpha;
|
||||
#endif
|
||||
// #ifndef _SCREEN_DISTORT_MODE
|
||||
// result.rgb = result.rgb * alpha;
|
||||
// #endif
|
||||
|
||||
UNITY_FLATTEN
|
||||
if(CheckLocalFlags(FLAG_BIT_PARTICLE_LINEARTOGAMMA_ON))
|
||||
{
|
||||
result.rgb = LinearToGammaSpace(result.rgb);
|
||||
}
|
||||
UNITY_FLATTEN
|
||||
if(CheckLocalFlags(FLAG_BIT_PARTICLE_LINEARTOGAMMA_ON))
|
||||
{
|
||||
result.rgb = LinearToGammaSpace(result.rgb);
|
||||
}
|
||||
|
||||
|
||||
alpha *= _AlphaAll;
|
||||
|
||||
#if defined (_ALPHAPREMULTIPLY_ON) || defined(_ALPHAMODULATE_ON)
|
||||
result *= alpha;
|
||||
#ifdef _ALPHAPREMULTIPLY_ON
|
||||
alpha *= _AdditiveToPreMultiplyAlphaLerp;
|
||||
#endif
|
||||
#endif
|
||||
half4 color = half4(result, alpha);
|
||||
|
||||
|
||||
|
||||
#ifdef _ALPHATEST_ON
|
||||
clip(color.a - _Cutoff);
|
||||
|
||||
#endif
|
||||
|
||||
color = min(color,1000);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#ifndef PARTICLESUNLITINPUT
|
||||
#define PARTICLESUNLITINPUT
|
||||
|
||||
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"
|
||||
|
||||
@@ -14,6 +12,7 @@
|
||||
float _IntersectRadius;
|
||||
half4 _IntersectColor;
|
||||
// #endif
|
||||
half _AdditiveToPreMultiplyAlphaLerp;
|
||||
half _Saturability;
|
||||
half _HueShift;
|
||||
half _Contrast;
|
||||
@@ -35,12 +34,25 @@
|
||||
half _fogintensity;
|
||||
half _Emi_Distortion_intensity;
|
||||
half _BaseMapUVRotation;
|
||||
half _BaseMapUVRotationSpeed;
|
||||
float _MaskMapUVRotation;
|
||||
float _NoiseMapUVRotation;
|
||||
half _uvRapSoft;
|
||||
half4 _EmissionMapColor;
|
||||
half _EmissionMapColorIntensity;
|
||||
|
||||
//--------------光照部分-------------
|
||||
float4 _BumpTex_ST;
|
||||
half _BumpScale;
|
||||
half4 _MaterialInfo;
|
||||
half4 _SpecularColor;
|
||||
//-----------SixWayLight----------
|
||||
half4 _SixWayInfo;
|
||||
half4 _SixWayEmissionColor;
|
||||
|
||||
half4 _MatCapColor;
|
||||
half4 _MatCapInfo;
|
||||
|
||||
half _EdgeFade;
|
||||
half4 _NoiseOffset;
|
||||
half4 _EmissionMapUVOffset;
|
||||
@@ -56,6 +68,21 @@
|
||||
half4 _MaskMapOffsetAnition;
|
||||
half4 _MaskMap3OffsetAnition;
|
||||
half4 _MaskMapVec;
|
||||
half4 _MaskRefineVec;
|
||||
|
||||
int _MaskMapGradientCount;
|
||||
half4 _MaskMapGradientFloat0;
|
||||
half4 _MaskMapGradientFloat1;
|
||||
half4 _MaskMapGradientFloat2;
|
||||
int _MaskMap2GradientCount;
|
||||
half4 _MaskMap2GradientFloat0;
|
||||
half4 _MaskMap2GradientFloat1;
|
||||
half4 _MaskMap2GradientFloat2;
|
||||
int _MaskMap3GradientCount;
|
||||
half4 _MaskMap3GradientFloat0;
|
||||
half4 _MaskMap3GradientFloat1;
|
||||
half4 _MaskMap3GradientFloat2;
|
||||
|
||||
float4 _PCCenter;
|
||||
float4 _TWParameter;
|
||||
float _TWStrength;
|
||||
@@ -109,8 +136,35 @@
|
||||
half4 _Dissolve_Vec2;
|
||||
|
||||
half4 _ColorBlendMap_ST;
|
||||
half2 _ColorBlendMapOffset;
|
||||
float4 _ColorBlendMapOffset;
|
||||
half4 _ColorBlendColor;
|
||||
half4 _ColorBlendVec;
|
||||
|
||||
half4 _RampColor0;
|
||||
half4 _RampColor1;
|
||||
half4 _RampColor2;
|
||||
half4 _RampColor3;
|
||||
half4 _RampColor4;
|
||||
half4 _RampColor5;
|
||||
half4 _RampColorAlpha0;
|
||||
half4 _RampColorAlpha1;
|
||||
half4 _RampColorAlpha2;
|
||||
uint _RampColorCount;
|
||||
half4 _RampColorBlendColor;
|
||||
float4 _RampColorMapOffset;
|
||||
half4 _RampColorMap_ST;
|
||||
|
||||
half4 _DissolveRampColor0;
|
||||
half4 _DissolveRampColor1;
|
||||
half4 _DissolveRampColor2;
|
||||
half4 _DissolveRampColor3;
|
||||
half4 _DissolveRampColor4;
|
||||
half4 _DissolveRampColor5;
|
||||
half4 _DissolveRampAlpha0;
|
||||
half4 _DissolveRampAlpha1;
|
||||
half4 _DissolveRampAlpha2;
|
||||
uint _DissolveRampCount;
|
||||
|
||||
|
||||
half3 _VertexOffset_Vec;
|
||||
half3 _VertexOffset_CustomDir;
|
||||
@@ -136,6 +190,8 @@
|
||||
|
||||
uint _UVModeFlag0;
|
||||
|
||||
uint _W9ParticleShaderColorChannelFlag;
|
||||
|
||||
CBUFFER_END
|
||||
|
||||
|
||||
@@ -173,6 +229,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SamplerState sampler_linear_repeat;
|
||||
SamplerState sampler_linear_clamp;
|
||||
SamplerState sampler_linear_RepeatU_ClampV;
|
||||
@@ -241,6 +298,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
half GetColorChannel(half4 color, int bitPos)
|
||||
{
|
||||
uint bits = _W9ParticleShaderColorChannelFlag >> bitPos;
|
||||
bits = bits & 3;
|
||||
if (bits == 0) return color.x;
|
||||
if (bits == 1) return color.y;
|
||||
if (bits == 2) return color.z;
|
||||
return color.w;
|
||||
}
|
||||
|
||||
|
||||
#include "../HLSL/EffectFlags.hlsl"
|
||||
@@ -264,11 +330,25 @@
|
||||
Texture2D _MaskMap;
|
||||
Texture2D _MaskMap2;
|
||||
Texture2D _MaskMap3;
|
||||
#ifdef _NORMALMAP
|
||||
Texture2D _BumpTex;
|
||||
#endif
|
||||
|
||||
#ifdef _FX_LIGHT_MODE_SIX_WAY
|
||||
Texture2D _RigRTBk;
|
||||
Texture2D _RigLBtF;
|
||||
Texture2D _SixWayEmissionRamp;
|
||||
#endif
|
||||
|
||||
#ifdef _SCREEN_DISTORT_MODE
|
||||
Texture2D _ScreenColorCopy1;
|
||||
#endif
|
||||
|
||||
#ifdef _MATCAP
|
||||
|
||||
#endif
|
||||
Texture2D _MatCapTex;
|
||||
|
||||
// Pre-multiplied alpha helper
|
||||
#if defined(_ALPHAPREMULTIPLY_ON) //if( blend: One OneMinusSrcAlpha)
|
||||
#define ALBEDO_MUL albedo
|
||||
@@ -292,6 +372,10 @@
|
||||
Texture2D _ColorBlendMap;
|
||||
#endif
|
||||
|
||||
#ifdef _COLOR_RAMP
|
||||
Texture2D _RampColorMap;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
half4 tex2D_TryLinearizeWithoutAlphaFX(sampler2D tex, float2 uv)
|
||||
@@ -568,6 +652,8 @@
|
||||
float2 colorBlendUV;
|
||||
float2 noiseMapUV;
|
||||
float2 noiseMaskMapUV;
|
||||
float2 bumpTexUV;
|
||||
float2 colorRampMapUV;
|
||||
};
|
||||
|
||||
BaseUVs ProcessBaseUVs(float4 meshTexcoord0, float2 specialUVInTexcoord3,float4 VaryingsP_Custom1,float4 VaryingsP_Custom2,float3 postionOS)
|
||||
@@ -657,6 +743,7 @@
|
||||
#ifdef _SCREEN_DISTORT_MODE
|
||||
particleUVs.mainTexUV = screenUV;
|
||||
#else
|
||||
_BaseMapUVRotation += time * _BaseMapUVRotationSpeed;
|
||||
baseMapUV = Rotate_Radians_float(baseMapUV, half2(0.5, 0.5), _BaseMapUVRotation); //主贴图旋转
|
||||
UNITY_BRANCH
|
||||
if(CheckLocalFlags(FLAG_BIT_PARTICLE_UIEFFECT_ON) & !CheckLocalFlags1(FLAG_BIT_PARTICLE_1_UIEFFECT_BASEMAP_MODE))
|
||||
@@ -680,6 +767,20 @@
|
||||
particleUVs.mainTexUV = UVOffsetAnimaiton(particleUVs.mainTexUV,_BaseMapMaskMapOffset.xy);
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(_NORMALMAP)
|
||||
if (CheckLocalFlags1(FLAG_BIT_PARTICLE_1_BUMP_TEX_UV_FOLLOW_MAINTEX))
|
||||
{
|
||||
particleUVs.bumpTexUV = particleUVs.mainTexUV;
|
||||
}
|
||||
else
|
||||
{
|
||||
float2 bumpTexUV = GetUVByUVMode(_UVModeFlag0,FLAG_BIT_UVMODE_POS_0_BUMPTEX,baseUVs);
|
||||
bumpTexUV = TRANSFORM_TEX(bumpTexUV, _BumpTex);
|
||||
particleUVs.bumpTexUV = bumpTexUV;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if defined(_MASKMAP_ON)
|
||||
@@ -706,6 +807,7 @@
|
||||
if(CheckLocalFlags1(FLAG_BIT_PARTICLE_1_MASK_MAP2))
|
||||
{
|
||||
float2 maskMap2UV = GetUVByUVMode(_UVModeFlag0,FLAG_BIT_UVMODE_POS_0_MASKMAP_2,baseUVs);
|
||||
maskMap2UV = Rotate_Radians_float(maskMap2UV,half2(0.5,0.5),_MaskMapVec.y);
|
||||
maskMap2UV = maskMap2UV * _MaskMap2_ST.xy + _MaskMap2_ST.zw;
|
||||
|
||||
maskMap2UV = UVOffsetAnimaiton(maskMap2UV,_MaskMapOffsetAnition.zw);
|
||||
@@ -716,6 +818,8 @@
|
||||
if(CheckLocalFlags1(FLAG_BIT_PARTICLE_1_MASK_MAP3))
|
||||
{
|
||||
float2 maskMap3UV = GetUVByUVMode(_UVModeFlag0,FLAG_BIT_UVMODE_POS_0_MASKMAP_3,baseUVs);
|
||||
maskMap3UV = Rotate_Radians_float(maskMap3UV,half2(0.5,0.5),_MaskMapVec.z);
|
||||
|
||||
maskMap3UV = maskMap3UV* _MaskMap3_ST.xy + _MaskMap3_ST.zw;
|
||||
|
||||
maskMap3UV = UVOffsetAnimaiton(maskMap3UV,_MaskMap3OffsetAnition.xy);
|
||||
@@ -724,9 +828,17 @@
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_EMISSION)
|
||||
if (CheckLocalFlags(FLAG_BIT_PARTICLE_EMISSION_FOLLOW_MAINTEX_UV))
|
||||
{
|
||||
particleUVs.emissionUV = particleUVs.mainTexUV;
|
||||
}
|
||||
else
|
||||
{
|
||||
float2 emissionUV = GetUVByUVMode(_UVModeFlag0,FLAG_BIT_UVMODE_POS_0_EMISSION_MAP,baseUVs);
|
||||
particleUVs.emissionUV = ParticleUVCommonProcess(emissionUV,_EmissionMap_ST,_EmissionMapUVOffset.xy,_EmissionMapUVRotation);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_DISSOLVE)
|
||||
@@ -762,10 +874,21 @@
|
||||
#endif
|
||||
|
||||
#ifdef _COLORMAPBLEND
|
||||
if (CheckLocalFlags(FLAG_BIT_PARTICLE_COLOR_BLEND_FOLLOW_MAINTEX_UV))
|
||||
{
|
||||
particleUVs.colorBlendUV = particleUVs.mainTexUV;
|
||||
}
|
||||
else
|
||||
{
|
||||
float2 colorBlendUV = GetUVByUVMode(_UVModeFlag0,FLAG_BIT_UVMODE_POS_0_COLOR_BLEND_MAP,baseUVs);
|
||||
particleUVs.colorBlendUV = ParticleUVCommonProcess(colorBlendUV,_ColorBlendMap_ST,_ColorBlendMapOffset.xy);
|
||||
|
||||
particleUVs.colorBlendUV = ParticleUVCommonProcess(colorBlendUV,_ColorBlendMap_ST,_ColorBlendMapOffset.xy,_ColorBlendVec.w);
|
||||
}
|
||||
#endif
|
||||
#ifdef _COLOR_RAMP
|
||||
float2 colorRampMapUV = GetUVByUVMode(_UVModeFlag0,FLAG_BIT_UVMODE_POS_0_RAMP_COLOR_MAP,baseUVs);
|
||||
particleUVs.colorRampMapUV = ParticleUVCommonProcess(colorRampMapUV,_RampColorMap_ST,_RampColorMapOffset.xy,_RampColorMapOffset.w);
|
||||
#endif
|
||||
|
||||
half cum_noise = 0;
|
||||
|
||||
//TODO
|
||||
@@ -784,6 +907,9 @@
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Texture2D _VertexOffset_Map;
|
||||
@@ -985,4 +1111,236 @@
|
||||
|
||||
return finalTexCoords;
|
||||
}
|
||||
|
||||
//--------------MatCap------------------
|
||||
|
||||
//-
|
||||
|
||||
struct AttributesParticle//即URP语境下的appdata
|
||||
{
|
||||
float4 vertex: POSITION;
|
||||
float3 normalOS: NORMAL;
|
||||
half4 color: COLOR;
|
||||
#if defined(_FLIPBOOKBLENDING_ON)
|
||||
float4 texcoords: TEXCOORD0; //texcoords.zw就是粒子那边新建的UV2
|
||||
float3 texcoordBlend: TEXCOORD3;//注意,假如需要UI支持,則Canvas要開放相關Channel
|
||||
#else
|
||||
float4 texcoords: TEXCOORD0;
|
||||
#endif
|
||||
|
||||
#if defined(_PARALLAX_MAPPING) || defined(_NORMALMAP) || defined(_FX_LIGHT_MODE_SIX_WAY)
|
||||
float4 tangentOS : TANGENT;
|
||||
#endif
|
||||
|
||||
float4 Custom1: TEXCOORD1;
|
||||
float4 Custom2: TEXCOORD2;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct VaryingsParticle//即URP语境下的v2f
|
||||
{
|
||||
float4 clipPos: SV_POSITION;
|
||||
|
||||
half4 color: COLOR;
|
||||
float4 texcoord: TEXCOORD0; // 主帖图 和 mask
|
||||
|
||||
#if defined (_EMISSION) || defined(_COLORMAPBLEND)
|
||||
float4 emissionColorBlendTexcoord: TEXCOORD1; // 流光
|
||||
#endif
|
||||
|
||||
#ifdef _NOISEMAP
|
||||
float4 noisemapTexcoord:TEXCOORD2;//Noise
|
||||
#endif
|
||||
|
||||
#if defined(_DISSOLVE)
|
||||
|
||||
float4 dissolveTexcoord:TEXCOORD15;
|
||||
float4 dissolveNoiseTexcoord: TEXCOORD5;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
float4 positionWS: TEXCOORD3;
|
||||
float4 positionOS: TEXCOORD12;
|
||||
|
||||
float4 texcoord2AndSpecialUV: TEXCOORD6; // UV2和SpecialUV
|
||||
|
||||
float4 positionNDC: TEXCOORD7;
|
||||
|
||||
|
||||
float4 VaryingsP_Custom1: TEXCOORD8;
|
||||
float4 VaryingsP_Custom2: TEXCOORD9;
|
||||
|
||||
|
||||
float4 normalWSAndAnimBlend: TEXCOORD10;
|
||||
|
||||
float3 fresnelViewDir :TEXCOORD11;
|
||||
|
||||
float3 viewDirWS :TEXCOORD13;
|
||||
float4 texcoordMaskMap2 : TEXCOORD14;
|
||||
|
||||
#ifdef _PARALLAX_MAPPING
|
||||
half3 tangentViewDir : TEXCOORD16;
|
||||
#endif
|
||||
|
||||
#ifndef _FX_LIGHT_MODE_UNLIT
|
||||
half3 vertexSH :TEXCOORD17;
|
||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||
half3 vertexLight :TEXCOORD18;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(_NORMALMAP) || defined(_FX_LIGHT_MODE_SIX_WAY)
|
||||
half4 tangentWS : TEXCOOR19;
|
||||
#endif
|
||||
#if defined (_NORMALMAP) || defined(_COLOR_RAMP)
|
||||
float4 bumpTexAndColorRampMapTexcoord : TEXCOOR20;
|
||||
#endif
|
||||
|
||||
#ifdef _FX_LIGHT_MODE_SIX_WAY
|
||||
half3 bakeDiffuseLighting0 :TEXCOOR21;
|
||||
half3 bakeDiffuseLighting1 :TEXCOOR22;
|
||||
half3 bakeDiffuseLighting2 :TEXCOOR23;
|
||||
half3 backBakeDiffuseLighting0 :TEXCOOR24;
|
||||
half3 backBakeDiffuseLighting1 :TEXCOOR25;
|
||||
half3 backBakeDiffuseLighting2 :TEXCOOR26;
|
||||
#endif
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
bool isProcessUVInFrag()
|
||||
{
|
||||
if(CheckLocalFlags(FLAG_BIT_PARTICLE_POLARCOORDINATES_ON) || CheckLocalFlags(FLAG_BIT_PARTICLE_UTWIRL_ON))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#if defined(_DEPTH_DECAL) || defined(_PARALLAX_MAPPING) || defined(_SCREEN_DISTORT_MODE)
|
||||
return true;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifndef _FX_LIGHT_MODE_UNLIT
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
|
||||
|
||||
void InitializeInputData(VaryingsParticle input, half3 normalTS, out InputData inputData)
|
||||
{
|
||||
inputData = (InputData)0;
|
||||
|
||||
#if defined(REQUIRES_WORLD_SPACE_POS_INTERPOLATOR)
|
||||
inputData.positionWS = input.positionWS;
|
||||
#endif
|
||||
|
||||
half3 viewDirWS = GetWorldSpaceNormalizeViewDir(input.positionWS);
|
||||
#if defined(_NORMALMAP) || defined(_DETAIL)
|
||||
float sgn = input.tangentWS.w; // should be either +1 or -1
|
||||
float3 bitangent = sgn * cross(input.normalWSAndAnimBlend.xyz, input.tangentWS.xyz);
|
||||
half3x3 tangentToWorld = half3x3(input.tangentWS.xyz, bitangent.xyz, input.normalWSAndAnimBlend.xyz);
|
||||
|
||||
#if defined(_NORMALMAP)
|
||||
inputData.tangentToWorld = tangentToWorld;
|
||||
#endif
|
||||
inputData.normalWS = TransformTangentToWorld(normalTS, tangentToWorld);
|
||||
#else
|
||||
inputData.normalWS = input.normalWSAndAnimBlend.xyz;
|
||||
#endif
|
||||
|
||||
inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS);
|
||||
inputData.viewDirectionWS = viewDirWS;
|
||||
|
||||
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
||||
inputData.shadowCoord = input.shadowCoord;
|
||||
#elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
|
||||
inputData.shadowCoord = TransformWorldToShadowCoord(inputData.positionWS);
|
||||
#else
|
||||
inputData.shadowCoord = float4(0, 0, 0, 0);
|
||||
#endif
|
||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||
inputData.fogCoord = InitializeInputDataFog(float4(input.positionWS, 1.0), input.fogFactorAndVertexLight.x);
|
||||
inputData.vertexLighting = input.fogFactorAndVertexLight.yzw;
|
||||
#else
|
||||
inputData.fogCoord = InitializeInputDataFog(float4(input.positionWS.xyz, 1.0), input.positionWS.w);
|
||||
#endif
|
||||
|
||||
// #if defined(DYNAMICLIGHTMAP_ON)
|
||||
// inputData.bakedGI = SAMPLE_GI(input.staticLightmapUV, input.dynamicLightmapUV, input.vertexSH, inputData.normalWS);
|
||||
// #else
|
||||
// inputData.bakedGI = SAMPLE_GI(input.staticLightmapUV, input.vertexSH, inputData.normalWS);
|
||||
// #endif
|
||||
|
||||
inputData.bakedGI = SampleSHPixel(input.vertexSH, inputData.normalWS);
|
||||
|
||||
inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.clipPos);
|
||||
inputData.shadowMask = SAMPLE_SHADOWMASK(input.staticLightmapUV);
|
||||
|
||||
#if defined(DEBUG_DISPLAY)
|
||||
#if defined(DYNAMICLIGHTMAP_ON)
|
||||
inputData.dynamicLightmapUV = input.dynamicLightmapUV;
|
||||
#endif
|
||||
#if defined(LIGHTMAP_ON)
|
||||
inputData.staticLightmapUV = input.staticLightmapUV;
|
||||
#else
|
||||
inputData.vertexSH = input.vertexSH;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int2 GetGradientIndex(half timeArr[6], int arrCount, half gradientTime)
|
||||
{
|
||||
|
||||
// 边界情况处理
|
||||
if (gradientTime < timeArr[0]) {
|
||||
return int2(-1, 0); // 小于最小值
|
||||
}
|
||||
if (gradientTime >= timeArr[arrCount - 1]) {
|
||||
return int2(arrCount - 1, arrCount); // 大于等于最大值
|
||||
}
|
||||
|
||||
// 顺序查找第一个大于X的元素索引
|
||||
[unroll]
|
||||
for (int i = 0; i < arrCount; i++) {
|
||||
if (timeArr[i] > gradientTime) {
|
||||
return int2(i - 1, i); // 返回区间索引
|
||||
}
|
||||
}
|
||||
return int2(-1, 0); // 理论上不会执行此处
|
||||
}
|
||||
half GetGradientIndexInterval(half timeArr[6],int arrCount,int2 indexes,half gradientTime)
|
||||
{
|
||||
//超出范围的直接在外面就判断好。
|
||||
// half smallVal = indexes.x < 0 ? 0:timeArr[indexes.x];
|
||||
half smallVal = timeArr[indexes.x];
|
||||
// half bigVal = indexes.y >= arrCount ? 1 : timeArr[indexes.y];
|
||||
half bigVal = timeArr[indexes.y];
|
||||
return (gradientTime - smallVal) / (bigVal - smallVal);
|
||||
}
|
||||
|
||||
half3 GetGradientColorValue(half3 colorArr[6],half timeArr[6], int arrCount,half gradientTime)
|
||||
{
|
||||
int2 indexes = GetGradientIndex(timeArr, arrCount, gradientTime);
|
||||
if (indexes.x < 0) return colorArr[0];
|
||||
if (indexes.y >= arrCount ) return colorArr[arrCount - 1];
|
||||
half interval = GetGradientIndexInterval(timeArr, arrCount, indexes, gradientTime);
|
||||
interval = SmoothStep01(interval);
|
||||
return lerp(colorArr[indexes.x], colorArr[indexes.y], interval);
|
||||
}
|
||||
|
||||
half GetGradientAlphaValue(half alphaArr[6],half timeArr[6], int arrCount,half gradientTime)
|
||||
{
|
||||
int2 indexes = GetGradientIndex(timeArr, arrCount, gradientTime);
|
||||
if (indexes.x < 0) return alphaArr[0];
|
||||
if (indexes.y >= arrCount ) return alphaArr[arrCount - 1];
|
||||
half interval = GetGradientIndexInterval(timeArr, arrCount, indexes, gradientTime);
|
||||
interval = SmoothStep01(interval);//TODO:消耗很大,如何避免?
|
||||
half alpha = lerp(alphaArr[indexes.x], alphaArr[indexes.y], interval);
|
||||
alpha *= alpha;//Make Alpha Smoother
|
||||
return alpha ;
|
||||
}
|
||||
#endif
|
||||
357
Packages/NBShaders/Shader/HLSL/SixWaySmokeLit.hlsl
Normal file
357
Packages/NBShaders/Shader/HLSL/SixWaySmokeLit.hlsl
Normal file
@@ -0,0 +1,357 @@
|
||||
#ifndef SIX_WAY_SMOKE_LIT_HLSL
|
||||
#define SIX_WAY_SMOKE_LIT_HLSL
|
||||
//这部分尽量借鉴 UnityEditor.VFX.HDRP.SixWaySmokeLit
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
#include "ParticlesUnlitInputNew.hlsl"
|
||||
|
||||
// Generated from UnityEditor.VFX.HDRP.SixWaySmokeLit+BSDFData
|
||||
// PackingRules = Exact
|
||||
struct BSDFData
|
||||
{
|
||||
uint materialFeatures;
|
||||
float absorptionRange;
|
||||
real4 diffuseColor;
|
||||
real3 fresnel0;
|
||||
real ambientOcclusion;
|
||||
float3 normalWS;
|
||||
float4 tangentWS;
|
||||
real3 geomNormalWS;
|
||||
real3 rigRTBk;
|
||||
real3 rigLBtF;
|
||||
real3 bakeDiffuseLighting0;//rigRTBk.x
|
||||
real3 bakeDiffuseLighting1;//rigRTBk.y
|
||||
real3 bakeDiffuseLighting2;// bsdfData.tangentWS.w > 0.0f ? rigRTBk.z : rigLBtF.z
|
||||
real3 backBakeDiffuseLighting0;//rigLBtF.x
|
||||
real3 backBakeDiffuseLighting1;//rigLBtF.y
|
||||
real3 backBakeDiffuseLighting2;// bsdfData.tangentWS.w > 0.0f ? rigLBtF.z : rigRTBk.z
|
||||
|
||||
//-----NBShaders-----
|
||||
real3 emission;
|
||||
real emissionInput;//NegativeTex.a
|
||||
real alpha;//PositiveTex.a
|
||||
|
||||
};
|
||||
|
||||
#define ABSORPTION_EPSILON max(REAL_MIN, 1e-5)
|
||||
|
||||
real3 ComputeDensityScales(real3 absorptionColor)
|
||||
{
|
||||
absorptionColor.rgb = max(ABSORPTION_EPSILON, absorptionColor.rgb);
|
||||
|
||||
// Empirical value used to parametrize absorption from color
|
||||
const real absorptionStrength = 0.2f;
|
||||
return 1.0f + log2(absorptionColor.rgb) / log2(absorptionStrength);
|
||||
}
|
||||
|
||||
real3 GetTransmissionWithAbsorption(real transmission, real4 absorptionColor, real absorptionRange)
|
||||
{
|
||||
#if defined(VFX_SIX_WAY_ABSORPTION)
|
||||
real3 densityScales = ComputeDensityScales(absorptionColor.rgb);
|
||||
|
||||
#ifdef VFX_BLENDMODE_PREMULTIPLY
|
||||
absorptionRange *= (absorptionColor.a > 0) ? absorptionColor.a : 1.0f;
|
||||
#endif
|
||||
|
||||
// real3 outTransmission = GetTransmissionWithAbsorption(transmission, densityScales, absorptionRange);
|
||||
real3 outTransmission = pow(saturate(transmission / absorptionRange), densityScales);
|
||||
outTransmission *= absorptionRange;
|
||||
|
||||
return outTransmission;
|
||||
#else
|
||||
return transmission.xxx * absorptionColor.rgb; // simple multiply
|
||||
#endif
|
||||
}
|
||||
|
||||
void ModifyBakedDiffuseLighting(BSDFData bsdfData, inout float3 bakeDiffuseLighting)
|
||||
{
|
||||
bakeDiffuseLighting = 0;
|
||||
|
||||
// Scale to be energy conserving: Total energy = 4*pi; divided by 6 directions
|
||||
float scale = 4.0f * PI / 6.0f;
|
||||
|
||||
float3 frontBakeDiffuseLighting = bsdfData.tangentWS.w > 0.0f ? bsdfData.bakeDiffuseLighting2 : bsdfData.backBakeDiffuseLighting2;
|
||||
float3 backBakeDiffuseLighting = bsdfData.tangentWS.w > 0.0f ? bsdfData.backBakeDiffuseLighting2 : bsdfData.bakeDiffuseLighting2;
|
||||
|
||||
float3x3 bakeDiffuseLightingMat;
|
||||
bakeDiffuseLightingMat[0] = bsdfData.bakeDiffuseLighting0;
|
||||
bakeDiffuseLightingMat[1] = bsdfData.bakeDiffuseLighting1;
|
||||
bakeDiffuseLightingMat[2] = frontBakeDiffuseLighting;
|
||||
bakeDiffuseLighting += GetTransmissionWithAbsorption(bsdfData.rigRTBk.x, bsdfData.diffuseColor, bsdfData.absorptionRange) * bakeDiffuseLightingMat[0];
|
||||
bakeDiffuseLighting += GetTransmissionWithAbsorption(bsdfData.rigRTBk.y, bsdfData.diffuseColor, bsdfData.absorptionRange) * bakeDiffuseLightingMat[1];
|
||||
bakeDiffuseLighting += GetTransmissionWithAbsorption(bsdfData.rigRTBk.z, bsdfData.diffuseColor, bsdfData.absorptionRange) * bakeDiffuseLightingMat[2];
|
||||
|
||||
bakeDiffuseLightingMat[0] = bsdfData.backBakeDiffuseLighting0;
|
||||
bakeDiffuseLightingMat[1] = bsdfData.backBakeDiffuseLighting1;
|
||||
bakeDiffuseLightingMat[2] = backBakeDiffuseLighting;
|
||||
bakeDiffuseLighting += GetTransmissionWithAbsorption(bsdfData.rigLBtF.x, bsdfData.diffuseColor, bsdfData.absorptionRange) * bakeDiffuseLightingMat[0];
|
||||
bakeDiffuseLighting += GetTransmissionWithAbsorption(bsdfData.rigLBtF.y, bsdfData.diffuseColor, bsdfData.absorptionRange) * bakeDiffuseLightingMat[1];
|
||||
bakeDiffuseLighting += GetTransmissionWithAbsorption(bsdfData.rigLBtF.z, bsdfData.diffuseColor, bsdfData.absorptionRange) * bakeDiffuseLightingMat[2];
|
||||
|
||||
bakeDiffuseLighting *= scale;
|
||||
|
||||
}
|
||||
|
||||
//世界空间到切线空间方向转换
|
||||
float3 TransformToLocalFrame(float3 L, BSDFData bsdfData)
|
||||
{
|
||||
float3 zVec = -bsdfData.normalWS;
|
||||
float3 xVec = bsdfData.tangentWS.xyz;
|
||||
float3 yVec = -cross(zVec, xVec) * bsdfData.tangentWS.w;//原代码没有负值,实际测试需要负值
|
||||
float3x3 tbn = float3x3(xVec, yVec, zVec);
|
||||
return mul(tbn, L);
|
||||
}
|
||||
|
||||
CBSDF EvaluateBSDF(float3 L, BSDFData bsdfData)
|
||||
{
|
||||
CBSDF cbsdf;
|
||||
ZERO_INITIALIZE(CBSDF, cbsdf);
|
||||
|
||||
float3 dir = TransformToLocalFrame(L, bsdfData);
|
||||
float3 weights = dir >= 0 ? bsdfData.rigRTBk.xyz : bsdfData.rigLBtF.xyz;
|
||||
float3 sqrDir = dir*dir;
|
||||
|
||||
cbsdf.diffR = GetTransmissionWithAbsorption(dot(sqrDir, weights), bsdfData.diffuseColor, bsdfData.absorptionRange);
|
||||
|
||||
return cbsdf;
|
||||
}
|
||||
|
||||
|
||||
//这一步最好在面板上做完
|
||||
half GetAbsorptionRange(float absorptionStrenth)
|
||||
{
|
||||
return INV_PI + saturate(absorptionStrenth) * (1 - INV_PI);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//---------NBShaderUtility-----------
|
||||
|
||||
//UseInVerTex
|
||||
void GetSixWayBakeDiffuseLight(real3 normalWS,real3 tangentWS,real3 biTangentWS,
|
||||
inout half3 bakeDiffuseLighting0,inout half3 bakeDiffuseLighting1,inout half3 bakeDiffuseLighting2,
|
||||
inout half3 backBakeDiffuseLighting0,inout half3 backBakeDiffuseLighting1,inout half3 backBakeDiffuseLighting2)
|
||||
{
|
||||
bakeDiffuseLighting0 = SampleSHVertex(tangentWS);
|
||||
bakeDiffuseLighting1 = SampleSHVertex(biTangentWS);
|
||||
bakeDiffuseLighting2 = SampleSHVertex(-normalWS);
|
||||
backBakeDiffuseLighting0 = SampleSHVertex(-tangentWS);
|
||||
backBakeDiffuseLighting1 = SampleSHVertex(-biTangentWS);
|
||||
backBakeDiffuseLighting2 = SampleSHVertex(normalWS);
|
||||
}
|
||||
|
||||
LightingData CreateSixWayLightingData(InputData inputData, half3 emission)
|
||||
{
|
||||
LightingData lightingData;
|
||||
|
||||
lightingData.giColor = inputData.bakedGI;
|
||||
lightingData.emissionColor = emission;
|
||||
lightingData.vertexLightingColor = 0;
|
||||
lightingData.mainLightColor = 0;
|
||||
lightingData.additionalLightsColor = 0;
|
||||
|
||||
return lightingData;
|
||||
}
|
||||
|
||||
void GetSixWayEmission(inout BSDFData bsdfData,Texture2D rampMap,half4 emissionColor,bool isRampMap)
|
||||
{
|
||||
float input = pow(bsdfData.emissionInput,_SixWayInfo.y);
|
||||
half3 emission = emissionColor * emissionColor.a;
|
||||
if (isRampMap)
|
||||
{
|
||||
half4 rampSample = rampMap.Sample(sampler_linear_clamp,half2(input,0.5));
|
||||
emission = emission * rampSample * rampSample.a;
|
||||
}
|
||||
else
|
||||
{
|
||||
emission *= input;
|
||||
}
|
||||
bsdfData.emission = emission;
|
||||
}
|
||||
|
||||
half3 LightingSixWay(Light light,InputData inputData, BSDFData bsdfData)
|
||||
{
|
||||
half3 cbsdf_R = EvaluateBSDF(light.direction,bsdfData).diffR;
|
||||
half3 radiance = light.color * light.distanceAttenuation * light.shadowAttenuation;
|
||||
return PI * cbsdf_R * radiance;
|
||||
}
|
||||
|
||||
|
||||
//光照流程--->原型为UniversalFragmentBlinnPhong
|
||||
half4 UniversalFragmentSixWay(InputData inputData,BSDFData bsdfData)
|
||||
{
|
||||
// #if defined(DEBUG_DISPLAY)
|
||||
// half4 debugColor;
|
||||
//
|
||||
// if (CanDebugOverrideOutputColor(inputData, surfaceData, debugColor))
|
||||
// {
|
||||
// return debugColor;
|
||||
// }
|
||||
// #endif
|
||||
|
||||
#ifdef _LIGHT_LAYERS
|
||||
uint meshRenderingLayers = GetMeshRenderingLayer();
|
||||
#endif
|
||||
half4 shadowMask = CalculateShadowMask(inputData);
|
||||
// AmbientOcclusionFactor aoFactor = CreateAmbientOcclusionFactor(inputData, surfaceData);
|
||||
AmbientOcclusionFactor aoFactor;
|
||||
aoFactor.directAmbientOcclusion = 1;
|
||||
aoFactor.indirectAmbientOcclusion = 1;
|
||||
Light mainLight = GetMainLight(inputData, shadowMask, aoFactor);
|
||||
|
||||
// MixRealtimeAndBakedGI(mainLight, inputData.normalWS, inputData.bakedGI, aoFactor);
|
||||
|
||||
// inputData.bakedGI *= surfaceData.albedo;
|
||||
|
||||
// LightingData lightingData = CreateLightingData(inputData, surfaceData);
|
||||
LightingData lightingData = CreateSixWayLightingData(inputData,bsdfData.emission);
|
||||
|
||||
#ifdef _LIGHT_LAYERS
|
||||
if (IsMatchingLightLayer(mainLight.layerMask, meshRenderingLayers))
|
||||
#endif
|
||||
{
|
||||
lightingData.mainLightColor += LightingSixWay(mainLight, inputData, bsdfData);
|
||||
}
|
||||
|
||||
#if defined(_ADDITIONAL_LIGHTS)
|
||||
uint pixelLightCount = GetAdditionalLightsCount();
|
||||
|
||||
#if USE_FORWARD_PLUS
|
||||
for (uint lightIndex = 0; lightIndex < min(URP_FP_DIRECTIONAL_LIGHTS_COUNT, MAX_VISIBLE_LIGHTS); lightIndex++)
|
||||
{
|
||||
FORWARD_PLUS_SUBTRACTIVE_LIGHT_CHECK
|
||||
|
||||
Light light = GetAdditionalLight(lightIndex, inputData, shadowMask, aoFactor);
|
||||
#ifdef _LIGHT_LAYERS
|
||||
if (IsMatchingLightLayer(light.layerMask, meshRenderingLayers))
|
||||
#endif
|
||||
{
|
||||
lightingData.additionalLightsColor += LightingSixWay(light, inputData, bsdfData);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
LIGHT_LOOP_BEGIN(pixelLightCount)
|
||||
Light light = GetAdditionalLight(lightIndex, inputData, shadowMask, aoFactor);
|
||||
#ifdef _LIGHT_LAYERS
|
||||
if (IsMatchingLightLayer(light.layerMask, meshRenderingLayers))
|
||||
#endif
|
||||
{
|
||||
lightingData.additionalLightsColor += LightingSixWay(light, inputData, bsdfData);
|
||||
}
|
||||
LIGHT_LOOP_END
|
||||
#endif
|
||||
|
||||
#if defined(_ADDITIONAL_LIGHTS_VERTEX)
|
||||
lightingData.vertexLightingColor += inputData.vertexLighting * surfaceData.albedo;
|
||||
#endif
|
||||
|
||||
return CalculateFinalColor(lightingData, bsdfData.alpha);
|
||||
}
|
||||
half3 LightingHalfLambert(half3 lightColor, half3 lightDir, half3 normal)
|
||||
{
|
||||
half NdotL = saturate(dot(normal, lightDir));
|
||||
NdotL = NdotL*0.5 + 0.5;
|
||||
return lightColor * NdotL;
|
||||
}
|
||||
half3 CalculateHalfLambertBlinnPhong(Light light, InputData inputData, SurfaceData surfaceData)
|
||||
{
|
||||
half3 attenuatedLightColor = light.color * (light.distanceAttenuation * light.shadowAttenuation);
|
||||
half3 lightDiffuseColor = LightingHalfLambert(attenuatedLightColor, light.direction, inputData.normalWS);
|
||||
|
||||
half3 lightSpecularColor = half3(0,0,0);
|
||||
#if defined(_SPECGLOSSMAP) || defined(_SPECULAR_COLOR)
|
||||
half smoothness = exp2(10 * surfaceData.smoothness + 1);
|
||||
|
||||
lightSpecularColor += LightingSpecular(attenuatedLightColor, light.direction, inputData.normalWS, inputData.viewDirectionWS, half4(surfaceData.specular, 1), smoothness);
|
||||
#endif
|
||||
|
||||
#if _ALPHAPREMULTIPLY_ON
|
||||
return lightDiffuseColor * surfaceData.albedo * surfaceData.alpha + lightSpecularColor;
|
||||
#else
|
||||
return lightDiffuseColor * surfaceData.albedo + lightSpecularColor;
|
||||
#endif
|
||||
}
|
||||
half4 UniversalFragmentHalfLambert(InputData inputData, half3 diffuse, half4 specularGloss, half smoothness, half3 emission, half alpha, half3 normalTS)
|
||||
{
|
||||
|
||||
SurfaceData surfaceData;
|
||||
|
||||
surfaceData.albedo = diffuse;
|
||||
surfaceData.alpha = alpha;
|
||||
surfaceData.emission = emission;
|
||||
surfaceData.metallic = 0;
|
||||
surfaceData.occlusion = 1;
|
||||
surfaceData.smoothness = smoothness;
|
||||
surfaceData.specular = specularGloss.rgb;
|
||||
surfaceData.clearCoatMask = 0;
|
||||
surfaceData.clearCoatSmoothness = 1;
|
||||
surfaceData.normalTS = normalTS;
|
||||
|
||||
|
||||
// #if defined(DEBUG_DISPLAY)
|
||||
// half4 debugColor;
|
||||
//
|
||||
// if (CanDebugOverrideOutputColor(inputData, surfaceData, debugColor))
|
||||
// {
|
||||
// return debugColor;
|
||||
// }
|
||||
// #endif
|
||||
|
||||
#ifdef _LIGHT_LAYERS
|
||||
uint meshRenderingLayers = GetMeshRenderingLayer();
|
||||
#endif
|
||||
|
||||
half4 shadowMask = CalculateShadowMask(inputData);
|
||||
AmbientOcclusionFactor aoFactor = CreateAmbientOcclusionFactor(inputData, surfaceData);
|
||||
Light mainLight = GetMainLight(inputData, shadowMask, aoFactor);
|
||||
|
||||
MixRealtimeAndBakedGI(mainLight, inputData.normalWS, inputData.bakedGI, aoFactor);
|
||||
|
||||
inputData.bakedGI *= surfaceData.albedo;
|
||||
|
||||
LightingData lightingData = CreateLightingData(inputData, surfaceData);
|
||||
#ifdef _LIGHT_LAYERS
|
||||
if (IsMatchingLightLayer(mainLight.layerMask, meshRenderingLayers))
|
||||
#endif
|
||||
{
|
||||
lightingData.mainLightColor += CalculateHalfLambertBlinnPhong(mainLight, inputData, surfaceData);
|
||||
}
|
||||
|
||||
#if defined(_ADDITIONAL_LIGHTS)
|
||||
uint pixelLightCount = GetAdditionalLightsCount();
|
||||
|
||||
#if USE_FORWARD_PLUS
|
||||
for (uint lightIndex = 0; lightIndex < min(URP_FP_DIRECTIONAL_LIGHTS_COUNT, MAX_VISIBLE_LIGHTS); lightIndex++)
|
||||
{
|
||||
FORWARD_PLUS_SUBTRACTIVE_LIGHT_CHECK
|
||||
|
||||
Light light = GetAdditionalLight(lightIndex, inputData, shadowMask, aoFactor);
|
||||
#ifdef _LIGHT_LAYERS
|
||||
if (IsMatchingLightLayer(light.layerMask, meshRenderingLayers))
|
||||
#endif
|
||||
{
|
||||
lightingData.additionalLightsColor += CalculateBlinnPhong(light, inputData, surfaceData);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
LIGHT_LOOP_BEGIN(pixelLightCount)
|
||||
Light light = GetAdditionalLight(lightIndex, inputData, shadowMask, aoFactor);
|
||||
#ifdef _LIGHT_LAYERS
|
||||
if (IsMatchingLightLayer(light.layerMask, meshRenderingLayers))
|
||||
#endif
|
||||
{
|
||||
lightingData.additionalLightsColor += CalculateHalfLambertBlinnPhong(light, inputData, surfaceData);
|
||||
}
|
||||
LIGHT_LOOP_END
|
||||
#endif
|
||||
|
||||
#if defined(_ADDITIONAL_LIGHTS_VERTEX)
|
||||
lightingData.vertexLightingColor += inputData.vertexLighting * surfaceData.albedo;
|
||||
#endif
|
||||
|
||||
return CalculateFinalColor(lightingData, surfaceData.alpha);
|
||||
}
|
||||
#endif
|
||||
3
Packages/NBShaders/Shader/HLSL/SixWaySmokeLit.hlsl.meta
Normal file
3
Packages/NBShaders/Shader/HLSL/SixWaySmokeLit.hlsl.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 70e94bdedafe40bfb7f8e77cdc4bef0f
|
||||
timeCreated: 1751704445
|
||||
@@ -23,12 +23,12 @@
|
||||
_Dissolve_Test_Toggle("__Dissolve_Test_Toggle",Float) = 0
|
||||
|
||||
|
||||
_ColorBlendMap_Toggle("__ColorBlendMap_Toggle",Float) = 0
|
||||
|
||||
_FresnelMode("__FresnelMode",Float) = 0
|
||||
_InvertFresnel_Toggle("__InvertFresnel_Toggle",Float) = 0
|
||||
_HueShift_Toggle("__HueShift_Toggle",Float) = 0
|
||||
_BackFaceColor_Toggle("_BackFaceColor_Toggle",Float) = 0
|
||||
_BackFristPassToggle("_BackFirstPassToggle",Float) = 0
|
||||
_BackFirstPassToggle("_BackFirstPassToggle",Float) = 0
|
||||
|
||||
_PolarCordinateOnlySpecialFunciton_Toggle("极坐标仅对特殊功能生效_Toggle",Float) = 0
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
_BaseMapMaskMapOffset ("xy主贴图偏移速度", vector) = (0, 0, 0, 0)
|
||||
|
||||
_BaseMapUVRotation ("主贴图旋转", Range(0, 360)) = 0
|
||||
_BaseMapUVRotationSpeed ("主贴图旋转速度",Float) = 0
|
||||
[HDR]_BaseColor ("主贴图颜色_hdr", Color) = (1, 1, 1, 1)//HDR颜色不需要做Gamma Linear转换,Unity默认用Linear颜色
|
||||
// _BaseColor ("Base Color", Color) = (1, 1, 1, 1)//HDR颜色不需要做Gamma Linear转换,Unity默认用Linear颜色
|
||||
[HDR]_BaseBackColor ("背面颜色_hdr", Color) = (1, 1, 1, 1)//HDR颜色不需要做Gamma Linear转换,Unity默认用Linear颜色
|
||||
@@ -75,12 +76,44 @@
|
||||
_CylinderMatrix3("圆柱偏移矩阵3",Vector) = (0,0,0,0)
|
||||
|
||||
_Cutoff ("裁剪位置", float) = 0
|
||||
|
||||
//--------------光照部分-------------
|
||||
_FxLightMode("灯光模式",Float) = 0
|
||||
_BumpMapToggle("法线贴图开关",Float) = 0
|
||||
_BumpMapMaskMode("法线贴图多通道模式",Float) = 0
|
||||
_BumpScale("Scale", Float) = 1.0
|
||||
_BumpTex("Normal Map", 2D) = "bump" {}
|
||||
_BumpTexFollowMainTexUVToggle("法线跟随主贴图UV",Float) = 0
|
||||
_MaterialInfo("x:金属度,y:光滑度",Vector) = (1,1,0,0)
|
||||
_BlinnPhongSpecularToggle("BlinnPhong高光开关",Float) = 0
|
||||
[HDR]_SpecularColor("BlinnPhong高光颜色",Color) = (1,1,1,1)
|
||||
//-----------SixWayLight----------
|
||||
_RigRTBk("六路正方向图(P)",2D) = "white"{}
|
||||
_RigLBtF("六路反方向图(N)",2D) = "white"{}
|
||||
_SixWayColorAbsorptionToggle("六路光颜色吸收开关",Float) = 0
|
||||
_SixWayInfo("x:六路吸收强度",Vector) = (0.5,0,0,0)
|
||||
_SixWayEmissionRamp("六路自发光Ramp",2D) = "white"{}
|
||||
[HDR]_SixWayEmissionColor("六路自发光颜色",Color) = (1,0.5,0,1)
|
||||
|
||||
//-----MatCap------
|
||||
_MatCapToggle("MatCap开关",Float) = 0
|
||||
_MatCapTex("MatCap图",2D) = "white"{}
|
||||
[HDR]_MatCapColor("MatCap颜色",Color) = (1,1,1,1)
|
||||
_MatCapInfo("x:MatCap叠加和相乘过渡",Vector) = (1,0,0,0)
|
||||
// _MatCapBlendMode("MatCap叠加模式",Float) = 0
|
||||
|
||||
//时间缩放影响开关----------
|
||||
[HideInInspector] _TimeMode("__TimeMode",float) = 0.0
|
||||
|
||||
_StencilWithoutPlayerToggle("剔除主角色开关",Float) = 0.0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// MaskMap------------
|
||||
// MaskMap-----------
|
||||
_MaskRefineToggle("遮罩整体调整开关",Float) = 0
|
||||
_MaskRefineVec("遮罩整体调整:x:Pow,y:相乘,z:相加",Vector) = (1,1,0,0)
|
||||
_MaskMap ("遮罩贴图 xy:UV缩放 zw:UV偏移", 2D) = "white" { }
|
||||
_MaskMap2 ("遮罩2贴图 xy:UV缩放 zw:UV偏移", 2D) = "white"{}
|
||||
_MaskMap3 ("遮罩3贴图 xy:UV缩放 zw:UV偏移", 2D) = "white"{}
|
||||
@@ -89,7 +122,23 @@
|
||||
_MaskMapUVRotation ("遮罩旋转", Range(0, 360)) = 0.0
|
||||
_MaskDistortion_intensity ("遮罩扭曲强度", float) = 0.0
|
||||
_MaskMapRotationSpeed("遮罩旋转速度", float) = 0.0
|
||||
_MaskMapVec("x整体遮罩强度",Vector) = (1,0,0,0)
|
||||
_MaskMapVec("x整体遮罩强度,y遮罩2旋转,z遮罩3旋转",Vector) = (1,0,0,0)
|
||||
|
||||
_MaskMapGradientToggle("遮罩渐变模式",Float) = 0
|
||||
_MaskMapGradientCount("颜色映射数量",Integer) = 2
|
||||
_MaskMapGradientFloat0("x:MaskAlpha0,y:Pos0,z:MaskAlpha1,w:Pos1",Vector) = (0,0,1,1)
|
||||
_MaskMapGradientFloat1("x:MaskAlpha2,y:Pos2,z:MaskAlpha3,w:Pos3",Vector) = (1,0,1,1)
|
||||
_MaskMapGradientFloat2("x:MaskAlpha4,y:Pos4,z:MaskAlpha5,w:Pos5",Vector) = (1,0,1,1)
|
||||
_MaskMap2GradientToggle("遮罩2渐变模式",Float) = 0
|
||||
_MaskMap2GradientCount("颜色映射数量",Integer) = 2
|
||||
_MaskMap2GradientFloat0("x:Mask2Alpha0,y:Pos0,z:Mask2Alpha1,w:Pos1",Vector) = (0,0,1,1)
|
||||
_MaskMap2GradientFloat1("x:Mask2Alpha2,y:Pos2,z:Mask2Alpha3,w:Pos3",Vector) = (1,0,1,1)
|
||||
_MaskMap2GradientFloat2("x:Mask2Alpha4,y:Pos4,z:Mask2Alpha5,w:Pos5",Vector) = (1,0,1,1)
|
||||
_MaskMap3GradientToggle("遮罩3渐变模式",Float) = 0
|
||||
_MaskMap3GradientCount("颜色映射数量",Integer) = 2
|
||||
_MaskMap3GradientFloat0("x:Mask3Alpha0,y:Pos0,z:Mask3Alpha1,w:Pos1",Vector) = (0,0,1,1)
|
||||
_MaskMap3GradientFloat1("x:Mask3Alpha2,y:Pos2,z:Mask3Alpha3,w:Pos3",Vector) = (1,0,1,1)
|
||||
_MaskMap3GradientFloat2("x:Mask3Alpha4,y:Pos4,z:Mask3Alpha5,w:Pos5",Vector) = (1,0,1,1)
|
||||
|
||||
// 擦除----------------
|
||||
//[Header(ChaChu(Anima For CustomData.z).......)]
|
||||
@@ -124,9 +173,7 @@
|
||||
_DistortionDirection ("扭曲方向xy, 色散强度z", vector) = (1,1,0,0)
|
||||
_Distortion_Choraticaberrat_Toggle("扭曲色散开关_Toggle",Float) = 0
|
||||
_Distortion_Choraticaberrat_WithNoise_Toggle("色散受扭曲影响_Toggle",Float) = 1
|
||||
|
||||
|
||||
|
||||
|
||||
// 流光 ----------
|
||||
//[Header(LiuGuang(Anima For CustomData.w).......)]
|
||||
//[Toggle(_EMISSION)]_N1 ("EMISSION?", float) = 0
|
||||
@@ -139,27 +186,66 @@
|
||||
_uvRapSoft ("LiuuvRapSoft-ignore", Range(0, 1)) = 0
|
||||
[HDR]_EmissionMapColor ("流光贴图颜色_hdr", Color) = (1, 1, 1, 1)
|
||||
_EmissionMapColorIntensity("流光颜色强度", float) = 1
|
||||
_EmissionFollowMainTexUV("流光跟随主贴图",Float) = 0
|
||||
|
||||
//颜色渐变贴图--------
|
||||
_ColorBlendMap_Toggle("__ColorBlendMap_Toggle",Float) = 0
|
||||
_ColorBlendMap("颜色渐变贴图 xy:UV缩放 zw:UV偏移",2D) = "white"{}
|
||||
[HDR]_ColorBlendColor("颜色渐变叠加_hdr",Color) = (1,1,1,1)
|
||||
_ColorBlendMapOffset("xy:颜色渐变贴图偏移动画",Vector) = (0,0,0,0)
|
||||
_ColorBlendAlphaMultiplyMode("颜色渐变Alpha相乘开关",Float) = 0
|
||||
_ColorBlendFollowMainTexUV("颜色渐变UV跟随主贴图UV",Float) = 0
|
||||
_ColorBlendVec("x:颜色渐变扰动强度z:Alpha强度w:旋转",Vector) = (0,0,1,0)
|
||||
|
||||
//颜色映射Ramp
|
||||
_RampColorToggle("颜色映射开关",Float) = 0
|
||||
_RampColorSourceMode("Ramp来源模式",Float) = 0
|
||||
_RampColorBlendMode("Ramp颜色混合模式",Float) = 0
|
||||
_RampColorMap("颜色映射黑白图",2D) = "white"{}
|
||||
_RampColor0("rgb:RampColor0,a:pos",Color) = (0,0,0,0)
|
||||
_RampColor1("rgb:RampColor1,a:pos",Color) = (1,0,0,1)
|
||||
_RampColor2("rgb:RampColor2,a:pos",Color) = (1,1,1,1)
|
||||
_RampColor3("rgb:RampColor3,a:pos",Color) = (1,1,1,1)
|
||||
_RampColor4("rgb:RampColor4,a:pos",Color) = (1,1,1,1)
|
||||
_RampColor5("rgb:RampColor5,a:pos",Color) = (1,1,1,1)
|
||||
_RampColorAlpha0("x:RampColorAlpha0,y:Pos0,z:RampColorAlpha1,w:Pos1",Vector) = (1,0,1,1)
|
||||
_RampColorAlpha1("x:RampColorAlpha2,y:Pos2,z:RampColorAlpha3,w:Pos3",Vector) = (1,0,1,1)
|
||||
_RampColorAlpha2("x:RampColorAlpha4,y:Pos4,z:RampColorAlpha5,w:Pos5",Vector) = (1,0,1,1)
|
||||
_RampColorCount("颜色映射数量",Integer) = 2
|
||||
[HDR]_RampColorBlendColor("颜色映射叠加颜色_hdr",Color) = (1,1,1,1)
|
||||
_RampColorMapOffset("xy:颜色映射贴图偏移动画,w:旋转",Vector) = (0,0,0,0)
|
||||
|
||||
|
||||
// Rongjie ------------------
|
||||
// [Header(RongJie(Anima For CustomData.y).......)]
|
||||
// [Toggle(_DISSOLVE)]_RJ ("RONGJIE?", float) = 0
|
||||
_Dissolve ("x:溶解强度 y:溶解描边范围 z:局部控制强度 w:溶解硬度, _DissolveWidth", vector) = (0.5, 0.1, 1, 0.1)
|
||||
_DissolveMap("溶解贴图 xy:UV缩放 zw:UV偏移",2D) = "grey"{}
|
||||
_Dissolve ("x:溶解强度 y:溶解值Pow z:过程溶解强度 w:溶解硬软度", vector) = (0.5, 1, 0, 0.1)
|
||||
_DissolveMap("溶解贴图 xy:UV缩放 zw:UV偏移",2D) = "grey"{}
|
||||
_DissolveMaskMap("局部溶解蒙版 xy:UV缩放 zw:UV偏移",2D) = "white"{}
|
||||
_DissolveOffsetRotateDistort("xy:溶解贴图偏移速度 z:溶解贴图旋转",Vector) = (0,0,0,0)
|
||||
[HDR]_DissolveLineColor("溶解描边颜色_hdr",Color) = (0,0,0,1)
|
||||
[HDR]_DissolveLineColor("溶解描边颜色_hdr",Color) = (1,0,0,1)
|
||||
_DissolveVoronoi_Vec("xy:噪波1缩放,zw:噪波2缩放",Vector) = (1,1,2,2)
|
||||
_DissolveVoronoi_Vec2("x:噪波1和噪波2混合系数(圆尖),y:噪波整体和溶解贴图混合系数,z:噪波1速度,w:噪波2速度",Vector) = (1,1,2,2)
|
||||
_DissolveVoronoi_Vec3("xy:噪波1偏移速度,zw:噪波2偏移速度",Vector) = (0,0,0,0)
|
||||
_DissolveVoronoi_Vec4("xy:噪波1偏移,zw:噪波2偏移",Vector) = (0,0,0,0)
|
||||
_Dissolve_Vec2("溶解丝滑度(溶解值黑白调整)黑色X,白色Y",Vector) = (0,1,0,0)
|
||||
_Dissolve_Vec2("x:Ramp位置偏移,y:Ramp范围",Vector) = (0.2,0.1,0,0)
|
||||
_DissolveRampMap("溶解Ramp图",2D) = "white"{}
|
||||
_DissolveRampColorBlendMode("溶解Ramp图混合模式",Float) = 0
|
||||
[HDR]_DissolveRampColor("溶解Ramp颜色_hdr",Color) = (1,1,1,1)
|
||||
|
||||
//颜色渐变贴图--------
|
||||
_ColorBlendMap("颜色渐变贴图 xy:UV缩放 zw:UV偏移",2D) = "white"{}
|
||||
[HDR]_ColorBlendColor("颜色渐变叠加_hdr",Color) = (1,1,1,1)
|
||||
_ColorBlendMapOffset("xy:颜色渐变贴图偏移动画",Vector) = (0,0,0,0)
|
||||
_DissolveLineMaskToggle("溶解描边开关",Float) = 0
|
||||
|
||||
_DissolveRampSourceMode("溶解Ramp来源模式",Float) = 0
|
||||
_DissolveRampColor0("rgb:DissolveRampColor0,a:pos",Color) = (1,0,0,0)
|
||||
_DissolveRampColor1("rgb:DissolveRampColor1,a:pos",Color) = (0,0,0,1)
|
||||
_DissolveRampColor2("rgb:DissolveRampColor2,a:pos",Color) = (1,1,1,1)
|
||||
_DissolveRampColor3("rgb:DissolveRampColor3,a:pos",Color) = (1,1,1,1)
|
||||
_DissolveRampColor4("rgb:DissolveRampColor4,a:pos",Color) = (1,1,1,1)
|
||||
_DissolveRampColor5("rgb:DissolveRampColor5,a:pos",Color) = (1,1,1,1)
|
||||
_DissolveRampAlpha0("x:DissolveRampAlpha0,y:Pos0,z:DissolveRampAlpha1,w:Pos1",Vector) = (1,0,1,1)
|
||||
_DissolveRampAlpha1("x:DissolveRampAlpha2,y:Pos2,z:DissolveRampAlpha3,w:Pos3",Vector) = (1,0,1,1)
|
||||
_DissolveRampAlpha2("x:DissolveRampAlpha4,y:Pos4,z:DissolveRampAlpha5,w:Pos5",Vector) = (1,0,1,1)
|
||||
_DissolveRampCount("溶解Ramp映射数量",Integer) = 2
|
||||
|
||||
|
||||
_CustomData1X ("ignore", float) = 0
|
||||
_CustomData1Y ("ignore", float) = 0
|
||||
@@ -179,6 +265,7 @@
|
||||
_fogintensity ("雾影响强度", Range(0, 1)) = 1
|
||||
// -------------------------------------
|
||||
// Hidden properties - Generic 通用的隐藏属性
|
||||
_AdditiveToPreMultiplyAlphaLerp("相加到预乘混合",Range(0,1)) = 0.0
|
||||
[HideInInspector] _Blend ("__mode-ignore", Float) = 0.0
|
||||
[HideInInspector] _AlphaClip ("__clip-ignore", Float) = 0.0
|
||||
[HideInInspector] _SrcBlend ("__src-ignore", Float) = 1.0
|
||||
@@ -187,10 +274,9 @@
|
||||
[HideInInspector] _ZTest ("__ztest-ignore", Float) = 4.0 //默认值LEqual
|
||||
[HideInInspector] _ZWrite("__ZWrite-ignore", Float) = 0 //默认值LEqual
|
||||
// [HideInInspector] _ZTestt ("__ztestt", Float) = 4.0//雨轩:注释掉了。。。这是个什么鬼。。。
|
||||
|
||||
|
||||
|
||||
|
||||
_CustomStencilTest ("__CustomStencilTest-ignore", Float) = 0
|
||||
_StencilKeyIndex("__StencilKeyIndex-ignore",Float) = 0
|
||||
[Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp ("__StencilComp-ignore", Float) = 8
|
||||
_Stencil("Stencil ID-ignore", Float) = 0
|
||||
[Enum(UnityEngine.Rendering.StencilOp)]_StencilOp("Stencil Operation-ignore", Float) = 0
|
||||
@@ -205,8 +291,9 @@
|
||||
_DepthOutline_Toggle("深度描边",Float) = 0
|
||||
[HDR]_DepthOutline_Color("深度描边颜色_hdr",Color) = (1,1,1,1)
|
||||
_DepthOutline_Vec("菲涅尔深度描边参数",Vector) = (0,0.5,0,0)
|
||||
_FresnelColorAffectByAlpha("菲涅尔颜色受Alpha影响",Float) = 1
|
||||
// _DepthOutline_withoutFresnel_Toggle("深度描边关闭菲涅尔",Float) = 0
|
||||
// _FresnelUnit2("菲涅尔通用2", Vector) = (0,1,0,0)
|
||||
// _FresnelUnit2("菲涅尔通用2", Vector) = (1,1,0,0)
|
||||
|
||||
_DepthDecal_Toggle("深度贴花",Float) = 0
|
||||
|
||||
@@ -224,7 +311,7 @@
|
||||
|
||||
_ParallaxMapping_Toggle("视差",Float) = 0
|
||||
_ParallaxMapping_Map("视差贴图",2D) = "white"{}
|
||||
_ParallaxMapping_Intensity("视差强度",Float) = 1
|
||||
_ParallaxMapping_Intensity("视差强度",Float) = 0.05
|
||||
_ParallaxMapping_Vec("遮蔽视差层数 x:最小值,y:最大值",Vector) = (5,30,0,0)
|
||||
|
||||
|
||||
@@ -233,7 +320,7 @@
|
||||
[HideInInspector] _BaseColorAddSubDiff ("_ColorMode", Vector) = (0, 0, 0, 0)
|
||||
[HideInInspector] _SoftParticlesEnabled ("__softparticlesenabled", Float) = 0.0
|
||||
[HideInInspector] _CameraFadingEnabled ("__camerafadingenabled", Float) = 0.0
|
||||
[HideInInspector] _SoftParticleFadeParams ("xy:软粒子远近裁剪面", Vector) = (0, 0, 0, 0)
|
||||
[HideInInspector] _SoftParticleFadeParams ("xy:软粒子远近裁剪面", Vector) = (0, 0.5, 0, 0)
|
||||
[HideInInspector] _CameraFadeParams ("__camerafadeparams_ignore", Vector) = (0, 0, 0, 0)
|
||||
[HideInInspector] _IntersectEnabled("__IntersectEnabled_ignore",Float) = 0.0
|
||||
[HideInInspector] _IntersectRadius("__IntersectRadius_ignore",Float) = 0.3
|
||||
@@ -241,8 +328,6 @@
|
||||
|
||||
[HideInInspector] _ScreenDistortModeToggle("_ScreenDistortModeToggle",Float) = 0
|
||||
|
||||
|
||||
|
||||
// Editmode props 编辑模式下的PropFlags?
|
||||
[HideInInspector] _QueueBias ("Queue偏移_QueueBias", Float) =0
|
||||
|
||||
@@ -282,14 +367,26 @@
|
||||
[HideInInspector] _W9ParticleCustomDataFlag2("_W9ParticleCustomDataFlag2", Integer) = 0
|
||||
[HideInInspector] _W9ParticleCustomDataFlag3("_W9ParticleCustomDataFlag3", Integer) = 0
|
||||
[HideInInspector] _UVModeFlag0("_UVModeFlag0", Integer) = 0
|
||||
[HideInInspector] _W9ParticleShaderGUIFoldToggle("_W9ParticleShaderGUIFoldToggle", Integer) = 31//前5个开关默认打开
|
||||
[HideInInspector] _W9ParticleShaderGUIFoldToggle("_W9ParticleShaderGUIFoldToggle", Integer) = 3//前2个开关默认打开
|
||||
[HideInInspector] _W9ParticleShaderGUIFoldToggle1("_W9ParticleShaderGUIFoldToggle1", Integer) = 255//这边默认全开
|
||||
|
||||
[HideInInspector] _W9ParticleShaderGUIFoldToggle2("_W9ParticleShaderGUIFoldToggle2", Integer) = 255//这边默认全开
|
||||
[HideInInspector] _W9ParticleShaderColorChannelFlag("_W9ParticleShaderColorChannelFlag", Integer) = 3//默认主贴图开A通道
|
||||
|
||||
|
||||
SaturabilityRangeVec("_Saturability",Vector) = (0,1,0,0)
|
||||
TexDistortionintensityRangeVec("_TexDistortion_intensity",Vector) = (-1,1,0,0)
|
||||
MaskDistortionIntensityRangeVec("_MaskDistortion_intensity",Vector) = (-2,2,0,0)
|
||||
EmiDistortionIntensityRangeVec("_TexDistortion_intensity",Vector) = (-1,1,0,0)
|
||||
BumpScaleRangeVec("_BumpScale",Vector) = (-1,1,0,0)
|
||||
DissolveXRangeVec("_Dissolve.x",Vector) = (-1,2,0,0)
|
||||
Dissolve2XRangeVec("_Dissolve_Vec2.x",Vector) = (0,1,0,0)
|
||||
Dissolve2YRangeVec("_Dissolve_Vec2.y",Vector) = (0,1,0,0)
|
||||
AlphaAllRangeVec("_AlphaAll",Vector) = (0,1,0,0)
|
||||
// _offsetUnits("深度偏移单位距离-ignore", range(-2000,2000)) = 0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" "CanUseSpriteAtlas"="True" }
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Sphere" "CanUseSpriteAtlas"="True" }
|
||||
|
||||
Stencil
|
||||
{
|
||||
@@ -330,6 +427,9 @@
|
||||
#pragma target 4.5
|
||||
#pragma exclude_renderers d3d11_9x
|
||||
#pragma exclude_renderers d3d9
|
||||
|
||||
#pragma enable_d3d11_debug_symbols // 保留D3D11调试符号
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _ _SCREEN_DISTORT_MODE
|
||||
@@ -345,9 +445,13 @@
|
||||
//后续Test类的关键字要找机会排除
|
||||
#pragma shader_feature_local _DISSOLVE_EDITOR_TEST
|
||||
#pragma shader_feature_local _COLORMAPBLEND//颜色渐变
|
||||
#pragma shader_feature_local _COLOR_RAMP//颜色映射
|
||||
|
||||
//将光照和UI混用,达到节省Keywords的目的。
|
||||
#pragma multi_compile _ UNITY_UI_CLIP_RECT _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS//UI 2D遮罩
|
||||
// #pragma multi_compile _ _UIPARTICLE_ON//用于UIParticle组件动态更改参数//暂时注释掉,觉得没什么意义
|
||||
#pragma multi_compile _ SOFT_UI_FRAME EVALUATE_SH_MIXED EVALUATE_SH_VERTEX//用于UI软蒙版
|
||||
|
||||
#pragma multi_compile_local _ UNITY_UI_CLIP_RECT//UI 2D遮罩
|
||||
// #pragma shader_feature_local _ _CH_XIANXING _CH_JINGXIANG _CH_SELF //线性擦除 径向擦除 mask擦除
|
||||
#pragma shader_feature_local _PARCUSTOMDATA_ON
|
||||
|
||||
//用于特效层关键字
|
||||
@@ -356,11 +460,9 @@
|
||||
#pragma shader_feature_local _ FRESNEL_CUBEMAP FRESNEL_REFLECTIONPROBE
|
||||
|
||||
|
||||
// #pragma multi_compile _ _UIPARTICLE_ON//用于UIParticle组件动态更改参数//暂时注释掉,觉得没什么意义
|
||||
#pragma multi_compile _ SOFT_UI_FRAME//用于UI软蒙版
|
||||
// -------------------------------------
|
||||
// Particle Keywords
|
||||
//#pragma shader_feature_local _ _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON //设置alpah Add 。。组合
|
||||
#pragma shader_feature_local _ _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON //设置alpah Add 。。组合
|
||||
#pragma shader_feature_local _ALPHATEST_ON
|
||||
//#pragma shader_feature_local _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON //粒子颜色和材质颜色的混合运算 暂时先不要了
|
||||
#pragma shader_feature_local _FLIPBOOKBLENDING_ON
|
||||
@@ -379,6 +481,14 @@
|
||||
#pragma shader_feature_local _PARALLAX_MAPPING
|
||||
|
||||
#pragma shader_feature_local _STENCIL_WITHOUT_PLAYER
|
||||
|
||||
//LIGHTING
|
||||
#pragma shader_feature_local _FX_LIGHT_MODE_UNLIT _FX_LIGHT_MODE_BLINN_PHONG _FX_LIGHT_MODE_HALF_LAMBERT _FX_LIGHT_MODE_PBR _FX_LIGHT_MODE_SIX_WAY
|
||||
#pragma shader_feature_local _ _NORMALMAP
|
||||
#pragma shader_feature_local _ _MATCAP
|
||||
#pragma shader_feature_local _ _SPECULAR_COLOR
|
||||
#pragma shader_feature_local _ VFX_SIX_WAY_ABSORPTION
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
@@ -404,7 +514,6 @@
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
|
||||
|
||||
#include "Packages/com.xuanxuan.render.utility/Shader/HLSL/XuanXuan_Utility.hlsl"
|
||||
#include "HLSL/ParticlesUnlitInputNew.hlsl"
|
||||
#include "HLSL/ParticlesUnlitForwardPassNew.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
@@ -429,6 +538,9 @@
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
|
||||
#pragma enable_d3d11_debug_symbols // 保留D3D11调试符号
|
||||
|
||||
#pragma shader_feature_local _ _SCREEN_DISTORT_MODE
|
||||
#pragma shader_feature_local _ _MASKMAP_ON
|
||||
// #pragma shader_feature_local _MASKMAP
|
||||
@@ -441,9 +553,12 @@
|
||||
#pragma shader_feature_local _DISSOLVE
|
||||
//后续Test类的关键字要找机会排除
|
||||
#pragma shader_feature_local _DISSOLVE_EDITOR_TEST
|
||||
#pragma shader_feature_local _COLORMAPBLEND//颜色渐变
|
||||
#pragma shader_feature_local _COLORMAPBLEND//颜色渐变
|
||||
#pragma shader_feature_local _COLOR_RAMP//颜色映射
|
||||
|
||||
#pragma multi_compile_local _ UNITY_UI_CLIP_RECT//UI 2D遮罩
|
||||
|
||||
|
||||
#pragma multi_compile_local _ UNITY_UI_CLIP_RECT _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS //UI 2D遮罩
|
||||
// #pragma shader_feature_local _ _CH_XIANXING _CH_JINGXIANG _CH_SELF //线性擦除 径向擦除 mask擦除
|
||||
#pragma shader_feature_local _PARCUSTOMDATA_ON
|
||||
|
||||
@@ -454,10 +569,10 @@
|
||||
|
||||
|
||||
// #pragma multi_compile _ _UIPARTICLE_ON//用于UIParticle组件动态更改参数//暂时注释掉,觉得没什么意义
|
||||
#pragma multi_compile _ SOFT_UI_FRAME//用于UI软蒙版
|
||||
#pragma multi_compile _ SOFT_UI_FRAME EVALUATE_SH_MIXED EVALUATE_SH_VERTEX//用于UI软蒙版
|
||||
// -------------------------------------
|
||||
// Particle Keywords
|
||||
//#pragma shader_feature_local _ _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON //设置alpah Add 。。组合
|
||||
#pragma shader_feature_local _ _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON //设置alpah Add 。。组合
|
||||
#pragma shader_feature_local _ALPHATEST_ON
|
||||
//#pragma shader_feature_local _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON //粒子颜色和材质颜色的混合运算 暂时先不要了
|
||||
#pragma shader_feature_local _FLIPBOOKBLENDING_ON
|
||||
@@ -477,7 +592,12 @@
|
||||
|
||||
#pragma shader_feature_local _STENCIL_WITHOUT_PLAYER
|
||||
|
||||
|
||||
//LIGHTING
|
||||
#pragma shader_feature_local _FX_LIGHT_MODE_UNLIT _FX_LIGHT_MODE_BLINN_PHONG _FX_LIGHT_MODE_HALF_LAMBERT _FX_LIGHT_MODE_PBR _FX_LIGHT_MODE_SIX_WAY
|
||||
#pragma shader_feature_local _ _NORMALMAP
|
||||
#pragma shader_feature_local _ _MATCAP
|
||||
#pragma shader_feature_local _ _SPECULAR_COLOR
|
||||
#pragma shader_feature_local _ VFX_SIX_WAY_ABSORPTION
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
@@ -492,14 +612,115 @@
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
// The DeclareDepthTexture.hlsl file contains utilities for sampling the Camera
|
||||
// depth texture.
|
||||
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
|
||||
|
||||
#include "Packages/com.xuanxuan.render.utility/Shader/HLSL/XuanXuan_Utility.hlsl"
|
||||
#include "HLSL/ParticlesUnlitForwardPassNew.hlsl"
|
||||
|
||||
|
||||
ENDHLSL
|
||||
|
||||
}
|
||||
|
||||
#include "HLSL/ParticlesUnlitInputNew.hlsl"
|
||||
// ------------------------------------------------------------------
|
||||
// Forward pass.
|
||||
Pass
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"LightMode" = "Universal2D"
|
||||
} //Queue设置是希望特效渲染在场景透明物体前面
|
||||
offset [_offsetFactor], [_offsetUnits]
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#define PARTICLE
|
||||
//20240228 target3.0 顶点着色器限制16个输出。提高版本
|
||||
#pragma target 4.5
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
|
||||
#pragma enable_d3d11_debug_symbols // 保留D3D11调试符号
|
||||
|
||||
#pragma shader_feature_local _ _SCREEN_DISTORT_MODE
|
||||
#pragma shader_feature_local _ _MASKMAP_ON
|
||||
// #pragma shader_feature_local _MASKMAP
|
||||
// #pragma shader_feature_local _MASKMAP2
|
||||
//#pragma shader_feature_local _NOISEMAP
|
||||
#pragma shader_feature_local _NOISEMAP
|
||||
//#pragma shader_feature_local _EMISSION //流光
|
||||
#pragma shader_feature_local _EMISSION
|
||||
//#pragma shader_feature_local _ _DISSOLVE //溶解
|
||||
#pragma shader_feature_local _DISSOLVE
|
||||
//后续Test类的关键字要找机会排除
|
||||
#pragma shader_feature_local _DISSOLVE_EDITOR_TEST
|
||||
#pragma shader_feature_local _COLORMAPBLEND//颜色渐变
|
||||
#pragma shader_feature_local _COLOR_RAMP//颜色映射
|
||||
|
||||
|
||||
|
||||
#pragma multi_compile_local _ UNITY_UI_CLIP_RECT _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS //UI 2D遮罩
|
||||
// #pragma shader_feature_local _ _CH_XIANXING _CH_JINGXIANG _CH_SELF //线性擦除 径向擦除 mask擦除
|
||||
#pragma shader_feature_local _PARCUSTOMDATA_ON
|
||||
|
||||
//用于特效层关键字
|
||||
// #pragma shader_feature_local _UIEFFECT_ON
|
||||
|
||||
#pragma shader_feature_local _ FRESNEL_CUBEMAP FRESNEL_REFLECTIONPROBE
|
||||
|
||||
|
||||
// #pragma multi_compile _ _UIPARTICLE_ON//用于UIParticle组件动态更改参数//暂时注释掉,觉得没什么意义
|
||||
#pragma multi_compile _ SOFT_UI_FRAME EVALUATE_SH_MIXED EVALUATE_SH_VERTEX//用于UI软蒙版
|
||||
// -------------------------------------
|
||||
// Particle Keywords
|
||||
#pragma shader_feature_local _ _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON //设置alpah Add 。。组合
|
||||
#pragma shader_feature_local _ALPHATEST_ON
|
||||
//#pragma shader_feature_local _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON //粒子颜色和材质颜色的混合运算 暂时先不要了
|
||||
#pragma shader_feature_local _FLIPBOOKBLENDING_ON
|
||||
#pragma shader_feature_local _SOFTPARTICLES_ON
|
||||
// #pragma shader_feature_local _OCCLUDEOPACITY_ON
|
||||
// #pragma shader_feature_local _ _SATURABILITY_ON
|
||||
|
||||
//UnscaleTime用于接收项目传的公开不受缩放影响的Time值
|
||||
#pragma shader_feature_local _UNSCALETIME
|
||||
//scriptableTime用于程序每帧传值
|
||||
#pragma shader_feature_local _SCRIPTABLETIME
|
||||
//#pragma shader_feature_local _DISTORTION_ON
|
||||
#pragma shader_feature_local _NOISEMAP_NORMALIZEED
|
||||
|
||||
#pragma shader_feature_local _DEPTH_DECAL
|
||||
#pragma shader_feature_local _PARALLAX_MAPPING
|
||||
|
||||
#pragma shader_feature_local _STENCIL_WITHOUT_PLAYER
|
||||
|
||||
//LIGHTING
|
||||
#pragma shader_feature_local _FX_LIGHT_MODE_UNLIT _FX_LIGHT_MODE_BLINN_PHONG _FX_LIGHT_MODE_HALF_LAMBERT _FX_LIGHT_MODE_PBR _FX_LIGHT_MODE_SIX_WAY
|
||||
#pragma shader_feature_local _ _NORMALMAP
|
||||
#pragma shader_feature_local _ _MATCAP
|
||||
#pragma shader_feature_local _ _SPECULAR_COLOR
|
||||
#pragma shader_feature_local _ VFX_SIX_WAY_ABSORPTION
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
// 之后进行优化时再说。
|
||||
#pragma multi_compile_fog
|
||||
// #define FOG_EXP2 1
|
||||
|
||||
#pragma vertex vertParticleUnlit
|
||||
#pragma fragment fragParticleUnlit
|
||||
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
// The DeclareDepthTexture.hlsl file contains utilities for sampling the Camera
|
||||
// depth texture.
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
|
||||
|
||||
#include "Packages/com.xuanxuan.render.utility/Shader/HLSL/XuanXuan_Utility.hlsl"
|
||||
#include "HLSL/ParticlesUnlitForwardPassNew.hlsl"
|
||||
|
||||
|
||||
@@ -508,5 +729,5 @@
|
||||
}
|
||||
}
|
||||
|
||||
CustomEditor "ParticleBaseGUI"
|
||||
CustomEditor "NBShaderEditor.ParticleBaseGUI"
|
||||
}
|
||||
@@ -13,6 +13,16 @@ MonoBehaviour:
|
||||
m_Name: StencilConfig
|
||||
m_EditorClassIdentifier: Assembly-CSharp-Editor:stencilTestHelper:StencilValuesConfig
|
||||
Config:
|
||||
- key: ParticleBaseDefault
|
||||
Values:
|
||||
DefaultQueue: 3100
|
||||
Ref: 0
|
||||
Comp: 8
|
||||
Pass: 0
|
||||
Fail: 0
|
||||
ZFail: 0
|
||||
ReadMask: 255
|
||||
WriteMask: 255
|
||||
- key: Disturbance
|
||||
Values:
|
||||
DefaultQueue: 3000
|
||||
@@ -53,16 +63,6 @@ MonoBehaviour:
|
||||
ZFail: 0
|
||||
ReadMask: 255
|
||||
WriteMask: 255
|
||||
- key: ParticleBaseDefault
|
||||
Values:
|
||||
DefaultQueue: 3100
|
||||
Ref: 0
|
||||
Comp: 8
|
||||
Pass: 0
|
||||
Fail: 0
|
||||
ZFail: 0
|
||||
ReadMask: 255
|
||||
WriteMask: 255
|
||||
- key: ParticleWithoutPlayer
|
||||
Values:
|
||||
DefaultQueue: 3100
|
||||
|
||||
@@ -0,0 +1,249 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
//因为GradientPicker窗口,在窗口打开时使用的是Gradient对象的Cache。
|
||||
//如果有Undo操作,导致MaterialProperty更新了,但Gradient却更新不到ColorPicer里。所以在这里进行强制更新。
|
||||
//后续需要强制更新Picker的时候,也可以用这里。
|
||||
//DeepSeek写的。谨慎用。
|
||||
public static class GradientReflectionHelper
|
||||
{
|
||||
#region GradientPicker 相关
|
||||
|
||||
private static Type _gradientPickerType;
|
||||
|
||||
// SetCurrentGradient 方法
|
||||
private static MethodInfo _setGradientMethod;
|
||||
private static Action<Gradient> _setGradientDelegate;
|
||||
|
||||
// RefreshGradientData 方法
|
||||
private static MethodInfo _refreshMethod;
|
||||
private static Action _refreshDelegate;
|
||||
|
||||
#endregion
|
||||
|
||||
#region GradientPreviewCache 相关
|
||||
|
||||
private static Type _gradientCacheType;
|
||||
private static MethodInfo _clearCacheMethod;
|
||||
private static Action _clearCacheDelegate;
|
||||
|
||||
#endregion
|
||||
|
||||
// 初始化状态
|
||||
private static bool _initialized;
|
||||
private static bool _isValid;
|
||||
private static readonly object _initLock = new object();
|
||||
|
||||
#region 公共API
|
||||
|
||||
[System.Diagnostics.Conditional("UNITY_EDITOR")]
|
||||
public static void SetCurrentGradient(Gradient gradient)
|
||||
{
|
||||
ExecuteAction(() =>
|
||||
{
|
||||
if (_setGradientDelegate != null)
|
||||
_setGradientDelegate(gradient);
|
||||
else if (_setGradientMethod != null)
|
||||
_setGradientMethod.Invoke(null, new object[] { gradient });
|
||||
}, "SetCurrentGradient");
|
||||
}
|
||||
|
||||
[System.Diagnostics.Conditional("UNITY_EDITOR")]
|
||||
public static void RefreshGradientData()
|
||||
{
|
||||
ExecuteAction(() =>
|
||||
{
|
||||
if (_refreshDelegate != null)
|
||||
_refreshDelegate();
|
||||
else if (_refreshMethod != null)
|
||||
_refreshMethod.Invoke(null, null);
|
||||
}, "RefreshGradientData");
|
||||
}
|
||||
|
||||
[System.Diagnostics.Conditional("UNITY_EDITOR")]
|
||||
public static void ClearGradientCache()
|
||||
{
|
||||
ExecuteAction(() =>
|
||||
{
|
||||
if (_clearCacheDelegate != null)
|
||||
_clearCacheDelegate();
|
||||
else if (_clearCacheMethod != null)
|
||||
_clearCacheMethod.Invoke(null, null);
|
||||
}, "ClearGradientCache");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 核心实现
|
||||
|
||||
private static void ExecuteAction(Action action, string methodName)
|
||||
{
|
||||
if (!Application.isEditor) return;
|
||||
|
||||
EnsureInitialized();
|
||||
if (!_isValid) return;
|
||||
|
||||
try
|
||||
{
|
||||
action?.Invoke();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"[GradientReflection] {methodName} failed: {ex.Message}");
|
||||
// 可选择性地禁用后续调用
|
||||
// _isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void EnsureInitialized()
|
||||
{
|
||||
if (_initialized) return;
|
||||
|
||||
lock (_initLock)
|
||||
{
|
||||
if (_initialized) return;
|
||||
|
||||
try
|
||||
{
|
||||
// 1. 初始化 GradientPicker 类型
|
||||
_gradientPickerType = Type.GetType("UnityEditor.GradientPicker, UnityEditor");
|
||||
if (_gradientPickerType != null)
|
||||
{
|
||||
// 初始化 SetCurrentGradient
|
||||
_setGradientMethod = GetStaticMethod(
|
||||
_gradientPickerType,
|
||||
"SetCurrentGradient",
|
||||
new[] { typeof(Gradient) }
|
||||
);
|
||||
if (_setGradientMethod != null)
|
||||
{
|
||||
_setGradientDelegate = CreateActionDelegate<Gradient>(_setGradientMethod);
|
||||
}
|
||||
|
||||
// 初始化 RefreshGradientData
|
||||
_refreshMethod = GetStaticMethod(
|
||||
_gradientPickerType,
|
||||
"RefreshGradientData",
|
||||
Type.EmptyTypes
|
||||
);
|
||||
if (_refreshMethod != null)
|
||||
{
|
||||
_refreshDelegate = CreateActionDelegate(_refreshMethod);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("[GradientReflection] GradientPicker type not found");
|
||||
}
|
||||
|
||||
// 2. 初始化 GradientPreviewCache
|
||||
_gradientCacheType = Type.GetType("UnityEditorInternal.GradientPreviewCache, UnityEditor");
|
||||
if (_gradientCacheType != null)
|
||||
{
|
||||
_clearCacheMethod = GetStaticMethod(
|
||||
_gradientCacheType,
|
||||
"ClearCache",
|
||||
Type.EmptyTypes
|
||||
);
|
||||
if (_clearCacheMethod != null)
|
||||
{
|
||||
_clearCacheDelegate = CreateActionDelegate(_clearCacheMethod);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("[GradientReflection] GradientPreviewCache type not found");
|
||||
}
|
||||
|
||||
// 3. 验证初始化状态
|
||||
_isValid = (_setGradientMethod != null || _refreshMethod != null) &&
|
||||
_clearCacheMethod != null;
|
||||
|
||||
if (!_isValid)
|
||||
{
|
||||
Debug.LogWarning($"[GradientReflection] Initialization incomplete. " +
|
||||
$"SetCurrentGradient: {(_setGradientMethod != null ? "OK" : "Missing")}, " +
|
||||
$"RefreshGradientData: {(_refreshMethod != null ? "OK" : "Missing")}, " +
|
||||
$"ClearCache: {(_clearCacheMethod != null ? "OK" : "Missing")}");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Debug.Log("[GradientReflection] Initialized successfully");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"[GradientReflection] Initialization failed: {e}");
|
||||
_isValid = false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_initialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static MethodInfo GetStaticMethod(Type type, string methodName, Type[] parameterTypes)
|
||||
{
|
||||
if (type == null) return null;
|
||||
|
||||
return type.GetMethod(
|
||||
methodName,
|
||||
BindingFlags.Public | BindingFlags.Static,
|
||||
null,
|
||||
parameterTypes,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
private static Action CreateActionDelegate(MethodInfo method)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (Action)Delegate.CreateDelegate(typeof(Action), method);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"[GradientReflection] Failed to create delegate for {method.Name}: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static Action<T> CreateActionDelegate<T>(MethodInfo method)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (Action<T>)Delegate.CreateDelegate(typeof(Action<T>), method);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"[GradientReflection] Failed to create delegate for {method.Name}: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 辅助功能
|
||||
|
||||
/// <summary>
|
||||
/// 检查是否所有反射方法都可用
|
||||
/// </summary>
|
||||
public static bool IsFullySupported => _isValid;
|
||||
|
||||
/// <summary>
|
||||
/// 获取反射初始化状态
|
||||
/// </summary>
|
||||
public static string GetReflectionStatus()
|
||||
{
|
||||
if (!_initialized) return "Not Initialized";
|
||||
|
||||
return $"GradientPicker: {(_gradientPickerType != null ? "Found" : "Missing")}\n" +
|
||||
$"- SetCurrentGradient: {(_setGradientMethod != null ? "OK" : "Missing")}\n" +
|
||||
$"- RefreshGradientData: {(_refreshMethod != null ? "OK" : "Missing")}\n" +
|
||||
$"GradientPreviewCache: {(_gradientCacheType != null ? "Found" : "Missing")}\n" +
|
||||
$"- ClearCache: {(_clearCacheMethod != null ? "OK" : "Missing")}";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ebe6cf7ae30f4357bae940f8ce409628
|
||||
timeCreated: 1753589587
|
||||
File diff suppressed because it is too large
Load Diff
399
Packages/XuanXuanRenderUtility/Editor/ShaderGUIResetTool.cs
Normal file
399
Packages/XuanXuanRenderUtility/Editor/ShaderGUIResetTool.cs
Normal file
@@ -0,0 +1,399 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using PlasticGui;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using ShaderPropertyPack = NBShaderEditor.ShaderGUIHelper.ShaderPropertyPack;
|
||||
using UnityEditor;
|
||||
namespace NBShaderEditor
|
||||
{
|
||||
public class ShaderGUIResetTool
|
||||
{
|
||||
private ShaderGUIHelper _helper;
|
||||
private Shader _shader;
|
||||
public bool IsInitResetData = false;
|
||||
|
||||
private Stack<(string,string)> _scopeContextStack = new Stack<(string,string)>();
|
||||
|
||||
public void CheckAllModifyOnValueChange()
|
||||
{
|
||||
foreach (var item in ResetItemDict.Values)
|
||||
{
|
||||
item.HasModified = item.CheckHasModifyOnValueChange();
|
||||
}
|
||||
}
|
||||
public void Init(ShaderGUIHelper helper)
|
||||
{
|
||||
_helper = helper;
|
||||
_shader = helper.shader;
|
||||
IsInitResetData = true;
|
||||
ResetItemDict.Clear();
|
||||
_scopeContextStack.Clear();
|
||||
}
|
||||
|
||||
public void EndInit()
|
||||
{
|
||||
IsInitResetData = false;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (_needUpdate)
|
||||
{
|
||||
_needUpdate = false;
|
||||
CheckAllModifyOnValueChange();
|
||||
}
|
||||
}
|
||||
|
||||
private bool _needUpdate = false;
|
||||
public void NeedUpdate()
|
||||
{
|
||||
_needUpdate = true;
|
||||
}
|
||||
|
||||
public ShaderGUIResetTool(ShaderGUIHelper helper)
|
||||
{
|
||||
Init(helper);
|
||||
}
|
||||
|
||||
public Dictionary<(string, string), ResetItem> ResetItemDict = new Dictionary<(string, string), ResetItem>();
|
||||
|
||||
public class ResetItem
|
||||
{
|
||||
public ResetItem Parent;
|
||||
public List<ResetItem> ChildResetItems = new List<ResetItem>();
|
||||
public Action ResetCallBack;
|
||||
public Action OnValueChangedCallBack;
|
||||
public Func<bool> CheckHasModifyOnValueChange;
|
||||
public Func<bool> CheckHasMixedValueOnValueChange;
|
||||
public (string, string) NameTuple;
|
||||
public bool HasModified = false;
|
||||
public bool HasMixedValue =false;
|
||||
public bool ChildHasModified = false;
|
||||
public bool ChildHasMixedValue = false;
|
||||
|
||||
|
||||
public void Init((string, string) nameTuple,Action resetCallBack,Action onValueChangedCallBack,Func<bool> checkHasModifyOnValueChange,Func<bool> checkHasMixedValueOnValueChange)
|
||||
{
|
||||
NameTuple = nameTuple;
|
||||
ResetCallBack = resetCallBack;
|
||||
OnValueChangedCallBack = onValueChangedCallBack;
|
||||
CheckHasModifyOnValueChange = checkHasModifyOnValueChange;
|
||||
CheckHasMixedValueOnValueChange = checkHasMixedValueOnValueChange;
|
||||
}
|
||||
|
||||
public void Execute(bool isParentCall = false)
|
||||
{
|
||||
ResetCallBack?.Invoke();
|
||||
OnValueChangedCallBack?.Invoke();
|
||||
HasModified = CheckHasModifyOnValueChange();
|
||||
HasMixedValue = CheckHasMixedValueOnValueChange();
|
||||
CheckOnValueChange(isParentCall);
|
||||
foreach (var item in ChildResetItems)
|
||||
{
|
||||
item.Execute(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void CheckOnValueChange(bool isParentCall = false)
|
||||
{
|
||||
HasModified = CheckHasModifyOnValueChange();
|
||||
HasMixedValue = CheckHasMixedValueOnValueChange();
|
||||
foreach (var childItem in ChildResetItems)
|
||||
{
|
||||
HasMixedValue |= childItem.HasMixedValue;
|
||||
HasModified |= childItem.HasModified;
|
||||
}
|
||||
|
||||
if (!isParentCall && Parent != null)
|
||||
{
|
||||
Parent.CheckOnValueChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void CheckOnValueChange((string,string) nameTuple)
|
||||
{
|
||||
if (ResetItemDict.ContainsKey(nameTuple))
|
||||
{
|
||||
ResetItemDict[nameTuple].CheckOnValueChange();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("不包含ResetItemDict:"+nameTuple);
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawResetModifyButton(Rect rect,(string, string) nameTuple, Action resetCallBack,
|
||||
Action onValueChangedCallBack,Func<bool> checkHasModifyOnValueChange,Func<bool> checkHasMixedValueOnValueChange,bool isSharedGlobalParent = false)
|
||||
{
|
||||
ConstructResetItem(nameTuple,resetCallBack,onValueChangedCallBack,checkHasModifyOnValueChange,checkHasMixedValueOnValueChange,isSharedGlobalParent);
|
||||
DrawResetModifyButtonFinal(rect,nameTuple);
|
||||
}
|
||||
public void DrawResetModifyButton(Rect rect,(string,string)nameTuple,ShaderPropertyPack pack, Action resetAction,Action onValueChangedCallBack,VectorValeType vectorValeType = VectorValeType.Undefine,bool isSharedGlobalParent = false)
|
||||
{
|
||||
|
||||
// (string, string) nameTuple = (label, pack.property.name);
|
||||
ConstructResetItem(nameTuple,
|
||||
resetAction: ()=>{
|
||||
SetPropertyToDefaultValue(pack,vectorValeType);
|
||||
resetAction?.Invoke();
|
||||
},onValueChangedCallBack:onValueChangedCallBack,
|
||||
checkHasModifyOnValueChange: () => IsPropertyModified(pack,vectorValeType),
|
||||
checkHasMixedValueOnValueChange: () => pack.property.hasMixedValue,
|
||||
isSharedGlobalParent: isSharedGlobalParent
|
||||
);
|
||||
if (ResetItemDict.ContainsKey(nameTuple))
|
||||
{
|
||||
DrawResetModifyButtonFinal(rect,nameTuple);
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawResetModifyButton(Rect rect, string label)
|
||||
{
|
||||
//大部分功能都是触发子类
|
||||
ConstructResetItem((label, ""), resetAction: () => { },onValueChangedCallBack: () => { }, () => false, () => false);
|
||||
DrawResetModifyButtonFinal(rect,(label,""));
|
||||
}
|
||||
|
||||
//isSharedGlobalParent==>有些组件是公用的,比如极坐标一类。这些是不会设置父Item的。
|
||||
public void ConstructResetItem((string,string) nameTuple, Action resetAction,
|
||||
Action onValueChangedCallBack,Func<bool> checkHasModifyOnValueChange,Func<bool> checkHasMixedValueOnValueChange,bool isSharedGlobalParent = false)
|
||||
{
|
||||
if(!IsInitResetData) return;
|
||||
if (!ResetItemDict.ContainsKey(nameTuple))
|
||||
{
|
||||
ResetItem item = new ResetItem();
|
||||
item.Init(nameTuple,resetAction,onValueChangedCallBack,checkHasModifyOnValueChange,checkHasMixedValueOnValueChange);
|
||||
ResetItemDict.Add(nameTuple,item);
|
||||
|
||||
if (_scopeContextStack.Count > 0 && !isSharedGlobalParent)
|
||||
{
|
||||
var contextNameTuple = _scopeContextStack.Peek();
|
||||
ResetItem parentItem = ResetItemDict[contextNameTuple];
|
||||
parentItem.ChildResetItems.Add(item);
|
||||
item.Parent = parentItem;
|
||||
}
|
||||
item.CheckOnValueChange();//Init
|
||||
}
|
||||
else
|
||||
{
|
||||
// Debug.LogError("ResetItem已经存在:"+nameTuple.ToString());
|
||||
}
|
||||
//就算是已经ContainsKey了,也Push和Pop一下。没有作用,但让写法更简单。
|
||||
_scopeContextStack.Push(nameTuple);
|
||||
}
|
||||
|
||||
|
||||
public void EndResetModifyButtonScope()
|
||||
{
|
||||
if(!IsInitResetData) return;
|
||||
if(_scopeContextStack.Count == 0) return;
|
||||
_scopeContextStack.Pop();
|
||||
}
|
||||
|
||||
public float ResetButtonSize => EditorGUIUtility.singleLineHeight;
|
||||
|
||||
private GUIContent resetIconContent = new GUIContent();
|
||||
//仅仅只是Drawer
|
||||
private void DrawResetModifyButtonFinal(Rect position, (string, string) nameTuple)
|
||||
{
|
||||
ResetItem item;
|
||||
// GUILayout.FlexibleSpace();
|
||||
if (ResetItemDict.ContainsKey(nameTuple))
|
||||
{
|
||||
item = ResetItemDict[nameTuple];
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
float btnSize = ResetButtonSize;
|
||||
string iconText;
|
||||
bool isDisabled = true;
|
||||
GUIStyle iconStyle;
|
||||
if (item.HasModified || item.HasMixedValue)
|
||||
{
|
||||
isDisabled = false;
|
||||
iconText = "R";
|
||||
iconStyle = GUI.skin.button;
|
||||
}
|
||||
else
|
||||
{
|
||||
isDisabled = true;
|
||||
iconText = "";
|
||||
iconStyle = GUI.skin.label;
|
||||
}
|
||||
|
||||
resetIconContent.text = iconText;
|
||||
EditorGUI.BeginDisabledGroup(isDisabled);
|
||||
// if (GUILayout.Button(iconTexture, GUILayout.Width(btnSize), GUILayout.Height(btnSize)))
|
||||
if (position.width <= 0)
|
||||
{
|
||||
position = GUILayoutUtility.GetRect(resetIconContent, GUI.skin.button, GUILayout.Width(btnSize),
|
||||
GUILayout.Height(btnSize));
|
||||
}
|
||||
if(GUI.Button(position,resetIconContent,iconStyle))
|
||||
{
|
||||
item.Execute();
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
public void SetPropertyToDefaultValue(ShaderPropertyPack pack,VectorValeType vectorValeType = VectorValeType.Undefine)
|
||||
{
|
||||
MaterialProperty property = pack.property;
|
||||
MaterialProperty.PropType propertyType = property.type;
|
||||
if (pack.property.type == MaterialProperty.PropType.Texture && vectorValeType != VectorValeType.Undefine)
|
||||
{
|
||||
propertyType = MaterialProperty.PropType.Vector;//Tilling or Offset
|
||||
}
|
||||
switch (propertyType)
|
||||
{
|
||||
case MaterialProperty.PropType.Color:
|
||||
Vector4 colorValue = _shader.GetPropertyDefaultVectorValue(pack.index);
|
||||
property.colorValue = new Color(colorValue.x, colorValue.y, colorValue.z, colorValue.x);
|
||||
break;
|
||||
|
||||
case MaterialProperty.PropType.Vector:
|
||||
Vector4 defaultVecValue;
|
||||
Vector4 vecValue;
|
||||
if (vectorValeType == VectorValeType.Tilling || vectorValeType == VectorValeType.Offset)
|
||||
{
|
||||
defaultVecValue = new Vector4(1f, 1f, 0f, 0f);
|
||||
vecValue = property.textureScaleAndOffset;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
defaultVecValue = _shader.GetPropertyDefaultVectorValue(pack.index);
|
||||
vecValue = property.vectorValue;
|
||||
}
|
||||
switch (vectorValeType)
|
||||
{
|
||||
case VectorValeType.Undefine: Debug.LogError("VectorValeType is undefined"); break;
|
||||
case VectorValeType.X: vecValue.x = defaultVecValue.x;property.vectorValue = vecValue;break;
|
||||
case VectorValeType.Y: vecValue.y = defaultVecValue.y;property.vectorValue = vecValue;break;
|
||||
case VectorValeType.Z: vecValue.z = defaultVecValue.z;property.vectorValue = vecValue;break;
|
||||
case VectorValeType.W: vecValue.w = defaultVecValue.w;property.vectorValue = vecValue;break;
|
||||
case VectorValeType.XY:vecValue.x = defaultVecValue.x; vecValue.y = defaultVecValue.y;
|
||||
property.vectorValue = vecValue;break;
|
||||
case VectorValeType.Tilling:vecValue.x = defaultVecValue.x; vecValue.y = defaultVecValue.y;
|
||||
property.textureScaleAndOffset = vecValue;break;
|
||||
case VectorValeType.ZW:vecValue.z = defaultVecValue.z; vecValue.w = defaultVecValue.w;
|
||||
property.vectorValue = vecValue;break;
|
||||
case VectorValeType.Offset:vecValue.z = defaultVecValue.z; vecValue.w = defaultVecValue.w;
|
||||
property.textureScaleAndOffset = vecValue;break;
|
||||
case VectorValeType.XYZ:vecValue.x = defaultVecValue.x; vecValue.y = defaultVecValue.y;
|
||||
vecValue.z = defaultVecValue.z; property.vectorValue = vecValue;break;
|
||||
case VectorValeType.XYZW: property.vectorValue = defaultVecValue;break;
|
||||
}
|
||||
break;
|
||||
|
||||
case MaterialProperty.PropType.Float or MaterialProperty.PropType.Range:
|
||||
float value = _shader.GetPropertyDefaultFloatValue(pack.index);
|
||||
property.floatValue = value;
|
||||
break;
|
||||
|
||||
case MaterialProperty.PropType.Texture:
|
||||
if (property.textureValue == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
property.textureValue = null;
|
||||
break;
|
||||
}
|
||||
// return property.textureValue.name == shader.GetPropertyTextureDefaultName(pack.index) ? false : true;
|
||||
|
||||
default:
|
||||
// 如果不属于上述类型,输出提示信息
|
||||
Debug.Log($"{property.displayName} has no default value or unsupported type");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsPropertyModified(ShaderPropertyPack pack,VectorValeType vectorValeType = VectorValeType.Undefine)
|
||||
{
|
||||
MaterialProperty property = pack.property;
|
||||
MaterialProperty.PropType propertyType = property.type;
|
||||
if (pack.property.type == MaterialProperty.PropType.Texture && vectorValeType != VectorValeType.Undefine)
|
||||
{
|
||||
propertyType = MaterialProperty.PropType.Vector;//Tilling or Offset
|
||||
}
|
||||
switch (propertyType)
|
||||
{
|
||||
case MaterialProperty.PropType.Color:
|
||||
Vector4 colorValue = _shader.GetPropertyDefaultVectorValue(pack.index);
|
||||
Color color = new Color(colorValue.x, colorValue.y, colorValue.z, colorValue.w);
|
||||
return property.colorValue == color ? false : true;
|
||||
|
||||
case MaterialProperty.PropType.Vector:
|
||||
|
||||
Vector4 defaultVecValue;
|
||||
Vector4 vecValue;
|
||||
if (vectorValeType == VectorValeType.Tilling || vectorValeType == VectorValeType.Offset)
|
||||
{
|
||||
defaultVecValue = new Vector4(1f, 1f, 0f, 0f);
|
||||
vecValue = property.textureScaleAndOffset;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
defaultVecValue = _shader.GetPropertyDefaultVectorValue(pack.index);
|
||||
vecValue = property.vectorValue;
|
||||
}
|
||||
|
||||
|
||||
Vector2 defaultVecXYValue = new Vector2(defaultVecValue.x, defaultVecValue.y);
|
||||
Vector2 defaultVecZWValue = new Vector2(defaultVecValue.z, defaultVecValue.w);
|
||||
Vector2 vecXYValue = new Vector2(vecValue.x, vecValue.y);
|
||||
Vector2 vecZWValue = new Vector2(vecValue.z, vecValue.w);
|
||||
Vector2 defaultVecXYZValue = new Vector3(defaultVecValue.x, defaultVecValue.y,defaultVecValue.z);
|
||||
Vector2 vecXYZValue = new Vector3(vecValue.x, vecValue.y,vecValue.z);
|
||||
|
||||
|
||||
bool isVecModified = false;
|
||||
switch (vectorValeType)
|
||||
{
|
||||
case VectorValeType.Undefine: Debug.LogError("VectorValeType is undefined"); break;
|
||||
case VectorValeType.X: isVecModified = Mathf.Approximately(vecValue.x,defaultVecValue.x) ? false : true;break;
|
||||
case VectorValeType.Y: isVecModified = Mathf.Approximately(vecValue.y,defaultVecValue.y) ? false : true;break;
|
||||
case VectorValeType.Z: isVecModified = Mathf.Approximately(vecValue.z,defaultVecValue.z) ? false : true;break;
|
||||
case VectorValeType.W: isVecModified = Mathf.Approximately(vecValue.w,defaultVecValue.w) ? false : true;break;
|
||||
case VectorValeType.XY:case VectorValeType.Tilling:
|
||||
isVecModified = vecXYValue == defaultVecXYValue ? false : true;break;
|
||||
case VectorValeType.ZW:case VectorValeType.Offset:
|
||||
isVecModified = vecZWValue == defaultVecZWValue ? false : true;break;
|
||||
case VectorValeType.XYZ:isVecModified = vecXYZValue == defaultVecXYZValue ? false : true ; break;
|
||||
case VectorValeType.XYZW:isVecModified= vecValue == defaultVecValue? false : true ; break;
|
||||
}
|
||||
return isVecModified;
|
||||
|
||||
case MaterialProperty.PropType.Float or MaterialProperty.PropType.Range:
|
||||
return Mathf.Approximately(property.floatValue, _shader.GetPropertyDefaultFloatValue(pack.index)) ? false : true;
|
||||
|
||||
case MaterialProperty.PropType.Texture:
|
||||
if (property.textureValue == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return property.textureValue.name == "textureExternal" ? false : true;
|
||||
}
|
||||
// return property.textureValue.name == shader.GetPropertyTextureDefaultName(pack.index) ? false : true;
|
||||
|
||||
default:
|
||||
// 如果不属于上述类型,输出提示信息
|
||||
return false;
|
||||
// Debug.Log($"{property.displayName} has no default value or unsupported type");
|
||||
// break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73135babda09451c9e5798b36897637b
|
||||
timeCreated: 1754727843
|
||||
248
Packages/XuanXuanRenderUtility/Editor/ShaderGUIToolBar.cs
Normal file
248
Packages/XuanXuanRenderUtility/Editor/ShaderGUIToolBar.cs
Normal file
@@ -0,0 +1,248 @@
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
namespace NBShaderEditor
|
||||
{
|
||||
|
||||
public class ShaderGUIToolBar
|
||||
{
|
||||
public ShaderGUIHelper Helper;
|
||||
|
||||
private int viewModeIndex;
|
||||
private readonly string[] viewModes = { "List", "Grid" };
|
||||
// private string searchText = "";
|
||||
private MaterialEditor _editor=>Helper.matEditor;
|
||||
public ShaderGUIToolBar(ShaderGUIHelper helper)
|
||||
{
|
||||
Helper = helper;
|
||||
}
|
||||
|
||||
private static Material copiedMaterial;
|
||||
private static Shader copiedShader;
|
||||
|
||||
// 帮助链接URL
|
||||
private const string HELP_URL = "https://owejt9diz2c.feishu.cn/wiki/BHz8wHHSjiYJagk7WrmcAcconlb?from=from_copylink";
|
||||
|
||||
private Vector2 imagePos;
|
||||
private Texture2D icon;
|
||||
private Texture2D image;
|
||||
|
||||
public void DrawToolbar()
|
||||
{
|
||||
|
||||
float BtnWidth = 30f;
|
||||
// 开始工具栏区域 (背景)
|
||||
EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
|
||||
|
||||
// 1. 选择当前材质
|
||||
if (GUILayout.Button(EditorGUIUtility.IconContent("Material On Icon","跳到当前材质|跳到当前材质"), EditorStyles.toolbarButton,GUILayout.Width(BtnWidth)))
|
||||
{
|
||||
EditorGUIUtility.PingObject(Helper.mats[0]);
|
||||
}
|
||||
|
||||
if (GUILayout.Button(EditorGUIUtility.IconContent("TreeEditor.Trash","清除没有使用的贴图|清除没有使用的贴图"), EditorStyles.toolbarButton,GUILayout.Width(BtnWidth)))
|
||||
{
|
||||
foreach (var mat in Helper.mats)
|
||||
{
|
||||
CleanUnusedTextureProperties(Helper.mats[0]);//先清理不属于当前Shader的贴图
|
||||
}
|
||||
Helper.isClearUnUsedTexture = true;
|
||||
}
|
||||
|
||||
if (GUILayout.Button(new GUIContent("C","复制材质属性"), EditorStyles.toolbarButton,GUILayout.Width(BtnWidth)))
|
||||
{
|
||||
copiedMaterial = Helper.mats[0];
|
||||
copiedShader = copiedMaterial.shader;
|
||||
}
|
||||
|
||||
if (GUILayout.Button(new GUIContent("V","粘贴材质属性"), EditorStyles.toolbarButton,GUILayout.Width(BtnWidth)))
|
||||
{
|
||||
if (copiedShader)
|
||||
{
|
||||
Helper.mats[0].shader = copiedShader;
|
||||
}
|
||||
|
||||
if (copiedMaterial)
|
||||
{
|
||||
Helper.mats[0].CopyPropertiesFromMaterial(copiedMaterial);
|
||||
}
|
||||
}
|
||||
if (GUILayout.Button(new GUIContent("R","特殊重置功能"), EditorStyles.toolbarButton,GUILayout.Width(BtnWidth)))
|
||||
{
|
||||
ShowResetPopupMenu();
|
||||
}
|
||||
if (GUILayout.Button(EditorGUIUtility.IconContent("d_UnityEditor.HierarchyWindow","折叠所有控件|折叠所有控件"), EditorStyles.toolbarButton,GUILayout.Width(BtnWidth)))
|
||||
{
|
||||
for (int i = 0;i<Helper.shaderFlags.Length;i++)
|
||||
{
|
||||
W9ParticleShaderFlags shaderFlags = (W9ParticleShaderFlags)Helper.shaderFlags[i];
|
||||
for (int j = 3; j <= 5; j++)
|
||||
{
|
||||
Helper.mats[i].SetInteger(shaderFlags.GetShaderFlagsId(j),0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 添加下拉菜单
|
||||
// viewModeIndex = EditorGUILayout.Popup(viewModeIndex, viewModes, EditorStyles.toolbarPopup, GUILayout.Width(BtnWidth));
|
||||
|
||||
// 3. 添加搜索框
|
||||
GUILayout.FlexibleSpace(); // 将搜索框推到中间
|
||||
|
||||
// // 搜索框样式
|
||||
// GUIStyle searchField = new GUIStyle("SearchTextField");
|
||||
// GUIStyle cancelButton = new GUIStyle("SearchCancelButton");
|
||||
//
|
||||
// EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(300));
|
||||
// {
|
||||
// EditorGUI.BeginChangeCheck();
|
||||
// searchText = EditorGUILayout.TextField(searchText, searchField);
|
||||
// if (EditorGUI.EndChangeCheck())
|
||||
// {
|
||||
// Helper.isSearchText = searchText.Length > 0;
|
||||
// Helper.searchText = searchText;
|
||||
// }
|
||||
//
|
||||
// // 清除搜索按钮
|
||||
// if (GUILayout.Button("", cancelButton))
|
||||
// {
|
||||
// searchText = "";
|
||||
// GUI.FocusControl(null); // 移除焦点
|
||||
// }
|
||||
// }
|
||||
// EditorGUILayout.EndHorizontal();
|
||||
|
||||
// // 4. 右侧按钮组
|
||||
// if (GUILayout.Button(EditorGUIUtility.IconContent("TreeEditor.Refresh"), EditorStyles.toolbarButton))
|
||||
// {
|
||||
// Debug.Log("Refresh clicked");
|
||||
// }
|
||||
//
|
||||
// // 选项菜单
|
||||
// if (GUILayout.Button(EditorGUIUtility.IconContent("_Popup"), EditorStyles.toolbarButton))
|
||||
// {
|
||||
// // 创建下拉菜单
|
||||
// GenericMenu menu = new GenericMenu();
|
||||
// menu.AddItem(new GUIContent("Option 1"), false, () => Debug.Log("Option 1"));
|
||||
// menu.AddItem(new GUIContent("Option 2"), false, () => Debug.Log("Option 2"));
|
||||
// menu.ShowAsContext();
|
||||
// }
|
||||
// 贴图加载
|
||||
if (icon == null)
|
||||
icon = AssetDatabase.LoadAssetAtPath<Texture2D>(AssetDatabase.GUIDToAssetPath("eaa39f504c2ce7646aece103ba9c4766"));
|
||||
if (image == null)
|
||||
image = AssetDatabase.LoadAssetAtPath<Texture2D>(AssetDatabase.GUIDToAssetPath("cc6c30349a33a1d4c8242a9ef1a68830"));
|
||||
if (GUILayout.Button(new GUIContent(icon,"爸爸!"), EditorStyles.toolbarButton,GUILayout.Width(BtnWidth)))
|
||||
{
|
||||
// 弹出 PopupWindow
|
||||
// 弹出浮动窗口
|
||||
FloatingImageWindow.ShowWindow(image);
|
||||
}
|
||||
|
||||
|
||||
if (GUILayout.Button(EditorGUIUtility.IconContent("d__Help@2x","说明文档|说明文档"), EditorStyles.toolbarButton,GUILayout.Width(BtnWidth)))
|
||||
{
|
||||
// 打开浏览器跳转到帮助链接
|
||||
Application.OpenURL(HELP_URL);
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal(); // 结束工具栏
|
||||
}
|
||||
|
||||
private void ShowResetPopupMenu()
|
||||
{
|
||||
GenericMenu menu = new GenericMenu();
|
||||
|
||||
menu.AddItem(new GUIContent("重置特殊UV通道"), false, () =>
|
||||
{
|
||||
Helper.ResetTool.ResetItemDict[("特殊UV通道选择","_SpecialUVChannelMode")].Execute();
|
||||
});
|
||||
menu.AddItem(new GUIContent("重置旋转扭曲"), false, () =>
|
||||
{
|
||||
Helper.ResetTool.ResetItemDict[("","_UTwirlEnabled")].Execute();
|
||||
});
|
||||
menu.AddItem(new GUIContent("重置极坐标"), false, () =>
|
||||
{
|
||||
Helper.ResetTool.ResetItemDict[("","_PolarCoordinatesEnabled")].Execute();
|
||||
});
|
||||
|
||||
// 弹出位置可以用 Event.current.mousePosition
|
||||
menu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero));
|
||||
}
|
||||
|
||||
private void CleanUnusedTextureProperties(Material mat)
|
||||
{
|
||||
if (mat == null || mat.shader == null) return;
|
||||
|
||||
Shader shader = mat.shader;
|
||||
|
||||
// 收集 Shader 里声明过的贴图属性
|
||||
var shaderTexProps = new HashSet<string>();
|
||||
int count = ShaderUtil.GetPropertyCount(shader);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (ShaderUtil.GetPropertyType(shader, i) == ShaderUtil.ShaderPropertyType.TexEnv)
|
||||
{
|
||||
shaderTexProps.Add(ShaderUtil.GetPropertyName(shader, i));
|
||||
}
|
||||
}
|
||||
|
||||
// 遍历材质所有贴图属性,找到 shader 不再声明的
|
||||
var allProps = mat.GetTexturePropertyNames();
|
||||
foreach (var propName in allProps)
|
||||
{
|
||||
if (!shaderTexProps.Contains(propName))
|
||||
{
|
||||
if (mat.GetTexture(propName) != null)
|
||||
{
|
||||
mat.SetTexture(propName, null);
|
||||
Debug.Log($"清理 {mat.name} 的无效贴图属性: {propName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// EditorWindow 显示图片
|
||||
public class FloatingImageWindow : EditorWindow
|
||||
{
|
||||
private Texture2D popupImage;
|
||||
|
||||
public static void ShowWindow(Texture2D image)
|
||||
{
|
||||
// 创建窗口
|
||||
FloatingImageWindow window = CreateInstance<FloatingImageWindow>();
|
||||
window.titleContent = new GUIContent("谢谢爸爸");
|
||||
window.popupImage = image;
|
||||
|
||||
// 设置初始尺寸
|
||||
if (image != null)
|
||||
window.position = new Rect(Screen.width / 2f - image.width / 2f,
|
||||
Screen.height / 2f - image.height / 2f,
|
||||
image.width,
|
||||
image.height);
|
||||
else
|
||||
window.position = new Rect(Screen.width / 2f - 100, Screen.height / 2f - 100, 200, 200);
|
||||
|
||||
window.ShowUtility(); // 浮动窗口
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
if (popupImage != null)
|
||||
{
|
||||
// 绘制图片
|
||||
Rect rect = new Rect(0, 0, position.width, position.height);
|
||||
GUI.DrawTexture(rect, popupImage, ScaleMode.ScaleToFit);
|
||||
}
|
||||
|
||||
// 可选:增加关闭按钮
|
||||
if (GUI.Button(new Rect(position.width - 25, 5, 20, 20), "X"))
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: deccdbc6963a48b2ace3358cbba67689
|
||||
timeCreated: 1754406958
|
||||
@@ -40,6 +40,7 @@ namespace stencilTestHelper
|
||||
public string stencilReadMask = "_StencilReadMask";
|
||||
public string stencilZFail = "_StencilZFail";
|
||||
public string stencilFail = "_StencilFail";
|
||||
public string stencilKexIndex = "_StencilKeyIndex";
|
||||
|
||||
public StencilPropertyNames()
|
||||
{
|
||||
@@ -47,7 +48,7 @@ namespace stencilTestHelper
|
||||
|
||||
public StencilPropertyNames(string stencilName, string stencilCompName, string stencilOpName,
|
||||
string stencilWriteMaskName, string stencilReadMaskName, string stencilZFailName,
|
||||
string stencilFailName)
|
||||
string stencilFailName,string stencilKexIndexName)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(stencilName))
|
||||
{
|
||||
@@ -77,6 +78,11 @@ namespace stencilTestHelper
|
||||
{
|
||||
stencilFail = stencilFailName;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(stencilKexIndexName))
|
||||
{
|
||||
stencilKexIndex = stencilKexIndexName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,6 +141,11 @@ namespace stencilTestHelper
|
||||
mat.SetFloat(stencilPropertyNames.stencilFail, (float)stencilValues.Fail);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(stencilPropertyNames.stencilKexIndex))
|
||||
{
|
||||
mat.SetFloat(stencilPropertyNames.stencilKexIndex,stencilValuesConfig.GetKeyIndex(stencilConfigKey));
|
||||
}
|
||||
|
||||
defaultQueue = stencilValues.DefaultQueue;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -44,6 +44,24 @@ namespace stencilTestHelper
|
||||
Debug.LogError("StencilValuesConfig: 不存在Key"+key);
|
||||
return null;
|
||||
}
|
||||
|
||||
public int GetKeyIndex(string key)
|
||||
{
|
||||
for (int i = 0; i < Config.Count; i++)
|
||||
{
|
||||
if (Config[i].key == key)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
Debug.LogError("StencilValuesConfig: 不存在Key"+key);
|
||||
return -1;
|
||||
}
|
||||
|
||||
public string GetKeyByIndex(int index)
|
||||
{
|
||||
return Config[index].key;
|
||||
}
|
||||
|
||||
|
||||
public StencilValues this[string key]
|
||||
|
||||
8
Packages/XuanXuanRenderUtility/Editor/Textures.meta
Normal file
8
Packages/XuanXuanRenderUtility/Editor/Textures.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 37a388ed2acdda44cba962b4f9196106
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Packages/XuanXuanRenderUtility/Editor/Textures/GiveMeMoney.jpg
Normal file
BIN
Packages/XuanXuanRenderUtility/Editor/Textures/GiveMeMoney.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 50 KiB |
@@ -0,0 +1,127 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc6c30349a33a1d4c8242a9ef1a68830
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 2
|
||||
compressionQuality: 20
|
||||
crunchedCompression: 1
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Packages/XuanXuanRenderUtility/Editor/Textures/alipayLogo.png
Normal file
BIN
Packages/XuanXuanRenderUtility/Editor/Textures/alipayLogo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
@@ -0,0 +1,127 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eaa39f504c2ce7646aece103ba9c4766
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -3,7 +3,8 @@
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:8f9e4d586616f13449cfeb86c5f704c2",
|
||||
"GUID:df380645f10b7bc4b97d4f5eb6303d95"
|
||||
"GUID:df380645f10b7bc4b97d4f5eb6303d95",
|
||||
"GUID:0e3b0e6ce60c7a34094f8f9822c0b7f2"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
|
||||
@@ -29,29 +29,12 @@ public abstract class ShaderFlagsBase
|
||||
return _material;
|
||||
}
|
||||
|
||||
protected abstract int GetShaderFlagsId(int index = 0);
|
||||
public abstract int GetShaderFlagsId(int index = 0);
|
||||
protected abstract string GetShaderFlagsName(int index = 0);
|
||||
|
||||
private void SetIntValue(Material material, int flagBits,int index = 0)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
// SerializedObject serializedObject = new SerializedObject(_material);
|
||||
// SerializedProperty serializedProperty = serializedObject.FindProperty("m_SavedProperties");
|
||||
// serializedProperty = serializedProperty.FindPropertyRelative("m_Floats");
|
||||
// for (int index = serializedProperty.arraySize - 1; index >= 0; index--)
|
||||
// {
|
||||
// var property = serializedProperty.GetArrayElementAtIndex(index);
|
||||
// string propertyName = property.displayName;
|
||||
// if (propertyName == "_W9PBRStandardShaderFlags")
|
||||
// {
|
||||
// var propertyType = property.propertyType;
|
||||
// Debug.Log("xxx: "+propertyType);
|
||||
//
|
||||
//
|
||||
// property.floatValue = (float) (flags | flagBits);
|
||||
// }
|
||||
// }
|
||||
// material.SetInt(GetShaderFlagsName(), flagBits);
|
||||
material.SetInteger(GetShaderFlagsId(index), flagBits);
|
||||
#else
|
||||
material.SetInteger(GetShaderFlagsId(index), flagBits);
|
||||
|
||||
@@ -21,6 +21,12 @@ inline half NB_Remap(half x, half inMin, half inMax, half outMin, half outMax)
|
||||
return saturate((x - inMin) / (inMax - inMin)) * (outMax - outMin) + outMin;
|
||||
}
|
||||
|
||||
inline half NB_Remap01(half x, half inMin, half inMax)
|
||||
{
|
||||
// x= clamp(x,inMin,inMax);
|
||||
return saturate((x - inMin) / (inMax - inMin));
|
||||
}
|
||||
|
||||
inline half NB_RemapNoClamp(half x, half inMin, half inMax, half outMin, half outMax)
|
||||
{
|
||||
// x= clamp(x,inMin,inMax);
|
||||
@@ -240,6 +246,14 @@ void Unity_Blend_HardLight_half(half Base, half Blend, half Opacity, out half Ou
|
||||
Out = lerp(Base, Out, Opacity);
|
||||
}
|
||||
|
||||
void Blend_HardLight_half(half Base, half Blend, out half Out)
|
||||
{
|
||||
half result1 = 1.0 - 2.0 * (1.0 - Base) * (1.0 - Blend);
|
||||
half result2 = 2.0 * Base * Blend;
|
||||
half zeroOrOne = step(Blend, 0.5);
|
||||
Out = result2 * zeroOrOne + (1 - zeroOrOne) * result1;
|
||||
}
|
||||
|
||||
float2 randomGradient(float2 p) {
|
||||
p = p + 0.02;
|
||||
float x = dot(p, float2(123.4, 234.5));
|
||||
@@ -348,4 +362,10 @@ half2 Rotate(half2 v, half cos0, half sin0)
|
||||
return half2(v.x * cos0 - v.y * sin0,
|
||||
v.x * sin0 + v.y * cos0);
|
||||
}
|
||||
|
||||
half SmoothStep01(half interval)//让01线性过渡变成SmoothStep过渡,但是控制计算量。
|
||||
{
|
||||
interval = saturate(interval);
|
||||
return interval * interval * ( 3 - 2 * interval );
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user