完成SampleCRT所有参数的配置实现

新增Boolean类型滤镜参数支持
This commit is contained in:
ALIENJACK\alien 2025-01-10 17:32:08 +08:00
parent e5667b55a1
commit 864b5879e1
8 changed files with 971 additions and 674 deletions

View File

@ -520,6 +520,77 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
gradient: {fileID: 46877084639177849} gradient: {fileID: 46877084639177849}
--- !u!1 &1280900818828460255
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1718494758036642021}
- component: {fileID: 406189280625441644}
- component: {fileID: 6728379839034828402}
m_Layer: 5
m_Name: BoolEdit
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1718494758036642021
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1280900818828460255}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 7754613193470953066}
m_Father: {fileID: 278706555072840209}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &406189280625441644
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1280900818828460255}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 306cc8c2b49d7114eaa3623786fc2126, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_PreferredWidth: -1
m_PreferredHeight: 40
m_FlexibleWidth: -1
m_FlexibleHeight: -1
m_LayoutPriority: 1
--- !u!114 &6728379839034828402
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1280900818828460255}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c864ef7d3920dfc4cb69a86ef3af426b, type: 3}
m_Name:
m_EditorClassIdentifier:
txt_value: {fileID: 7822831767140937850}
--- !u!1 &1501213187178026014 --- !u!1 &1501213187178026014
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1372,6 +1443,7 @@ RectTransform:
- {fileID: 2450201408575734812} - {fileID: 2450201408575734812}
- {fileID: 7216060871118576844} - {fileID: 7216060871118576844}
- {fileID: 3461365397350504029} - {fileID: 3461365397350504029}
- {fileID: 1718494758036642021}
- {fileID: 816049057894123782} - {fileID: 816049057894123782}
m_Father: {fileID: 4478785627166277610} m_Father: {fileID: 4478785627166277610}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -1396,6 +1468,7 @@ MonoBehaviour:
m_Icon: {fileID: 1062489471918314902} m_Icon: {fileID: 1062489471918314902}
com_floatEdit: {fileID: 3979886008433050043} com_floatEdit: {fileID: 3979886008433050043}
com_intEdit: {fileID: 7283495606979218283} com_intEdit: {fileID: 7283495606979218283}
com_boolEdit: {fileID: 6728379839034828402}
com_enumEdit: {fileID: 3614321873420207159} com_enumEdit: {fileID: 3614321873420207159}
--- !u!114 &4314371315188452187 --- !u!114 &4314371315188452187
MonoBehaviour: MonoBehaviour:
@ -1679,6 +1752,106 @@ MonoBehaviour:
m_ChildScaleWidth: 0 m_ChildScaleWidth: 0
m_ChildScaleHeight: 0 m_ChildScaleHeight: 0
m_ReverseArrangement: 0 m_ReverseArrangement: 0
--- !u!1 &6033457221832404715
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8543458054403131507}
- component: {fileID: 6646371810488858664}
- component: {fileID: 7822831767140937850}
- component: {fileID: 3722671482862039384}
m_Layer: 5
m_Name: value
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &8543458054403131507
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6033457221832404715}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 7754613193470953066}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &6646371810488858664
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6033457221832404715}
m_CullTransparentMesh: 1
--- !u!114 &7822831767140937850
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6033457221832404715}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 12800000, guid: 33a3bdf8f6bd1ec4eba7c4bc58183212, type: 3}
m_FontSize: 20
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 2
m_MaxSize: 40
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 1
m_LineSpacing: 1
m_Text: ENUMNAME
--- !u!114 &3722671482862039384
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6033457221832404715}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 306cc8c2b49d7114eaa3623786fc2126, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_PreferredWidth: -1
m_PreferredHeight: -1
m_FlexibleWidth: 1
m_FlexibleHeight: -1
m_LayoutPriority: 1
--- !u!1 &6058311224544485353 --- !u!1 &6058311224544485353
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -2246,6 +2419,69 @@ MonoBehaviour:
m_FillOrigin: 0 m_FillOrigin: 0
m_UseSpriteMesh: 0 m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1 m_PixelsPerUnitMultiplier: 1
--- !u!1 &7928927824150591534
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7754613193470953066}
- component: {fileID: 4099568322977131793}
m_Layer: 5
m_Name: content
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &7754613193470953066
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7928927824150591534}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 8543458054403131507}
m_Father: {fileID: 1718494758036642021}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &4099568322977131793
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7928927824150591534}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 30649d3a9faa99c48a7b1166b86bf2a0, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Padding:
m_Left: 0
m_Right: 0
m_Top: 0
m_Bottom: 0
m_ChildAlignment: 0
m_Spacing: 5
m_ChildForceExpandWidth: 1
m_ChildForceExpandHeight: 1
m_ChildControlWidth: 1
m_ChildControlHeight: 1
m_ChildScaleWidth: 0
m_ChildScaleHeight: 0
m_ReverseArrangement: 0
--- !u!1 &8045610840842517781 --- !u!1 &8045610840842517781
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -337,6 +337,12 @@ namespace AxibugEmuOnline.Client
int.TryParse(rawStr, out intVal); int.TryParse(rawStr, out intVal);
return intVal; return intVal;
} }
else if (valueType == typeof(bool))
{
bool boolVal;
bool.TryParse(rawStr, out boolVal);
return boolVal;
}
else if (valueType.IsEnum) else if (valueType.IsEnum)
{ {
var names = Enum.GetNames(valueType); var names = Enum.GetNames(valueType);

View File

@ -29,6 +29,16 @@ namespace Assets.Script.AppMain.Filter
{ {
m_defaultValue = defaultValue; m_defaultValue = defaultValue;
} }
public static implicit operator T(FilterParameter<T> value)
{
return value.GetValue();
}
public static implicit operator FilterParameter<T>(T value)
{
return new FilterParameter<T>(value);
}
} }
public class BoolParameter : FilterParameter<bool> public class BoolParameter : FilterParameter<bool>
@ -39,6 +49,11 @@ namespace Assets.Script.AppMain.Filter
{ {
return value.GetValue(); return value.GetValue();
} }
public static implicit operator BoolParameter(bool value)
{
return new BoolParameter(value);
}
} }
public class Vector2Parameter : FilterParameter<Vector2> public class Vector2Parameter : FilterParameter<Vector2>
@ -49,6 +64,11 @@ namespace Assets.Script.AppMain.Filter
{ {
return value.GetValue(); return value.GetValue();
} }
public static implicit operator Vector2Parameter(Vector2 value)
{
return new Vector2Parameter(value);
}
} }
public class FloatParameter : FilterParameter<float> public class FloatParameter : FilterParameter<float>
@ -59,6 +79,11 @@ namespace Assets.Script.AppMain.Filter
{ {
return value.GetValue(); return value.GetValue();
} }
public static implicit operator FloatParameter(float value)
{
return new FloatParameter(value);
}
} }
public class IntParameter : FilterParameter<int> public class IntParameter : FilterParameter<int>
@ -69,5 +94,10 @@ namespace Assets.Script.AppMain.Filter
{ {
return value.GetValue(); return value.GetValue();
} }
public static implicit operator IntParameter(int value)
{
return new IntParameter(value);
}
} }
} }

