Res: Port more Pokefan531 color shaders (closes #3437)

This commit is contained in:
Vicki Pfau 2025-05-19 23:29:02 -07:00
parent 03ad202c4d
commit 6c4bd1efa0
21 changed files with 457 additions and 0 deletions

View File

@ -67,6 +67,7 @@ Misc:
- Res: Port hq2x and OmniScale shaders from SameBoy
- Res: Port NSO-gba-colors shader (closes mgba.io/i/2834)
- Res: Update gba-colors shader (closes mgba.io/i/2976)
- Res: Port more Pokefan531 color shaders (closes mgba.io/i/3437)
- Scripting: Add `callbacks:oneshot` for single-call callbacks
0.10.5: (2025-03-08)

View File

@ -0,0 +1,20 @@
// Shader that replicates the LCD Colorspace from a Nintendo DS Lite --
varying vec2 texCoord;
varying mat4 profile;
uniform sampler2D tex;
uniform vec2 texSize;
const float target_gamma = 2.2;
const float display_gamma = 2.2;
void main() {
// bring out our stored luminance value
float lum = profile[3].w;
// our adjustments need to happen in linear gamma
vec4 screen = pow(texture2D(tex, texCoord), vec4(target_gamma)).rgba;
screen = clamp(screen * lum, 0.0, 1.0);
screen = profile * screen;
gl_FragColor = pow(screen, vec4(1.0 / display_gamma));
}

View File

@ -0,0 +1,34 @@
uniform int color_mode;
attribute vec4 position;
varying vec2 texCoord;
varying mat4 profile;
const mat4 DSL_sRGB = mat4(
0.93, 0.025, 0.008, 0.0, //red channel
0.14, 0.90, -0.03, 0.0, //green channel
-0.07, 0.075, 1.022, 0.0, //blue channel
0.0, 0.0, 0.0, 0.935 //alpha channel
);
const mat4 DSL_DCI = mat4(
0.76, 0.055, 0.0225, 0.0, //red channel
0.27, 0.875, 0.0225, 0.0, //green channel
-0.03, 0.07, 0.955, 0.0, //blue channel
0.0, 0.0, 0.0, 0.97 //alpha channel
);
const mat4 DSL_Rec2020 = mat4(
0.585, 0.09, 0.0225, 0.0, //red channel
0.3725, 0.825, 0.035, 0.0, //green channel
0.0425, 0.085, 0.9425, 0.0, //blue channel
0.0, 0.0, 0.0, 1.0 //alpha channel
);
void main() {
if (color_mode == 1) profile = DSL_sRGB;
else if (color_mode == 2) profile = DSL_DCI;
else if (color_mode == 3) profile = DSL_Rec2020;
gl_Position = position;
texCoord = (position.st + vec2(1.0, 1.0)) * vec2(0.5, 0.5);
}

View File

@ -0,0 +1,19 @@
[shader]
name=Nintendo DS Lite Color
author=Pokefan531 and hunterk
description=Shader that replicates the LCD Colorspace from a Nintendo DS Lite.
passes=1
[pass.0]
fragmentShader=dslite-color.fs
vertexShader=dslite-color.vs
blend=1
width=-1
height=-1
[pass.0.uniform.color_mode]
type=int
default=1
min=1
max=3
readableName=Color Profile (1=sRGB, 2=DCI, 3=Rec2020)

View File

@ -0,0 +1,20 @@
// Shader that replicates the LCD Colorspace from a Gameboy Micro (OXY-001) --
varying vec2 texCoord;
varying mat4 profile;
uniform sampler2D tex;
uniform vec2 texSize;
const float target_gamma = 2.2;
const float display_gamma = 2.2;
void main() {
// bring out our stored luminance value
float lum = profile[3].w;
// our adjustments need to happen in linear gamma
vec4 screen = pow(texture2D(tex, texCoord), vec4(target_gamma)).rgba;
screen = clamp(screen * lum, 0.0, 1.0);
screen = profile * screen;
gl_FragColor = pow(screen, vec4(1.0 / display_gamma));
}

View File

@ -0,0 +1,34 @@
uniform int color_mode;
attribute vec4 position;
varying vec2 texCoord;
varying mat4 profile;
const mat4 GBM_sRGB = mat4(
0.8025, 0.10, 0.1225, 0.0, //red channel
0.31, 0.6875, 0.1125, 0.0, //green channel
-0.1125, 0.2125, 0.765, 0.0, //blue channel
0.0, 0.0, 0.0, 0.9 //alpha channel
);
const mat4 GBM_DCI = mat4(
0.6675, 0.125, 0.13, 0.0, //red channel
0.3825, 0.675, 0.1475, 0.0, //green channel
-0.05, 0.20, 0.7225, 0.0, //blue channel
0.0, 0.0, 0.0, 0.96 //alpha channel
);
const mat4 GBM_Rec2020 = mat4(
0.525, 0.15, 0.13, 0.0, //red channel
0.43, 0.65, 0.155, 0.0, //green channel
0.045, 0.20, 0.715, 0.0, //blue channel
0.0, 0.0, 0.0, 1.0 //alpha channel
);
void main() {
if (color_mode == 1) profile = GBM_sRGB;
else if (color_mode == 2) profile = GBM_DCI;
else if (color_mode == 3) profile = GBM_Rec2020;
gl_Position = position;
texCoord = (position.st + vec2(1.0, 1.0)) * vec2(0.5, 0.5);
}

View File

@ -0,0 +1,19 @@
[shader]
name=GB Micro Color
author=Pokefan531 and hunterk
description=Shader that replicates the LCD Colorspace from a Gameboy Micro (OXY-001).
passes=1
[pass.0]
fragmentShader=gb-micro-color.fs
vertexShader=gb-micro-color.vs
blend=1
width=-1
height=-1
[pass.0.uniform.color_mode]
type=int
default=1
min=1
max=3
readableName=Color Profile (1=sRGB, 2=DCI, 3=Rec2020)

View File

@ -14,6 +14,8 @@ height=-1
[pass.0.uniform.darken_screen]
type=float
default=0.5
min=0
max=1
readableName=Darken Screen
[pass.0.uniform.color_mode]

View File

@ -0,0 +1,21 @@
// Shader that replicates the LCD Colorspace from Gameboy Color --
varying vec2 texCoord;
varying mat4 profile;
uniform sampler2D tex;
uniform vec2 texSize;
uniform float lighten_screen;
const float target_gamma = 2.2;
const float display_gamma = 2.2;
void main() {
// bring out our stored luminance value
float lum = profile[3].w;
// our adjustments need to happen in linear gamma
vec4 screen = pow(texture2D(tex, texCoord), vec4(target_gamma - lighten_screen)).rgba;
screen = clamp(screen * lum, 0.0, 1.0);
screen = profile * screen;
gl_FragColor = pow(screen, vec4(1.0 / display_gamma));
}

View File

@ -0,0 +1,34 @@
uniform int color_mode;
attribute vec4 position;
varying vec2 texCoord;
varying mat4 profile;
const mat4 GBC_sRGB = mat4(
0.905, 0.10, 0.1575, 0.0, //red channel
0.195, 0.65, 0.1425, 0.0, //green channel
-0.10, 0.25, 0.70, 0.0, //blue channel
0.0, 0.0, 0.0, 0.91 //alpha channel
);
const mat4 GBC_DCI = mat4(
0.76, 0.125, 0.16, 0.0, //red channel
0.27, 0.6375, 0.18, 0.0, //green channel
-0.03, 0.2375, 0.66, 0.0, //blue channel
0.0, 0.0, 0.0, 0.97 //alpha channel
);
const mat4 GBC_Rec2020 = mat4(
0.61, 0.155, 0.16, 0.0, //red channel
0.345, 0.615, 0.1875, 0.0, //green channel
0.045, 0.23, 0.6525, 0.0, //blue channel
0.0, 0.0, 0.0, 1.0 //alpha channel
);
void main() {
if (color_mode == 1) profile = GBC_sRGB;
else if (color_mode == 2) profile = GBC_DCI;
else if (color_mode == 3) profile = GBC_Rec2020;
gl_Position = position;
texCoord = (position.st + vec2(1.0, 1.0)) * vec2(0.5, 0.5);
}

View File

@ -0,0 +1,26 @@
[shader]
name=GBC Color
author=Pokefan531 and hunterk
description=Modifies the color output to simulate the GBA LCD characteristics.
passes=1
[pass.0]
fragmentShader=gbc-color.fs
vertexShader=gbc-color.vs
blend=1
width=-1
height=-1
[pass.0.uniform.lighten_screen]
type=float
default=1.0
min=0
max=1
readableName=External Lighten Screen
[pass.0.uniform.color_mode]
type=int
default=1
min=1
max=3
readableName=Color Profile (1=sRGB, 2=DCI, 3=Rec2020)

View File

@ -0,0 +1,19 @@
[shader]
name=Nintendo DS Color
author=Pokefan531 and hunterk
description=Shader that replicates the LCD Colorspace from a Nintendo DS Phat.
passes=1
[pass.0]
fragmentShader=nds-color.fs
vertexShader=nds-color.vs
blend=1
width=-1
height=-1
[pass.0.uniform.color_mode]
type=int
default=1
min=1
max=3
readableName=Color Profile (1=sRGB, 2=DCI, 3=Rec2020)

View File

@ -0,0 +1,20 @@
// Shader that replicates the LCD Colorspace from a Nintendo DS Phat --
varying vec2 texCoord;
varying mat4 profile;
uniform sampler2D tex;
uniform vec2 texSize;
const float target_gamma = 2.2;
const float display_gamma = 2.2;
void main() {
// bring out our stored luminance value
float lum = profile[3].w;
// our adjustments need to happen in linear gamma
vec4 screen = pow(texture2D(tex, texCoord), vec4(target_gamma)).rgba;
screen = clamp(screen * lum, 0.0, 1.0);
screen = profile * screen;
gl_FragColor = pow(screen, vec4(1.0 / display_gamma));
}

View File

@ -0,0 +1,34 @@
uniform int color_mode;
attribute vec4 position;
varying vec2 texCoord;
varying mat4 profile;
const mat4 NDS_sRGB = mat4(
0.835, 0.10, 0.105, 0.0, //red channel
0.27, 0.6375, 0.175, 0.0, //green channel
-0.105, 0.2625, 0.72, 0.0, //blue channel
0.0, 0.0, 0.0, 0.905 //alpha channel
);
const mat4 NDS_DCI = mat4(
0.70, 0.125, 0.12, 0.0, //red channel
0.34, 0.625, 0.20, 0.0, //green channel
-0.04, 0.25, 0.68, 0.0, //blue channel
0.0, 0.0, 0.0, 0.96 //alpha channel
);
const mat4 NDS_Rec2020 = mat4(
0.555, 0.1475, 0.1175, 0.0, //red channel
0.39, 0.6075, 0.2075, 0.0, //green channel
0.055, 0.245, 0.675, 0.0, //blue channel
0.0, 0.0, 0.0, 1.0 //alpha channel
);
void main() {
if (color_mode == 1) profile = NDS_sRGB;
else if (color_mode == 2) profile = NDS_DCI;
else if (color_mode == 3) profile = NDS_Rec2020;
gl_Position = position;
texCoord = (position.st + vec2(1.0, 1.0)) * vec2(0.5, 0.5);
}

View File

@ -14,6 +14,8 @@ height=-1
[pass.0.uniform.darken_screen]
type=float
default=0.8
min=0
max=1
readableName=Darken Screen
[pass.0.uniform.color_mode]

View File

@ -0,0 +1,26 @@
[shader]
name=NSO GBC Color
author=Pokefan531 and hunterk
description=Shader that replicates the Nintendo Switch Online's GBC color filter.
passes=1
[pass.0]
fragmentShader=nso-gbc-color.fs
vertexShader=nso-gbc-color.vs
blend=1
width=-1
height=-1
[pass.0.uniform.lighten_screen]
type=float
default=0.0
min=0
max=1
readableName=Lighten Screen
[pass.0.uniform.color_mode]
type=int
default=1
min=1
max=3
readableName=Color Profile (1=sRGB, 2=DCI, 3=Rec2020)

View File

@ -0,0 +1,19 @@
// Shader that replicates the Nintendo Switch Online's GBC color filter --
varying vec2 texCoord;
varying mat4 profile;
uniform sampler2D tex;
uniform vec2 texSize;
uniform float lighten_screen;
void main() {
// bring out our stored luminance value
float lum = profile[3].w;
// our adjustments need to happen in linear gamma
vec4 screen = pow(texture2D(tex, texCoord), vec4(1.24, 0.8, 0.7, 1.0)).rgba;
screen = clamp(screen * lum, 0.0, 1.0);
screen = profile * screen;
gl_FragColor = pow(screen, vec4(1.0));
}

View File

@ -0,0 +1,34 @@
uniform int color_mode;
attribute vec4 position;
varying vec2 texCoord;
varying mat4 profile;
const mat4 GBC_sRGB = mat4(
0.84, 0.105, 0.15, 0.0, //red channel
0.265, 0.67, 0.30, 0.0, //green channel
0.0, 0.24, 0.525, 0.0, //blue channel
0.175, 0.18, 0.18, 0.85 //alpha channel
);
const mat4 GBC_DCI = mat4(
0.84, 0.105, 0.15, 0.0, //red channel
0.265, 0.67, 0.30, 0.0, //green channel
0.0, 0.24, 0.525, 0.0, //blue channel
0.175, 0.18, 0.18, 1.0 //alpha channel
);
const mat4 GBC_Rec2020 = mat4(
0.84, 0.105, 0.15, 0.0, //red channel
0.265, 0.67, 0.30, 0.0, //green channel
0.0, 0.24, 0.525, 0.0, //blue channel
0.175, 0.18, 0.18, 1.0 //alpha channel
);
void main() {
if (color_mode == 1) profile = GBC_sRGB;
else if (color_mode == 2) profile = GBC_DCI;
else if (color_mode == 3) profile = GBC_Rec2020;
gl_Position = position;
texCoord = (position.st + vec2(1.0, 1.0)) * vec2(0.5, 0.5);
}

View File

@ -0,0 +1,19 @@
[shader]
name=GBA SP 101 Color
author=Pokefan531 and hunterk
description=Shader that replicates the LCD Colorspace from a Gameboy SP 101 (backlit version).
passes=1
[pass.0]
fragmentShader=sp101-color.fs
vertexShader=sp101-color.vs
blend=1
width=-1
height=-1
[pass.0.uniform.color_mode]
type=int
default=1
min=1
max=3
readableName=Color Profile (1=sRGB, 2=DCI, 3=Rec2020)

View File

@ -0,0 +1,20 @@
// Shader that replicates the LCD Colorspace from a Gameboy SP 101 (backlit version) --
varying vec2 texCoord;
varying mat4 profile;
uniform sampler2D tex;
uniform vec2 texSize;
const float target_gamma = 2.2;
const float display_gamma = 2.2;
void main() {
// bring out our stored luminance value
float lum = profile[3].w;
// our adjustments need to happen in linear gamma
vec4 screen = pow(texture2D(tex, texCoord), vec4(target_gamma)).rgba;
screen = clamp(screen * lum, 0.0, 1.0);
screen = profile * screen;
gl_FragColor = pow(screen, vec4(1.0 / display_gamma));
}

View File

@ -0,0 +1,34 @@
uniform int color_mode;
attribute vec4 position;
varying vec2 texCoord;
varying mat4 profile;
const mat4 SP1_sRGB = mat4(
0.96, 0.0325, 0.001, 0.0, //red channel
0.11, 0.89, -0.03, 0.0, //green channel
-0.07, 0.0775, 1.029, 0.0, //blue channel
0.0, 0.0, 0.0, 0.935 //alpha channel
);
const mat4 SP1_DCI = mat4(
0.805, 0.0675, 0.017, 0.0, //red channel
0.24, 0.86, 0.02, 0.0, //green channel
-0.045, 0.0725, 0.963, 0.0, //blue channel
0.0, 0.0, 0.0, 0.955 //alpha channel
);
const mat4 SP1_Rec2020 = mat4(
0.625, 0.10, 0.015, 0.0, //red channel
0.35, 0.82, 0.0325, 0.0, //green channel
0.025, 0.08, 0.9525, 0.0, //blue channel
0.0, 0.0, 0.0, 1.0 //alpha channel
);
void main() {
if (color_mode == 1) profile = SP1_sRGB;
else if (color_mode == 2) profile = SP1_DCI;
else if (color_mode == 3) profile = SP1_Rec2020;
gl_Position = position;
texCoord = (position.st + vec2(1.0, 1.0)) * vec2(0.5, 0.5);
}