mirror of
https://github.com/italicsjenga/slang-shaders.git
synced 2024-11-22 15:51:30 +11:00
Merge pull request #222 from MajorPainTheCactus/hdr_2_2
V2.2 Sony PVM 4K HDR Shader
This commit is contained in:
commit
5d0831f1c4
|
@ -36,6 +36,7 @@ THIS SHADER DOES NOT SUPPORT WRGB OLED (Due to the sub pixel layout of WRGB - QD
|
|||
|
||||
layout(push_constant) uniform Push
|
||||
{
|
||||
// User Settings
|
||||
float MaxNits;
|
||||
float LCDResolution;
|
||||
float LCDSubpixel;
|
||||
|
@ -44,10 +45,11 @@ layout(push_constant) uniform Push
|
|||
float GreenConvergence;
|
||||
float BlueConvergence;
|
||||
|
||||
// Developer Settings
|
||||
float CRTResolution;
|
||||
float Contrast;
|
||||
float HorizontalSharpness;
|
||||
float HorizontalAttack;
|
||||
|
||||
// Vertical Settings
|
||||
float RedScanlineMin;
|
||||
float RedScanlineMax;
|
||||
float RedScanlineAttack;
|
||||
|
@ -57,6 +59,15 @@ layout(push_constant) uniform Push
|
|||
float BlueScanlineMin;
|
||||
float BlueScanlineMax;
|
||||
float BlueScanlineAttack;
|
||||
|
||||
// Horizontal Settings
|
||||
float RedBeamSharpness;
|
||||
float RedBeamAttack;
|
||||
float GreenBeamSharpness;
|
||||
float GreenBeamAttack;
|
||||
float BlueBeamSharpness;
|
||||
float BlueBeamAttack;
|
||||
|
||||
#if WHITE_BALANCE_CONTROL
|
||||
float WhiteTemperature;
|
||||
float WhiteTint;
|
||||
|
@ -64,40 +75,47 @@ layout(push_constant) uniform Push
|
|||
} params;
|
||||
|
||||
|
||||
#pragma parameter Title "SONY PVM/BVM HDR SHADER" 0.0 0.0 0.0 0.0
|
||||
#pragma parameter Space0 " " 0.0 0.0 0.0 0.0
|
||||
#pragma parameter Support0 "SUPPORTED: RGB/BGR LCD, QD-OLED Displays" 0.0 0.0 0.0 0.0
|
||||
#pragma parameter Support1 "NOT SUPPORTED: WRGB OLED Displays" 0.0 0.0 0.0 0.0
|
||||
#pragma parameter Support2 "MIN SPEC: DisplayHDR 600, 4K" 0.0 0.0 0.0 0.0
|
||||
#pragma parameter Support3 "REC SPEC: DisplayHDR 1000, 4K+" 0.0 0.0 0.0 0.0
|
||||
#pragma parameter Space1 " " 0.0 0.0 0.0 0.0
|
||||
#pragma parameter Instructions0 "ENABLE HDR: On" 0.0 0.0 0.0 0.0
|
||||
#pragma parameter Instructions1 "VERTICAL SCALING: Integer 4K - 10x, 8K - 20x" 0.0 0.0 0.0 0.0
|
||||
#pragma parameter Instructions2 "HORIZONTAL SCALING: Core Provided Apect Ratio" 0.0 0.0 0.0 0.0
|
||||
#pragma parameter Space2 " " 0.0 0.0 0.0 0.0
|
||||
#pragma parameter UserSettings "USER SETTINGS:" 0.0 0.0 0.0 0.0
|
||||
#pragma parameter MaxNits " Display's Peak Luminance" 700.0 0.0 10000.0 10.0
|
||||
#pragma parameter LCDResolution " Display's Resolution: 4K/8K" 0.0 0.0 1.0 1.0
|
||||
#pragma parameter LCDSubpixel " Display's Subpixel Layout: RGB/BGR" 0.0 0.0 1.0 1.0
|
||||
#pragma parameter ExpandGamut " Original/Vivid" 0.0 0.0 1.0 1.0
|
||||
#pragma parameter RedConvergence " Red Convergence" -1.20 -10.0 10.0 0.05
|
||||
#pragma parameter GreenConvergence " Green Convergence" 0.0 -10.0 10.0 0.05
|
||||
#pragma parameter BlueConvergence " Blue Convergence" -0.1 -10.0 10.0 0.05
|
||||
#pragma parameter Space3 " " 0.0 0.0 0.0 0.0
|
||||
#pragma parameter DeveloperSettings "DEVELOPER SETTINGS:" 0.0 0.0 0.0 0.0
|
||||
#pragma parameter CRTResolution " CRT Resolution: 600TVL/800TVL/1000TVL" 0.0 0.0 2.0 1.0
|
||||
#pragma parameter Contrast " Contrast" -0.3 -3.0 3.0 0.05
|
||||
#pragma parameter HorizontalSharpness " Horizontal Sharpness" 1.5 0.0 5.0 0.1
|
||||
#pragma parameter HorizontalAttack " Horizontal Attack" 0.45 0.0 1.0 0.05
|
||||
#pragma parameter RedScanlineMin " Red Scanline Min" 0.55 0.0 2.0 0.01
|
||||
#pragma parameter RedScanlineMax " Red Scanline Max" 0.75 0.0 2.0 0.01
|
||||
#pragma parameter RedScanlineAttack " Red Scanline Attack" 0.65 0.0 1.0 0.01
|
||||
#pragma parameter GreenScanlineMin " Green Scanline Min" 0.65 0.0 2.0 0.01
|
||||
#pragma parameter GreenScanlineMax " Green Scanline Max" 0.90 0.0 2.0 0.01
|
||||
#pragma parameter GreenScanlineAttack " Green Scanline Attack" 0.13 0.0 1.0 0.01
|
||||
#pragma parameter BlueScanlineMin " Blue Scanline Min" 0.72 0.0 2.0 0.01
|
||||
#pragma parameter BlueScanlineMax " Blue Scanline Max" 1.15 0.0 2.0 0.01
|
||||
#pragma parameter BlueScanlineAttack " Blue Scanline Attack" 1.0 0.0 1.0 0.01
|
||||
#pragma parameter Title "SONY PVM/BVM HDR SHADER" 0.0 0.0 0.0 0.0
|
||||
#pragma parameter Space0 " " 0.0 0.0 0.0 0.0
|
||||
#pragma parameter Support0 "SUPPORTED: RGB/BGR LCD, QD-OLED Displays" 0.0 0.0 0.0 0.0
|
||||
#pragma parameter Support1 "NOT SUPPORTED: WRGB OLED Displays" 0.0 0.0 0.0 0.0
|
||||
#pragma parameter Support2 "MIN SPEC: DisplayHDR 600, 4K" 0.0 0.0 0.0 0.0
|
||||
#pragma parameter Support3 "REC SPEC: DisplayHDR 1000, 4K+" 0.0 0.0 0.0 0.0
|
||||
#pragma parameter Space1 " " 0.0 0.0 0.0 0.0
|
||||
#pragma parameter Instructions0 "HDR: Enable HDR: On" 0.0 0.0 0.0 0.0
|
||||
#pragma parameter Instructions1 "SCALING: Integer Scale: ON" 0.0 0.0 0.0 0.0
|
||||
#pragma parameter Instructions2 "SCALING: Integer Overscale: ON" 0.0 0.0 0.0 0.0
|
||||
#pragma parameter Instructions3 "SCALING: Apect Ratio: Core Provided" 0.0 0.0 0.0 0.0
|
||||
#pragma parameter Space2 " " 0.0 0.0 0.0 0.0
|
||||
#pragma parameter UserSettings "USER SETTINGS:" 0.0 0.0 0.0 0.0
|
||||
#pragma parameter MaxNits " Display's Peak Luminance" 700.0 0.0 10000.0 10.0
|
||||
#pragma parameter LCDResolution " Display's Resolution: 4K/8K" 0.0 0.0 1.0 1.0
|
||||
#pragma parameter LCDSubpixel " Display's Subpixel Layout: RGB/BGR" 0.0 0.0 1.0 1.0
|
||||
#pragma parameter ExpandGamut " Original/Vivid" 0.0 0.0 1.0 1.0
|
||||
#pragma parameter RedConvergence " Red Convergence" -0.50 -10.0 10.0 0.05
|
||||
#pragma parameter GreenConvergence " Green Convergence" 0.00 -10.0 10.0 0.05
|
||||
#pragma parameter BlueConvergence " Blue Convergence" 0.00 -10.0 10.0 0.05
|
||||
#pragma parameter Space3 " " 0.0 0.0 0.0 0.0
|
||||
#pragma parameter DeveloperSettings "DEVELOPER SETTINGS:" 0.0 0.0 0.0 0.0
|
||||
#pragma parameter CRTResolution " CRT Resolution: 600TVL/800TVL/1000TVL" 0.0 0.0 2.0 1.0
|
||||
#pragma parameter Contrast " Contrast" -0.3 -3.0 3.0 0.05
|
||||
#pragma parameter DeveloperSettings0 " VERTICAL SETTINGS:" 0.0 0.0 0.0 0.0
|
||||
#pragma parameter RedScanlineMin " Red Scanline Min" 0.55 0.0 2.0 0.01
|
||||
#pragma parameter RedScanlineMax " Red Scanline Max" 0.82 0.0 2.0 0.01
|
||||
#pragma parameter RedScanlineAttack " Red Scanline Attack" 0.65 0.0 1.0 0.01
|
||||
#pragma parameter GreenScanlineMin " Green Scanline Min" 0.55 0.0 2.0 0.01
|
||||
#pragma parameter GreenScanlineMax " Green Scanline Max" 0.90 0.0 2.0 0.01
|
||||
#pragma parameter GreenScanlineAttack " Green Scanline Attack" 0.13 0.0 1.0 0.01
|
||||
#pragma parameter BlueScanlineMin " Blue Scanline Min" 0.72 0.0 2.0 0.01
|
||||
#pragma parameter BlueScanlineMax " Blue Scanline Max" 1.00 0.0 2.0 0.01
|
||||
#pragma parameter BlueScanlineAttack " Blue Scanline Attack" 0.65 0.0 1.0 0.01
|
||||
#pragma parameter DeveloperSettings1 " HORIZONTAL SETTINGS:" 0.0 0.0 0.0 0.0
|
||||
#pragma parameter RedBeamSharpness " Red Beam Sharpness" 1.75 0.0 5.0 0.05
|
||||
#pragma parameter RedBeamAttack " Red Beam Attack" 0.72 0.0 1.0 0.01
|
||||
#pragma parameter GreenBeamSharpness " Green Beam Sharpness" 1.60 0.0 5.0 0.05
|
||||
#pragma parameter GreenBeamAttack " Green Beam Attack" 0.80 0.0 1.0 0.01
|
||||
#pragma parameter BlueBeamSharpness " Blue Beam Sharpness" 1.90 0.0 5.0 0.05
|
||||
#pragma parameter BlueBeamAttack " Blue Beam Attack" 0.45 0.0 1.0 0.01
|
||||
|
||||
#if WHITE_BALANCE_CONTROL
|
||||
//#pragma parameter WhiteTemperature "White Temperature" 6500.0 0.0 13000.0 50.0
|
||||
|
@ -162,13 +180,6 @@ float ModInteger(float a, float b)
|
|||
#define kBlack vec3(0.0, 0.0, 0.0)
|
||||
#define kWhite vec3(1.0, 1.0, 1.0)
|
||||
|
||||
#define kRedBGR vec3(0.0, 0.0, 1.0)
|
||||
#define kGreenBGR vec3(0.0, 1.0, 0.0)
|
||||
#define kBlueBGR vec3(1.0, 0.0, 0.0)
|
||||
#define kMagentaBGR vec3(1.0, 0.0, 1.0)
|
||||
#define kYellowBGR vec3(0.0, 1.0, 1.0)
|
||||
#define kCyanBGR vec3(1.0, 1.0, 0.0)
|
||||
|
||||
#define kBGRAxis 2
|
||||
#define kTVLAxis 3
|
||||
#define kResolutionAxis 2
|
||||
|
@ -177,13 +188,13 @@ float ModInteger(float a, float b)
|
|||
#define kNotSupported { kBlack, kBlack, kBlack, kBlack, kBlack, kBlack, kBlack }
|
||||
|
||||
#define kRGBX { kRed, kGreen, kBlue, kBlack, kBlack, kBlack, kBlack }
|
||||
#define kBGRX { kBlueBGR, kGreenBGR, kRedBGR, kBlack, kBlack, kBlack, kBlack }
|
||||
#define kBGRX { kBlue, kGreen, kRed, kBlack, kBlack, kBlack, kBlack }
|
||||
|
||||
#define kRYCBX { kRed, kYellow, kCyan, kBlue, kBlack, kBlack, kBlack }
|
||||
#define kBCYRX { kBlueBGR, kCyanBGR, kYellowBGR, kRedBGR, kBlack, kBlack, kBlack }
|
||||
#define kBCYRX { kBlue, kCyan, kYellow, kRed, kBlack, kBlack, kBlack }
|
||||
|
||||
#define kRRGGBBX { kRed, kRed, kGreen, kGreen, kBlue, kBlue, kBlack }
|
||||
#define kBBGGRRX { kBlueBGR, kBlueBGR, kGreenBGR, kGreenBGR, kRedBGR, kRedBGR, kBlack }
|
||||
#define kBBGGRRX { kBlue, kBlue, kGreen, kGreen, kRed, kRed, kBlack }
|
||||
|
||||
const uint kPhosphorMaskSize [kResolutionAxis][kTVLAxis][kBGRAxis] = {
|
||||
{ // 4K
|
||||
|
@ -220,9 +231,19 @@ const vec4 kFallOffControlPoints = vec4(0.0f, 0.0f, 0.0f, 1.0f);
|
|||
const vec4 kAttackControlPoints = vec4(0.0f, 1.0f, 1.0f, 1.0f);
|
||||
//const vec4 kScanlineControlPoints = vec4(1.0f, 1.0f, 0.0f, 0.0f);
|
||||
|
||||
vec4 HorizControlPoints(const bool falloff)
|
||||
vec4 RedBeamControlPoints(const bool falloff)
|
||||
{
|
||||
return falloff ? kFallOffControlPoints + vec4(0.0f, 0.0f, params.HorizontalAttack, 0.0f) : kAttackControlPoints - vec4(0.0f, params.HorizontalAttack, 0.0f, 0.0f);
|
||||
return falloff ? kFallOffControlPoints + vec4(0.0f, 0.0f, params.RedBeamAttack, 0.0f) : kAttackControlPoints - vec4(0.0f, params.RedBeamAttack, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
vec4 GreenBeamControlPoints(const bool falloff)
|
||||
{
|
||||
return falloff ? kFallOffControlPoints + vec4(0.0f, 0.0f, params.GreenBeamAttack, 0.0f) : kAttackControlPoints - vec4(0.0f, params.GreenBeamAttack, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
vec4 BlueBeamControlPoints(const bool falloff)
|
||||
{
|
||||
return falloff ? kFallOffControlPoints + vec4(0.0f, 0.0f, params.BlueBeamAttack, 0.0f) : kAttackControlPoints - vec4(0.0f, params.BlueBeamAttack, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
float Bezier(const float t0, const vec4 control_points)
|
||||
|
@ -256,7 +277,7 @@ vec3 Ramp(const vec3 luminance, const vec3 colour)
|
|||
return clamp(luminance * colour, 0.0, 1.0);
|
||||
}
|
||||
|
||||
vec3 ScanlineColour(const float current_position, const float current_center, const float source_tex_coord_x, const float narrowed_source_pixel_offset, inout float next_prev )
|
||||
vec3 ScanlineColour(const float current_position, const float current_center, const float source_tex_coord_x, const vec3 narrowed_source_pixel_offset, inout float next_prev )
|
||||
{
|
||||
const float current_source_position_y = (vTexCoord.y * global.SourceSize.y) - next_prev;
|
||||
const float current_source_center_y = floor(current_source_position_y) + 0.5f;
|
||||
|
@ -299,10 +320,9 @@ vec3 ScanlineColour(const float current_position, const float current_center, co
|
|||
const vec3 hdr_colour_1 = InverseTonemap(sdr_balanced_1, params.MaxNits, params.MaxNits, kLumaRatio);
|
||||
|
||||
/* Horizontal interpolation between pixels */
|
||||
|
||||
const vec3 horiz_interp = vec3(Bezier(narrowed_source_pixel_offset, HorizControlPoints(sdr_linear_0.x > sdr_linear_1.x)),
|
||||
Bezier(narrowed_source_pixel_offset, HorizControlPoints(sdr_linear_0.y > sdr_linear_1.y)),
|
||||
Bezier(narrowed_source_pixel_offset, HorizControlPoints(sdr_linear_0.z > sdr_linear_1.z)));
|
||||
const vec3 horiz_interp = vec3(Bezier(narrowed_source_pixel_offset.x, RedBeamControlPoints(sdr_linear_0.x > sdr_linear_1.x)),
|
||||
Bezier(narrowed_source_pixel_offset.y, GreenBeamControlPoints(sdr_linear_0.y > sdr_linear_1.y)),
|
||||
Bezier(narrowed_source_pixel_offset.z, BlueBeamControlPoints(sdr_linear_0.z > sdr_linear_1.z)));
|
||||
|
||||
const vec3 hdr_colour = mix(hdr_colour_0, hdr_colour_1, horiz_interp);
|
||||
const vec3 sdr_colour = mix(sdr_linear_0, sdr_linear_1, horiz_interp);
|
||||
|
@ -333,7 +353,9 @@ void main()
|
|||
const float source_tex_coord_x = current_source_center_x / global.SourceSize.x;
|
||||
|
||||
const float source_pixel_offset = current_source_position_x - floor(current_source_position_x);
|
||||
const float narrowed_source_pixel_offset = clamp(((source_pixel_offset - 0.5f) * params.HorizontalSharpness) + 0.5f, 0.0f, 1.0f);
|
||||
|
||||
const vec3 beam_sharpness = vec3(params.RedBeamSharpness, params.GreenBeamSharpness, params.BlueBeamSharpness);
|
||||
const vec3 narrowed_source_pixel_offset = clamp(((vec3(source_pixel_offset) - vec3(0.5f)) * beam_sharpness) + vec3(0.5f), vec3(0.0f), vec3(1.0f));
|
||||
|
||||
float next_prev = 0.0f;
|
||||
|
||||
|
|
Loading…
Reference in a new issue