RetroArch shaders for ReShade (4.0+)

More
3 years 9 months ago #41 by Puxirepublic
Replied by Puxirepublic on topic RetroArch shaders for ReShade 3.0 (NTSC/PAL Added)
Dear @matsilagi, requests for crtglow_gauss, since it's RetroArch built-in shaders still not ported yet. Thanks!

Please Log in or Create an account to join the conversation.

More
3 years 9 months ago #42 by matsilagi

File Attachment:
File Attachment:
File Attachment:


I haven't tested every shaders but unfortunately CRT Aperture still produce a blurry inaccurate picture compared to others where every lines are well displayed.


Updated it again on my GitHub, hopefully that fixes it. (I didn't see any other errors on it)

Please Log in or Create an account to join the conversation.

More
3 years 9 months ago #43 by Flamex
Unfortunately, that doesn't fix the problem.... :(
I have tested with different games, resolutions or ratios, most of other crt shaders works as well as RetroArch versions but not this one.
Thanks for trying anyway
I can post some pics for comparison if you are interested

Please Log in or Create an account to join the conversation.

More
3 years 8 months ago #44 by matsilagi
Yes, it would be nice.

I don't know what else to change, it should work as intended.

Please Log in or Create an account to join the conversation.

More
3 years 8 months ago #45 by qdclonman
@matsilagi Bilinear Interpolation please~~

Please Log in or Create an account to join the conversation.

More
3 years 8 months ago - 3 years 8 months ago #46 by Flamex
Ok I've used Retroarch for this test so I can use both native or reshade shaders with the same source.
Please note that my resolution is 1920x1200 so I can use a scale ratio of 5x the native resolution.

As you can see the results are similar with both versions ( not exactly the same parameters ) but on Easymode I have to disable the Lanczos filter.
Does aperture has an internal Lanczos filter ?

unfiltered picture
File Attachment:


RA Hyllian
File Attachment:
RA+RS Hyllian
File Attachment:
Last edit: 3 years 8 months ago by Flamex.

Please Log in or Create an account to join the conversation.

More
3 years 8 months ago - 3 years 8 months ago #47 by Flamex
RA Easymode
File Attachment:
RA+RS Easymode (Lanczos off)
File Attachment:
RA+RS Easymode (Lanczos on)
File Attachment:
Last edit: 3 years 8 months ago by Flamex.

Please Log in or Create an account to join the conversation.

More
3 years 8 months ago #48 by Flamex
RA Aperture
File Attachment:
RA+RS Aperture
File Attachment:

Please Log in or Create an account to join the conversation.

More
3 years 8 months ago #49 by matsilagi
Ah yes, Aperture has an internal Lanczos filter, yes.
Its probably something on all of them, due to the fact the lanczos uses the internal res, which ReShade doesn't.

Anyways, i guess disabling it is the only solution for the moment.

Please Log in or Create an account to join the conversation.

More
3 years 8 months ago #50 by Flamex

Ah yes, Aperture has an internal Lanczos filter, yes.
Its probably something on all of them, due to the fact the lanczos uses the internal res, which ReShade doesn't.

Anyways, i guess disabling it is the only solution for the moment.


So, there's one hope !
If you can, it would be interesting to implement an on/off switch on the Lanzcos filter to several shaders to compare just like the easymode one.

Please Log in or Create an account to join the conversation.

More
3 years 4 months ago #51 by mr_blastman
Replied by mr_blastman on topic RetroArch shaders for ReShade 3.0 (NTSC/PAL Added)
Thank you for this!

Any chance of porting Solid12345's shaders for Retroarch?

Please Log in or Create an account to join the conversation.

More
3 years 2 months ago #52 by brad86
Any chance of porting over the Game Boy shaders. They look fantastic, and there really is no replacement for them.

Please Log in or Create an account to join the conversation.

More
3 years 2 months ago #53 by Fu-Bama
ArtifactColors.fx
#if ARTIFACT_COLORS_MUL_FIX
	//on directx the matrices must be multiplied in reverse
	#if (__RENDERER__ >= 0x10000)
		#define MUL(A, B) mul(A, B)
	#else
		#define MUL(A, B) mul(B, A)
	#endif
#else
	#define MUL(A, B) mul(A, B)
#endif
I think this issue was fixed some time ago reshade.me/forum/troubleshooting/4029-ma...-vector-multiply-bug
What version of ReShade did you use when porting?

Please Log in or Create an account to join the conversation.

More
1 year 9 months ago - 1 year 9 months ago #54 by ScreamerofStars
Replied by ScreamerofStars on topic RetroArch shaders for ReShade 3.0 (NTSC/PAL Added)
necroing this thread, but NTSC filters hates DX9 and DX11

also, any plans to port some more royale stuff like Xm29and the professional CRT screens?
Last edit: 1 year 9 months ago by ScreamerofStars.

Please Log in or Create an account to join the conversation.

More
1 year 9 months ago - 1 year 9 months ago #55 by gamehancer
hi matsilagi I need your help if possible I would like to know if we can convert a first adobe shader into fx if I explain to you some years ago I asked on the forum how we can do to have the same effect vhs that this video without the date / time only the effect looks for you even in the video below

Last edit: 1 year 9 months ago by gamehancer.

Please Log in or Create an account to join the conversation.

More
1 year 4 months ago #56 by Dooberknob
I'm not able to get most of these shaders to behave in reshade the way they do in retroarch. Retroarch seems to automatically detect the content resolution, and the display resolution, then make sure the scanlines are spaced equidistantly between the pixels (provided integer scale is enabled.)

For example, I'm playing Doom set to 480p on a 1440p monitor. With scanlines-abs.fx I'm able to achieve the above scenario by setting the Scanlines Height to 480. However I can't figure out how to do this with any of the other CTR shaders regardless of what I enter in the Screen/Frame Width/Height parameters.

Anyone know what I'm doing wrong?

Please Log in or Create an account to join the conversation.

More
1 year 1 month ago - 1 year 1 month ago #57 by SamHammich

I'm not able to get most of these shaders to behave in reshade the way they do in retroarch. Retroarch seems to automatically detect the content resolution, and the display resolution, then make sure the scanlines are spaced equidistantly between the pixels (provided integer scale is enabled.)

For example, I'm playing Doom set to 480p on a 1440p monitor. With scanlines-abs.fx I'm able to achieve the above scenario by setting the Scanlines Height to 480. However I can't figure out how to do this with any of the other CTR shaders regardless of what I enter in the Screen/Frame Width/Height parameters.

Anyone know what I'm doing wrong?


I'm not sure which filter or game settings you're running, but my results have always been fine by running the game at my desktop res and setting the filter's resolution for both screen and frame to match the target content resolution. I mostly use Geom, Lottes, and Easymode for this.

Unless the game is running at your desktop resolution with the native resolution running internally in the render stretched to fullscreen (eg Half-Life at 480p resolutions does this), you'll need to be actually running Doom at the higher resolution with the HUD scaled up to match its original size, then applying the filter over the high res image. Some source ports should have this in the settings. Otherwise reshade will try building the crt image out of the same number of pixels as a 480p image, which just isn't going to work.

The way you set the resolution, whatever your aspect ratio, is to multiply the target vertical resolution by the aspect ratio to get the correct horizontal resolution. So 480x16/9=853.333' which you might get away with rounding up or down. Loads of retro-styled modern games use 360p or 180p as this scales better to modern resolutions & aspect ratios. If the horizontal resolution doesn't seem to be lining up accurately & is warping the dimensions of some 2D assets despite some tweaking, just set the X axis to the full resolution of your screen or whatever you're running the game at, as this will be much less noticeable than the vertical resolution. Some games seem to shift UI elements around on higher resolutions unfortunately.

So that's more or less how I've gotten the results I like out of it.
Last edit: 1 year 1 month ago by SamHammich. Reason: forgot to specify who my response was addressing

Please Log in or Create an account to join the conversation.

More
11 months 2 weeks ago - 11 months 2 weeks ago #58 by Diego0920
I would be so happy if ArtifactColors at least was updated to Reshade 4.0+
When I used it was amazing (click for fullscreen)






One thing I don't like as much these days is the actual artifacting (green & purple colors around edges). I would prefer only the color bleed to stay, probably. Maybe add an artifacting on/off option instead.
Last edit: 11 months 2 weeks ago by Diego0920.

Please Log in or Create an account to join the conversation.

More
11 months 2 weeks ago #59 by Tojkar

I would be so happy if ArtifactColors at least was updated to Reshade 4.0+
One thing I don't like as much these days is the actual artifacting (green & purple colors around edges). I would prefer only the color bleed to stay, probably.

I too would love to see this shader ported to 4.x.

To make the job easier, I'll paste here the original code:
[code]/*
Adapted for RetroArch from Flyguy's "Apple II-Like Artifact Colors" from shadertoy:
www.shadertoy.com/view/llyGzR

"Colors created through NTSC artifacting on 4-bit patterns, similar to the Apple II's lo-res mode."

"Ported to ReShade by Matsilagi and luluco250"
*/

#if ARTIFACT_COLORS_MUL_FIX
//on directx the matrices must be multiplied in reverse
#if (__RENDERER__ >= 0x10000)
#define MUL(A, B) mul(A, B)
#else
#define MUL(A, B) mul(B, A)
#endif
#else
#define MUL(A, B) mul(A, B)
#endif

#include "ReShade.fxh"

//Macros/////////////////////////////////////////////////////////////////////////////////////////

uniform float display_sizeX <
ui_type = "drag";
ui_min = 1.0;
ui_max = BUFFER_WIDTH;
ui_label = "Screen Width [ArtifactColors]";
> = BUFFER_WIDTH;

uniform float display_sizeY <
ui_type = "drag";
ui_min = 1.0;
ui_max = BUFFER_HEIGHT;
ui_label = "Screen Height [ArtifactColors]";
> = BUFFER_HEIGHT;

uniform float HUE <
ui_type = "drag";
ui_min = 0.0;
ui_max = 1.0;
ui_step = 0.01;
ui_label = "Hue [ArtifactColors]";
> = 0.0;

uniform float SATURATION <
ui_type = "drag";
ui_min = 0.0;
ui_max = 100.0;
ui_step = 1.0;
ui_label = "Saturation [ArtifactColors]";
> = 30.0;

uniform float BRIGHTNESS <
ui_type = "drag";
ui_min = 0.0;
ui_max = 2.0;
ui_label = "Brightness [ArtifactColors]";
ui_step = 0.01;
> = 1.0;

uniform float F_COL <
ui_type = "drag";
ui_min = 4.0;
ui_max = 8.0;
ui_step = 1.0;
ui_label = "F Col [ArtifactColors]";
ui_tooltip = "Realtime changes not available in DX9.\nUse F_COL_DX9 to mod that in DX9.\n(Preprocessor Definition)";
> = 4.0;

uniform float F_COL_BW <
ui_type = "drag";
ui_min = 10.0;
ui_max = 200.0;
ui_step = 1.0;
ui_label = "F Col BW [ArtifactColors]";
ui_tooltip = "Realtime changes not available in DX9.\nUse F_COL_BW_DX9 to mod that in DX9.\n(Preprocessor Definition)";
> = 50.0;

uniform float F_LUMA_LP <
ui_type = "drag";
ui_min = 1.0;
ui_max = 12.0;
ui_step = 1.0;
ui_label = "F Luma LP [ArtifactColors]";
ui_tooltip = "Realtime changes not available in DX9.\nUse F_LUMA_LP_DX9 to mod that in DX9.\n(Preprocessor Definition)";
> = 6.0;

uniform int Viewmode <
ui_type = "combo";
ui_label = "View Mode [ArtifactColors]";
ui_items = "Composite\0RGB\0Luma\0Chroma\0Signal\0Split\0";
> = 0;

//DirectX 9 fixes HERE WE GOOOOOO fuck...
#ifndef F_COL_DX9
#define F_COL_DX9 4.0
#endif

#ifndef F_LUMA_LP_DX9
#define F_LUMA_LP_DX9 6.0
#endif

#ifndef F_COL_BW_DX9
#define F_COL_BW_DX9 50.0
#endif

#define FIR_SIZE 29

#define display_size float2(display_sizeX,display_sizeY)

//Statics////////////////////////////////////////////////////////////////////////////////////////

static const float pi = atan(1.0) * 4.0;
static const float tau = atan(1.0) * 8.0;
static const float3x3 rgb2yiq = float3x3(
0.299, 0.596, 0.211,
0.587,-0.274,-0.523,
0.114,-0.322, 0.312
);
static const float3x3 yiq2rgb = float3x3(
1.000, 1.000, 1.000,
0.956,-0.272,-1.106,
0.621,-0.647, 1.703
);

//Uniforms///////////////////////////////////////////////////////////////////////////////////////
//Textures///////////////////////////////////////////////////////////////////////////////////////

texture ArtifactChannel0_tex {
Width = BUFFER_WIDTH;
Height = BUFFER_HEIGHT;
Format = RGBA32F;
};

texture tArtifactColors_Modulator {
Width = BUFFER_WIDTH;
Height = BUFFER_HEIGHT;
Format = R16F;
};
sampler sArtifactColors_Modulator {
Texture = tArtifactColors_Modulator;
};

texture tArtifactColors_Demodulator {
Width = BUFFER_WIDTH;
Height = BUFFER_HEIGHT;
Format = RGBA16F;
};

sampler sArtifactColors_Demodulator {
Texture = tArtifactColors_Demodulator;
};

sampler ArtifactChannel0 {
Texture = ArtifactChannel0_tex;
};

//Functions//////////////////////////////////////////////////////////////////////////////////////

//Angle -> 2D rotation matrix
float2x2 rotate(float a) {
return float2x2(
cos(a), sin(a),
-sin(a), cos(a)
);
}

//Non-normalized texture sampling
float4 sample2D(sampler sp, float2 res, float2 uv) {
return tex2D(sp, uv / res);
}

//Complex multiply
float2 cmul(float2 a, float2 b) {
return float2((a.x * b.x) - (a.y * b.y), (a.x * b.y) + (a.y * b.y));
}

float sinc(float x) { //reshade warns about division by zero here, even though there should be none
//return (x == 0.0) ? 1.0 : sin(x * pi) / max(x * pi, 0.001); //so we'll use max()
return (x == 0.0) ? 1.0 : sin(x * pi) / (x * pi);
}

//https://en.wikipedia.org/wiki/Window_function
float WindowBlackman(float a, int N, int i) {
float a0 = (1.0 - a) / 2.0;
float a1 = 0.5;
float a2 = a / 2.0;

float wnd = a0;
wnd -= a1 * cos(2.0 * pi * (float(i) / float(N - 1)));
wnd += a2 * cos(4.0 * pi * (float(i) / float(N - 1)));

return wnd;
}

//FIR lowpass filter
//Fc = Cutoff freq., Fs = Sample freq., N = # of taps, i = Tap index
float Lowpass(float Fc, float Fs, int N, int i) {
float wc = (Fc / Fs);

float wnd = WindowBlackman(0.16, N, i);

return 2.0 * wc * wnd * sinc(2.0 * wc * float(i - N / 2));
}

//FIR bandpass filter
//Fa/Fb = Low/High cutoff freq., Fs = Sample freq., N = # of taps, i = Tap index
float Bandpass(float Fa, float Fb, float Fs, int N, int i) {
float wa = (Fa / Fs);
float wb = (Fb / Fs);

float wnd = WindowBlackman(0.16, N, i);

return 2.0 * (wb - wa) * wnd * (sinc(2.0 * wb * float(i - N / 2)) - sinc(2.0 * wa * float(i - N / 2)));
}

//Complex oscillator, Fo = Oscillator freq., Fs = Sample freq., n = Sample index
float2 Oscillator(float Fo, float Fs, float N) {
float phase = (tau * Fo * floor(N)) / Fs;
return float2(cos(phase), sin(phase));
}

float2 p_sh(float2 p_){

float2 xx = float2(320.0, 240.0); //output screen res
float2 ar = float2(1.0,1.0); //final aspect ratio (calculated)

xx = display_size;

ar = float(1.0).xx;

return 0.5 * float2(
step(0.0, 1.0 - ar.y) * (1.0 - 1.0 / ar.y),
step(1.0, ar.y) * (1.0 - ar.y));
}

//Shaders////////////////////////////////////////////////////////////////////////////////////////

float4 PS_Stock(float4 vpos : SV_Position, float2 texcoord : TexCoord) : SV_Target
{
float2 p_ = texcoord.xy*float2((float)BUFFER_WIDTH,(float)BUFFER_HEIGHT);
float2 xx = float2(320.0,240.0);
float2 ar = float2(1.0,1.0); //final aspect ratio (calculated)

xx = ReShade::ScreenSize.xy;
ar = float(1.0).xx;

xx = display_size;

p_ = texcoord;
p_ -= 0.5;
p_ *= ar;
p_ += 0.5;

if(ar.y<1.0){p_ -= 0.5; p_ = p_*(1.0/ar.y); p_ += 0.5; }

p_ = floor(p_*xx)/xx;
p_ += p_sh(p_);

return tex2D(ReShade::BackBuffer, p_).rgba;
}

float PS_Modulator(
float4 pos : SV_POSITION,
float2 uv : TEXCOORD
) : SV_TARGET {
float Fs = BUFFER_WIDTH;
float Fcol = Fs * (1.0 / F_COL);
float n = floor(uv.x * BUFFER_WIDTH);

float3 cRGB = tex2D(ArtifactChannel0, uv).rgb;
float3 cYIQ = MUL(rgb2yiq, cRGB);

float2 cOsc = Oscillator(Fcol, Fs, n);

float sig = cYIQ.x + dot(cOsc, cYIQ.yz);

return sig;
}

float4 PS_Demodulator(
float4 pos : SV_POSITION,
float2 uv : TEXCOORD
) : SV_TARGET {
float2 _uv = uv * ReShade::ScreenSize;

float Fs = BUFFER_WIDTH;
float Fcol = Fs * (1.0 / F_COL_DX9);
float Fcolbw = Fs * (1.0 / F_COL_BW_DX9);
float Flumlp = Fs * (1.0 / F_LUMA_LP_DX9);
float n = floor(_uv.x);

if (__RENDERER__ != 0x09300){
Fcol = Fs * (1.0 / F_COL);
Fcolbw = Fs * (1.0 / F_COL_BW);
Flumlp = Fs * (1.0 / F_LUMA_LP);
}

float y_sig = 0.0;
float iq_sig = 0.0;

float2 cOsc = Oscillator(Fcol, Fs, n);

n += float(FIR_SIZE) / 2.0;

//Separate luma(Y) & chroma(IQ) signals
[unroll]
for (int i = 0; i < FIR_SIZE; ++i) {
int tpidx = FIR_SIZE - i - 1;
float lp = Lowpass(Flumlp, Fs, FIR_SIZE, tpidx);
float bp = Bandpass(Fcol - Fcolbw, Fcol + Fcolbw, Fs, FIR_SIZE, tpidx);

y_sig += sample2D(sArtifactColors_Modulator, ReShade::ScreenSize, float2(n - float(i), _uv.y)).x * lp;
iq_sig += sample2D(sArtifactColors_Modulator, ReShade::ScreenSize, float2(n - float(i), _uv.y)).x * bp;
}

//Shift IQ signal down from Fcol to DC
float2 iq_sig_mix = cmul(float2(iq_sig, 0.0), cOsc);

return float4(y_sig, iq_sig_mix, 0.0);
}

float4 PS_Final(
float4 pos : SV_POSITION,
float2 uv : TEXCOORD
) : SV_TARGET {
float Fs = BUFFER_WIDTH;
float Fcol = Fs * (1.0 / F_COL);
float Flumlp = Fs * (1.0 / F_LUMA_LP);
float n = floor(uv.x * BUFFER_WIDTH);

if (__RENDERER__ != 0x09300){
Fcol = Fs * (1.0 / F_COL_DX9);
Flumlp = Fs * (1.0 / F_LUMA_LP_DX9);
}

float2 _uv = uv * ReShade::ScreenSize;

float luma = sample2D(sArtifactColors_Demodulator, ReShade::ScreenSize, _uv).x;
float2 chroma = 0.0;

//Filtering out unwanted high frequency content from the chroma(IQ) signal
[unroll]
for (int i = 0; i < FIR_SIZE; ++i) {
int tpidx = FIR_SIZE - i -1;
float lp = Lowpass(Flumlp, Fs, FIR_SIZE, tpidx);
chroma += sample2D(sArtifactColors_Demodulator, ReShade::ScreenSize, _uv - float2(i - FIR_SIZE / 2, 0)).yz * lp;
}


//chroma *= rotate(tau * HUE);
chroma = MUL(chroma, rotate(tau * HUE));

float3 color = MUL(yiq2rgb, float3(BRIGHTNESS * luma, chroma * SATURATION));

if (Viewmode == 0) {
return float4(color, 0.0);
} else if (Viewmode == 1) {
return tex2D(sArtifactColors_Modulator, uv).xxxx;
} else if (Viewmode == 2){
return float4(luma.xxx, 0.0);
} else if (Viewmode == 3){
return float4(40.0 * chroma + 0.5, 0.0, 0.0);
} else if (Viewmode == 4){
return 0.5 * tex2D(sArtifactColors_Demodulator, uv).xxxx + 0.25;
} else if (Viewmode == 5){
if (uv.

Please Log in or Create an account to join the conversation.

More
11 months 2 weeks ago #60 by Tojkar

I would be so happy if ArtifactColors at least was updated to Reshade 4.0+
One thing I don't like as much these days is the actual artifacting (green & purple colors around edges). I would prefer only the color bleed to stay, probably.

I too would love to see this shader ported to 4.x.

Tried to paste the shader here tagged as code but for some reason the forums consider it as spam.

Please Log in or Create an account to join the conversation.