initial PAL simulation implementation
This commit is contained in:
parent
eeed80fe76
commit
532f5c5df1
5 changed files with 48 additions and 13 deletions
|
@ -33,6 +33,8 @@ void main() {
|
||||||
// hardware post-processing effects
|
// hardware post-processing effects
|
||||||
#if signal == SIGNAL_NTSC
|
#if signal == SIGNAL_NTSC
|
||||||
color = ntsc(color);
|
color = ntsc(color);
|
||||||
|
#elif signal == SIGNAL_PAL
|
||||||
|
color = pal(color);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// physical post-processing effects
|
// physical post-processing effects
|
||||||
|
|
|
@ -52,9 +52,10 @@ suffix.valBits=-bit
|
||||||
|
|
||||||
screen.SCREEN=Screen
|
screen.SCREEN=Screen
|
||||||
|
|
||||||
option.signal=Signal
|
option.signal=Encoding
|
||||||
value.signal.0=RGB (Off)
|
value.signal.0=None
|
||||||
value.signal.1=NTSC
|
value.signal.1=NTSC
|
||||||
|
value.signal.2=PAL
|
||||||
|
|
||||||
option.wire=Connector
|
option.wire=Connector
|
||||||
value.wire.0=Composite
|
value.wire.0=Composite
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
|
|
||||||
#include "/var/signal.glsl"
|
#include "/var/signal.glsl"
|
||||||
|
|
||||||
#define signal 0 // [0 1]
|
#define signal 0 // [0 1 2]
|
||||||
#define wire 0 // [0 1]
|
#define wire 0 // [0 1]
|
||||||
|
|
||||||
|
float luminance(vec3 color) {
|
||||||
|
return dot(color, vec3(0.299, 0.587, 0.114));
|
||||||
|
}
|
||||||
|
|
||||||
vec3 ntsc(vec3 color) {
|
vec3 ntsc(vec3 color) {
|
||||||
// convert to YIQ
|
// convert to YIQ
|
||||||
float y = dot(color, vec3(0.299, 0.587, 0.114));
|
float y = luminance(color);
|
||||||
float i = dot(color, vec3(0.596, -.274, -.322));
|
float i = dot(color, vec3(0.596, -.274, -.322));
|
||||||
float q = dot(color, vec3(0.211, -.523, 0.312));
|
float q = dot(color, vec3(0.211, -.523, 0.312));
|
||||||
|
|
||||||
|
@ -17,7 +21,7 @@ vec3 ntsc(vec3 color) {
|
||||||
|
|
||||||
// decode faux signal
|
// decode faux signal
|
||||||
#if wire == WIRE_COMPOSITE
|
#if wire == WIRE_COMPOSITE
|
||||||
float composite = phase + quad + (y * 5.500); // p + q + (y * 5.5MHz)
|
float composite = phase + (y * 5.500); // p + (y * 5.5MHz)
|
||||||
y = round(composite * 5.500) / 30.250;
|
y = round(composite * 5.500) / 30.250;
|
||||||
phase = composite - quad - (y * 5.500);
|
phase = composite - quad - (y * 5.500);
|
||||||
quad = composite - phase - (y * 5.500);
|
quad = composite - phase - (y * 5.500);
|
||||||
|
@ -28,11 +32,38 @@ vec3 ntsc(vec3 color) {
|
||||||
// convert back to RGB
|
// convert back to RGB
|
||||||
vec3 yiqColor = vec3(y, i, q);
|
vec3 yiqColor = vec3(y, i, q);
|
||||||
|
|
||||||
vec3 outColor = vec3(0);
|
float r = dot(yiqColor, vec3(1, 0.956, 0.619));
|
||||||
outColor.r = dot(yiqColor, vec3(1, 0.956, 0.619));
|
float g = dot(yiqColor, vec3(1, -.272, -.674));
|
||||||
outColor.g = dot(yiqColor, vec3(1, -.272, -.674));
|
float b = dot(yiqColor, vec3(1, -1.106, 1.703));
|
||||||
outColor.b = dot(yiqColor, vec3(1, -1.106, 1.703));
|
|
||||||
|
|
||||||
return outColor;
|
return vec3(r, g, b).rgb;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 pal(vec3 color) {
|
||||||
|
// convert to YUV
|
||||||
|
float y = luminance(color);
|
||||||
|
float u = 0.492 * (color.b - y);
|
||||||
|
float v = 0.877 * (color.r - y);
|
||||||
|
|
||||||
|
// faux pal signal
|
||||||
|
float carrier = 6.283 * 4.434;
|
||||||
|
float phase = sin(carrier) * u - cos(carrier) * v;
|
||||||
|
float quad = cos(carrier) * u - sin(carrier) * v;
|
||||||
|
|
||||||
|
// decode faux signal
|
||||||
|
#if wire == WIRE_COMPOSITE
|
||||||
|
float composite = y + phase;
|
||||||
|
#endif
|
||||||
|
u = quad * cos(carrier);
|
||||||
|
v = phase * sin(carrier);
|
||||||
|
|
||||||
|
// convert back to RGB
|
||||||
|
vec3 yuvColor = vec3(y, u, v);
|
||||||
|
|
||||||
|
float r = y + (1.140 * v);
|
||||||
|
float g = y - (0.395 * u) - (0.581 * v);
|
||||||
|
float b = y + (2.033 * u);
|
||||||
|
|
||||||
|
return vec3(r, g, b).rgb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,14 +13,14 @@ profile.VR32=pixelSize=8 colorMode=1 !dithering colorDepth=1 monoPalette=2 vWarp
|
||||||
|
|
||||||
# -- SCREENS --
|
# -- SCREENS --
|
||||||
# default
|
# default
|
||||||
screen=<profile> <empty> pixelSize <empty> [COLOR] [SCREEN] [CONSOLE] [FX]
|
screen=<profile> <empty> <empty> <empty> pixelSize <empty> [COLOR] [SCREEN] [CONSOLE] [FX]
|
||||||
|
|
||||||
# colors
|
# colors
|
||||||
screen.COLOR.columns=3
|
screen.COLOR.columns=3
|
||||||
screen.COLOR=colorMode dithering <empty> colorDepth <empty> monoPalette hueBits satBits valBits
|
screen.COLOR=colorMode dithering <empty> colorDepth <empty> monoPalette hueBits satBits valBits
|
||||||
|
|
||||||
# screen effects
|
# screen effects
|
||||||
screen.SCREEN=signal wire interlacing scanline aberration
|
screen.SCREEN=signal wire <empty> <empty> interlacing scanline <empty> <empty> aberration
|
||||||
|
|
||||||
# console effects
|
# console effects
|
||||||
screen.CONSOLE.columns=1
|
screen.CONSOLE.columns=1
|
||||||
|
@ -29,7 +29,7 @@ screen.PSX=vWarp tWarp # playstation
|
||||||
screen.REALITY=hBlur # nintendo 64
|
screen.REALITY=hBlur # nintendo 64
|
||||||
|
|
||||||
# custom effects
|
# custom effects
|
||||||
screen.FX=dof dofRes worldCurvature worldRadius
|
screen.FX=dof dofRes <empty> <empty> worldCurvature worldRadius
|
||||||
|
|
||||||
# -- CONDITIONALS --
|
# -- CONDITIONALS --
|
||||||
gbuffers_hand.enabled=tWarp
|
gbuffers_hand.enabled=tWarp
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
#define SIGNAL_RGB 0
|
#define SIGNAL_RGB 0
|
||||||
#define SIGNAL_NTSC 1
|
#define SIGNAL_NTSC 1
|
||||||
|
#define SIGNAL_PAL 2
|
||||||
|
|
||||||
#define WIRE_COMPOSITE 0
|
#define WIRE_COMPOSITE 0
|
||||||
#define WIRE_SVIDEO 1
|
#define WIRE_SVIDEO 1
|
||||||
|
|
Loading…
Reference in a new issue