forked from sin365/AxibugEmuOnline
滤镜添加
This commit is contained in:
parent
eb2f5d268c
commit
412c9759df
AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppSettings/Filter
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5c1ebe19e88e8840b17582b45643281
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,106 @@
|
||||
using Assets.Script.AppMain.Filter;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxibugEmuOnline.Client.Filters
|
||||
{
|
||||
[Strip(RuntimePlatform.PSP2)]
|
||||
public class RLPRO_CRT : FilterEffect
|
||||
{
|
||||
public override string Name => nameof(RLPRO_CRT);
|
||||
protected override string ShaderName => null;
|
||||
|
||||
#region BleedPass_Param
|
||||
public FilterParameter<EnumBleedMode> BleedMode = new FilterParameter<EnumBleedMode>(EnumBleedMode.NTSCOld3Phase);
|
||||
[Range(0, 15)]
|
||||
public FloatParameter BleedAmount = new FloatParameter(1f);
|
||||
#endregion
|
||||
#region CRTAperture_Param
|
||||
[Range(0, 5)]
|
||||
public FloatParameter GlowHalation = new FloatParameter(0.1f);
|
||||
[Range(0, 2)]
|
||||
public FloatParameter GlowDifusion = new FloatParameter(0.05f);
|
||||
[Range(0, 2)]
|
||||
public FloatParameter MaskColors = new FloatParameter(2.0f);
|
||||
[Range(0, 1)]
|
||||
public FloatParameter MaskStrength = new FloatParameter(0.3f);
|
||||
[Range(0, 5)]
|
||||
public FloatParameter GammaInput = new FloatParameter(2.4f);
|
||||
[Range(0, 5)]
|
||||
public FloatParameter GammaOutput = new FloatParameter(2.4f);
|
||||
[Range(0, 2.5f)]
|
||||
public FloatParameter Brightness = new FloatParameter(1.5f);
|
||||
#endregion
|
||||
|
||||
Material m_bleedMat;
|
||||
Material m_crtApertureMat;
|
||||
Material m_tvEffectMat;
|
||||
|
||||
protected override void OnInit(Material renderMat)
|
||||
{
|
||||
m_bleedMat = new Material(Shader.Find("Filter/RLPro_Bleed"));
|
||||
m_crtApertureMat = new Material(Shader.Find("Filter/RLPro_CRT_Aperture"));
|
||||
}
|
||||
|
||||
protected override void OnRenderer(Material renderMat, Texture src, RenderTexture result)
|
||||
{
|
||||
var rt1 = BleedPass(src);
|
||||
var rt2 = CRT_AperturePass(rt1);
|
||||
|
||||
Graphics.Blit(rt2, result);
|
||||
|
||||
RenderTexture.ReleaseTemporary(rt1);
|
||||
RenderTexture.ReleaseTemporary(rt2);
|
||||
}
|
||||
|
||||
private RenderTexture BleedPass(Texture src)
|
||||
{
|
||||
var rt = RenderTexture.GetTemporary(src.width, src.height);
|
||||
|
||||
m_bleedMat.DisableKeyword("_NTSCOld3Phase");
|
||||
m_bleedMat.DisableKeyword("_NTSC3Phase");
|
||||
m_bleedMat.DisableKeyword("_NTSC2Phase");
|
||||
|
||||
switch (BleedMode.GetValue())
|
||||
{
|
||||
case EnumBleedMode.NTSCOld3Phase:
|
||||
m_bleedMat.EnableKeyword("_NTSCOld3Phase");
|
||||
break;
|
||||
case EnumBleedMode.NTSC3Phase:
|
||||
m_bleedMat.EnableKeyword("_NTSC3Phase");
|
||||
break;
|
||||
case EnumBleedMode.NTSC2Phase:
|
||||
m_bleedMat.EnableKeyword("_NTSC2Phase");
|
||||
break;
|
||||
}
|
||||
|
||||
m_bleedMat.SetFloat("bleedAmount", BleedAmount.GetValue());
|
||||
|
||||
Graphics.Blit(src, rt, m_bleedMat);
|
||||
|
||||
return rt;
|
||||
}
|
||||
private RenderTexture CRT_AperturePass(Texture src)
|
||||
{
|
||||
var rt = RenderTexture.GetTemporary(src.width, src.height);
|
||||
|
||||
m_crtApertureMat.SetFloat("GLOW_HALATION", GlowHalation.GetValue());
|
||||
m_crtApertureMat.SetFloat("GLOW_DIFFUSION", GlowDifusion.GetValue());
|
||||
m_crtApertureMat.SetFloat("MASK_COLORS", MaskColors.GetValue());
|
||||
m_crtApertureMat.SetFloat("MASK_STRENGTH", MaskStrength.GetValue());
|
||||
m_crtApertureMat.SetFloat("GAMMA_INPUT", GammaInput.GetValue());
|
||||
m_crtApertureMat.SetFloat("GAMMA_OUTPUT", GammaOutput.GetValue());
|
||||
m_crtApertureMat.SetFloat("BRIGHTNESS", Brightness.GetValue());
|
||||
|
||||
Graphics.Blit(src, rt, m_crtApertureMat);
|
||||
|
||||
return rt;
|
||||
}
|
||||
|
||||
public enum EnumBleedMode
|
||||
{
|
||||
NTSCOld3Phase,
|
||||
NTSC3Phase,
|
||||
NTSC2Phase,
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fcc83c5bfa946f748811247794560a56
|
@ -0,0 +1,175 @@
|
||||
Shader "Filter/RLPro_Bleed"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Base (RGB)", 2D) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
|
||||
#pragma shader_feature_local _NTSCOld3Phase _NTSC3Phase _NTSC2Phase
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_TexelSize;
|
||||
float2 _iResolution;
|
||||
|
||||
float bleedAmount = 1.0;
|
||||
int bleedLength = 21;
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
half3 rgb2yiq(half3 c)
|
||||
{
|
||||
return half3(
|
||||
(0.2989 * c.x + 0.5959 * c.y + 0.2115 * c.z),
|
||||
(0.5870 * c.x - 0.2744 * c.y - 0.5229 * c.z),
|
||||
(0.1140 * c.x - 0.3216 * c.y + 0.3114 * c.z)
|
||||
);
|
||||
}
|
||||
|
||||
half3 yiq2rgb(half3 c)
|
||||
{
|
||||
return half3(
|
||||
(1.0 * c.x + 1.0 * c.y + 1.0 * c.z),
|
||||
(0.956 * c.x - 0.2720 * c.y - 1.1060 * c.z),
|
||||
(0.6210 * c.x - 0.6474 * c.y + 1.7046 * c.z)
|
||||
);
|
||||
}
|
||||
|
||||
half3 t2d(float2 p)
|
||||
{
|
||||
half3 col = tex2D(_MainTex, p).rgb;
|
||||
|
||||
return rgb2yiq(col);
|
||||
}
|
||||
|
||||
#define fixCoord (p - float2( 0.5 * ONE_X, 0.0))
|
||||
#define fetch_offset(offset, one_x) t2d(fixCoord + float2( (offset) * (ONE_X), 0.0));
|
||||
#define get_t2d(offset, one_x) tex2D(_MainTex, p + (offset)*(one_x)).rgb;
|
||||
|
||||
float4 FragNTSCOld3Phase(v2f i) : COLOR
|
||||
{
|
||||
float2 uv = i.uv;
|
||||
float2 p = uv;
|
||||
float ONE_X = 1.0 / _ScreenParams.x;
|
||||
|
||||
ONE_X *= bleedAmount;
|
||||
bleedLength = 25;
|
||||
float maxTexLength = 50.0;
|
||||
float luma_filter[25]; luma_filter[0] = -0.000071070; luma_filter[1] = -0.000032816; luma_filter[2] = 0.000128784; luma_filter[3] = 0.000134711; luma_filter[4] = -0.000226705; luma_filter[5] = -0.000777988; luma_filter[6] = -0.000997809; luma_filter[7] = -0.000522802; luma_filter[8] = 0.000344691; luma_filter[9] = 0.000768930; luma_filter[10] = 0.000275591; luma_filter[11] = -0.000373434; luma_filter[12] = 0.000522796; luma_filter[13] = 0.003813817; luma_filter[14] = 0.007502825; luma_filter[15] = 0.006786001; luma_filter[16] = -0.002636726; luma_filter[17] = -0.019461182; luma_filter[18] = -0.033792479; luma_filter[19] = -0.029921972; luma_filter[20] = 0.005032552; luma_filter[21] = 0.071226466; luma_filter[22] = 0.151755921; luma_filter[23] = 0.218166470; luma_filter[24] = 0.243902439;
|
||||
float chroma_filter[24 + 1]; chroma_filter[0] = 0.001845562; chroma_filter[1] = 0.002381606; chroma_filter[2] = 0.003040177; chroma_filter[3] = 0.003838976; chroma_filter[4] = 0.004795341; chroma_filter[5] = 0.005925312; chroma_filter[6] = 0.007242534; chroma_filter[7] = 0.008757043; chroma_filter[8] = 0.010473987; chroma_filter[9] = 0.012392365; chroma_filter[10] = 0.014503872; chroma_filter[11] = 0.016791957; chroma_filter[12] = 0.019231195; chroma_filter[13] = 0.021787070; chroma_filter[14] = 0.024416251; chroma_filter[15] = 0.027067414; chroma_filter[16] = 0.029682613; chroma_filter[17] = 0.032199202; chroma_filter[18] = 0.034552198; chroma_filter[19] = 0.036677005; chroma_filter[20] = 0.038512317; chroma_filter[21] = 0.040003044; chroma_filter[22] = 0.041103048; chroma_filter[23] = 0.041777517; chroma_filter[24] = 0.042004791;
|
||||
half3 signal = half3(0.0,0.0,0.0);
|
||||
half3 norm = half3(0.0,0.0,0.0);
|
||||
half3 adj = half3(0.0,0.0,0.0);
|
||||
int taps = bleedLength - 4;
|
||||
for (int ii = 0; ii < taps % 1023; ii++)
|
||||
{
|
||||
float offset = float(ii);
|
||||
half3 sums = fetch_offset(offset - float(taps), ONE_X) + fetch_offset(float(taps) - offset, ONE_X);
|
||||
adj = half3(luma_filter[ii + 3], chroma_filter[ii], chroma_filter[ii]);
|
||||
signal += sums * adj;
|
||||
norm += adj;
|
||||
}
|
||||
adj = half3(luma_filter[taps], chroma_filter[taps], chroma_filter[taps]);
|
||||
half4 col23 = tex2D(_MainTex, fixCoord);
|
||||
signal += rgb2yiq(col23.rgb) * adj;
|
||||
norm += adj;
|
||||
signal = signal / norm;
|
||||
float3 rgb = yiq2rgb(signal);
|
||||
|
||||
float alpha = col23.a + (rgb.r + rgb.g + rgb.b) / 3;
|
||||
return half4(rgb, alpha);
|
||||
}
|
||||
|
||||
float4 FragNTSC3Phase(v2f i) : COLOR
|
||||
{
|
||||
float2 uv = i.uv;
|
||||
float2 p = uv;
|
||||
float ONE_X = 1.0 / _iResolution.x;
|
||||
|
||||
ONE_X *= bleedAmount;
|
||||
bleedLength = 25;
|
||||
float maxTexLength = 50.0;
|
||||
float luma_filter[25]; luma_filter[0] = -0.000012020; luma_filter[1] = -0.000022146; luma_filter[2] = -0.000013155; luma_filter[3] = -0.000012020; luma_filter[4] = -0.000049979; luma_filter[5] = -0.000113940; luma_filter[6] = -0.000122150; luma_filter[7] = -0.000005612; luma_filter[8] = 0.000170516; luma_filter[9] = 0.000237199; luma_filter[10] = 0.000169640; luma_filter[11] = 0.000285688; luma_filter[12] = 0.000984574; luma_filter[13] = 0.002018683; luma_filter[14] = 0.002002275; luma_filter[15] = -0.000909882; luma_filter[16] = -0.007049081; luma_filter[17] = -0.013222860; luma_filter[18] = -0.012606931; luma_filter[19] = 0.002460860; luma_filter[20] = 0.035868225; luma_filter[21] = 0.084016453; luma_filter[22] = 0.135563500; luma_filter[23] = 0.175261268; luma_filter[24] = 0.190176552;
|
||||
float chroma_filter[25]; chroma_filter[0] = -0.000118847; chroma_filter[1] = -0.000271306; chroma_filter[2] = -0.000502642; chroma_filter[3] = -0.000930833; chroma_filter[4] = -0.001451013; chroma_filter[5] = -0.002064744; chroma_filter[6] = -0.002700432; chroma_filter[7] = -0.003241276; chroma_filter[8] = -0.003524948; chroma_filter[9] = -0.003350284; chroma_filter[10] = -0.002491729; chroma_filter[11] = -0.000721149; chroma_filter[12] = 0.002164659; chroma_filter[13] = 0.006313635; chroma_filter[14] = 0.011789103; chroma_filter[15] = 0.018545660; chroma_filter[16] = 0.026414396; chroma_filter[17] = 0.035100710; chroma_filter[18] = 0.044196567; chroma_filter[19] = 0.053207202; chroma_filter[20] = 0.061590275; chroma_filter[21] = 0.068803602; chroma_filter[22] = 0.074356193; chroma_filter[23] = 0.077856564; chroma_filter[24] = 0.079052396;
|
||||
half3 signal = half3(0.0,0.0,0.0);
|
||||
half3 norm = half3(0.0,0.0,0.0);
|
||||
half3 adj = half3(0.0,0.0,0.0);
|
||||
int taps = bleedLength - 4;
|
||||
for (int ii = 0; ii < taps % 1023; ii++)
|
||||
{
|
||||
float offset = float(ii);
|
||||
half3 sums = fetch_offset(offset - float(taps), ONE_X) + fetch_offset(float(taps) - offset, ONE_X);
|
||||
adj = half3(luma_filter[ii + 3], chroma_filter[ii], chroma_filter[ii]);
|
||||
signal += sums * adj;
|
||||
norm += adj;
|
||||
}
|
||||
adj = half3(luma_filter[taps], chroma_filter[taps], chroma_filter[taps]);
|
||||
half4 col23 = tex2D(_MainTex, fixCoord);
|
||||
signal += rgb2yiq(col23.rgb) * adj;
|
||||
norm += adj;
|
||||
signal = signal / norm;
|
||||
float3 rgb = yiq2rgb(signal);
|
||||
|
||||
float alpha = col23.a + (rgb.r + rgb.g + rgb.b) / 3;
|
||||
return half4(rgb, alpha);
|
||||
}
|
||||
|
||||
float4 FragNTSC2Phase(v2f i) : COLOR
|
||||
{
|
||||
float2 uv = i.uv;
|
||||
float2 p = uv;
|
||||
float ONE_X = 1.0 / _ScreenParams.x;
|
||||
|
||||
ONE_X *= bleedAmount;
|
||||
bleedLength = 33;
|
||||
float maxTexLength = 50.0;
|
||||
float luma_filter[33]; luma_filter[0] = -0.000174844; luma_filter[1] = -0.000205844; luma_filter[2] = -0.000149453; luma_filter[3] = -0.000051693; luma_filter[4] = 0.000000000; luma_filter[5] = -0.000066171; luma_filter[6] = -0.000245058; luma_filter[7] = -0.000432928; luma_filter[8] = -0.000472644; luma_filter[9] = -0.000252236; luma_filter[10] = 0.000198929; luma_filter[11] = 0.000687058; luma_filter[12] = 0.000944112; luma_filter[13] = 0.000803467; luma_filter[14] = 0.000363199; luma_filter[15] = 0.000013422; luma_filter[16] = 0.000253402; luma_filter[17] = 0.001339461; luma_filter[18] = 0.002932972; luma_filter[19] = 0.003983485; luma_filter[20] = 0.003026683; luma_filter[21] = -0.001102056; luma_filter[22] = -0.008373026; luma_filter[23] = -0.016897700; luma_filter[24] = -0.022914480; luma_filter[25] = -0.021642347; luma_filter[26] = -0.008863273; luma_filter[27] = 0.017271957; luma_filter[28] = 0.054921920; luma_filter[29] = 0.098342579; luma_filter[30] = 0.139044281; luma_filter[31] = 0.168055832; luma_filter[32] = 0.178571429;
|
||||
float chroma_filter[33]; chroma_filter[0] = 0.001384762; chroma_filter[1] = 0.001678312; chroma_filter[2] = 0.002021715; chroma_filter[3] = 0.002420562; chroma_filter[4] = 0.002880460; chroma_filter[5] = 0.003406879; chroma_filter[6] = 0.004004985; chroma_filter[7] = 0.004679445; chroma_filter[8] = 0.005434218; chroma_filter[9] = 0.006272332; chroma_filter[10] = 0.007195654; chroma_filter[11] = 0.008204665; chroma_filter[12] = 0.009298238; chroma_filter[13] = 0.010473450; chroma_filter[14] = 0.011725413; chroma_filter[15] = 0.013047155; chroma_filter[16] = 0.014429548; chroma_filter[17] = 0.015861306; chroma_filter[18] = 0.017329037; chroma_filter[19] = 0.018817382; chroma_filter[20] = 0.020309220; chroma_filter[21] = 0.021785952; chroma_filter[22] = 0.023227857; chroma_filter[23] = 0.024614500; chroma_filter[24] = 0.025925203; chroma_filter[25] = 0.027139546; chroma_filter[26] = 0.028237893; chroma_filter[27] = 0.029201910; chroma_filter[28] = 0.030015081; chroma_filter[29] = 0.030663170; chroma_filter[30] = 0.031134640; chroma_filter[31] = 0.031420995; chroma_filter[32] = 0.031517031;
|
||||
half3 signal = half3(0.0,0.0,0.0);
|
||||
half3 norm = half3(0.0,0.0,0.0);
|
||||
half3 adj = half3(0.0,0.0,0.0);
|
||||
int taps = bleedLength - 4;
|
||||
for (int ii = 0; ii < taps % 1023; ii++)
|
||||
{
|
||||
float offset = float(ii);
|
||||
half3 sums = fetch_offset(offset - float(taps), ONE_X) + fetch_offset(float(taps) - offset, ONE_X);
|
||||
adj = half3(luma_filter[ii + 3], chroma_filter[ii], chroma_filter[ii]);
|
||||
signal += sums * adj;
|
||||
norm += adj;
|
||||
}
|
||||
adj = half3(luma_filter[taps], chroma_filter[taps], chroma_filter[taps]);
|
||||
half4 col23 = tex2D(_MainTex, fixCoord);
|
||||
signal += rgb2yiq(col23.rgb) * adj;
|
||||
norm += adj;
|
||||
signal = signal / norm;
|
||||
float3 rgb = yiq2rgb(signal);
|
||||
|
||||
float alpha = col23.a + (rgb.r + rgb.g + rgb.b) / 3;
|
||||
return half4(rgb, alpha);
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
#if _NTSCOld3Phase
|
||||
return FragNTSCOld3Phase(i);
|
||||
#elif _NTSC3Phase
|
||||
return FragNTSC3Phase(i);
|
||||
#else
|
||||
return FragNTSC2Phase(i);
|
||||
#endif
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d7b367e99136835468184ea471e79e02
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,144 @@
|
||||
Shader "Filter/RLPro_CRT_Aperture"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Base (RGB)", 2D) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
|
||||
#pragma shader_feature_local _NTSCOld3Phase _NTSC3Phase _NTSC2Phase
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment Frag0
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
#define FIX(c) max(abs(c), 1e-5)
|
||||
#define saturate(c) clamp(c, 0.0, 1.0)
|
||||
#define PI 3.14159265359
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_TexelSize;
|
||||
float2 _iResolution;
|
||||
|
||||
float GLOW_HALATION = 0.1;
|
||||
float GLOW_DIFFUSION = 0.05;
|
||||
float MASK_COLORS = 2.0;
|
||||
float MASK_STRENGTH = 0.3;
|
||||
float GAMMA_INPUT = 2.4;
|
||||
float GAMMA_OUTPUT = 2.4;
|
||||
float BRIGHTNESS = 1.5;
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
float mod(float x, float y)
|
||||
{
|
||||
return x - y * floor(x / y);
|
||||
}
|
||||
|
||||
float fract(float x)
|
||||
{
|
||||
return x - floor(x);
|
||||
}
|
||||
|
||||
float2 fract(float2 x)
|
||||
{
|
||||
return x - floor(x);
|
||||
}
|
||||
|
||||
float4 fract(float4 x)
|
||||
{
|
||||
return x - floor(x);
|
||||
}
|
||||
|
||||
float3 TEX2D(float2 c)
|
||||
{
|
||||
return pow(abs(tex2D(_MainTex, c).rgb), float3(GAMMA_INPUT, GAMMA_INPUT, GAMMA_INPUT)).xyz;
|
||||
}
|
||||
|
||||
float3x3 get_color_matrix(float2 co, float2 dx)
|
||||
{
|
||||
return float3x3(TEX2D(co - dx), TEX2D(co), TEX2D(co + dx));
|
||||
}
|
||||
|
||||
float3 blur(float3x3 m, float dist, float rad)
|
||||
{
|
||||
float3 x = float3(dist - 1.0, dist, dist + 1.0) / rad;
|
||||
float3 w = exp2(x * x * -1.0);
|
||||
|
||||
return (m[0] * w.x + m[1] * w.y + m[2] * w.z) / (w.x + w.y + w.z);
|
||||
}
|
||||
|
||||
float3 filter_gaussian(float2 co, float2 tex_size)
|
||||
{
|
||||
float2 dx = float2(1.0 / tex_size.x, 0.0);
|
||||
float2 dy = float2(0.0, 1.0 / tex_size.y);
|
||||
float2 pix_co = co * tex_size;
|
||||
float2 tex_co = (floor(pix_co) + 0.5) / tex_size;
|
||||
float2 dist = (fract(pix_co) - 0.5) * -1.0;
|
||||
float3x3 line0 = get_color_matrix(tex_co - dy, dx);
|
||||
float3x3 line1 = get_color_matrix(tex_co, dx);
|
||||
float3x3 line2 = get_color_matrix(tex_co + dy, dx);
|
||||
float3x3 column = float3x3(blur(line0, dist.x, 0.5), blur(line1, dist.x, 0.5), blur(line2, dist.x, 0.5));
|
||||
return blur(column, dist.y, 0.5);
|
||||
}
|
||||
|
||||
float3 filter_lanczos(float2 co, float2 tex_size, float sharp)
|
||||
{
|
||||
tex_size.x *= sharp;
|
||||
|
||||
float2 dx = float2(1.0 / tex_size.x, 0.0);
|
||||
float2 pix_co = co * tex_size - float2(0.5, 0.0);
|
||||
float2 tex_co = (floor(pix_co) + float2(0.5, 0.001)) / tex_size;
|
||||
float2 dist = fract(pix_co);
|
||||
float4 coef = PI * float4(dist.x + 1.0, dist.x, dist.x - 1.0, dist.x - 2.0);
|
||||
coef = FIX(coef);
|
||||
coef = 2.0 * sin(coef) * sin(coef / 2.0) / (coef * coef);
|
||||
coef /= dot(coef, float4(1.0, 1.0, 1.0, 1.0));
|
||||
float4 col1 = float4(TEX2D(tex_co), 1.0);
|
||||
float4 col2 = float4(TEX2D(tex_co + dx), 1.0);
|
||||
float4x4 fkfk = mul(coef.x, float4x4(col1, col1, col2, col2));
|
||||
float4x4 fkfks = mul(coef.y, float4x4(col1, col1, col2, col2));
|
||||
float4x4 fkfkb = mul(coef.z, float4x4(col1, col1, col2, col2));
|
||||
return float3(fkfk[0].x, fkfk[0].y, fkfk[0].z);
|
||||
}
|
||||
|
||||
float3 mix(float3 x, float3 y, float3 a) {
|
||||
return float3(x * (1 - a) + y * a);
|
||||
}
|
||||
|
||||
float3 get_mask_weight(float x)
|
||||
{
|
||||
float i = mod(floor(x), MASK_COLORS);
|
||||
if (i == 0.0) return mix(float3(1.0, 0.0, 1.0), float3(1.0, 0.0, 0.0), MASK_COLORS - 2.0);
|
||||
else if (i == 1.0) return float3(0.0, 1.0, 0.0);
|
||||
else return float3(0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
float4 Frag0(v2f i) : SV_Target
|
||||
{
|
||||
float2 pos = i.uv;
|
||||
float3 col_glow = filter_gaussian(pos, _ScreenParams.xy);
|
||||
float3 col_soft = filter_lanczos(pos, _ScreenParams.xy, 1);
|
||||
float3 col_sharp = filter_lanczos(pos, _ScreenParams.xy, 3);
|
||||
float3 col = sqrt(col_sharp * col_soft);
|
||||
col_glow = saturate(col_glow - col);
|
||||
col += col_glow * col_glow * GLOW_HALATION;
|
||||
col = mix(col, col * get_mask_weight(pos.x) * MASK_COLORS, MASK_STRENGTH);
|
||||
col += col_glow * GLOW_DIFFUSION;
|
||||
col = pow(abs(col * BRIGHTNESS), float3(1.0 / GAMMA_OUTPUT, 1.0 / GAMMA_OUTPUT, 1.0 / GAMMA_OUTPUT));
|
||||
half4 col1 = tex2D(_MainTex, pos);
|
||||
float fade = 1;
|
||||
|
||||
return lerp(col1,float4(col, col1.a+(col.r+col.g+col.b)/3),fade);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f63497435389f8548ab973da8535e1b5
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user