View File

@ -11,58 +11,44 @@ public class SimpleCRT : FilterEffect
protected override string ShaderName => "Filter/yunoda-3DCG/SimpleCRT"; protected override string ShaderName => "Filter/yunoda-3DCG/SimpleCRT";
[Range(0, 1000)] [Range(0, 1000)][Description("White Noise Freq")] public IntParameter whiteNoiseFrequency = new IntParameter(1);
[Description("White Noise Freq")] [Range(0, 1)][Description("White Noise Time Left (sec)")] public FloatParameter whiteNoiseLength = new FloatParameter(0.1f);
public IntParameter whiteNoiseFrequency = new IntParameter(1);
[Range(0, 1)]
[Description("White Noise Time Left (sec)")]
public FloatParameter whiteNoiseLength = new FloatParameter(0.1f);
private float whiteNoiseTimeLeft; private float whiteNoiseTimeLeft;
public int screenJumpFrequency = 1; [Range(0, 1000)][Description("Screen Jump Freq")] public IntParameter screenJumpFrequency = 1;
public float screenJumpLength = 0.2f; [Range(0, 1f)][Description("Screen Jump Length")] public FloatParameter screenJumpLength = 0.2f;
public float screenJumpMinLevel = 0.1f; [Range(0, 1f)][Description("Jump Min")] public FloatParameter screenJumpMinLevel = 0.1f;
public float screenJumpMaxLevel = 0.9f; [Range(0, 1f)][Description("Jump Max")] public FloatParameter screenJumpMaxLevel = 0.9f;
private float screenJumpTimeLeft; private float screenJumpTimeLeft;
public float flickeringStrength = 0.002f; [Range(0, 1f)][Description("Flickering Strength")] public FloatParameter flickeringStrength = 0.002f;
public float flickeringCycle = 111f; [Range(0, 333f)][Description("Flickering Cycle")] public FloatParameter flickeringCycle = 111f;
public bool isSlippage = true; [Description("Slip Page")] public BoolParameter isSlippage = true;
public bool isSlippageNoise = true; [Description("Slip Noise")] public BoolParameter isSlippageNoise = true;
public float slippageStrength = 0.005f; [Range(0, 1)][Description("Slip Strength")] public FloatParameter slippageStrength = 0.005f;
public float slippageInterval = 1f; [Range(0, 100)][Description("Slip Intervalw")] public float slippageInterval = 1f;
public float slippageScrollSpeed = 33f; [Range(0, 330)][Description("Slip Scroll Speed")] public float slippageScrollSpeed = 33f;
public float slippageSize = 11f; [Range(0, 100f)][Description("Slip Size")] public FloatParameter slippageSize = 11f;
public float chromaticAberrationStrength = 0.005f; [Range(0, 1f)][Description("Chromatic Aberration Strength")] public FloatParameter chromaticAberrationStrength = 0.005f;
public bool isChromaticAberration = true; [Description("Chromatic Aberration")] public bool isChromaticAberration = true;
public bool isMultipleGhost = true; [Description("Multiple Ghost")] public BoolParameter isMultipleGhost = true;
public float multipleGhostStrength = 0.01f; [Range(0, 1f)][Description("Multiple Ghost Strength")] public FloatParameter multipleGhostStrength = 0.01f;
public bool isScanline = true; [Description("Scanline")] public BoolParameter isScanline = true;
public bool isMonochrome = false; [Description("Monochrome")] public BoolParameter isMonochrome = false;
public bool isLetterBox = false; [Description("Letter Box")] public bool isLetterBox = false;
public bool isLetterBoxEdgeBlur = false; public bool isLetterBoxEdgeBlur = false;
public LeterBoxType letterBoxType; [Description("Letter Box Type")] public FilterParameter<LeterBoxType> letterBoxType = default(LeterBoxType);
public enum LeterBoxType public enum LeterBoxType
{ {
Black, Black,
Blur Blur
} }
public bool isFilmDirt = false;
public Texture2D filmDirtTex;
public bool isDecalTex = false;
public Texture2D decalTex;
public Vector2 decalTexPos;
public Vector2 decalTexScale;
public Vector2Int resolutions;
#region Properties in shader #region Properties in shader
private int _WhiteNoiseOnOff; private int _WhiteNoiseOnOff;
private int _ScanlineOnOff; private int _ScanlineOnOff;
@ -148,7 +134,7 @@ public class SimpleCRT : FilterEffect
material.SetInteger(_LetterBoxOnOff, isLetterBox ? 0 : 1); material.SetInteger(_LetterBoxOnOff, isLetterBox ? 0 : 1);
//material.SetInteger(_LetterBoxEdgeBlurOnOff, isLetterBoxEdgeBlur ? 0 : 1); //material.SetInteger(_LetterBoxEdgeBlurOnOff, isLetterBoxEdgeBlur ? 0 : 1);
material.SetInteger(_LetterBoxType, (int)letterBoxType); material.SetInteger(_LetterBoxType, (int)letterBoxType.GetValue());
material.SetInteger(_ScanlineOnOff, isScanline ? 1 : 0); material.SetInteger(_ScanlineOnOff, isScanline ? 1 : 0);
material.SetInteger(_MonochormeOnOff, isMonochrome ? 1 : 0); material.SetInteger(_MonochormeOnOff, isMonochrome ? 1 : 0);
@ -158,8 +144,6 @@ public class SimpleCRT : FilterEffect
material.SetInteger(_ChromaticAberrationOnOff, isChromaticAberration ? 1 : 0); material.SetInteger(_ChromaticAberrationOnOff, isChromaticAberration ? 1 : 0);
material.SetInteger(_MultipleGhostOnOff, isMultipleGhost ? 1 : 0); material.SetInteger(_MultipleGhostOnOff, isMultipleGhost ? 1 : 0);
material.SetFloat(_MultipleGhostStrength, multipleGhostStrength); material.SetFloat(_MultipleGhostStrength, multipleGhostStrength);
material.SetInteger(_FilmDirtOnOff, isFilmDirt ? 1 : 0);
material.SetTexture(_FilmDirtTex, filmDirtTex);
//////Slippage //////Slippage
material.SetInteger(_SlippageOnOff, isSlippage ? 1 : 0); material.SetInteger(_SlippageOnOff, isSlippage ? 1 : 0);
@ -185,12 +169,5 @@ public class SimpleCRT : FilterEffect
material.SetFloat(_ScreenJumpLevel, 0); material.SetFloat(_ScreenJumpLevel, 0);
} }
} }
//////
//////Decal Texture
material.SetTexture(_DecalTex, decalTex);
material.SetInteger(_DecalTexOnOff, isDecalTex ? 1 : 0);
material.SetVector(_DecalTexPos, decalTexPos);
material.SetVector(_DecalTexScale, decalTexScale);
} }
} }

