diff --git a/AxibugEmuOnline.Client/Assets/Scene/AxibugEmuOnline.Client.unity b/AxibugEmuOnline.Client/Assets/Scene/AxibugEmuOnline.Client.unity index 2da0c26..e6a5bc7 100644 --- a/AxibugEmuOnline.Client/Assets/Scene/AxibugEmuOnline.Client.unity +++ b/AxibugEmuOnline.Client/Assets/Scene/AxibugEmuOnline.Client.unity @@ -150,25 +150,16 @@ MonoBehaviour: m_GameObject: {fileID: 74796456} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3} + m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3} m_Name: m_EditorClassIdentifier: - m_MoveRepeatDelay: 0.5 - m_MoveRepeatRate: 0.1 - m_XRTrackingOrigin: {fileID: 0} - m_ActionsAsset: {fileID: -944628639613478452, guid: eb413fd14a8483440af9652b7e4df5e1, type: 3} - m_PointAction: {fileID: 0} - m_MoveAction: {fileID: 0} - m_SubmitAction: {fileID: 0} - m_CancelAction: {fileID: 0} - m_LeftClickAction: {fileID: 0} - m_MiddleClickAction: {fileID: 0} - m_RightClickAction: {fileID: 0} - m_ScrollWheelAction: {fileID: 0} - m_TrackedDevicePositionAction: {fileID: 0} - m_TrackedDeviceOrientationAction: {fileID: 0} - m_DeselectOnBackgroundClick: 1 - m_PointerBehavior: 0 + m_HorizontalAxis: Horizontal + m_VerticalAxis: Vertical + m_SubmitButton: Submit + m_CancelButton: Cancel + m_InputActionsPerSecond: 10 + m_RepeatDelay: 0.5 + m_ForceModuleActive: 0 --- !u!114 &74796458 MonoBehaviour: m_ObjectHideFlags: 0 @@ -2508,7 +2499,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 1639091784002085428, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3} propertyPath: m_RootOrder - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 1639091784002085428, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3} propertyPath: m_AnchorMax.x @@ -13451,8 +13442,8 @@ GameObject: m_Component: - component: {fileID: 1475480929} - component: {fileID: 1475480931} - - component: {fileID: 1475480930} - component: {fileID: 1475480932} + - component: {fileID: 1475480930} m_Layer: 5 m_Name: GameCamera m_TagString: MainCamera @@ -13847,7 +13838,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 1963501579241001456, guid: 334eee9f85f308347844f8f5e99167c3, type: 3} propertyPath: m_RootOrder - value: 3 + value: 2 objectReference: {fileID: 0} - target: {fileID: 1963501579241001456, guid: 334eee9f85f308347844f8f5e99167c3, type: 3} propertyPath: m_AnchorMax.x @@ -13956,7 +13947,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3531919739338806919, guid: 1de15a80c8c1aa94486563740a15d91c, type: 3} propertyPath: m_RootOrder - value: 4 + value: 3 objectReference: {fileID: 0} - target: {fileID: 3531919739338806919, guid: 1de15a80c8c1aa94486563740a15d91c, type: 3} propertyPath: m_AnchorMax.x @@ -14109,7 +14100,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 4478785627166277610, guid: d3c2508a55398a24db5d68f68d2702ea, type: 3} propertyPath: m_RootOrder - value: 2 + value: 1 objectReference: {fileID: 0} - target: {fileID: 4478785627166277610, guid: d3c2508a55398a24db5d68f68d2702ea, type: 3} propertyPath: m_AnchorMax.x diff --git a/AxibugEmuOnline.Client/Assets/Script/Filter/FixingPixelArtGrille.cs b/AxibugEmuOnline.Client/Assets/Script/Filter/FixingPixelArtGrille.cs index c82008c..f8bfb13 100644 --- a/AxibugEmuOnline.Client/Assets/Script/Filter/FixingPixelArtGrille.cs +++ b/AxibugEmuOnline.Client/Assets/Script/Filter/FixingPixelArtGrille.cs @@ -1,3 +1,5 @@ +using AxibugEmuOnline.Client; +using AxibugEmuOnline.Client.ClientCore; using UnityEngine; using UnityEngine.Rendering.PostProcessing; @@ -5,7 +7,51 @@ using UnityEngine.Rendering.PostProcessing; [PostProcess(typeof(FixingPixelArtGrilleRenderer), PostProcessEvent.BeforeStack, "Filter/FixingPixelArtGrille")] public sealed class FixingPixelArtGrille : PostProcessEffectSettings { - // 在这里可以添加效果的参数 + public ParameterOverride MaskStyle = new ParameterOverride { value = EnumMaskStyle.ApertureGrille }; + + [Tooltip("Emulated input resolution\nOptimize for resize")] + public Vector2Parameter DrawResolution = new Vector2Parameter + { + value = new Vector2(272, 240) + }; + + [Tooltip("Hardness of scanline")] + [Range(-32, 0)] + public FloatParameter HardScan = new FloatParameter { value = -10 }; + + [Tooltip("Hardness of pixels in scanline")] + [Range(-6, 0)] + public FloatParameter HardPix = new FloatParameter { value = -2 }; + + [Tooltip("Hardness of short vertical bloom")] + [Range(-8, 0)] + public FloatParameter HardBloomScan = new FloatParameter { value = -4.0f }; + + [Tooltip("Hardness of short horizontal bloom")] + [Range(-4, 0)] + public FloatParameter HardBloomPix = new FloatParameter { value = -1.5f }; + + [Tooltip("Amount of small bloom effect")] + [Range(0, 1)] + public FloatParameter BloomAmount = new FloatParameter { value = 1 / 16f }; + + [Tooltip("Display warp")] + public Vector2Parameter Warp = new Vector2Parameter { value = new Vector2(1f / 64f, 1f / 24f) }; + + [Tooltip("Amount of shadow mask Light")] + [Range(1, 3)] + public FloatParameter MaskLight = new FloatParameter { value = 1.5f }; + [Range(0.1f, 1)] + [Tooltip("Amount of shadow mask Dark")] + public FloatParameter MaskDrak = new FloatParameter { value = 0.5f }; + + public enum EnumMaskStyle + { + TVStyle, + ApertureGrille, + StretchedVGA, + VGAStyle + } } public sealed class FixingPixelArtGrilleRenderer : PostProcessEffectRenderer @@ -21,6 +67,39 @@ public sealed class FixingPixelArtGrilleRenderer : PostProcessEffectRenderer0.5)return float3(0.0,0.0,0.0); return Test(ToLinear(tex2D(_MainTex,pos.xy).rgb));} // Distance in emulated pixels to nearest texel. -float2 Dist(float2 pos){pos=pos*res;return -((pos-floor(pos))-float2(0.5,0.5));} +float2 Dist(float2 pos){pos=pos*_res;return -((pos-floor(pos))-float2(0.5,0.5));} // 1D Gaussian. float Gaus(float pos,float scale){return exp2(scale*pos*pos);} @@ -120,7 +116,7 @@ float3 Horz3(float2 pos,float off){ float3 d=Fetch(pos,float2( 1.0,off)); float dst=Dist(pos).x; // Convert distance to weight. - float scale=hardPix; + float scale=_hardPix; float wb=Gaus(dst-1.0,scale); float wc=Gaus(dst+0.0,scale); float wd=Gaus(dst+1.0,scale); @@ -136,7 +132,7 @@ float3 Horz5(float2 pos,float off){ float3 e=Fetch(pos,float2( 2.0,off)); float dst=Dist(pos).x; // Convert distance to weight. - float scale=hardPix; + float scale=_hardPix; float wa=Gaus(dst-2.0,scale); float wb=Gaus(dst-1.0,scale); float wc=Gaus(dst+0.0,scale); @@ -156,7 +152,7 @@ float3 Horz7(float2 pos,float off){ float3 g=Fetch(pos,float2( 3.0,off)); float dst=Dist(pos).x; // Convert distance to weight. - float scale=hardBloomPix; + float scale=_hardBloomPix; float wa=Gaus(dst-3.0,scale); float wb=Gaus(dst-2.0,scale); float wc=Gaus(dst-1.0,scale); @@ -170,12 +166,12 @@ float3 Horz7(float2 pos,float off){ // Return scanline weight. float Scan(float2 pos,float off){ float dst=Dist(pos).y; - return Gaus(dst+off,hardScan);} + return Gaus(dst+off,_hardScan);} // Return scanline weight for bloom. float BloomScan(float2 pos,float off){ float dst=Dist(pos).y; - return Gaus(dst+off,hardBloomScan);} + return Gaus(dst+off,_hardBloomScan);} // Allow nearest three lines to effect pixel. float3 Tri(float2 pos){ @@ -205,62 +201,58 @@ float3 Bloom(float2 pos){ float2 Warp(float2 pos){ pos=pos*2.0-1.0; - pos*=float2(1.0+(pos.y*pos.y)*warp.x,1.0+(pos.x*pos.x)*warp.y); + pos*=float2(1.0+(pos.y*pos.y)*_warp.x,1.0+(pos.x*pos.x)*_warp.y); return pos*0.5+0.5;} - -#if 0 -// Very compressed TV style shadow mask. -float3 Mask(float2 pos){ - float line=maskLight; - float odd=0.0; - if(fract(pos.x/6.0)<0.5)odd=1.0; - if(fract((pos.y+odd)/2.0)<0.5)line=maskDark; - pos.x=fract(pos.x/3.0); - float3 mask=float3(maskDark,maskDark,maskDark); - if(pos.x<0.333)mask.r=maskLight; - else if(pos.x<0.666)mask.g=maskLight; - else mask.b=maskLight; - mask*=line; - return mask;} -#endif - -#if 1 -// Aperture-grille. -float3 Mask(float2 pos){ - pos.x=fract(pos.x/3.0); - float3 mask=float3(maskDark,maskDark,maskDark); - if(pos.x<0.333)mask.r=maskLight; - else if(pos.x<0.666)mask.g=maskLight; - else mask.b=maskLight; - return mask;} -#endif - -#if 0 -// Stretched VGA style shadow mask (same as prior shaders). -float3 Mask(float2 pos){ - pos.x+=pos.y*3.0; - float3 mask=float3(maskDark,maskDark,maskDark); - pos.x=fract(pos.x/6.0); - if(pos.x<0.333)mask.r=maskLight; - else if(pos.x<0.666)mask.g=maskLight; - else mask.b=maskLight; - return mask;} -#endif - -#if 0 + +#if defined(_MASKSTYLE_TVSTYLE) + // Very compressed TV style shadow mask. + float3 Mask(float2 pos){ + float lineee=_maskLight; + float odd=0.0; + if(fract(pos.x/6.0)<0.5)odd=1.0; + if(fract((pos.y+odd)/2.0)<0.5) lineee=_maskDark; + pos.x=fract(pos.x/3.0); + float3 mask=float3(_maskDark,_maskDark,_maskDark); + if(pos.x<0.333)mask.r=_maskLight; + else if(pos.x<0.666)mask.g=_maskLight; + else mask.b=_maskLight; + mask*=lineee; + return mask; + } +#elif defined(_MASKSTYLE_APERTUREGRILLE) + // Aperture-grille. + float3 Mask(float2 pos){ + pos.x=fract(pos.x/3.0); + float3 mask=float3(_maskDark,_maskDark,_maskDark); + if(pos.x<0.333)mask.r=_maskLight; + else if(pos.x<0.666)mask.g=_maskLight; + else mask.b=_maskLight; + return mask;} +#elif defined(_MASKSTYLE_STRETCHEDVGA) + // Stretched VGA style shadow mask (same as prior shaders). + float3 Mask(float2 pos){ + pos.x+=pos.y*3.0; + float3 mask=float3(_maskDark,_maskDark,_maskDark); + pos.x=fract(pos.x/6.0); + if(pos.x<0.333)mask.r=_maskLight; + else if(pos.x<0.666)mask.g=_maskLight; + else mask.b=_maskLight; + return mask;} +#elif defined(_MASKSTYLE_VGASTYLE) // VGA style shadow mask. float3 Mask(float2 pos){ pos.xy=floor(pos.xy*float2(1.0,0.5)); pos.x+=pos.y*3.0; - float3 mask=float3(maskDark,maskDark,maskDark); + float3 mask=float3(_maskDark,_maskDark,_maskDark); pos.x=fract(pos.x/6.0); - if(pos.x<0.333)mask.r=maskLight; - else if(pos.x<0.666)mask.g=maskLight; - else mask.b=maskLight; - return mask;} + if(pos.x<0.333)mask.r=_maskLight; + else if(pos.x<0.666)mask.g=_maskLight; + else mask.b=_maskLight; + return mask;} #endif + // Draw dividing bars. float Bar(float pos,float bar){pos-=bar;return pos*pos<4.0?0.0:1.0;} @@ -268,11 +260,11 @@ float Bar(float pos,float bar){pos-=bar;return pos*pos<4.0?0.0:1.0;} float4 mainImage(float2 fragCoord){ float4 fragColor = float4(1,1,1,1); -float2 pos=Warp(fragCoord.xy/iResolution.xy); +float2 pos=Warp(fragCoord.xy/_iResolution.xy); fragColor.rgb=Tri(pos)*Mask(fragCoord.xy); - fragColor.rgb+=Bloom(pos)*bloomAmount; + fragColor.rgb+=Bloom(pos)*_bloomAmount; fragColor.a=1.0; fragColor.rgb=ToSrgb(fragColor.rgb); @@ -288,7 +280,7 @@ float2 pos=Warp(fragCoord.xy/iResolution.xy); fixed4 frag (v2f i) : SV_Target { - float2 pos = iResolution.xy*i.uv; + float2 pos = _iResolution.xy*i.uv; fixed4 col = mainImage(pos); return col; } diff --git a/AxibugEmuOnline.Client/Assets/Script/Filter/GameCamera Profile.asset b/AxibugEmuOnline.Client/Assets/Script/Filter/GameCamera Profile.asset index 4c7223e..f62c966 100644 --- a/AxibugEmuOnline.Client/Assets/Script/Filter/GameCamera Profile.asset +++ b/AxibugEmuOnline.Client/Assets/Script/Filter/GameCamera Profile.asset @@ -1,6 +1,20 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: ---- !u!114 &-3536514882628332180 +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 8e6292b2c06870d4495f009f912b9600, type: 3} + m_Name: GameCamera Profile + m_EditorClassIdentifier: + settings: + - {fileID: 8004032914748422304} +--- !u!114 &8004032914748422304 MonoBehaviour: m_ObjectHideFlags: 3 m_CorrespondingSourceObject: {fileID: 0} @@ -16,17 +30,33 @@ MonoBehaviour: enabled: overrideState: 1 value: 1 ---- !u!114 &11400000 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 8e6292b2c06870d4495f009f912b9600, type: 3} - m_Name: GameCamera Profile - m_EditorClassIdentifier: - settings: - - {fileID: -3536514882628332180} + MaskStyle: + overrideState: 0 + value: 3 + DrawResolution: + overrideState: 0 + value: {x: 272, y: 240} + HardScan: + overrideState: 0 + value: -10 + HardPix: + overrideState: 0 + value: -2 + HardBloomScan: + overrideState: 0 + value: -4.06 + HardBloomPix: + overrideState: 0 + value: -1.15 + BloomAmount: + overrideState: 0 + value: 0.483 + Warp: + overrideState: 0 + value: {x: 0.12, y: 0.04} + MaskLight: + overrideState: 0 + value: 3 + MaskDrak: + overrideState: 0 + value: 0.1 diff --git a/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesControllerMapper.cs b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesControllerMapper.cs index 7c055b8..a7a5c16 100644 --- a/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesControllerMapper.cs +++ b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesControllerMapper.cs @@ -98,7 +98,6 @@ namespace AxibugEmuOnline.Client public static IKeyListener GetKey(int controllerInput, EnumButtonType nesConBtnType) { string configKey = $"NES_{controllerInput}_{nesConBtnType}"; - if (PlayerPrefs.HasKey(configKey)) { return new KeyListener(PlayerPrefs.GetString(configKey)); diff --git a/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.cs b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.cs index fa78912..aff4956 100644 --- a/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.cs +++ b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.cs @@ -199,6 +199,7 @@ namespace AxibugEmuOnline.Client UnityEditor.EditorUtility.SetDirty(db); UnityEditor.AssetDatabase.SaveAssets(); } + #endif } }