Please show off what crt shaders can do!

Here you go: https://github.com/Dogway/emulation-random/tree/master/RetroArch/Shaders

Place “grade.slang” in /shaders_slang/misc/

2 Likes

I added an aperture grille effect and a bit of bloom and I think this is even better than the last preset I posted in terms of dynamic range and contrast; highlights look even better now IMO and there’s no loss of detail in dark areas compared to the previous preset. Upper range is smoothed out a bit, too. A bit of bloom is a really great way to compensate for the darkness added by the mask since it seems to mostly affect the mid range. Very pleased with these results.

Like the last preset I posted, you’ll need to put the grade shader in the appropriate directory for this to work- see my previous post for info.

shaders = "8"
shader0 = "shaders_slang/misc/grade.slang"
filter_linear0 = "true"
wrap_mode0 = "clamp_to_border"
mipmap_input0 = "false"
alias0 = "WhitePointPass"
float_framebuffer0 = "false"
srgb_framebuffer0 = "false"
scale_type_x0 = "source"
scale_x0 = "1.000000"
scale_type_y0 = "source"
scale_y0 = "1.000000"
shader1 = "shaders_slang/crt/shaders/guest/afterglow.slang"
filter_linear1 = "true"
wrap_mode1 = "clamp_to_border"
mipmap_input1 = "false"
alias1 = "AfterglowPass"
float_framebuffer1 = "false"
srgb_framebuffer1 = "false"
scale_type_x1 = "source"
scale_x1 = "1.000000"
scale_type_y1 = "source"
scale_y1 = "1.000000"
shader2 = "shaders_slang/crt/shaders/guest/avg-lum.slang"
filter_linear2 = "true"
wrap_mode2 = "clamp_to_border"
mipmap_input2 = "true"
alias2 = "AvgLumPass"
float_framebuffer2 = "true"
srgb_framebuffer2 = "false"
scale_type_x2 = "source"
scale_x2 = "1.000000"
scale_type_y2 = "source"
scale_y2 = "1.000000"
shader3 = "shaders_slang/crt/shaders/guest/linearize.slang"
filter_linear3 = "true"
wrap_mode3 = "clamp_to_border"
mipmap_input3 = "false"
alias3 = "LinearizePass"
float_framebuffer3 = "true"
srgb_framebuffer3 = "false"
scale_type_x3 = "source"
scale_x3 = "1.000000"
scale_type_y3 = "source"
scale_y3 = "1.000000"
shader4 = "shaders_slang/crt/shaders/guest/blur_horiz.slang"
filter_linear4 = "true"
wrap_mode4 = "clamp_to_border"
mipmap_input4 = "false"
alias4 = ""
float_framebuffer4 = "true"
srgb_framebuffer4 = "false"
scale_type_x4 = "source"
scale_x4 = "1.000000"
scale_type_y4 = "source"
scale_y4 = "1.000000"
shader5 = "shaders_slang/crt/shaders/guest/blur_vert.slang"
filter_linear5 = "true"
wrap_mode5 = "clamp_to_border"
mipmap_input5 = "false"
alias5 = "GlowPass"
float_framebuffer5 = "true"
srgb_framebuffer5 = "false"
scale_type_x5 = "source"
scale_x5 = "1.000000"
scale_type_y5 = "source"
scale_y5 = "1.000000"
shader6 = "shaders_slang/crt/shaders/guest/linearize_scanlines.slang"
filter_linear6 = "true"
wrap_mode6 = "clamp_to_border"
mipmap_input6 = "false"
alias6 = ""
float_framebuffer6 = "true"
srgb_framebuffer6 = "false"
scale_type_x6 = "source"
scale_x6 = "1.000000"
scale_type_y6 = "source"
scale_y6 = "1.000000"
shader7 = "shaders_slang/crt/shaders/guest/crt-guest-dr-venom.slang"
filter_linear7 = "true"
wrap_mode7 = "clamp_to_border"
mipmap_input7 = "false"
alias7 = ""
float_framebuffer7 = "false"
srgb_framebuffer7 = "false"
scale_type_x7 = "viewport"
scale_x7 = "1.000000"
scale_type_y7 = "viewport"
scale_y7 = "1.000000"
parameters = "g_gamma_out;g_gamma_in;g_gamma_type;g_vignette;g_vstr;g_vpower;g_csize;g_bsize;g_crtgamut;wp_temperature;g_sat;g_vibr;g_lum;g_cntrst;g_mid;g_lift;blr;blg;blb;wlr;wlg;wlb;rg;rb;gr;gb;br;bg;LUT_Size1;LUT1_toggle;LUT_Size2;LUT2_toggle;SW;AR;PR;AG;PG;AB;PB;sat;lsmooth;GAMMA_INPUT;TAPSH;GLOW_FALLOFF_H;TAPSV;GLOW_FALLOFF_V;TATE;IOS;OS;BLOOM;brightboost;brightboost1;gsl;scanline1;scanline2;beam_min;beam_max;beam_size;h_sharp;s_sharp;csize;bsize;warpX;warpY;glow;shadowMask;masksize;vertmask;slotmask;slotwidth;double_slot;slotms;mcut;maskDark;maskLight;CGWG;gamma_out;spike;inter;interm;bloom;scans"
g_gamma_out = "2.200000"
g_gamma_in = "2.400000"
g_gamma_type = "1.000000"
g_vignette = "0.000000"
g_vstr = "40.000000"
g_vpower = "0.200000"
g_csize = "0.000000"
g_bsize = "600.000000"
g_crtgamut = "1.000000"
wp_temperature = "7871.000000"
g_sat = "0.000000"
g_vibr = "-0.000000"
g_lum = "0.000000"
g_cntrst = "0.000000"
g_mid = "0.500000"
g_lift = "0.000000"
blr = "0.000000"
blg = "0.000000"
blb = "0.000000"
wlr = "1.000000"
wlg = "1.000000"
wlb = "1.000000"
rg = "0.000000"
rb = "0.000000"
gr = "0.000000"
gb = "0.000000"
br = "0.000000"
bg = "0.000000"
LUT_Size1 = "16.000000"
LUT1_toggle = "0.000000"
LUT_Size2 = "64.000000"
LUT2_toggle = "0.000000"
SW = "1.000000"
AR = "0.070000"
PR = "0.050000"
AG = "0.070000"
PG = "0.050000"
AB = "0.070000"
PB = "0.050000"
sat = "0.100000"
lsmooth = "0.900000"
GAMMA_INPUT = "2.200000"
TAPSH = "4.000000"
GLOW_FALLOFF_H = "0.000000"
TAPSV = "4.000000"
GLOW_FALLOFF_V = "0.000000"
TATE = "0.000000"
IOS = "0.000000"
OS = "1.000000"
BLOOM = "0.000000"
brightboost = "1.000000"
brightboost1 = "1.000000"
gsl = "2.000000"
scanline1 = "15.000000"
scanline2 = "5.000000"
beam_min = "1.500001"
beam_max = "0.750000"
beam_size = "0.000000"
h_sharp = "5.000000"
s_sharp = "0.000000"
csize = "0.000000"
bsize = "600.000000"
warpX = "0.000000"
warpY = "0.000000"
glow = "0.000000"
shadowMask = "0.000000"
masksize = "1.000000"
vertmask = "0.000000"
slotmask = "0.000000"
slotwidth = "2.000000"
double_slot = "1.000000"
slotms = "1.000000"
mcut = "0.000000"
maskDark = "0.500000"
maskLight = "1.500000"
CGWG = "0.500000"
gamma_out = "2.200000"
spike = "1.000000"
inter = "400.000000"
interm = "1.000000"
bloom = "0.200000"
scans = "0.500000"
textures = "SamplerLUT1;SamplerLUT2"
SamplerLUT1 = "shaders_slang/crt/shaders/guest/lut/sony_trinitron1.png"
SamplerLUT1_linear = "true"
SamplerLUT1_wrap_mode = "clamp_to_border"
SamplerLUT1_mipmap = "false"
SamplerLUT2 = "shaders_slang/crt/shaders/guest/lut/sony_trinitron2.png"
SamplerLUT2_linear = "true"
SamplerLUT2_wrap_mode = "clamp_to_border"
SamplerLUT2_mipmap = "false"
4 Likes

