slang-shaders/bezel/Mega_Bezel/shaders/HyperspaceMadness/hsm-megatron/crt-sony-megatron-source-pass.slang

98 lines
3.3 KiB
Plaintext
Raw Normal View History

2022-06-25 10:06:45 +10:00
#version 450
/*
A shader that tries to emulate a sony PVM type aperture grille screen but with full brightness.
The novel thing about this shader is that it relies on the HDR shaders to brighten up the image so that when
we apply this shader which emulates the apperture grille the resulting screen isn't left too dark.
I think you need at least a DisplayHDR 600 monitor but to get close to CRT levels of brightness I think DisplayHDR 1000.
Please Enable HDR in RetroArch 1.10+
NOTE: when this shader is envoked the Contrast, Peak Luminance and Paper White Luminance in the HDR menu do nothing instead set those values through the shader parameters
For this shader set Paper White Luminance to above 700 and Peak Luminance to the peak luminance of your monitor.
Also try to use a integer scaling - its just better - overscaling is fine.
This shader doesn't do any geometry warping or bouncing of light around inside the screen etc - I think these effects just add unwanted noise, I know people disagree. Please feel free to make you own and add them
Dont use this shader directly - use the hdr\crt-make-model-hdr.slangp where make and model are the make and model of the CRT you want.
THIS SHADER DOES NOT SUPPORT WRGB OLED (Due to the sub pixel layout of WRGB - RGB QD-OLED or LCD (and variants thereof screens are fine)
*/
layout(push_constant) uniform Push
{
float hcrt_hdr;
float hcrt_colour_space;
float hcrt_max_nits;
float hcrt_paper_white_nits;
float hcrt_lcd_resolution;
float hcrt_lcd_subpixel;
float hcrt_colour_system;
float hcrt_expand_gamut;
float hcrt_white_temperature;
float hcrt_brightness;
float hcrt_contrast;
float hcrt_saturation;
float hcrt_gamma_in;
} params;
/* HSM Removed
layout(std140, set = 0, binding = 0) uniform UBO
{
mat4 MVP;
vec4 SourceSize;
vec4 OriginalSize;
vec4 OutputSize;
uint FrameCount;
} global;
*/
#include "../hsm/common/hsm-globals-and-screen-scale-params.inc"
#include "include/parameters.h"
#define HCRT_HDR params.hcrt_hdr
#define HCRT_OUTPUT_COLOUR_SPACE params.hcrt_colour_space
#define HCRT_CRT_COLOUR_SYSTEM params.hcrt_colour_system
#define HCRT_WHITE_TEMPERATURE params.hcrt_white_temperature
#define HCRT_BRIGHTNESS params.hcrt_brightness
#define HCRT_CONTRAST params.hcrt_contrast
#define HCRT_SATURATION params.hcrt_saturation
#define HCRT_GAMMA_IN params.hcrt_gamma_in
#define COMPAT_TEXTURE(c, d) texture(c, d)
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
void main()
{
gl_Position = global.MVP * Position;
vTexCoord = TexCoord * vec2(1.00001); // To resolve rounding issues when sampling
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source;
#include "include/colour_grade.h"
void main()
{
vec3 source = COMPAT_TEXTURE(Source, vTexCoord).rgb;
// Put the source back in the original gamma space
source = HSM_Delinearize(vec4(source, 1), GAMMA_INPUT).rgb;
const vec3 colour = ColourGrade(source);
FragColor = vec4(colour, 1.0);
}