View File

@ -10,6 +10,8 @@ namespace AxibugEmuOnline.Client
[SerializeField] [SerializeField]
OptionUI_ValueEditItem_IntEdit com_intEdit; OptionUI_ValueEditItem_IntEdit com_intEdit;
[SerializeField] [SerializeField]
OptionUI_ValueEditItem_BoolEdit com_boolEdit;
[SerializeField]
OptionUI_ValueEditItem_EnumEdit com_enumEdit; OptionUI_ValueEditItem_EnumEdit com_enumEdit;
IValueEditControl m_currentCom; IValueEditControl m_currentCom;
@ -18,6 +20,7 @@ namespace AxibugEmuOnline.Client
{ {
com_floatEdit.gameObject.SetActive(false); com_floatEdit.gameObject.SetActive(false);
com_intEdit.gameObject.SetActive(false); com_intEdit.gameObject.SetActive(false);
com_boolEdit.gameObject.SetActive(false);
com_enumEdit.gameObject.SetActive(false); com_enumEdit.gameObject.SetActive(false);
if (menuData is ValueSetMenu) if (menuData is ValueSetMenu)
@ -31,13 +34,17 @@ namespace AxibugEmuOnline.Client
{ {
m_currentCom = com_intEdit; m_currentCom = com_intEdit;
} }
else if(valueMenu.ValueType == typeof(bool))
{
m_currentCom = com_boolEdit;
}
else if (valueMenu.ValueType.IsEnum) else if (valueMenu.ValueType.IsEnum)
{ {
m_currentCom = com_enumEdit; m_currentCom = com_enumEdit;
} }
else else
{ {
App.log.Warning($"尚未支持的数据类型:{valueMenu.ValueType}"); App.log.Error($"尚未支持的数据类型:{valueMenu.ValueType}");
return; return;
} }

View File

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace AxibugEmuOnline.Client
{
public class OptionUI_ValueEditItem_BoolEdit : MonoBehaviour, IValueEditControl
{
[SerializeField]
Text txt_value;
private ValueSetMenu m_valueMenu;
public void SetData(ValueSetMenu valueMenu)
{
m_valueMenu = valueMenu;
txt_value.text = valueMenu.ValueRaw.ToString();
}
public void OnLeft()
{
OnExecute();
}
public void OnRight()
{
OnExecute();
}
public void OnExecute()
{
var value = (bool)m_valueMenu.ValueRaw;
value = !value;
txt_value.text = value.ToString();
m_valueMenu.OnValueChanged(value);
}
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: c864ef7d3920dfc4cb69a86ef3af426b