This commit is contained in:
ALIENJACK\alien 2024-12-27 13:31:18 +08:00
commit 37bbbd7cfd
13 changed files with 222 additions and 165 deletions

View File

@ -777,7 +777,7 @@ MonoBehaviour:
m_MinWidth: -1 m_MinWidth: -1
m_MinHeight: -1 m_MinHeight: -1
m_PreferredWidth: -1 m_PreferredWidth: -1
m_PreferredHeight: 50 m_PreferredHeight: 40
m_FlexibleWidth: -1 m_FlexibleWidth: -1
m_FlexibleHeight: -1 m_FlexibleHeight: -1
m_LayoutPriority: 1 m_LayoutPriority: 1
@ -1350,7 +1350,7 @@ MonoBehaviour:
m_MinWidth: -1 m_MinWidth: -1
m_MinHeight: -1 m_MinHeight: -1
m_PreferredWidth: -1 m_PreferredWidth: -1
m_PreferredHeight: 50 m_PreferredHeight: 40
m_FlexibleWidth: -1 m_FlexibleWidth: -1
m_FlexibleHeight: -1 m_FlexibleHeight: -1
m_LayoutPriority: 1 m_LayoutPriority: 1

View File

@ -3037,6 +3037,10 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.y propertyPath: m_AnchoredPosition.y
value: 0 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6838719776118089301, guid: 1de15a80c8c1aa94486563740a15d91c, type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7707092914009063575, guid: 1de15a80c8c1aa94486563740a15d91c, type: 3} - target: {fileID: 7707092914009063575, guid: 1de15a80c8c1aa94486563740a15d91c, type: 3}
propertyPath: m_AnchorMax.y propertyPath: m_AnchorMax.y
value: 0 value: 0

View File

@ -136,7 +136,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 0 m_IsActive: 1
--- !u!224 &33805170 --- !u!224 &33805170
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -364,7 +364,6 @@ RectTransform:
m_Children: m_Children:
- {fileID: 33805170} - {fileID: 33805170}
- {fileID: 1376779137} - {fileID: 1376779137}
- {fileID: 1373072004}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
@ -372,92 +371,6 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0} m_Pivot: {x: 0, y: 0}
--- !u!1 &1373072003
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1373072004}
- component: {fileID: 1373072006}
- component: {fileID: 1373072005}
m_Layer: 5
m_Name: GameObject
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!224 &1373072004
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1373072003}
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: 1319295996}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 318.00003, y: 179}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1373072005
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1373072003}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e96dacbf1b116f64da658fbad66839e2, 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_Texture: {fileID: 0}
m_UVRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
m_EffectFactor: 1
m_ColorFactor: 1
m_BlurFactor: 1
m_EffectMode: 0
m_ColorMode: 0
m_BlurMode: 3
m_EffectColor: {r: 1, g: 1, b: 1, a: 1}
m_DesamplingRate: 1
m_ReductionRate: 1
m_FilterMode: 1
m_EffectMaterial: {fileID: 21380876918929932, guid: 1a1a8e44196ca754a9a7b9cb80e17573, type: 2}
m_BlurIterations: 3
m_FitToScreen: 1
m_CaptureOnEnable: 0
--- !u!222 &1373072006
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1373072003}
m_CullTransparentMesh: 1
--- !u!1 &1376779136 --- !u!1 &1376779136
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -94,5 +94,21 @@ namespace AxibugEmuOnline.Client
Value = overrideValue; Value = overrideValue;
} }
} }
[AttributeUsage(AttributeTargets.Class)]
internal class StripAttribute : Attribute
{
HashSet<RuntimePlatform> m_stripPlats;
/// <summary>
/// 指示一个滤镜是否会在指定的平台被剔除
/// </summary>
/// <param name="strip">会被剔除的平台</param>
public StripAttribute(params RuntimePlatform[] stripPlatform)
{
m_stripPlats = new HashSet<RuntimePlatform>(stripPlatform);
}
public bool NeedStrip => m_stripPlats.Contains(Application.platform);
}
} }
} }

View File

