滤镜机制参数修改,不再限制源纹理要求rendertexture类型
This commit is contained in:
parent
f129651e99
commit
91ca428269
@ -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);
|
m_material.SetTexture("_MainTex", src);
|
||||||
OnRenderer(m_material, rt, result);
|
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
|
public class EditableParamerter
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
}
|
}
|
||||||
|
|
||||||
private RenderTexture result = null;
|
private RenderTexture result = null;
|
||||||
public RenderTexture ExecuteFilterRender(RenderTexture rt)
|
public Texture ExecuteFilterRender(Texture src)
|
||||||
{
|
{
|
||||||
if (result == null)
|
if (result == null)
|
||||||
result = RenderTexture.GetTemporary(Screen.width, Screen.height);
|
result = RenderTexture.GetTemporary(Screen.width, Screen.height);
|
||||||
@ -47,14 +47,14 @@ namespace AxibugEmuOnline.Client
|
|||||||
foreach (var filter in Filters)
|
foreach (var filter in Filters)
|
||||||
{
|
{
|
||||||
if (!filter.m_setting.Enable.GetValue()) continue;
|
if (!filter.m_setting.Enable.GetValue()) continue;
|
||||||
filter.m_setting.Render(rt, result);
|
filter.m_setting.Render(src, result);
|
||||||
anyFilterEnable = true;
|
anyFilterEnable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (anyFilterEnable)
|
if (anyFilterEnable)
|
||||||
return result;
|
return result;
|
||||||
else
|
else
|
||||||
return rt;
|
return src;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> 关闭滤镜预览 </summary>
|
/// <summary> 关闭滤镜预览 </summary>
|
||||||
|
@ -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("_iResolution", new Vector4(result.width, result.height, 0, 0));
|
||||||
renderMat.SetVector("_res", new Vector4(DrawResolution.GetValue().x, DrawResolution.GetValue().y, 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");
|
renderMat.EnableKeyword("_MASKSTYLE_STRETCHEDVGA");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Graphics.Blit(rt, result, renderMat);
|
Graphics.Blit(src, result, renderMat);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,9 +7,9 @@ public sealed class LCDPostEffect : FilterEffect
|
|||||||
|
|
||||||
protected override string ShaderName => "Filter/LCDPostEffect";
|
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));
|
renderMat.SetVector("_iResolution", new Vector4(Screen.width, Screen.height, 0, 0));
|
||||||
Graphics.Blit(rt, result, renderMat);
|
Graphics.Blit(src, result, renderMat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using AxibugEmuOnline.Client;
|
using AxibugEmuOnline.Client;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public sealed class MattiasCRT : FilterEffect
|
public sealed class MattiasCRT : FilterEffect
|
||||||
@ -7,9 +7,9 @@ public sealed class MattiasCRT : FilterEffect
|
|||||||
|
|
||||||
protected override string ShaderName => "Filter/MattiasCRT";
|
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));
|
renderMat.SetVector("_iResolution", new Vector4(result.width, result.height, 0, 0));
|
||||||
Graphics.Blit(rt, result, renderMat);
|
Graphics.Blit(src, result, renderMat);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
using AxibugEmuOnline.Client.ClientCore;
|
using AxibugEmuOnline.Client.ClientCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -16,13 +16,13 @@ namespace AxibugEmuOnline.Client
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region GPU_TURBO
|
#region GPU_TURBO
|
||||||
//图像数据字节数
|
//图像数据字节数
|
||||||
private int TexBufferSize_gpu;
|
private int TexBufferSize_gpu;
|
||||||
//图像数据指针
|
//图像数据指针
|
||||||
private IntPtr wrapTexBufferPointer_gpu;
|
private IntPtr wrapTexBufferPointer_gpu;
|
||||||
//Unity 2D纹理对象,用于UI上绘制最终输出画面
|
//Unity 2D纹理对象,用于UI上绘制最终输出画面
|
||||||
private Texture2D wrapTex_gpu;
|
private Texture2D wrapTex_gpu;
|
||||||
//nes调色板数据,已转换为unity纹理对象
|
//nes调色板数据,已转换为unity纹理对象
|
||||||
private Texture2D pPal_gpu;
|
private Texture2D pPal_gpu;
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private Material GPUTurboMat_gpu;
|
private Material GPUTurboMat_gpu;
|
||||||
@ -30,12 +30,12 @@ namespace AxibugEmuOnline.Client
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region CPU
|
#region CPU
|
||||||
//图像数据字节数
|
//图像数据字节数
|
||||||
private int TexBufferSize_cpu;
|
private int TexBufferSize_cpu;
|
||||||
//图像数据指针
|
//图像数据指针
|
||||||
private GCHandle wrapTexBufferGH;
|
private GCHandle wrapTexBufferGH;
|
||||||
private IntPtr wrapTexBufferPointer_cpu;
|
private IntPtr wrapTexBufferPointer_cpu;
|
||||||
//Unity 2D纹理对象,用于UI上绘制最终输出画面
|
//Unity 2D纹理对象,用于UI上绘制最终输出画面
|
||||||
private Texture2D wrapTex_cpu;
|
private Texture2D wrapTex_cpu;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -61,8 +61,8 @@ namespace AxibugEmuOnline.Client
|
|||||||
public unsafe void SetDrawData(uint* screenData)
|
public unsafe void SetDrawData(uint* screenData)
|
||||||
{
|
{
|
||||||
PrepareUI(screenData);
|
PrepareUI(screenData);
|
||||||
if (GPUTurbo) PrepareForGPU(screenData);//判断使用GPU还是CPU
|
if (GPUTurbo) PrepareForGPU(screenData);//判断使用GPU还是CPU
|
||||||
else PrepareForCPU(screenData);//使用CPU
|
else PrepareForCPU(screenData);//使用CPU
|
||||||
|
|
||||||
if (GPUTurbo)
|
if (GPUTurbo)
|
||||||
{
|
{
|
||||||
@ -155,7 +155,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
for (int line = 0; line < PPU.SCREEN_HEIGHT; line++)
|
for (int line = 0; line < PPU.SCREEN_HEIGHT; line++)
|
||||||
{
|
{
|
||||||
//PS:如果是CPU计算,宽度减少16的不必要部分,才能对齐
|
//PS:如果是CPU计算,宽度减少16的不必要部分,才能对齐
|
||||||
width = PPU.SCREEN_WIDTH - 16;
|
width = PPU.SCREEN_WIDTH - 16;
|
||||||
|
|
||||||
while (width > 0)
|
while (width > 0)
|
||||||
@ -163,17 +163,17 @@ namespace AxibugEmuOnline.Client
|
|||||||
var edx = screenData[pScn + 8];
|
var edx = screenData[pScn + 8];
|
||||||
|
|
||||||
uint index = edx & 0xFF;
|
uint index = edx & 0xFF;
|
||||||
//按下标颜色查找表中真实颜色
|
//按下标颜色查找表中真实颜色
|
||||||
var colorData = palRaw[index];
|
var colorData = palRaw[index];
|
||||||
//dst中颜色排列为abgr,而colorData排列为argb
|
//dst中颜色排列为abgr,而colorData排列为argb
|
||||||
uint r = (colorData & 0x00FF0000) >> 16; // 提取Red通道
|
uint r = (colorData & 0x00FF0000) >> 16; // 提取Red通道
|
||||||
uint g = (colorData & 0x0000FF00) >> 8; // 提取Green通道
|
uint g = (colorData & 0x0000FF00) >> 8; // 提取Green通道
|
||||||
uint b = (colorData & 0x000000FF); // 提取Blue通道
|
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);
|
uint abgr = 0xFF000000 | (b << 16) | (g << 8) | (r << 0);
|
||||||
|
|
||||||
//放进颜色矩阵
|
//放进颜色矩阵
|
||||||
Dst[pDst] = abgr;
|
Dst[pDst] = abgr;
|
||||||
|
|
||||||
pScn += 1;
|
pScn += 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user