mirror of
https://github.com/italicsjenga/slang-shaders.git
synced 2025-03-23 12:21:20 +11:00
add luminance param to geom, add some params to geom-deluxe
This commit is contained in:
parent
b38342095a
commit
ee0ce4c140
3 changed files with 35 additions and 47 deletions
crt/shaders
|
@ -21,6 +21,7 @@ layout(push_constant) uniform Push
|
|||
float scanline_weight;
|
||||
float CURVATURE;
|
||||
float interlace_detect;
|
||||
float lum;
|
||||
} registers;
|
||||
|
||||
layout(std140, set = 0, binding = 0) uniform UBO
|
||||
|
@ -40,9 +41,10 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter y_tilt "CRTGeom Vertical Tilt" 0.0 -0.5 0.5 0.05
|
||||
#pragma parameter overscan_x "CRTGeom Horiz. Overscan %" 100.0 -125.0 125.0 1.0
|
||||
#pragma parameter overscan_y "CRTGeom Vert. Overscan %" 100.0 -125.0 125.0 1.0
|
||||
#pragma parameter DOTMASK "CRTGeom Dot Mask Toggle" 0.3 0.0 0.3 0.3
|
||||
#pragma parameter DOTMASK "CRTGeom Dot Mask Strength" 0.3 0.0 1.0 0.05
|
||||
#pragma parameter SHARPER "CRTGeom Sharpness" 1.0 1.0 3.0 1.0
|
||||
#pragma parameter scanline_weight "CRTGeom Scanline Weight" 0.3 0.1 0.5 0.05
|
||||
#pragma parameter lum "CRTGeom Luminance" 0.0 0.0 1.0 0.01
|
||||
#pragma parameter interlace_detect "CRTGeom Interlacing Simulation" 1.0 0.0 1.0 1.0
|
||||
|
||||
/*
|
||||
|
@ -75,7 +77,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#define OVERSAMPLE
|
||||
|
||||
// Use the older, purely gaussian beam profile; uncomment for speed
|
||||
#define USEGAUSSIAN
|
||||
//#define USEGAUSSIAN
|
||||
|
||||
// Macros.
|
||||
#define FIX(c) max(abs(c), 1e-5);
|
||||
|
@ -154,37 +156,6 @@ vec3 maxscale()
|
|||
return vec3((hi+lo)*aspect*0.5,max(hi.x-lo.x,hi.y-lo.y));
|
||||
}
|
||||
|
||||
// Calculate the influence of a scanline on the current pixel.
|
||||
//
|
||||
// 'distance' is the distance in texture coordinates from the current
|
||||
// pixel to the scanline in question.
|
||||
// 'color' is the colour of the scanline at the horizontal location of
|
||||
// the current pixel.
|
||||
vec4 scanlineWeights(float distance, vec4 color)
|
||||
{
|
||||
// "wid" controls the width of the scanline beam, for each RGB
|
||||
// channel The "weights" lines basically specify the formula
|
||||
// that gives you the profile of the beam, i.e. the intensity as
|
||||
// a function of distance from the vertical center of the
|
||||
// scanline. In this case, it is gaussian if width=2, and
|
||||
// becomes nongaussian for larger widths. Ideally this should
|
||||
// be normalized so that the integral across the beam is
|
||||
// independent of its width. That is, for a narrower beam
|
||||
// "weights" should have a higher peak at the center of the
|
||||
// scanline than for a wider beam.
|
||||
#ifdef USEGAUSSIAN
|
||||
vec4 wid = 0.3 + 0.1 * pow(color, vec4(3.0));
|
||||
vec4 weights = vec4(distance / wid);
|
||||
|
||||
return 0.4 * exp(-weights * weights) / wid;
|
||||
#else
|
||||
vec4 wid = 2.0 + 2.0 * pow(color, vec4(4.0));
|
||||
vec4 weights = vec4(distance / registers.scanline_weight);
|
||||
|
||||
return 1.4 * exp(-pow(weights * inversesqrt(0.5 * wid), wid)) / (0.6 + 0.2 * wid);
|
||||
#endif
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = global.MVP * Position;
|
||||
|
@ -289,11 +260,11 @@ vec4 scanlineWeights(float distance, vec4 color)
|
|||
#ifdef USEGAUSSIAN
|
||||
vec4 wid = 0.3 + 0.1 * pow(color, vec4(3.0));
|
||||
vec4 weights = vec4(distance / wid);
|
||||
return 0.4 * exp(-weights * weights) / wid;
|
||||
return (registers.lum + 0.4) * exp(-weights * weights) / wid;
|
||||
#else
|
||||
vec4 wid = 2.0 + 2.0 * pow(color, vec4(4.0));
|
||||
vec4 weights = vec4(distance / registers.scanline_weight);
|
||||
return 1.4 * exp(-pow(weights * inversesqrt(0.5 * wid), wid)) / (0.6 + 0.2 * wid);
|
||||
return (registers.lum + 1.4) * exp(-pow(weights * inversesqrt(0.5 * wid), wid)) / (0.6 + 0.2 * wid);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -14,18 +14,18 @@
|
|||
|
||||
#include "../../../include/subpixel_masks.h"
|
||||
|
||||
#define u_tex_size0 global.SourceSize
|
||||
#define u_tex_size1 global.internal1Size
|
||||
#define u_quad_dims global.OutputSize
|
||||
#define u_tex_size0 global.SourceSize.xy
|
||||
#define u_tex_size1 global.internal1Size.xy
|
||||
#define u_quad_dims global.OutputSize.xy
|
||||
|
||||
// Comment the next line to disable interpolation in linear gamma (and gain speed).
|
||||
//#define LINEAR_PROCESSING
|
||||
#define LINEAR_PROCESSING
|
||||
|
||||
// Enable 3x oversampling of the beam profile
|
||||
#define OVERSAMPLE
|
||||
|
||||
// Use the older, purely gaussian beam profile
|
||||
#define USEGAUSSIAN
|
||||
//#define USEGAUSSIAN
|
||||
|
||||
// Macros.
|
||||
#define FIX(c) max(abs(c), 1e-5)
|
||||
|
@ -39,6 +39,8 @@ layout(location = 1) out vec2 v_sinangle;
|
|||
layout(location = 2) out vec2 v_cosangle;
|
||||
layout(location = 3) out vec3 v_stretch;
|
||||
layout(location = 4) out vec2 v_one;
|
||||
layout(location = 5) out vec2 ilfac;
|
||||
layout(location = 6) out vec2 TextureSize;
|
||||
|
||||
float intersect(vec2 xy , vec2 sinangle, vec2 cosangle)
|
||||
{
|
||||
|
@ -105,9 +107,13 @@ void main()
|
|||
v_sinangle = sin(ang);
|
||||
v_cosangle = cos(ang);
|
||||
v_stretch = maxscale(v_sinangle, v_cosangle);
|
||||
|
||||
TextureSize = global.SourceSize.xy;
|
||||
|
||||
ilfac = vec2(1.0, clamp(floor(global.SourceSize.y/200.0), 1.0, 2.0));
|
||||
|
||||
// The size of one texel, in texture-coordinates.
|
||||
v_one = 1.0 / u_tex_size0.xy;
|
||||
v_one = ilfac / TextureSize.xy;
|
||||
}
|
||||
|
||||
#pragma stage fragment
|
||||
|
@ -116,6 +122,8 @@ layout(location = 1) in vec2 v_sinangle;
|
|||
layout(location = 2) in vec2 v_cosangle;
|
||||
layout(location = 3) in vec3 v_stretch;
|
||||
layout(location = 4) in vec2 v_one;
|
||||
layout(location = 5) in vec2 ilfac;
|
||||
layout(location = 6) in vec2 TextureSize;
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
layout(set = 0, binding = 2) uniform sampler2D blur;
|
||||
layout(set = 0, binding = 3) uniform sampler2D internal1;
|
||||
|
@ -194,11 +202,11 @@ vec4 scanlineWeights(float distance, vec4 color)
|
|||
#ifdef USEGAUSSIAN
|
||||
vec4 wid = 0.3 + 0.1 * pow(color, vec4(3.0));
|
||||
vec4 weights = vec4(distance / wid);
|
||||
return 0.4 * exp(-weights * weights) / wid;
|
||||
return (geom_lum + 0.4) * exp(-weights * weights) / wid;
|
||||
#else
|
||||
vec4 wid = 2.0 + 2.0 * pow(color, vec4(4.0));
|
||||
vec4 weights = vec4(distance / 0.3);
|
||||
return 1.4 * exp(-pow(weights * inversesqrt(0.5 * wid), wid)) / (0.6 + 0.2 * wid);
|
||||
vec4 weights = vec4(distance / scanline_weight);
|
||||
return (geom_lum + 1.4) * exp(-pow(weights * inversesqrt(0.5 * wid), wid)) / (0.6 + 0.2 * wid);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -236,7 +244,10 @@ void main()
|
|||
|
||||
// Of all the pixels that are mapped onto the texel we are
|
||||
// currently rendering, which pixel are we currently rendering?
|
||||
vec2 ratio_scale = xy * u_tex_size0.xy - vec2(0.5);
|
||||
|
||||
vec2 ilvec = vec2(0.0, ilfac.y * interlace_detect > 1.5 ? mod(float(global.FrameCount), 2.0) : 0.0);
|
||||
|
||||
vec2 ratio_scale = (xy * TextureSize - vec2(0.5, 0.5) + ilvec) / ilfac;
|
||||
|
||||
#ifdef OVERSAMPLE
|
||||
float oversample_filter = fwidth(ratio_scale.y);
|
||||
|
@ -244,7 +255,7 @@ void main()
|
|||
vec2 uv_ratio = fract(ratio_scale);
|
||||
|
||||
// Snap to the center of the underlying texel.
|
||||
xy = (floor(ratio_scale) + vec2(0.5)) / u_tex_size0.xy;
|
||||
xy = (floor(ratio_scale)*ilfac + vec2(0.5, 0.5) - ilvec) / TextureSize;
|
||||
|
||||
// Calculate Lanczos scaling coefficients describing the effect
|
||||
// of various neighbour texels in a scanline on the current
|
||||
|
|
|
@ -2,7 +2,7 @@ layout(push_constant) uniform Push
|
|||
{
|
||||
float phosphor_power, phosphor_amplitude, CRTgamma, width, aspect_x, aspect_y, d, R, angle_x, angle_y,
|
||||
aperture_strength, halation, curvature, cornersize, cornersmooth, overscan_x, overscan_y,
|
||||
monitorgamma, mask_type;
|
||||
monitorgamma, mask_type, SHARPER, scanline_weight, geom_lum, interlace_detect;
|
||||
} params;
|
||||
|
||||
layout(std140, set = 0, binding = 0) uniform UBO
|
||||
|
@ -35,6 +35,9 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter monitorgamma "Gamma of output display" 2.2 0.7 4.0 0.05
|
||||
#pragma parameter aspect_x "Aspect ratio X" 1.0 0.3 1.0 0.01
|
||||
#pragma parameter aspect_y "Aspect ratio Y" 0.75 0.3 1.0 0.01
|
||||
#pragma parameter scanline_weight "CRTGeom Scanline Weight" 0.3 0.1 0.5 0.05
|
||||
#pragma parameter geom_lum "CRTGeom Luminance" 0.0 0.0 1.0 0.01
|
||||
#pragma parameter interlace_detect "CRTGeom Interlacing Simulation" 1.0 0.0 1.0 1.0
|
||||
|
||||
#define phosphor_power params.phosphor_power
|
||||
#define phosphor_amplitude params.phosphor_amplitude
|
||||
|
@ -47,6 +50,9 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#define monitorgamma params.monitorgamma
|
||||
#define halation params.halation
|
||||
#define aperture_strength params.aperture_strength
|
||||
#define geom_lum params.geom_lum
|
||||
#define scanline_weight params.scanline_weight
|
||||
#define interlace_detect params.interlace_detect
|
||||
vec2 aspect = vec2(params.aspect_x, params.aspect_y);
|
||||
vec2 angle = vec2(params.angle_x, params.angle_y);
|
||||
vec2 overscan = vec2(params.overscan_x, params.overscan_y);
|
||||
|
|
Loading…
Add table
Reference in a new issue