Look at you, using bloom, lol.

Screens are looking better, I think the bloom is helping with contrast making the image pop more.

1 Like

Definitely! Highlights are brighter and there’s a smoother transition between shades at the high end, but the dark shades are mostly unaffected. It works a lot better than bright boost as a way to compensate for the mask, IMO.

2 Likes

Most certainly.

Yeah, thats been my experience with it, lol.

1 Like

I have been have a good time with the reshade shaders in retroarch. It’s like J.J. Abrams threw up on all my games with len’s flares, bloom, and halos. It’s most fun for games like Super Metroid and Castlevania Dracula X. (It’s also hard to capture the fast explosions and the fx around them) Having quasi real time lighting in older games is interesting. First shot is venom guest+reshade and then just venom guest.

3 Likes

The first two reshade shots are much more interesting than the X-Men shot. I could see this being interesting in certain games. It’d be cool to see some vector games with this, I’d imagine.

In motion it can all get a little epileptic inducing but then it looks a little dull in stills. I quickly messed around with a vector shader. I’m not sure why retroarch takes screenshots of tempest so low when my resolution in mame is higher.

5 Likes

Improved the glass shader (still WIP), I admit this is not for everyone but I really wanted a glass shader for arcade games.

Also the reflection blur parameter isn’t working must be some shuffling of parameters, I’m not really familiarized with shaders.

