forked from sin365/AxibugEmuOnline
新增一个滤镜MattiasCRT,滤镜文件夹位置移动
This commit is contained in:
parent
c3d0bce281
commit
0783d7d90e
@ -5064,6 +5064,30 @@ PrefabInstance:
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2835547163257332666, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2835547163257332666, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3}
|
||||
propertyPath: m_AnchorMin.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2835547163257332666, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2835547163257332666, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3}
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2835547163257332666, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2835547163257332666, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2840751913792599391, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
@ -7932,6 +7956,30 @@ PrefabInstance:
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4575683635464055717, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4575683635464055717, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3}
|
||||
propertyPath: m_AnchorMin.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4575683635464055717, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4575683635464055717, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3}
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4575683635464055717, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4575683635464055717, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4578492792357404689, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
@ -12912,6 +12960,30 @@ PrefabInstance:
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7770431731865515504, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7770431731865515504, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3}
|
||||
propertyPath: m_AnchorMin.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7770431731865515504, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7770431731865515504, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3}
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7770431731865515504, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7770431731865515504, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7770651122324487533, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3}
|
||||
propertyPath: m_AnchorMax.x
|
||||
value: 0
|
||||
@ -15352,6 +15424,8 @@ MonoBehaviour:
|
||||
m_BeforeStackBundles:
|
||||
- assemblyQualifiedName: FixingPixelArtGrille, AxibugEmuOnline.Client, Version=0.0.0.0,
|
||||
Culture=neutral, PublicKeyToken=null
|
||||
- assemblyQualifiedName: MattiasCRT, AxibugEmuOnline.Client, Version=0.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=null
|
||||
m_AfterStackBundles: []
|
||||
--- !u!1 &1498586261
|
||||
GameObject:
|
||||
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0208df1cb66f4944a51a099464e00dc
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,293 +0,0 @@
|
||||
|
||||
Shader "PostEffect/FixingPixcelArtGrille"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Base (RGB)", 2D) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
|
||||
#pragma shader_feature_local _MASKSTYLE_TVSTYLE _MASKSTYLE_APERTUREGRILLE _MASKSTYLE_STRETCHEDVGA _MASKSTYLE_VGASTYLE
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_TexelSize;
|
||||
|
||||
//
|
||||
// PUBLIC DOMAIN CRT STYLED SCAN-LINE SHADER
|
||||
//
|
||||
// by Timothy Lottes
|
||||
//
|
||||
// This is more along the style of a really good CGA arcade monitor.
|
||||
// With RGB inputs instead of NTSC.
|
||||
// The shadow mask example has the mask rotated 90 degrees for less chromatic aberration.
|
||||
//
|
||||
// Left it unoptimized to show the theory behind the algorithm.
|
||||
//
|
||||
// It is an example what I personally would want as a display option for pixel art games.
|
||||
// Please take and use, change, or whatever.
|
||||
//
|
||||
|
||||
float2 _iResolution = float2(1920,1080);
|
||||
|
||||
// Emulated input resolution.
|
||||
// Optimize for resize.
|
||||
float2 _res = float2(272.0,240.0);
|
||||
|
||||
// Hardness of scanline.
|
||||
// -8.0 = soft
|
||||
// -16.0 = medium
|
||||
float _hardScan = -10.0;
|
||||
|
||||
// Hardness of pixels in scanline.
|
||||
// -2.0 = soft
|
||||
// -4.0 = hard
|
||||
float _hardPix =-2.0;
|
||||
|
||||
// Hardness of short vertical bloom.
|
||||
// -1.0 = wide to the point of clipping (bad)
|
||||
// -1.5 = wide
|
||||
// -4.0 = not very wide at all
|
||||
float _hardBloomScan = -4.0;
|
||||
|
||||
// Hardness of short horizontal bloom.
|
||||
// -0.5 = wide to the point of clipping (bad)
|
||||
// -1.0 = wide
|
||||
// -2.0 = not very wide at all
|
||||
float _hardBloomPix = -1.5;
|
||||
|
||||
// Amount of small bloom effect.
|
||||
// 1.0/1.0 = only bloom
|
||||
// 1.0/16.0 = what I think is a good amount of small bloom
|
||||
// 0.0 = no bloom
|
||||
float _bloomAmount = 1.0/16.0;
|
||||
|
||||
// Display warp.
|
||||
// 0.0 = none
|
||||
// 1.0/8.0 = extreme
|
||||
float2 _warp = float2(1.0/64.0,1.0/24.0);
|
||||
|
||||
// Amount of shadow mask.
|
||||
float _maskDark = 0.5;
|
||||
float _maskLight = 1.5;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
float fract(float x){
|
||||
return x-floor(x);
|
||||
}
|
||||
|
||||
// sRGB to Linear.
|
||||
// Assuing using sRGB typed textures this should not be needed.
|
||||
float ToLinear1(float c){return(c<=0.04045)?c/12.92:pow((c+0.055)/1.055,2.4);}
|
||||
float3 ToLinear(float3 c){return float3(ToLinear1(c.r),ToLinear1(c.g),ToLinear1(c.b));}
|
||||
|
||||
// Linear to sRGB.
|
||||
// Assuing using sRGB typed textures this should not be needed.
|
||||
float ToSrgb1(float c){return(c<0.0031308?c*12.92:1.055*pow(c,0.41666)-0.055);}
|
||||
float3 ToSrgb(float3 c){return float3(ToSrgb1(c.r),ToSrgb1(c.g),ToSrgb1(c.b));}
|
||||
|
||||
|
||||
float3 Test(float3 c){return c*(1.0/64.0)+c*c*c;}
|
||||
|
||||
// Nearest emulated sample given floating point position and texel offset.
|
||||
// Also zero's off screen.
|
||||
float3 Fetch( float2 pos,float2 off){
|
||||
pos=floor(pos*_res+off)/_res;
|
||||
if(max(abs(pos.x-0.5),abs(pos.y-0.5))>0.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));}
|
||||
|
||||
// 1D Gaussian.
|
||||
float Gaus(float pos,float scale){return exp2(scale*pos*pos);}
|
||||
|
||||
// 3-tap Gaussian filter along horz line.
|
||||
float3 Horz3(float2 pos,float off){
|
||||
float3 b=Fetch(pos,float2(-1.0,off));
|
||||
float3 c=Fetch(pos,float2( 0.0,off));
|
||||
float3 d=Fetch(pos,float2( 1.0,off));
|
||||
float dst=Dist(pos).x;
|
||||
// Convert distance to weight.
|
||||
float scale=_hardPix;
|
||||
float wb=Gaus(dst-1.0,scale);
|
||||
float wc=Gaus(dst+0.0,scale);
|
||||
float wd=Gaus(dst+1.0,scale);
|
||||
// Return filtered sample.
|
||||
return (b*wb+c*wc+d*wd)/(wb+wc+wd);}
|
||||
|
||||
// 5-tap Gaussian filter along horz line.
|
||||
float3 Horz5(float2 pos,float off){
|
||||
float3 a=Fetch(pos,float2(-2.0,off));
|
||||
float3 b=Fetch(pos,float2(-1.0,off));
|
||||
float3 c=Fetch(pos,float2( 0.0,off));
|
||||
float3 d=Fetch(pos,float2( 1.0,off));
|
||||
float3 e=Fetch(pos,float2( 2.0,off));
|
||||
float dst=Dist(pos).x;
|
||||
// Convert distance to weight.
|
||||
float scale=_hardPix;
|
||||
float wa=Gaus(dst-2.0,scale);
|
||||
float wb=Gaus(dst-1.0,scale);
|
||||
float wc=Gaus(dst+0.0,scale);
|
||||
float wd=Gaus(dst+1.0,scale);
|
||||
float we=Gaus(dst+2.0,scale);
|
||||
// Return filtered sample.
|
||||
return (a*wa+b*wb+c*wc+d*wd+e*we)/(wa+wb+wc+wd+we);}
|
||||
|
||||
// 7-tap Gaussian filter along horz line.
|
||||
float3 Horz7(float2 pos,float off){
|
||||
float3 a=Fetch(pos,float2(-3.0,off));
|
||||
float3 b=Fetch(pos,float2(-2.0,off));
|
||||
float3 c=Fetch(pos,float2(-1.0,off));
|
||||
float3 d=Fetch(pos,float2( 0.0,off));
|
||||
float3 e=Fetch(pos,float2( 1.0,off));
|
||||
float3 f=Fetch(pos,float2( 2.0,off));
|
||||
float3 g=Fetch(pos,float2( 3.0,off));
|
||||
float dst=Dist(pos).x;
|
||||
// Convert distance to weight.
|
||||
float scale=_hardBloomPix;
|
||||
float wa=Gaus(dst-3.0,scale);
|
||||
float wb=Gaus(dst-2.0,scale);
|
||||
float wc=Gaus(dst-1.0,scale);
|
||||
float wd=Gaus(dst+0.0,scale);
|
||||
float we=Gaus(dst+1.0,scale);
|
||||
float wf=Gaus(dst+2.0,scale);
|
||||
float wg=Gaus(dst+3.0,scale);
|
||||
// Return filtered sample.
|
||||
return (a*wa+b*wb+c*wc+d*wd+e*we+f*wf+g*wg)/(wa+wb+wc+wd+we+wf+wg);}
|
||||
|
||||
// Return scanline weight.
|
||||
float Scan(float2 pos,float off){
|
||||
float dst=Dist(pos).y;
|
||||
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);}
|
||||
|
||||
// Allow nearest three lines to effect pixel.
|
||||
float3 Tri(float2 pos){
|
||||
float3 a=Horz3(pos,-1.0);
|
||||
float3 b=Horz5(pos, 0.0);
|
||||
float3 c=Horz3(pos, 1.0);
|
||||
float wa=Scan(pos,-1.0);
|
||||
float wb=Scan(pos, 0.0);
|
||||
float wc=Scan(pos, 1.0);
|
||||
return a*wa+b*wb+c*wc;}
|
||||
|
||||
// Small bloom.
|
||||
float3 Bloom(float2 pos){
|
||||
float3 a=Horz5(pos,-2.0);
|
||||
float3 b=Horz7(pos,-1.0);
|
||||
float3 c=Horz7(pos, 0.0);
|
||||
float3 d=Horz7(pos, 1.0);
|
||||
float3 e=Horz5(pos, 2.0);
|
||||
float wa=BloomScan(pos,-2.0);
|
||||
float wb=BloomScan(pos,-1.0);
|
||||
float wc=BloomScan(pos, 0.0);
|
||||
float wd=BloomScan(pos, 1.0);
|
||||
float we=BloomScan(pos, 2.0);
|
||||
return a*wa+b*wb+c*wc+d*wd+e*we;}
|
||||
|
||||
// Distortion of scanlines, and end of screen alpha.
|
||||
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);
|
||||
return pos*0.5+0.5;}
|
||||
|
||||
#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);
|
||||
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
|
||||
|
||||
|
||||
|
||||
// Draw dividing bars.
|
||||
float Bar(float pos,float bar){pos-=bar;return pos*pos<4.0?0.0:1.0;}
|
||||
|
||||
// Entry.
|
||||
float4 mainImage(float2 fragCoord){
|
||||
|
||||
float4 fragColor = float4(1,1,1,1);
|
||||
float2 pos=Warp(fragCoord.xy/_iResolution.xy);
|
||||
|
||||
fragColor.rgb=Tri(pos)*Mask(fragCoord.xy);
|
||||
|
||||
fragColor.rgb+=Bloom(pos)*_bloomAmount;
|
||||
|
||||
fragColor.a=1.0;
|
||||
fragColor.rgb=ToSrgb(fragColor.rgb);
|
||||
|
||||
return fragColor;
|
||||
}
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float2 pos = _iResolution.xy*i.uv;
|
||||
fixed4 col = mainImage(pos);
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,293 @@
|
||||
|
||||
Shader "PostEffect/FixingPixcelArtGrille"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Base (RGB)", 2D) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
|
||||
#pragma shader_feature_local _MASKSTYLE_TVSTYLE _MASKSTYLE_APERTUREGRILLE _MASKSTYLE_STRETCHEDVGA _MASKSTYLE_VGASTYLE
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_TexelSize;
|
||||
|
||||
//
|
||||
// PUBLIC DOMAIN CRT STYLED SCAN-LINE SHADER
|
||||
//
|
||||
// by Timothy Lottes
|
||||
//
|
||||
// This is more along the style of a really good CGA arcade monitor.
|
||||
// With RGB inputs instead of NTSC.
|
||||
// The shadow mask example has the mask rotated 90 degrees for less chromatic aberration.
|
||||
//
|
||||
// Left it unoptimized to show the theory behind the algorithm.
|
||||
//
|
||||
// It is an example what I personally would want as a display option for pixel art games.
|
||||
// Please take and use, change, or whatever.
|
||||
//
|
||||
|
||||
float2 _iResolution = float2(1920,1080);
|
||||
|
||||
// Emulated input resolution.
|
||||
// Optimize for resize.
|
||||
float2 _res = float2(272.0,240.0);
|
||||
|
||||
// Hardness of scanline.
|
||||
// -8.0 = soft
|
||||
// -16.0 = medium
|
||||
float _hardScan = -10.0;
|
||||
|
||||
// Hardness of pixels in scanline.
|
||||
// -2.0 = soft
|
||||
// -4.0 = hard
|
||||
float _hardPix =-2.0;
|
||||
|
||||
// Hardness of short vertical bloom.
|
||||
// -1.0 = wide to the point of clipping (bad)
|
||||
// -1.5 = wide
|
||||
// -4.0 = not very wide at all
|
||||
float _hardBloomScan = -4.0;
|
||||
|
||||
// Hardness of short horizontal bloom.
|
||||
// -0.5 = wide to the point of clipping (bad)
|
||||
// -1.0 = wide
|
||||
// -2.0 = not very wide at all
|
||||
float _hardBloomPix = -1.5;
|
||||
|
||||
// Amount of small bloom effect.
|
||||
// 1.0/1.0 = only bloom
|
||||
// 1.0/16.0 = what I think is a good amount of small bloom
|
||||
// 0.0 = no bloom
|
||||
float _bloomAmount = 1.0/16.0;
|
||||
|
||||
// Display warp.
|
||||
// 0.0 = none
|
||||
// 1.0/8.0 = extreme
|
||||
float2 _warp = float2(1.0/64.0,1.0/24.0);
|
||||
|
||||
// Amount of shadow mask.
|
||||
float _maskDark = 0.5;
|
||||
float _maskLight = 1.5;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
float fract(float x){
|
||||
return x-floor(x);
|
||||
}
|
||||
|
||||
// sRGB to Linear.
|
||||
// Assuing using sRGB typed textures this should not be needed.
|
||||
float ToLinear1(float c){return(c<=0.04045)?c/12.92:pow((c+0.055)/1.055,2.4);}
|
||||
float3 ToLinear(float3 c){return float3(ToLinear1(c.r),ToLinear1(c.g),ToLinear1(c.b));}
|
||||
|
||||
// Linear to sRGB.
|
||||
// Assuing using sRGB typed textures this should not be needed.
|
||||
float ToSrgb1(float c){return(c<0.0031308?c*12.92:1.055*pow(c,0.41666)-0.055);}
|
||||
float3 ToSrgb(float3 c){return float3(ToSrgb1(c.r),ToSrgb1(c.g),ToSrgb1(c.b));}
|
||||
|
||||
|
||||
float3 Test(float3 c){return c*(1.0/64.0)+c*c*c;}
|
||||
|
||||
// Nearest emulated sample given floating point position and texel offset.
|
||||
// Also zero's off screen.
|
||||
float3 Fetch( float2 pos,float2 off){
|
||||
pos=floor(pos*_res+off)/_res;
|
||||
if(max(abs(pos.x-0.5),abs(pos.y-0.5))>0.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));}
|
||||
|
||||
// 1D Gaussian.
|
||||
float Gaus(float pos,float scale){return exp2(scale*pos*pos);}
|
||||
|
||||
// 3-tap Gaussian filter along horz line.
|
||||
float3 Horz3(float2 pos,float off){
|
||||
float3 b=Fetch(pos,float2(-1.0,off));
|
||||
float3 c=Fetch(pos,float2( 0.0,off));
|
||||
float3 d=Fetch(pos,float2( 1.0,off));
|
||||
float dst=Dist(pos).x;
|
||||
// Convert distance to weight.
|
||||
float scale=_hardPix;
|
||||
float wb=Gaus(dst-1.0,scale);
|
||||
float wc=Gaus(dst+0.0,scale);
|
||||
float wd=Gaus(dst+1.0,scale);
|
||||
// Return filtered sample.
|
||||
return (b*wb+c*wc+d*wd)/(wb+wc+wd);}
|
||||
|
||||
// 5-tap Gaussian filter along horz line.
|
||||
float3 Horz5(float2 pos,float off){
|
||||
float3 a=Fetch(pos,float2(-2.0,off));
|
||||
float3 b=Fetch(pos,float2(-1.0,off));
|
||||
float3 c=Fetch(pos,float2( 0.0,off));
|
||||
float3 d=Fetch(pos,float2( 1.0,off));
|
||||
float3 e=Fetch(pos,float2( 2.0,off));
|
||||
float dst=Dist(pos).x;
|
||||
// Convert distance to weight.
|
||||
float scale=_hardPix;
|
||||
float wa=Gaus(dst-2.0,scale);
|
||||
float wb=Gaus(dst-1.0,scale);
|
||||
float wc=Gaus(dst+0.0,scale);
|
||||
float wd=Gaus(dst+1.0,scale);
|
||||
float we=Gaus(dst+2.0,scale);
|
||||
// Return filtered sample.
|
||||
return (a*wa+b*wb+c*wc+d*wd+e*we)/(wa+wb+wc+wd+we);}
|
||||
|
||||
// 7-tap Gaussian filter along horz line.
|
||||
float3 Horz7(float2 pos,float off){
|
||||
float3 a=Fetch(pos,float2(-3.0,off));
|
||||
float3 b=Fetch(pos,float2(-2.0,off));
|
||||
float3 c=Fetch(pos,float2(-1.0,off));
|
||||
float3 d=Fetch(pos,float2( 0.0,off));
|
||||
float3 e=Fetch(pos,float2( 1.0,off));
|
||||
float3 f=Fetch(pos,float2( 2.0,off));
|
||||
float3 g=Fetch(pos,float2( 3.0,off));
|
||||
float dst=Dist(pos).x;
|
||||
// Convert distance to weight.
|
||||
float scale=_hardBloomPix;
|
||||
float wa=Gaus(dst-3.0,scale);
|
||||
float wb=Gaus(dst-2.0,scale);
|
||||
float wc=Gaus(dst-1.0,scale);
|
||||
float wd=Gaus(dst+0.0,scale);
|
||||
float we=Gaus(dst+1.0,scale);
|
||||
float wf=Gaus(dst+2.0,scale);
|
||||
float wg=Gaus(dst+3.0,scale);
|
||||
// Return filtered sample.
|
||||
return (a*wa+b*wb+c*wc+d*wd+e*we+f*wf+g*wg)/(wa+wb+wc+wd+we+wf+wg);}
|
||||
|
||||
// Return scanline weight.
|
||||
float Scan(float2 pos,float off){
|
||||
float dst=Dist(pos).y;
|
||||
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);}
|
||||
|
||||
// Allow nearest three lines to effect pixel.
|
||||
float3 Tri(float2 pos){
|
||||
float3 a=Horz3(pos,-1.0);
|
||||
float3 b=Horz5(pos, 0.0);
|
||||
float3 c=Horz3(pos, 1.0);
|
||||
float wa=Scan(pos,-1.0);
|
||||
float wb=Scan(pos, 0.0);
|
||||
float wc=Scan(pos, 1.0);
|
||||
return a*wa+b*wb+c*wc;}
|
||||
|
||||
// Small bloom.
|
||||
float3 Bloom(float2 pos){
|
||||
float3 a=Horz5(pos,-2.0);
|
||||
float3 b=Horz7(pos,-1.0);
|
||||
float3 c=Horz7(pos, 0.0);
|
||||
float3 d=Horz7(pos, 1.0);
|
||||
float3 e=Horz5(pos, 2.0);
|
||||
float wa=BloomScan(pos,-2.0);
|
||||
float wb=BloomScan(pos,-1.0);
|
||||
float wc=BloomScan(pos, 0.0);
|
||||
float wd=BloomScan(pos, 1.0);
|
||||
float we=BloomScan(pos, 2.0);
|
||||
return a*wa+b*wb+c*wc+d*wd+e*we;}
|
||||
|
||||
// Distortion of scanlines, and end of screen alpha.
|
||||
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);
|
||||
return pos*0.5+0.5;}
|
||||
|
||||
#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);
|
||||
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
|
||||
|
||||
|
||||
|
||||
// Draw dividing bars.
|
||||
float Bar(float pos,float bar){pos-=bar;return pos*pos<4.0?0.0:1.0;}
|
||||
|
||||
// Entry.
|
||||
float4 mainImage(float2 fragCoord){
|
||||
|
||||
float4 fragColor = float4(1,1,1,1);
|
||||
float2 pos=Warp(fragCoord.xy/_iResolution.xy);
|
||||
|
||||
fragColor.rgb=Tri(pos)*Mask(fragCoord.xy);
|
||||
|
||||
fragColor.rgb+=Bloom(pos)*_bloomAmount;
|
||||
|
||||
fragColor.a=1.0;
|
||||
fragColor.rgb=ToSrgb(fragColor.rgb);
|
||||
|
||||
return fragColor;
|
||||
}
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float2 pos = _iResolution.xy*i.uv;
|
||||
fixed4 col = mainImage(pos);
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,21 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &-2985742813244632235
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 3
|
||||
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: 98a055cea8a1355429d1cbb752c4e60e, type: 3}
|
||||
m_Name: MattiasCRT
|
||||
m_EditorClassIdentifier:
|
||||
active: 1
|
||||
enabled:
|
||||
overrideState: 1
|
||||
value: 1
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -14,6 +30,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
settings:
|
||||
- {fileID: 117625959343581733}
|
||||
- {fileID: -2985742813244632235}
|
||||
--- !u!114 &117625959343581733
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 3
|
||||
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 890a033cb91c7a24f9dbc97bf87f6dca
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,28 @@
|
||||
using AxibugEmuOnline.Client;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.PostProcessing;
|
||||
|
||||
[System.Serializable]
|
||||
[PostProcess(typeof(MattiasCRTRenderer), PostProcessEvent.BeforeStack, "Filter/MattiasCRT")]
|
||||
public sealed class MattiasCRT : FilterEffect
|
||||
{
|
||||
public override string Name => nameof(MattiasCRT);
|
||||
}
|
||||
|
||||
public sealed class MattiasCRTRenderer : PostProcessEffectRenderer<MattiasCRT>
|
||||
{
|
||||
private Shader shader;
|
||||
private Material material;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
shader = Shader.Find("Filter/MattiasCRT");
|
||||
material = new Material(shader);
|
||||
}
|
||||
|
||||
public override void Render(PostProcessRenderContext context)
|
||||
{
|
||||
material.SetVector("_iResolution", new Vector4(Screen.width, Screen.height, 0, 0));
|
||||
context.command.Blit(context.source, context.destination, material);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 98a055cea8a1355429d1cbb752c4e60e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,98 @@
|
||||
|
||||
Shader "Filter/MattiasCRT"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Base (RGB)", 2D) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_TexelSize;
|
||||
float2 _iResolution;
|
||||
|
||||
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 );
|
||||
float3 oricol = tex2D(_MainTex,uv).xyz;
|
||||
float3 col;
|
||||
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;
|
||||
|
||||
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.g += 0.05*tex2D(_MainTex,0.75*float2(x+-0.022, -0.02)+float2(uv.x+0.000,uv.y-0.002)).y;
|
||||
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 = 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;
|
||||
}
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float2 pos = _iResolution.xy*i.uv;
|
||||
fixed4 col = mainImage(pos);
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5dd9160e7dde4dd4db07347ce4780217
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user