diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterEffect.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterEffect.cs index c00f2b3..9ec1ef0 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterEffect.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterEffect.cs @@ -48,13 +48,13 @@ namespace AxibugEmuOnline.Client } } - public void Render(RenderTexture rt, RenderTexture result) + public void Render(Texture src, RenderTexture result) { - m_material.SetTexture("_MainTex", rt); - OnRenderer(m_material, rt, result); + m_material.SetTexture("_MainTex", src); + OnRenderer(m_material, src, result); } - protected abstract void OnRenderer(Material renderMat, RenderTexture rt, RenderTexture result); + protected abstract void OnRenderer(Material renderMat, Texture src, RenderTexture result); public class EditableParamerter { diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterManager.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterManager.cs index 92d5a81..03a6b8a 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterManager.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterManager.cs @@ -38,7 +38,7 @@ namespace AxibugEmuOnline.Client } private RenderTexture result = null; - public RenderTexture ExecuteFilterRender(RenderTexture rt) + public Texture ExecuteFilterRender(Texture src) { if (result == null) result = RenderTexture.GetTemporary(Screen.width, Screen.height); @@ -47,14 +47,14 @@ namespace AxibugEmuOnline.Client foreach (var filter in Filters) { if (!filter.m_setting.Enable.GetValue()) continue; - filter.m_setting.Render(rt, result); + filter.m_setting.Render(src, result); anyFilterEnable = true; } if (anyFilterEnable) return result; else - return rt; + return src; } /// 关闭滤镜预览 diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FixingPixelArtGrille/FixingPixelArtGrille.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FixingPixelArtGrille/FixingPixelArtGrille.cs index df690a3..999267e 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FixingPixelArtGrille/FixingPixelArtGrille.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FixingPixelArtGrille/FixingPixelArtGrille.cs @@ -34,7 +34,7 @@ public sealed class FixingPixelArtGrille : FilterEffect } - protected override void OnRenderer(Material renderMat, RenderTexture rt, RenderTexture result) + protected override void OnRenderer(Material renderMat, Texture src, RenderTexture result) { renderMat.SetVector("_iResolution", new Vector4(result.width, result.height, 0, 0)); renderMat.SetVector("_res", new Vector4(DrawResolution.GetValue().x, DrawResolution.GetValue().y, 0, 0)); @@ -67,6 +67,6 @@ public sealed class FixingPixelArtGrille : FilterEffect renderMat.EnableKeyword("_MASKSTYLE_STRETCHEDVGA"); break; } - Graphics.Blit(rt, result, renderMat); + Graphics.Blit(src, result, renderMat); } } \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/LCDPostEffect/LCDPostEffect.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/LCDPostEffect/LCDPostEffect.cs index 94b1d78..f8ccca3 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/LCDPostEffect/LCDPostEffect.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/LCDPostEffect/LCDPostEffect.cs @@ -7,9 +7,9 @@ public sealed class LCDPostEffect : FilterEffect protected override string ShaderName => "Filter/LCDPostEffect"; - protected override void OnRenderer(Material renderMat, RenderTexture rt, RenderTexture result) + protected override void OnRenderer(Material renderMat, Texture src, RenderTexture result) { renderMat.SetVector("_iResolution", new Vector4(Screen.width, Screen.height, 0, 0)); - Graphics.Blit(rt, result, renderMat); + Graphics.Blit(src, result, renderMat); } } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/MattiasCRT/MattiasCRT.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/MattiasCRT/MattiasCRT.cs index 01716dc..6e6c79d 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/MattiasCRT/MattiasCRT.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/MattiasCRT/MattiasCRT.cs @@ -1,4 +1,4 @@ -using AxibugEmuOnline.Client; +using AxibugEmuOnline.Client; using UnityEngine; public sealed class MattiasCRT : FilterEffect @@ -7,9 +7,9 @@ public sealed class MattiasCRT : FilterEffect protected override string ShaderName => "Filter/MattiasCRT"; - protected override void OnRenderer(Material renderMat, RenderTexture rt, RenderTexture result) + protected override void OnRenderer(Material renderMat, Texture src, RenderTexture result) { renderMat.SetVector("_iResolution", new Vector4(result.width, result.height, 0, 0)); - Graphics.Blit(rt, result, renderMat); + Graphics.Blit(src, result, renderMat); } } \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/NesEmulator/VideoProvider.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/NesEmulator/VideoProvider.cs index 431270b..680a3d1 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/NesEmulator/VideoProvider.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/NesEmulator/VideoProvider.cs @@ -1,4 +1,4 @@ -using AxibugEmuOnline.Client.ClientCore; +using AxibugEmuOnline.Client.ClientCore; using System; using System.Runtime.InteropServices; using UnityEngine; @@ -16,13 +16,13 @@ namespace AxibugEmuOnline.Client #endregion #region GPU_TURBO - //ͼֽ + //图像数据字节数 private int TexBufferSize_gpu; - //ͼָ + //图像数据指针 private IntPtr wrapTexBufferPointer_gpu; - //Unity 2D,UIϻ + //Unity 2D纹理对象,用于UI上绘制最终输出画面 private Texture2D wrapTex_gpu; - //nesɫ,תΪunity + //nes调色板数据,已转换为unity纹理对象 private Texture2D pPal_gpu; [SerializeField] private Material GPUTurboMat_gpu; @@ -30,12 +30,12 @@ namespace AxibugEmuOnline.Client #endregion #region CPU - //ͼֽ + //图像数据字节数 private int TexBufferSize_cpu; - //ͼָ + //图像数据指针 private GCHandle wrapTexBufferGH; private IntPtr wrapTexBufferPointer_cpu; - //Unity 2D,UIϻ + //Unity 2D纹理对象,用于UI上绘制最终输出画面 private Texture2D wrapTex_cpu; #endregion @@ -61,8 +61,8 @@ namespace AxibugEmuOnline.Client public unsafe void SetDrawData(uint* screenData) { PrepareUI(screenData); - if (GPUTurbo) PrepareForGPU(screenData);//жʹGPUCPU - else PrepareForCPU(screenData);//ʹCPU + if (GPUTurbo) PrepareForGPU(screenData);//判断使用GPU还是CPU + else PrepareForCPU(screenData);//使用CPU if (GPUTurbo) { @@ -155,7 +155,7 @@ namespace AxibugEmuOnline.Client for (int line = 0; line < PPU.SCREEN_HEIGHT; line++) { - //PSCPU㣬ȼ16IJҪ֣ܶ + //PS:如果是CPU计算,宽度减少16的不必要部分,才能对齐 width = PPU.SCREEN_WIDTH - 16; while (width > 0) @@ -163,17 +163,17 @@ namespace AxibugEmuOnline.Client var edx = screenData[pScn + 8]; uint index = edx & 0xFF; - //±ɫұʵɫ + //按下标颜色查找表中真实颜色 var colorData = palRaw[index]; - //dstɫΪabgr,colorDataΪargb - uint r = (colorData & 0x00FF0000) >> 16; // ȡRedͨ - uint g = (colorData & 0x0000FF00) >> 8; // ȡGreenͨ - uint b = (colorData & 0x000000FF); // ȡBlueͨ + //dst中颜色排列为abgr,而colorData排列为argb + uint r = (colorData & 0x00FF0000) >> 16; // 提取Red通道 + uint g = (colorData & 0x0000FF00) >> 8; // 提取Green通道 + uint b = (colorData & 0x000000FF); // 提取Blue通道 - //rgbɫunity rgb System.Drawing.Color ɫ + //用rgb构建颜色对象(如果非unity 可以用这个rgb 构建System.Drawing.Color 单个颜色对象) uint abgr = 0xFF000000 | (b << 16) | (g << 8) | (r << 0); - //Žɫ + //放进颜色矩阵 Dst[pDst] = abgr; pScn += 1;