4 Likes

This is looking nice! The text is a great way to show off the image reflection.

My only complaint is the screen reflection, see upper right hand corner. The best implementation I’ve seen of screen reflection so far, imo is @HyperspaceMadness’s method.

Regardless I’m looking forward to seeing what you do with this!

EDIT: Changed some text based on @HyperspaceMadness’s input.

1 Like

Just to clarify what Syh is talking about with the screen reflection. In the Mega Bezel the screen reflection is just a simple texture blended additively on top of the screen, so the reflection you end up seeing is directly related to what you put in the texture map.

2 Likes

Thanks it’s sometimes hard to articulate things like this, lol.

Fixed it, sort of… in my previous post.

Currently I’m experimenting with “shaped bezel” reflections. Right now, if you just use reflections, you can shape the “inner rounding” of the bezel with a curvature. But the “outer rounding/edge” of the bezel will always be straight. Out there in the wild wild world you can find bezels that are rounded on the outside as well, so without additional tweaking you will not be able to place a reflection that only effects the space between the inner and the outer rounded edges.

So I’m doing what @HyperspaceMadness already suggested before:

I put the reflection on top of a background image (usually with “blend color with background bezel” so that the original texture/structure of the bezel will still be visible). The reflection exceeds the limits of the bezel, at least until the position with the highest curvature is covered.

Then I put the same (or nearly the same) image on top as overlay image. But before this I modify the background image by “cutting out” the area of the bezel completely (or alternatively apply some opacity for that area). Now the reflection can be seen until it vanishes behind the opaqueness of the top overlay image. Like this I can shape the reflection in any way I want (you could call it “masking” with a top overlay).

Here’s an example:

It’s not perfect yet, but I’m getting there slowly … :wink:

2 Likes

Hi, I’m new to the forum and this topic called to my attention the shaders particulary for me aren’t that good they tend to distort the pixels in a way I dislike.

There is only one shader that is worth using for me, this is the dotmask.glsl available for v1.3.4 if I’m not wrong and is not available anymore ¿¿???, this shader represents what is a RGB mesh very similar to the filter of my old CRT tv, there is actually a similar version of this for MAME called RGB3 effect available on MAMEplus 0.155 it uses a .png file located within the “artwork” address. this filter is even better than the dotmask.glsl in short I’m happy not to notice sharp edges of the pixels by using RBG3 effect on MAME. My point is asking for a port of this effect that is like an improvement of dotmask.glsl.

As I’m new thanks to anyone that contribute here this is an unvaluable effort of yours thanks.

1 Like

You should try the blendoverlay shader, it will let you use the RBG3 png from MAME that you like. You just have to point to the image in the shader preset.