@ -2,6 +2,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection;
using UnityEngine; using UnityEngine;
using static AxibugEmuOnline.Client.FilterEffect; using static AxibugEmuOnline.Client.FilterEffect;
@ -20,19 +21,7 @@ namespace AxibugEmuOnline.Client
public FilterManager(CanvasGroup filterPreview, CanvasGroup mainBg) public FilterManager(CanvasGroup filterPreview, CanvasGroup mainBg)
{ {
#if UNITY_PSP2 loadFilters();
m_filters = new List<Filter>();
m_filterRomSetting = new FilterRomSetting();
m_previewFilterWraper = new AlphaWraper(mainBg, filterPreview, false);
return;
#endif
m_filters = new List<Filter>
{
new Filter(new FixingPixelArtGrille()),
new Filter(new LCDPostEffect()),
new Filter(new MattiasCRT()),
};
var json = PlayerPrefs.GetString(nameof(FilterRomSetting)); var json = PlayerPrefs.GetString(nameof(FilterRomSetting));
m_filterRomSetting = JsonUtility.FromJson<FilterRomSetting>(json) ?? new FilterRomSetting(); m_filterRomSetting = JsonUtility.FromJson<FilterRomSetting>(json) ?? new FilterRomSetting();
@ -41,6 +30,23 @@ namespace AxibugEmuOnline.Client
ShutDownFilter(); ShutDownFilter();
} }
private void loadFilters()
{
m_filters = new List<Filter>();
var effectBaseType = typeof(FilterEffect);
foreach (var type in effectBaseType.Assembly.GetTypes())
{
if (type.IsAbstract) continue;
if (type.IsInterface) continue;
if (!effectBaseType.IsAssignableFrom(type)) continue;
var stripAtt = type.GetCustomAttribute<StripAttribute>();
if (stripAtt != null && stripAtt.NeedStrip) continue;
var effect = Activator.CreateInstance(type) as FilterEffect;
m_filters.Add(new Filter(effect));
}
}
private RenderTexture result = null; private RenderTexture result = null;
public Texture ExecuteFilterRender(Texture src) public Texture ExecuteFilterRender(Texture src)
{ {

View File

@ -2,6 +2,7 @@
using AxibugEmuOnline.Client; using AxibugEmuOnline.Client;
using UnityEngine; using UnityEngine;
[Strip(RuntimePlatform.PSP2)]
public sealed class FixingPixelArtGrille : FilterEffect public sealed class FixingPixelArtGrille : FilterEffect
{ {
public override string Name => nameof(FixingPixelArtGrille); public override string Name => nameof(FixingPixelArtGrille);

View File

@ -17,7 +17,6 @@ Shader "Filter/MattiasCRT"
#include "UnityCG.cginc" #include "UnityCG.cginc"
sampler2D _MainTex; sampler2D _MainTex;
float4 _MainTex_TexelSize;
float2 _iResolution; float2 _iResolution;
float2 curve(float2 uv) float2 curve(float2 uv)

View File

@ -0,0 +1,70 @@
using Assets.Script.AppMain.Filter;
using AxibugEmuOnline.Client;
using UnityEngine;
using UnityEngine.Rendering;
[Strip(RuntimePlatform.PSP2)]
public class RetroArchMattiasCRTGlow : FilterEffect
{
public override string Name => nameof(RetroArchMattiasCRTGlow);
protected override string ShaderName => "Filter/RetroArch/MattiasCRTWithGlow";
[Range(0.02f, 20f)]
public FloatParameter InputGamma = new FloatParameter(11);
[Range(0.02f, 1f)]
public FloatParameter GaussianWidth = new FloatParameter(0.4f);
[Range(0.02f, 1f)]
public FloatParameter ColorBoost = new FloatParameter(0.4f);
[Range(0.02f, 1f)]
public FloatParameter GlowWhitePoint = new FloatParameter(0.4f);
[Range(0.1f, 6f)]
public FloatParameter GlowRolloff = new FloatParameter(2.2f);
[Range(0.05f, 0.8f)]
public FloatParameter GlowStrength = new FloatParameter(0.45f);
[Range(0.02f, 2.6f)]
public FloatParameter MonitorGamma = new FloatParameter(2.2f);
int m_gamma_ID = Shader.PropertyToID("_gamma");
int m_horiz_gauss_width_ID = Shader.PropertyToID("_horiz_gauss_width");
int m_BOOST_ID = Shader.PropertyToID("_BOOST");
int m_GLOW_WHITEPOINT_ID = Shader.PropertyToID("_GLOW_WHITEPOINT");
int m_GLOW_ROLLOFF_ID = Shader.PropertyToID("_GLOW_ROLLOFF");
int m_BLOOM_STRENGTH_ID = Shader.PropertyToID("_BLOOM_STRENGTH");
int m_OUTPUT_GAMMA_ID = Shader.PropertyToID("_OUTPUT_GAMMA");
CommandBuffer m_multipPassCmd;
int m_wrapRT;
protected override void OnInit(Material renderMat)
{
m_multipPassCmd = new CommandBuffer();
m_wrapRT = Shader.PropertyToID($"{Name}.WrapRT");
}
protected override void OnRenderer(Material renderMat, Texture src, RenderTexture result)
{
m_multipPassCmd.Clear();
m_multipPassCmd.GetTemporaryRT(m_wrapRT, result.width, result.height);
renderMat.SetVector("_iResolution", new Vector2(result.width, result.height));
renderMat.SetFloat(m_gamma_ID, InputGamma.GetValue());
renderMat.SetFloat(m_horiz_gauss_width_ID, GaussianWidth.GetValue());
renderMat.SetFloat(m_BOOST_ID, ColorBoost.GetValue());
renderMat.SetFloat(m_GLOW_WHITEPOINT_ID, GlowWhitePoint.GetValue());
renderMat.SetFloat(m_GLOW_ROLLOFF_ID, GlowRolloff.GetValue());
renderMat.SetFloat(m_BLOOM_STRENGTH_ID, GlowStrength.GetValue());
renderMat.SetFloat(m_OUTPUT_GAMMA_ID, MonitorGamma.GetValue());
m_multipPassCmd.Blit(src, result);
for (int i = 0; i < renderMat.shader.passCount; i++)
{
m_multipPassCmd.Blit(result, m_wrapRT, renderMat, i);
m_multipPassCmd.Blit(m_wrapRT, result);
}
m_multipPassCmd.ReleaseTemporaryRT(m_wrapRT);
Graphics.ExecuteCommandBuffer(m_multipPassCmd);
}
}

View File

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

View File

@ -23,64 +23,19 @@ Material:
m_SavedProperties: m_SavedProperties:
serializedVersion: 3 serializedVersion: 3
m_TexEnvs: m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex: - _MainTex:
m_Texture: {fileID: 0} m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1} m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0} m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: [] m_Ints: []
m_Floats: m_Floats:
- _BumpScale: 1 - _BLOOM_STRENGTH: 0.45
- _Cutoff: 0.5 - _BOOST: 0.4
- _DetailNormalMapScale: 1 - _GLOW_ROLLOFF: 2.2
- _DstBlend: 0 - _GLOW_WHITEPOINT: 0.4
- _GlossMapScale: 1 - _OUTPUT_GAMMA: 2.2
- _Glossiness: 0.5 - _gamma: 11
- _GlossyReflections: 1 - _horiz_gauss_width: 0.4
- _Metallic: 0 m_Colors: []
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
- _gamma: 2.24
- _horiz_gauss_width: 1.89
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: [] m_BuildTextureStacks: []
m_AllowLocking: 1 m_AllowLocking: 1

View File

@ -1,13 +1,13 @@
Shader "Filter/RetroArch/Glow" Shader "Filter/RetroArch/MattiasCRTWithGlow"
{ {
Properties Properties
{ {
_MainTex ("Texture", 2D) = "white" _MainTex ("Texture", 2D) = "white"
_gamma("Input Gamma option: 2.4/2.0/2.6/0.02",float) = 2.4 _gamma("Input Gamma option: 2.4/2.0/2.6/0.02",float) = 11
_horiz_gauss_width("Gaussian Width option: 0.5/0.4/0.6/0.02",float) = 0.5 _horiz_gauss_width("Gaussian Width option: 0.5/0.4/0.6/0.02",float) = 0.4
_BOOST("Color Boost option: 1.0/0.5/1.5/0.02",float) = 1.0 _BOOST("Color Boost option: 1.0/0.5/1.5/0.02",float) = 0.4
_GLOW_WHITEPOINT("Glow Whitepoint option: 1.0/0.5/1.1/0.02",float) = 1.0 _GLOW_WHITEPOINT("Glow Whitepoint option: 1.0/0.5/1.1/0.02",float) = 0.4
_GLOW_ROLLOFF("Glow Rolloff option: 3.0 1.2 6.0 0.1",float) = 3.0 _GLOW_ROLLOFF("Glow Rolloff option: 3.0 1.2 6.0 0.1",float) = 2.2
_BLOOM_STRENGTH("Glow Strength option: 0.45/0.0/0.8/0.05",float) = 0.45 _BLOOM_STRENGTH("Glow Strength option: 0.45/0.0/0.8/0.05",float) = 0.45
_OUTPUT_GAMMA("Monitor Gamma option: 2.2/1.8/2.6/0.02",float) = 2.2 _OUTPUT_GAMMA("Monitor Gamma option: 2.2/1.8/2.6/0.02",float) = 2.2
} }
@ -43,6 +43,93 @@
ENDCG ENDCG
} }
Pass
{
Name "MattiasCRT"
CGPROGRAM
#include "UnityCG.cginc"
#pragma vertex vert_img
#pragma fragment frag
sampler2D _MainTex;
float2 _iResolution;
struct v2f
{
float4 pos : POSITION;
float2 uv : TEXCOORD0;
};
float2 curve(float2 uv)
{
uv = (uv - 0.5) * 2.0;
uv *= 1.1;
uv.x *= 1.0 + pow((abs(uv.y) / 5.0), 2.0);
uv.y *= 1.0 + pow((abs(uv.x) / 4.0), 2.0);
uv = (uv / 2.0) + 0.5;
uv = uv *0.92 + 0.04;
return uv;
}
float4 mainImage( float2 fragCoord )
{
float4 fragColor = float4(0,0,0,1);
float2 q = fragCoord.xy / _iResolution.xy;
float2 uv = q;
uv = curve( uv );
float x = sin(0.3*_Time+uv.y*21.0)*sin(0.7*_Time+uv.y*29.0)*sin(0.3+0.33*_Time+uv.y*31.0)*0.0017;
float3 col;
col.r = tex2D(_MainTex,float2(x+uv.x+0.001,uv.y+0.001)).x+0.05;
col.g = tex2D(_MainTex,float2(x+uv.x+0.000,uv.y-0.002)).y+0.05;
col.b = tex2D(_MainTex,float2(x+uv.x-0.002,uv.y+0.000)).z+0.05;
col.r += 0.08*tex2D(_MainTex,0.75*float2(x+0.025, -0.027)+float2(uv.x+0.001,uv.y+0.001)).x;
col.b += 0.08*tex2D(_MainTex,0.75*float2(x+-0.02, -0.018)+float2(uv.x-0.002,uv.y+0.000)).z;
col.g += 0.05*tex2D(_MainTex,0.75*float2(x+-0.022, -0.02)+float2(uv.x+0.000,uv.y-0.002)).y;
col = clamp(col*0.6+0.4*col*col*1.0,0.0,1.0);
float vig = (0.0 + 1.0*16.0*uv.x*uv.y*(1.0-uv.x)*(1.0-uv.y));
col *= pow(vig,0.3);
col *= float3(0.95,1.05,0.95);
col *= 2.8;
float scans = clamp( 0.35+0.35*sin(3.5*_Time+uv.y*_iResolution.y*1.5), 0.0, 1.0);
float s = pow(scans,1.7);
col = col*( 0.4+0.7*s) ;
col *= 1.0+0.01*sin(110.0*_Time);
if (uv.x < 0.0 || uv.x > 1.0)
col *= 0.0;
if (uv.y < 0.0 || uv.y > 1.0)
col *= 0.0;
col*=1.0-0.65*clamp((fragCoord.x % 2.0 -1.0 )*2.0,0.0,1.0);
float comp = smoothstep( 0.1, 0.9, sin(_Time) );
fragColor = float4(col,1.0);
return fragColor;
}
fixed4 frag(v2f i) : SV_Target
{
float2 pos = _iResolution.xy*i.uv;
fixed4 col = mainImage(pos);
return col;
}
ENDCG
}
Pass Pass
{ {
Name "gauss_horiz" Name "gauss_horiz"

View File

@ -22,16 +22,20 @@ namespace AxibugEmuOnline.Client
private void OnSliderValueChanged(float value) private void OnSliderValueChanged(float value)
{ {
txt_value.text = $"{value:.00}"; txt_value.text = $"{value:.00}";
m_valueMenu.OnValueChanged(value);
if (!m_dataSetting) m_valueMenu.OnValueChanged(value);
} }
bool m_dataSetting;
public void SetData(ValueSetMenu valueMenu) public void SetData(ValueSetMenu valueMenu)
{ {
m_dataSetting = true;
m_valueMenu = valueMenu; m_valueMenu = valueMenu;
slider.minValue = (float)valueMenu.Min; slider.minValue = (float)valueMenu.Min;
slider.maxValue = (float)valueMenu.Max; slider.maxValue = (float)valueMenu.Max;
slider.value = (float)valueMenu.ValueRaw; slider.value = (float)valueMenu.ValueRaw;
m_step = (slider.maxValue - slider.minValue) * 0.05f; m_step = (slider.maxValue - slider.minValue) * 0.05f;
m_dataSetting = false;
} }
public void OnLeft() public void OnLeft()