Also dotmask.glsl is in the crt shaders folder. Just looked where the shaders get added to RetroArch from, maybe it was moved in between releases?

Can you post your reshade settings?

1 Like

Do you want the Tekken one or Street Fighter one?

I love the god rays! I’m curious what this looks like in motion, “epileptic” sounds like it might be distracting :wink:

This one also looks quite cool, so you know what might be different than a standard glow?

Both. I’m struggling a lot to find good reshade combination for games outside of Retroarch.

1 Like

ReShade shader (Copy and save this as a .fx text file):

uniform float ResolutionX=512.0;
uniform float ResolutionY=448.0;
uniform float CornerBlur=1.5;
uniform float CornerSize=1.5;
uniform float Gamma1=2.2;
uniform float Gamma2=2.2;
uniform float Brightness=1.0;
uniform float Curvature=1.0;
uniform float ViewerDistance=3.0;
uniform float CurvatureRadius=3.0;
uniform float ScanlineWeight=0.2;
uniform float DotMaskWeight=0.0;
#include "ReShade.fxh"
#define TextureSize float2(ResolutionX,ResolutionY)
#define InputSize float2(ResolutionX,ResolutionY)
#define OutputSize BUFFER_SCREEN_SIZE
#define sinangle sin(0.0)
#define cosangle cos(0.0)
#define stretch max()
#define aspect float2(1.0,0.75)
#define FIX(c)max(abs(c),1e-5)
#define PI 3.141592653589
#define fmod(x,y)(x-y*trunc(x/y))
#define mod_factor texcoord.x*TextureSize.x*OutputSize.x/InputSize.x
#define TEX2D(c)pow(tex2D(ReShade::BackBuffer,(c)),Gamma1)
uniform int framecount<source="framecount";>;
float intersect(float2 xy)
{
float A=dot(xy,xy)+ViewerDistance*ViewerDistance;
float B=2.0*(CurvatureRadius*(dot(xy,sinangle)-ViewerDistance*cosangle*cosangle)-ViewerDistance*ViewerDistance);
float C=ViewerDistance*ViewerDistance+2.0*CurvatureRadius*ViewerDistance*cosangle*cosangle;
return(-B-sqrt(B*B-4.0*A*C))/(2.0*A);
}
float2 bkwtrans(float2 xy)
{
float c=intersect(xy);
float2 _pnt=c*xy;
_pnt-=-CurvatureRadius*sinangle;
_pnt/=CurvatureRadius;
float2 tang=sinangle/cosangle;
float2 poc=_pnt/cosangle;
float A=dot(tang,tang)+1.0;
float B=-2.0*dot(poc,tang);
float C=dot(poc,poc)-1.0;
float a=(-B+sqrt(B*B-4.0*A*C))/(2.0*A);
float2 uv=(_pnt-a*sinangle)/cosangle;
float r=FIX(CurvatureRadius*acos(a));
return uv*r/sin(r/CurvatureRadius);
}
float2 fwtrans(float2 uv)
{
float r=FIX(sqrt(dot(uv,uv)));
uv*=sin(r/CurvatureRadius)/r;
float x=1.0-cos(r/CurvatureRadius);
float D=ViewerDistance/CurvatureRadius+x*cosangle*cosangle+dot(uv,sinangle);
return ViewerDistance*(uv*cosangle-x*sinangle)/D;
}
float3 max()
{
float2 c=bkwtrans(-CurvatureRadius*sinangle/(1.0+CurvatureRadius/ViewerDistance*cosangle*cosangle));
float2 a=0.5*aspect;
float2 lo=float2(fwtrans(float2(-a.x,c.y)).x,fwtrans(float2(c.x,-a.y)).y)/aspect;
float2 hi=float2(fwtrans(float2(+a.x,c.y)).x,fwtrans(float2(c.x,+a.y)).y)/aspect;
return float3((hi+lo)*aspect*0.5,max(hi.x-lo.x,hi.y-lo.y));
}
float2 transform(float2 coord)
{
coord=(coord-0.5)*aspect*stretch.z+stretch.xy;
return(bkwtrans(coord)/1.0/aspect+0.5);
}
float corner(float2 coord)
{
coord=(coord-0.5)*1.0+0.5;
coord=min(coord,1.0-coord)*float2(1.0,OutputSize.y/OutputSize.x);
float2 cdist=max(CornerSize/100.0,max((1.0-smoothstep(100.0,600.0,CornerBlur*100.0))*0.01,0.002));
coord=(cdist-min(coord,cdist));
float dist=sqrt(dot(coord,coord));
return clamp((cdist.x-dist)*CornerBlur*100.0,0.0,1.0);
}
float4 scanlineWeights(float distance,float4 color)
{
float4 wid=2.0+2.0*pow(color,4.0);
float4 weights=distance/ScanlineWeight;
return 1.4*exp(-pow(weights*rsqrt(0.5*wid),wid))/(0.6+0.2*wid);
}
float3 AdvancedCrtPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
{
float2 ilfac=float2(1.0,clamp(floor(InputSize.y/200.0),1.0,2.0));
float2 coone=ilfac/TextureSize;
float2 xy=Curvature?transform(texcoord):texcoord;
float cval=corner(xy);
float2 ilvec=float2(0.0,ilfac.y*0.0>1.5?fmod(framecount,2.0):0.0);
float2 ratio_scale=(xy*TextureSize-0.5+ilvec)/ilfac;
float filter=fwidth(ratio_scale.y);
float2 uv_ratio=frac(ratio_scale);
xy=(floor(ratio_scale)*ilfac+0.5-ilvec)/TextureSize;
float4 coeffs=PI*float4(1.0+uv_ratio.x,uv_ratio.x,1.0-uv_ratio.x,2.0-uv_ratio.x);
coeffs=FIX(coeffs);
coeffs=2.0*sin(coeffs)*sin(coeffs/2.0)/(coeffs*coeffs);
coeffs/=dot(coeffs,1.0);
float4 col1=clamp(TEX2D(xy+float2(-coone.x,0.0))*coeffs.x+TEX2D(xy)*coeffs.y+TEX2D(xy+float2(coone.x,0.0))*coeffs.z+TEX2D(xy+float2(2.0*coone.x,0.0))*coeffs.w,0.0,1.0);
float4 col2=clamp(TEX2D(xy+float2(-coone.x,coone.y))*coeffs.x+TEX2D(xy+float2(0.0,coone.y))*coeffs.y+TEX2D(xy+coone)*coeffs.z+TEX2D(xy+float2(2.0*coone.x,coone.y))*coeffs.w,0.0,1.0);
float4 weights1=scanlineWeights(uv_ratio.y,col1);
float4 weights2=scanlineWeights(1.0-uv_ratio.y,col2);
uv_ratio.y=uv_ratio.y+1.0/3.0*filter;
weights1=(weights1+scanlineWeights(abs(uv_ratio.y),col1))/3.0;
weights2=(weights2+scanlineWeights(abs(1.0-uv_ratio.y),col2))/3.0;
uv_ratio.y=uv_ratio.y-2.0/3.0*filter;
weights1=weights1+scanlineWeights(abs(uv_ratio.y),col1)/3.0;
weights2=weights2+scanlineWeights(abs(1.0-uv_ratio.y),col2)/3.0;
float3 mul_res=(col1*weights1+col2*weights2).rgb*cval;
float3 maskweights=lerp(float3(1.0,1.0-DotMaskWeight,1.0),float3(1.0-DotMaskWeight,1.0,1.0-DotMaskWeight),floor(fmod(mod_factor,2.0)));
mul_res*=maskweights*Brightness;
mul_res=pow(mul_res,1.0/Gamma2);
return float4(mul_res,1.0);
}
technique AdvancedCRT
{
pass
{
VertexShader=PostProcessVS;
PixelShader=AdvancedCrtPS;
}
}

This is for 2D PS2 games. Change the “ResolutionX” and “ResolutionY” to the resolution of the console you are emulating.

EDIT - I no longer have the older shader I made for Tekken. You can change “ResolutionX” to “1920.0” and “ResolutionY” to “1080.0” (or change them to whatever your screen resolution is). I do this for 3D games personally. Maybe you will like it too.

Also, I fixed the line doubling problem in interlaced games an older version of this shader had.

4 Likes