├── Shaders ├── Flip eyes - OU.hlsl ├── Flip eyes - SBS.hlsl ├── 3D to 2D - OU.hlsl ├── 3D to 2D - SBS.hlsl ├── Anaglyph 3D - OU to red-blue.hlsl ├── Anaglyph 3D - OU to red-green.hlsl ├── Anaglyph 3D - SBS to red-blue.hlsl ├── Anaglyph 3D - SBS to red-green.hlsl ├── Anaglyph 3D - OU to trioscopic.hlsl ├── Anaglyph 3D - SBS to trioscopic.hlsl ├── Dual projector convergence - OU.hlsl ├── Dual projector convergence - SBS.hlsl ├── Gamma correction.hlsl ├── Reframe.hlsl ├── Parallax - OU.hlsl ├── Parallax - SBS.hlsl ├── Resolution demo.hlsl ├── ScreenXizer - Cubemap.hlsl ├── Anaglyph 3D - OU to red-cyan.hlsl ├── Anaglyph 3D - SBS to red-cyan.hlsl ├── Bottomizer.hlsl ├── Spot correction.hlsl ├── Black bar filler.hlsl ├── HDR to SDR (S-Log).hlsl ├── ScreenXizer - Cinerama.hlsl ├── HDR to SDR.hlsl ├── HDR to SDR + overexposure.hlsl ├── HDR to SDR (vibrant).hlsl └── Screen file.hlsl └── README.md /Shaders/Flip eyes - OU.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: Flip left/right eye image for over-under 3D content 8 | */ 9 | 10 | sampler s0; 11 | 12 | float4 main(float2 tex : TEXCOORD0) : COLOR { 13 | tex.y = tex.y > .5 ? tex.y - .5 : tex.y + .5; 14 | return (tex2D(s0, tex)).rgbb; 15 | } -------------------------------------------------------------------------------- /Shaders/Flip eyes - SBS.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: Flip left/right eye image for side-by-side 3D content 8 | */ 9 | 10 | sampler s0; 11 | 12 | float4 main(float2 tex : TEXCOORD0) : COLOR { 13 | tex.x = tex.x > .5 ? tex.x - .5 : tex.x + .5; 14 | return (tex2D(s0, tex)).rgbb; 15 | } -------------------------------------------------------------------------------- /Shaders/3D to 2D - OU.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: Left eye retain for half-size over-under 3D content 8 | */ 9 | 10 | sampler s0; 11 | float4 p0 : register(c0); 12 | 13 | #define height (p0[1]) 14 | 15 | float4 main(float2 tex : TEXCOORD0) : COLOR { 16 | tex.y *= .5; 17 | float3 leftPixel = tex2D(s0, tex).rgb; 18 | tex.y += 1. / height; 19 | return (tex.y * height) % 1 < .5 ? leftPixel.rgbb : (leftPixel + tex2D(s0, tex).rgb).rgbb * .5; 20 | } -------------------------------------------------------------------------------- /Shaders/3D to 2D - SBS.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: Left eye retain for half-size side-by-side 3D content 8 | */ 9 | 10 | sampler s0; 11 | float4 p0 : register(c0); 12 | 13 | #define width (p0[0]) 14 | 15 | float4 main(float2 tex : TEXCOORD0) : COLOR { 16 | tex.x *= .5; 17 | float3 leftPixel = tex2D(s0, tex).rgb; 18 | tex.x += 1. / width; 19 | return (tex.x * width) % 1 < .5 ? leftPixel.rgbb : (leftPixel + tex2D(s0, tex).rgb).rgbb * .5; 20 | } -------------------------------------------------------------------------------- /Shaders/Anaglyph 3D - OU to red-blue.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: Prepare over-under 3D content for red-blue glasses 8 | */ 9 | 10 | sampler s0; 11 | float4 p0 : register(c0); 12 | 13 | #define width (p0[0]) 14 | #define height (p0[1]) 15 | 16 | float4 main(float2 tex : TEXCOORD0) : COLOR { 17 | tex.y *= .5; 18 | float2 texr = tex; 19 | texr.y += .5; 20 | float pixelSize = 1. / width; 21 | float3 leftPixel = float3(tex2D(s0, tex).r, 0, tex2D(s0, texr).b); 22 | tex.x += pixelSize; 23 | texr.x += pixelSize; 24 | float3 rightPixel = float3(tex2D(s0, tex).r, 0, tex2D(s0, texr).b); 25 | return (tex.x * width) % 1 < .5 ? leftPixel.rgbb : (leftPixel + rightPixel).rgbb * .5; 26 | } -------------------------------------------------------------------------------- /Shaders/Anaglyph 3D - OU to red-green.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: Prepare over-under 3D content for red-green glasses 8 | */ 9 | 10 | sampler s0; 11 | float4 p0 : register(c0); 12 | 13 | #define width (p0[0]) 14 | #define height (p0[1]) 15 | 16 | float4 main(float2 tex : TEXCOORD0) : COLOR { 17 | tex.y *= .5; 18 | float2 texr = tex; 19 | texr.y += .5; 20 | float pixelSize = 1. / width; 21 | float3 leftPixel = float3(tex2D(s0, tex).r, tex2D(s0, texr).g, 0); 22 | tex.x += pixelSize; 23 | texr.x += pixelSize; 24 | float3 rightPixel = float3(tex2D(s0, tex).r, tex2D(s0, texr).g, 0); 25 | return (tex.x * width) % 1 < .5 ? leftPixel.rgbb : (leftPixel + rightPixel).rgbb * .5; 26 | } -------------------------------------------------------------------------------- /Shaders/Anaglyph 3D - SBS to red-blue.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: Prepare side-by-side 3D content for red-blue glasses 8 | */ 9 | 10 | sampler s0; 11 | float4 p0 : register(c0); 12 | 13 | #define width (p0[0]) 14 | #define height (p0[1]) 15 | 16 | float4 main(float2 tex : TEXCOORD0) : COLOR { 17 | tex.x *= .5; 18 | float2 texr = tex; 19 | texr.x += .5; 20 | float pixelSize = 1. / width; 21 | float3 leftPixel = float3(tex2D(s0, tex).r, 0, tex2D(s0, texr).b); 22 | tex.x += pixelSize; 23 | texr.x += pixelSize; 24 | float3 rightPixel = float3(tex2D(s0, tex).r, 0, tex2D(s0, texr).b); 25 | return (tex.x * width) % 1 < .5 ? leftPixel.rgbb : (leftPixel + rightPixel).rgbb * .5; 26 | } -------------------------------------------------------------------------------- /Shaders/Anaglyph 3D - SBS to red-green.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: Prepare side-by-side 3D content for red-green glasses 8 | */ 9 | 10 | sampler s0; 11 | float4 p0 : register(c0); 12 | 13 | #define width (p0[0]) 14 | #define height (p0[1]) 15 | 16 | float4 main(float2 tex : TEXCOORD0) : COLOR { 17 | tex.x *= .5; 18 | float2 texr = tex; 19 | texr.x += .5; 20 | float pixelSize = 1. / width; 21 | float3 leftPixel = float3(tex2D(s0, tex).r, tex2D(s0, texr).g, 0); 22 | tex.x += pixelSize; 23 | texr.x += pixelSize; 24 | float3 rightPixel = float3(tex2D(s0, tex).r, tex2D(s0, texr).g, 0); 25 | return (tex.x * width) % 1 < .5 ? leftPixel.rgbb : (leftPixel + rightPixel).rgbb * .5; 26 | } -------------------------------------------------------------------------------- /Shaders/Anaglyph 3D - OU to trioscopic.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: Prepare over-under 3D content for trioscopic glasses 8 | */ 9 | 10 | sampler s0; 11 | float4 p0 : register(c0); 12 | 13 | #define width (p0[0]) 14 | #define height (p0[1]) 15 | 16 | float4 main(float2 tex : TEXCOORD0) : COLOR { 17 | tex.y *= .5; 18 | float2 texr = tex; 19 | texr.y += .5; 20 | float pixelSize = 1. / width; 21 | float3 leftPixel = float3(tex2D(s0, texr).r, tex2D(s0, tex).g, tex2D(s0, texr).b); 22 | tex.x += pixelSize; 23 | texr.x += pixelSize; 24 | float3 rightPixel = float3(tex2D(s0, texr).r, tex2D(s0, tex).g, tex2D(s0, texr).b); 25 | return (tex.x * width) % 1 < .5 ? leftPixel.rgbb : (leftPixel + rightPixel).rgbb * .5; 26 | } -------------------------------------------------------------------------------- /Shaders/Anaglyph 3D - SBS to trioscopic.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: Prepare side-by-side 3D content for trioscopic glasses 8 | */ 9 | 10 | sampler s0; 11 | float4 p0 : register(c0); 12 | 13 | #define width (p0[0]) 14 | #define height (p0[1]) 15 | 16 | float4 main(float2 tex : TEXCOORD0) : COLOR { 17 | tex.x *= .5; 18 | float2 texr = tex; 19 | texr.x += .5; 20 | float pixelSize = 1. / width; 21 | float3 leftPixel = float3(tex2D(s0, texr).r, tex2D(s0, tex).g, tex2D(s0, texr).b); 22 | tex.x += pixelSize; 23 | texr.x += pixelSize; 24 | float3 rightPixel = float3(tex2D(s0, texr).r, tex2D(s0, tex).g, tex2D(s0, texr).b); 25 | return (tex.x * width) % 1 < .5 ? leftPixel.rgbb : (leftPixel + rightPixel).rgbb * .5; 26 | } -------------------------------------------------------------------------------- /Shaders/Dual projector convergence - OU.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: Simple projector convergence for over-under dual projection (3D or HDR) 8 | */ 9 | 10 | // Configuration --------------------------------------------------------------- 11 | const static float secX = 0; // Secondary projector offset on X axis 12 | const static float secY = 0.05; // Secondary projector offset on Y axis 13 | // ----------------------------------------------------------------------------- 14 | 15 | sampler s0; 16 | 17 | float4 main(float2 tex : TEXCOORD0) : COLOR { 18 | float ot = tex.y; 19 | tex.x = ot > 0.5 ? tex.x - secX : tex.x; 20 | tex.y = ot > 0.5 ? tex.y - secY : tex.y; 21 | return tex.x >= 0 && tex.y >= 0 && tex.x <= 1 && tex.y <= 1 ? tex2D(s0, tex).rgbb : float4(0,0,0,0); 22 | } -------------------------------------------------------------------------------- /Shaders/Dual projector convergence - SBS.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: Simple projector convergence for side-by-side dual projection (3D or HDR) 8 | */ 9 | 10 | // Configuration --------------------------------------------------------------- 11 | const static float secX = 0; // Secondary projector offset on X axis 12 | const static float secY = 0.05; // Secondary projector offset on Y axis 13 | // ----------------------------------------------------------------------------- 14 | 15 | sampler s0; 16 | 17 | float4 main(float2 tex : TEXCOORD0) : COLOR { 18 | float ot = tex.x; 19 | tex.x = ot > 0.5 ? tex.x - secX : tex.x; 20 | tex.y = ot > 0.5 ? tex.y - secY : tex.y; 21 | return tex.x >= 0 && tex.y >= 0 && tex.x <= 1 && tex.y <= 1 ? tex2D(s0, tex).rgbb : float4(0,0,0,0); 22 | } -------------------------------------------------------------------------------- /Shaders/Gamma correction.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: Simple gamma correction 8 | */ 9 | 10 | // Configuration --------------------------------------------------------------- 11 | const static float sourceGamma = 1.6; // Original gamma (most projectors are in the 1.6-1.8 range) 12 | const static float targetGamma = 2.2; // Target gamma level 13 | // Possible target candidates are: 14 | // 2.2 - Used for low-end panels which fail to show distinguishable blacks 15 | // 2.4 - TV standard 16 | // 2.6 - DCI standard 17 | // ----------------------------------------------------------------------------- 18 | 19 | // Precalculated value 20 | const static float correction = targetGamma / sourceGamma; 21 | 22 | sampler s0; 23 | 24 | float4 main(float2 tex : TEXCOORD0) : COLOR { 25 | return pow((tex2D(s0, tex)).rgbb, correction); 26 | } -------------------------------------------------------------------------------- /Shaders/Reframe.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: Keep content in the screen's largest given area by ratio 8 | */ 9 | 10 | // Configuration --------------------------------------------------------------- 11 | const static float targetRatio = 16.0/9; // Frame ratio to keep the content in 12 | // ----------------------------------------------------------------------------- 13 | 14 | sampler s0; 15 | float4 p0 : register(c0); 16 | 17 | #define width (p0[0]) 18 | #define height (p0[1]) 19 | 20 | float4 main(float2 tex : TEXCOORD0) : COLOR { 21 | float ratio = width / height; 22 | float scale = ratio > targetRatio ? ratio / targetRatio : (targetRatio / ratio); 23 | float offset = (scale - 1) * 0.5; 24 | tex = tex * scale - float2(offset, offset); 25 | return tex.x >= 0.0 && tex.x <= 1.0 && tex.y >= 0.0 && tex.y <= 1.0 ? tex2D(s0, tex).rgbb : float4(0,0,0,0); 26 | } -------------------------------------------------------------------------------- /Shaders/Parallax - OU.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: Parallax correction for over-under 3D content 8 | */ 9 | 10 | // Configuration --------------------------------------------------------------- 11 | static const float parallax = -.01; // Parallax offset ratio, +: closer, -: deeper, logical limits: [-.05; .05] 12 | static const float focus = 0; // Focus point offset ratio 13 | // ----------------------------------------------------------------------------- 14 | 15 | sampler s0; 16 | 17 | float4 main(float2 tex : TEXCOORD0) : COLOR { 18 | // separation with parallax settings 19 | float texr = tex.x; 20 | float parallaxRange = 1. + (parallax > 0 ? -parallax : parallax); 21 | tex.x = ((parallax >= 0) ? focus : focus - parallax) + tex.x * parallaxRange; 22 | texr = ((parallax >= 0) ? parallax - focus : -focus) + texr * parallaxRange; 23 | 24 | // merge 25 | tex.x = tex.y < .5 ? tex.x : texr; 26 | return (tex2D(s0, tex)).rgbb; 27 | } -------------------------------------------------------------------------------- /Shaders/Parallax - SBS.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: Parallax correction for side-by-side 3D content 8 | */ 9 | 10 | // Configuration --------------------------------------------------------------- 11 | static const float parallax = -.01; // Parallax offset ratio, +: closer, -: deeper, logical limits: [-.05; .05] 12 | static const float focus = 0; // Focus point offset ratio 13 | // ----------------------------------------------------------------------------- 14 | 15 | sampler s0; 16 | 17 | float4 main(float2 tex : TEXCOORD0) : COLOR { 18 | // separation with parallax settings 19 | float texr = tex.x + .5; 20 | float parallaxRange = 1. + (parallax > 0 ? -parallax : parallax); 21 | tex.x = clamp((((parallax >= 0) ? focus : focus - parallax) + tex.x / .5 * parallaxRange) * .5, 0, .5); 22 | texr = clamp((((parallax >= 0) ? parallax - focus : -focus) + (texr - 1) / .5 * parallaxRange) * .5 + .5, .5, 1); 23 | 24 | // merge 25 | tex.x = tex.x < .5 ? tex.x : texr; 26 | return (tex2D(s0, tex)).rgbb; 27 | } -------------------------------------------------------------------------------- /Shaders/Resolution demo.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: Shows half resolution 4:2:0, 4:4:4, full resolution 4:2:0, and 4:4:4 in order 8 | */ 9 | 10 | sampler s0; 11 | float4 p0 : register(c0); 12 | 13 | #define width (p0[0]) 14 | #define height (p0[1]) 15 | 16 | float4 halfColor(float4 color, float2 tex, float downscale) { 17 | float2 downscaled = float2(downscale / width, downscale / height); 18 | float2 colorTL = tex - tex % downscaled; 19 | float luma = (color.r + color.g + color.b) * 0.33; 20 | float4 colorAVG = 21 | 0.25 * (tex2D(s0, tex) + 22 | tex2D(s0, float2(tex.x + 1.0 / width, tex.y)) + 23 | tex2D(s0, float2(tex.x, tex.y + 1.0 / height)) + 24 | tex2D(s0, float2(tex.x + 1.0 / width, tex.y + 1.0 / height))); 25 | float pixelLuma = luma / ((colorAVG.r + colorAVG.g + colorAVG.b) * 0.33); 26 | return colorAVG * pixelLuma; 27 | } 28 | 29 | float4 halfRes(float2 tex) { 30 | float2 halfPixelSize = float2(2.0 / width, 2.0 / height); 31 | return tex2D(s0, tex - tex % halfPixelSize); 32 | } 33 | 34 | float4 main(float2 tex : TEXCOORD0) : COLOR { 35 | float otex = tex.x; 36 | tex.x = 0.375 + tex.x % 0.25; 37 | float4 result = otex < 0.5 ? halfRes(tex) : tex2D(s0, tex); 38 | return otex.x % 0.5 < 0.25 ? halfColor(result, tex, otex.x < 0.5 ? 4 : 2) : result; 39 | } 40 | -------------------------------------------------------------------------------- /Shaders/ScreenXizer - Cubemap.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: Warp screen edges to side screens with cube wrapping 8 | */ 9 | 10 | // Configuration --------------------------------------------------------------- 11 | const static float expand = 0.3; // Ratio to scale to sides 12 | const static float sideFactor = 2.0; // Move contents on the sides to the front of the given side 13 | const static float projection = 0; // 1 for projection, 0 for single screen demo 14 | // ----------------------------------------------------------------------------- 15 | 16 | sampler s0; 17 | 18 | float4 main(float2 tex : TEXCOORD0) : COLOR { 19 | float sideness = max((abs(tex.x - 0.5) - (0.5 - 1.0 / 3.0)) * 3.0, 0.0) * (1.0 - expand / 6.0) + expand / 6.0; 20 | float scale = sideness * 2.0 + 1.0; 21 | tex.y = projection < 0.5 ? ((tex.y - (1.0 - sideness) / 3.0) / scale) * 3.0 : tex.y; 22 | // TODO: optimize tex.x 23 | tex.x = tex.x < 1.0/3.0 ? pow(tex.x * 3.0, sideFactor) * expand * 0.5 : ( 24 | tex.x < 2.0/3.0 ? ((tex.x - 1.0/3.0) * 3.0) / (1.0 / (1.0 - expand)) + expand * 0.5 : ( 25 | (1.0 - pow(1.0 - (tex.x - 2.0/3.0) * 3.0, sideFactor)) * expand * 0.5 + (1.0 - expand * 0.5) 26 | ) 27 | ); 28 | return tex.y >= 0.0 && tex.y <= 1.0 ? tex2D(s0, tex).rgbb : float4(0,0,0,0); 29 | } -------------------------------------------------------------------------------- /Shaders/Anaglyph 3D - OU to red-cyan.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: Prepare over-under 3D content for red-cyan glasses 8 | */ 9 | 10 | // Configuration --------------------------------------------------------------- 11 | const static float addDubois = 0; // Apply Dubois correction for poor red usage (1 = on, 0 = off) 12 | // ----------------------------------------------------------------------------- 13 | 14 | sampler s0; 15 | float4 p0 : register(c0); 16 | 17 | #define width (p0[0]) 18 | #define height (p0[1]) 19 | 20 | inline float3 dubois(float4 l, float4 r) { // By kazuya2k8 at https://forum.doom9.org/showthread.php?t=170475 21 | float red = l.r* 0.456 + l.g* 0.500 + l.b* 0.176 + r.r*-0.043 + r.g*-0.088 + r.b*-0.002; 22 | float green = l.r*-0.040 + l.g*-0.038 + l.b*-0.016 + r.r* 0.378 + r.g* 0.734 + r.b*-0.018; 23 | float blue = l.r*-0.015 + l.g*-0.021 + l.b*-0.005 + r.r*-0.072 + r.g*-0.113 + r.b* 1.226; 24 | return float3(red, green, blue); 25 | } 26 | 27 | float4 main(float2 tex : TEXCOORD0) : COLOR { 28 | tex.y *= .5; 29 | float2 texr = tex; 30 | texr.y += .5; 31 | float pixelSize = 1. / width; 32 | float3 leftPixel = addDubois < .5 ? float3(tex2D(s0, tex).r, tex2D(s0, texr).gb) : dubois(tex2D(s0, tex), tex2D(s0, texr)); 33 | tex.x += pixelSize; 34 | texr.x += pixelSize; 35 | float3 rightPixel = addDubois < .5 ? float3(tex2D(s0, tex).r, tex2D(s0, texr).gb) : dubois(tex2D(s0, tex), tex2D(s0, texr)); 36 | return (tex.x * width) % 1 < .5 ? leftPixel.rgbb : (leftPixel + rightPixel).rgbb * .5; 37 | } -------------------------------------------------------------------------------- /Shaders/Anaglyph 3D - SBS to red-cyan.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: Prepare side-by-side 3D content for red-cyan glasses 8 | */ 9 | 10 | // Configuration --------------------------------------------------------------- 11 | const static float addDubois = 0; // Apply Dubois correction for poor red usage (1 = on, 0 = off) 12 | // ----------------------------------------------------------------------------- 13 | 14 | sampler s0; 15 | float4 p0 : register(c0); 16 | 17 | #define width (p0[0]) 18 | #define height (p0[1]) 19 | 20 | inline float3 dubois(float4 l, float4 r) { // By kazuya2k8 at https://forum.doom9.org/showthread.php?t=170475 21 | float red = l.r* 0.456 + l.g* 0.500 + l.b* 0.176 + r.r*-0.043 + r.g*-0.088 + r.b*-0.002; 22 | float green = l.r*-0.040 + l.g*-0.038 + l.b*-0.016 + r.r* 0.378 + r.g* 0.734 + r.b*-0.018; 23 | float blue = l.r*-0.015 + l.g*-0.021 + l.b*-0.005 + r.r*-0.072 + r.g*-0.113 + r.b* 1.226; 24 | return float3(red, green, blue); 25 | } 26 | 27 | float4 main(float2 tex : TEXCOORD0) : COLOR { 28 | tex.x *= .5; 29 | float2 texr = tex; 30 | texr.x += .5; 31 | float pixelSize = 1. / width; 32 | float3 leftPixel = addDubois < .5 ? float3(tex2D(s0, tex).r, tex2D(s0, texr).gb) : dubois(tex2D(s0, tex), tex2D(s0, texr)); 33 | tex.x += pixelSize; 34 | texr.x += pixelSize; 35 | float3 rightPixel = addDubois < .5 ? float3(tex2D(s0, tex).r, tex2D(s0, texr).gb) : dubois(tex2D(s0, tex), tex2D(s0, texr)); 36 | return (tex.x * width) % 1 < .5 ? leftPixel.rgbb : (leftPixel + rightPixel).rgbb * .5; 37 | } -------------------------------------------------------------------------------- /Shaders/Bottomizer.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: Move wide content to the bottom of the frame 8 | */ 9 | 10 | // Configuration --------------------------------------------------------------- 11 | const static float v = 5 / 256.0; // Target darkness (peak noise level) 12 | // ----------------------------------------------------------------------------- 13 | 14 | sampler s0; 15 | float4 p0 : register(c0); 16 | 17 | #define width (p0[0]) 18 | #define height (p0[1]) 19 | 20 | float cp(float w, float h) { // Check a point if it's below target darnkess 21 | float3 p = tex2D(s0, float2(w, h)).rgb; 22 | return p.r < v && p.g < v && p.b < v; 23 | } 24 | 25 | float checkLayer(float t) { 26 | return cp(0, t) && cp(0.2, t) && cp(0.4, t) && cp(0.6, t) && cp(0.8, t) && cp(1, t); 27 | } 28 | 29 | float ratioTest(float container, float ratio) { 30 | float h = 0.05 + container / ratio; 31 | return ratio > container ? checkLayer((1 + h) * 0.5) && checkLayer((1 - h) * 0.5) : 0; 32 | } 33 | 34 | float2 ratioOffset(float container, float ratio) { 35 | return float2(0, (container / ratio + 1) * 0.5 - 1); 36 | } 37 | 38 | float4 main(float2 tex : TEXCOORD0) : COLOR { 39 | float container = width / height; 40 | tex += 41 | ratioTest(container, 2.34) ? ratioOffset(container, 2.34) : 42 | ratioTest(container, 2.2) ? ratioOffset(container, 2.2) : 43 | ratioTest(container, 2) ? ratioOffset(container, 2) : 44 | ratioTest(container, 1.85) ? ratioOffset(container, 1.85) : 45 | float2(0, 0); 46 | return tex2D(s0, tex).rgbb; 47 | } -------------------------------------------------------------------------------- /Shaders/Spot correction.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: Corrects spots with incorrect colors 8 | */ 9 | 10 | // Configuration --------------------------------------------------------------- 11 | const static float referenceX = 1920; // Reference screen width 12 | const static float referenceY = 1080; // Reference screen height 13 | const static float spotX = 600; // Spot center at reference width 14 | const static float spotY = 564; // Spot center at reference height 15 | const static float radiusX = 400; // Width of the screen covered in the spot 16 | const static float radiusY = 400; // Height of the screen covered in the spot 17 | const static float redMul = 1.0; // Red multiplier (for cyan spots) 18 | const static float greenMul = 1.0; // Green multiplier (for magenta spots) 19 | const static float blueMul = 1.3; // Blue multiplier (for yellow spots) 20 | // ----------------------------------------------------------------------------- 21 | 22 | sampler s0; 23 | float4 p0 : register(c0); 24 | 25 | #define width (p0[0]) 26 | #define height (p0[1]) 27 | 28 | float4 main(float2 tex : TEXCOORD0) : COLOR { 29 | float heightDiff = (width * referenceY) / (height * referenceX); 30 | float2 pos = float2(spotX / referenceX, spotY / referenceY - (heightDiff - 1) * 0.5); 31 | float2 r = float2(radiusX / referenceX, radiusY / referenceY * heightDiff); 32 | float2 dist = float2((pos.x - tex.x) / r.x, (pos.y - tex.y) / r.y); 33 | float wetness = max(1 - sqrt(dist.x * dist.x + dist.y * dist.y), 0); 34 | float3 wet = tex2D(s0, tex).rgb * float3(redMul, greenMul, blueMul); 35 | return tex2D(s0, tex).rgbb * (1 - wetness) + wet.rgbb * wetness; 36 | } -------------------------------------------------------------------------------- /Shaders/Black bar filler.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: Fill black bars by cylindrically warping the image 8 | */ 9 | 10 | sampler s0; 11 | float4 p0 : register(c0); 12 | 13 | #define width (p0[0]) 14 | #define height (p0[1]) 15 | 16 | const static float v = 5 / 256.0; // Target darkness (peak noise level) 17 | 18 | float cp(float w, float h) { // Check a point if it's below target darnkess 19 | float3 p = tex2D(s0, float2(w, h)).rgb; 20 | return p.r < v && p.g < v && p.b < v; 21 | } 22 | 23 | float checkLayer(float t) { 24 | return cp(0, t) && cp(0.2, t) && cp(0.4, t) && cp(0.6, t) && cp(0.8, t) && cp(1, t); 25 | } 26 | 27 | float ratioTest(float container, float ratio) { 28 | float h = 0.05 + container / ratio; 29 | return ratio > container ? checkLayer((1 + h) * 0.5) && checkLayer((1 - h) * 0.5) : 0; 30 | } 31 | 32 | float2 warp(float2 tex, float container, float content, float factor) { 33 | float a = factor * content / container; 34 | return float2(tex.x, atan(a * (tex.y - 0.5)) / a + 0.5); 35 | } 36 | 37 | inline float4 getTex(float2 tex) { 38 | return tex.x >= 0 && tex.x <= 1 && tex.y >=0 && tex.y <= 1 ? tex2D(s0, tex) : 0; 39 | } 40 | 41 | float4 main(float2 tex : TEXCOORD0) : COLOR { 42 | float container = width / height; 43 | if (ratioTest(container, 2.2)) { 44 | tex = warp(tex, container, 2.2, 1.8); 45 | } else if (ratioTest(container, 2)) { 46 | tex = warp(tex, container, 2, 1); 47 | } 48 | 49 | // Anti-aliased output with standard 8x MSAA pattern 50 | float2 px = float2(1.0 / width, 1.0 / height); // pixel size 51 | float4 aa1 = getTex(tex + float2(px.x * 0.1, px.y * -0.3)); 52 | float4 aa2 = getTex(tex + float2(px.x * -0.1, px.y * 0.3)); 53 | float4 aa3 = getTex(tex + float2(px.x * 0.5, px.y * 0.1)); 54 | float4 aa4 = getTex(tex + float2(px.x * -0.3, px.y * -0.5)); 55 | float4 aa5 = getTex(tex + float2(px.x * -0.5, px.y * 0.5)); 56 | float4 aa6 = getTex(tex + float2(px.x * -0.7, px.y * -0.1)); 57 | float4 aa7 = getTex(tex + float2(px.x * 0.3, px.y * 0.7)); 58 | float4 aa8 = getTex(tex + float2(px.x * 0.7, px.y * -0.7)); 59 | return (aa1 + aa2 + aa3 + aa4 + aa5 + aa6 + aa7 + aa8) * 0.125; 60 | } 61 | -------------------------------------------------------------------------------- /Shaders/HDR to SDR (S-Log).hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: Try to get the SDR part of S-Log HDR content 8 | */ 9 | 10 | // Configuration --------------------------------------------------------------- 11 | const static float peakLuminance = 100.0; // Peak playback screen luminance in nits 12 | const static float kneeLuminance = 75.0; // Compression knee in luminance 13 | const static float compression = 1.0; // Compression ratio 14 | const static float maxCLL = 10000.0; // Maximum content light level in nits 15 | const static float minMDL = 0.0; // Minimum mastering display luminance in nits 16 | const static float maxMDL = 10000.0; // Maximum mastering display luminance in nits 17 | // ----------------------------------------------------------------------------- 18 | 19 | // Precalculated values 20 | const static float linGain = maxCLL / peakLuminance * (maxMDL - minMDL) / maxMDL; 21 | const static float blackPoint = minMDL / maxMDL; 22 | const static float knee = kneeLuminance / maxCLL; 23 | 24 | sampler s0; 25 | 26 | inline float peakGain(float3 pixel) { 27 | return max(pixel.r, max(pixel.g, pixel.b)); 28 | } 29 | 30 | inline float3 sLog2srgb(float3 sLog) { 31 | return (pow(10.0, ((((sLog * 256.0 - 16.0) / 219.0) - 0.616596 - 0.03) / 0.432699)) - 0.037584) / 10.8857; 32 | } 33 | 34 | inline float3 srgb2lin(float3 srgb) { 35 | return srgb <= 0.04045 ? srgb / 12.92 : pow((srgb + 0.055) / 1.055, 2.4); 36 | } 37 | 38 | inline float3 lin2srgb(float3 lin) { 39 | return lin <= 0.0031308 ? lin * 12.92 : 1.055 * pow(lin, 0.416667) - 0.055; 40 | } 41 | 42 | inline float3 bt2020to709(float3 bt2020) { // in linear space 43 | return float3( 44 | bt2020.r * 1.6605 + bt2020.g * -0.5876 + bt2020.b * -0.0728, 45 | bt2020.r * -0.1246 + bt2020.g * 1.1329 + bt2020.b * -0.0083, 46 | bt2020.r * -0.0182 + bt2020.g * -0.1006 + bt2020.b * 1.1187); 47 | } 48 | 49 | inline float3 compress(float3 pixel) { // in linear space 50 | float kneeMax = knee * linGain + blackPoint; 51 | float strength = saturate((peakGain(pixel) - kneeMax) / ((linGain + blackPoint) - kneeMax)); 52 | return pixel / ((compression - 1) * strength + 1); 53 | } 54 | 55 | float4 main(float2 tex : TEXCOORD0) : COLOR { 56 | float3 pxval = tex2D(s0, tex).rgb; 57 | float3 lin = bt2020to709(srgb2lin(sLog2srgb(pxval))) * linGain + blackPoint; 58 | float3 final = lin2srgb(compress(lin)); 59 | return final.rgbb; 60 | } -------------------------------------------------------------------------------- /Shaders/ScreenXizer - Cinerama.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: Warp screen edges to side screens with cylinder wrapping 8 | */ 9 | 10 | // Configuration --------------------------------------------------------------- 11 | const static float expand = 0.3; // Ratio of the whole image width to scale to both sides 12 | const static float edgeFactor = 2.0; // Warp this much more to the edges 13 | const static float projection = 0; // 1 for projection, 0 for single screen demo 14 | const static float middleRatio = 1.0 / 3.0; // Ratio of the undistorted content in the center relative to the screen size 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Precalculated values 18 | const static float sideSquash = 1.0 - middleRatio; // Scale back sides by this much not to overshoot the screen 19 | const static float sidePartWidth = sideSquash * 0.5; 20 | const static float rightPartFrom = 1.0 - sidePartWidth; 21 | const static float sidePart = expand * 0.5; // Ratio of one side expansion to the original width 22 | const static float middlePart = 1.0 - expand; // Ratio of the unwarped image to the original width 23 | const static float middleScale = middlePart / middleRatio; // When the middle part is retained, this is the height scale to get back the original aspect ratio 24 | const static float sideScale = 1.0 / sidePartWidth; // Scales side coordinates to the 0-1 range 25 | 26 | sampler s0; 27 | 28 | inline float scaleFromCenter(float what, float with) { 29 | return (what - 0.5) * with + 0.5; 30 | } 31 | 32 | float4 main(float2 tex : TEXCOORD0) : COLOR { 33 | float left = tex.x < sidePartWidth; 34 | float right = tex.x > rightPartFrom; 35 | float middle = left == right; 36 | float visible = 1.0; 37 | 38 | if (projection < 0.5) { 39 | float leftY = scaleFromCenter(tex.y, tex.x * sideScale * sideSquash + middleRatio); 40 | float rightY = scaleFromCenter(tex.y, (1.0 - tex.x) * sideScale * sideSquash + middleRatio); 41 | tex.y = scaleFromCenter(left * leftY + middle * tex.y + right * rightY, middleScale); 42 | visible = tex.y >= 0.0 && tex.y <= 1.0; 43 | } 44 | 45 | float leftX = pow(tex.x * sideScale, edgeFactor) * sidePart; 46 | float middleX = scaleFromCenter(tex.x, middleScale); 47 | float rightX = 1.0 - pow((1.0 - tex.x) * sideScale, edgeFactor) * sidePart; 48 | tex.x = left * leftX + middle * middleX + right * rightX; 49 | 50 | return visible * tex2D(s0, tex).rgbb + (1 - visible) * float4(0,0,0,0); 51 | } 52 | -------------------------------------------------------------------------------- /Shaders/HDR to SDR.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: Try to get the SDR part of HDR content 8 | */ 9 | 10 | // Configuration --------------------------------------------------------------- 11 | const static float peakLuminance = 250.0; // Peak playback screen luminance in nits 12 | const static float knee = 0.75; // Compressor knee position 13 | const static float ratio = 1.0; // Compressor ratio: 1 = disabled, <1 = expander 14 | const static float maxCLL = 10000.0; // Maximum content light level in nits 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Precalculated values 18 | const static float gain = maxCLL / peakLuminance; 19 | const static float compressor = 1.0 / ratio; 20 | 21 | // PQ constants 22 | const static float m1inv = 16384 / 2610.0; 23 | const static float m2inv = 32 / 2523.0; 24 | const static float c1 = 3424 / 4096.0; 25 | const static float c2 = 2413 / 128.0; 26 | const static float c3 = 2392 / 128.0; 27 | 28 | sampler s0; 29 | 30 | inline float minGain(float3 pixel) { 31 | return min(pixel.r, min(pixel.g, pixel.b)); 32 | } 33 | 34 | inline float midGain(float3 pixel) { 35 | return pixel.r < pixel.g ? 36 | (pixel.r < pixel.b ? 37 | min(pixel.g, pixel.b) : // min = r 38 | min(pixel.r, pixel.g)) : // min = b 39 | (pixel.g < pixel.b ? 40 | min(pixel.r, pixel.b) : // min = g 41 | min(pixel.r, pixel.g)); // min = b 42 | } 43 | 44 | inline float maxGain(float3 pixel) { 45 | return max(pixel.r, max(pixel.g, pixel.b)); 46 | } 47 | 48 | inline float3 compress(float3 pixel) { 49 | float gain = maxGain(pixel); 50 | return pixel * (gain < knee ? gain : knee + max(gain - knee, 0) * compressor) / gain; 51 | } 52 | 53 | inline float3 fixClip(float3 pixel) { 54 | // keep the (mid - min) / (max - min) ratio 55 | float preMin = minGain(pixel); 56 | float preMid = midGain(pixel); 57 | float preMax = maxGain(pixel); 58 | float3 clip = saturate(pixel); 59 | float postMin = minGain(clip); 60 | float postMid = midGain(clip); 61 | float postMax = maxGain(clip); 62 | float ratio = (preMid - preMin) / (preMax - preMin); 63 | float newMid = ratio * (postMax - postMin) + postMin; 64 | return float3(clip.r != postMid ? clip.r : newMid, 65 | clip.g != postMid ? clip.g : newMid, 66 | clip.b != postMid ? clip.b : newMid); 67 | } 68 | 69 | inline float3 pq2lin(float3 pq) { // Returns luminance in nits 70 | float3 p = pow(pq, m2inv); 71 | float3 d = max(p - c1, 0) / (c2 - c3 * p); 72 | return pow(d, m1inv) * gain; 73 | } 74 | 75 | inline float3 srgb2lin(float3 srgb) { 76 | return srgb <= 0.04045 ? srgb / 12.92 : pow((srgb + 0.055) / 1.055, 2.4); 77 | } 78 | 79 | inline float3 lin2srgb(float3 lin) { 80 | return lin <= 0.0031308 ? lin * 12.92 : 1.055 * pow(lin, 0.416667) - 0.055; 81 | } 82 | 83 | inline float3 bt2020to709(float3 bt2020) { // in linear space 84 | return float3( 85 | bt2020.r * 1.6605 + bt2020.g * -0.5876 + bt2020.b * -0.0728, 86 | bt2020.r * -0.1246 + bt2020.g * 1.1329 + bt2020.b * -0.0083, 87 | bt2020.r * -0.0182 + bt2020.g * -0.1006 + bt2020.b * 1.1187); 88 | } 89 | 90 | float4 main(float2 tex : TEXCOORD0) : COLOR { 91 | float3 pxval = tex2D(s0, tex).rgb; 92 | float3 lin = bt2020to709(pq2lin(pxval)); 93 | float3 final = lin2srgb(compress(lin)); 94 | return fixClip(final).rgbb; 95 | } -------------------------------------------------------------------------------- /Shaders/HDR to SDR + overexposure.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: Try to get the SDR part of HDR content with overexposure as SBS 3D 8 | */ 9 | 10 | // Configuration --------------------------------------------------------------- 11 | const static float peakLuminance = 250.0; // Peak playback screen luminance in nits 12 | const static float knee = 0.75; // Compressor knee position 13 | const static float ratio = 1.0; // Compressor ratio: 1 = disabled, <1 = expander 14 | const static float maxCLL = 10000.0; // Maximum content light level in nits 15 | // ----------------------------------------------------------------------------- 16 | 17 | // Precalculated values 18 | const static float gain = maxCLL / peakLuminance; 19 | const static float compressor = 1.0 / ratio; 20 | 21 | // PQ constants 22 | const static float m1inv = 16384 / 2610.0; 23 | const static float m2inv = 32 / 2523.0; 24 | const static float c1 = 3424 / 4096.0; 25 | const static float c2 = 2413 / 128.0; 26 | const static float c3 = 2392 / 128.0; 27 | 28 | sampler s0; 29 | 30 | inline float minGain(float3 pixel) { 31 | return min(pixel.r, min(pixel.g, pixel.b)); 32 | } 33 | 34 | inline float midGain(float3 pixel) { 35 | return pixel.r < pixel.g ? 36 | (pixel.r < pixel.b ? 37 | min(pixel.g, pixel.b) : // min = r 38 | min(pixel.r, pixel.g)) : // min = b 39 | (pixel.g < pixel.b ? 40 | min(pixel.r, pixel.b) : // min = g 41 | min(pixel.r, pixel.g)); // min = b 42 | } 43 | 44 | inline float maxGain(float3 pixel) { 45 | return max(pixel.r, max(pixel.g, pixel.b)); 46 | } 47 | 48 | inline float3 compress(float3 pixel) { 49 | float gain = maxGain(pixel); 50 | return pixel * (gain < knee ? gain : knee + max(gain - knee, 0) * compressor) / gain; 51 | } 52 | 53 | inline float3 fixClip(float3 pixel) { 54 | // keep the (mid - min) / (max - min) ratio 55 | float preMin = minGain(pixel); 56 | float preMid = midGain(pixel); 57 | float preMax = maxGain(pixel); 58 | float3 clip = saturate(pixel); 59 | float postMin = minGain(clip); 60 | float postMid = midGain(clip); 61 | float postMax = maxGain(clip); 62 | float ratio = (preMid - preMin) / (preMax - preMin); 63 | float newMid = ratio * (postMax - postMin) + postMin; 64 | return float3(clip.r != postMid ? clip.r : newMid, 65 | clip.g != postMid ? clip.g : newMid, 66 | clip.b != postMid ? clip.b : newMid); 67 | } 68 | 69 | inline float3 pq2lin(float3 pq) { // Returns luminance in nits 70 | float3 p = pow(pq, m2inv); 71 | float3 d = max(p - c1, 0) / (c2 - c3 * p); 72 | return pow(d, m1inv) * gain; 73 | } 74 | 75 | inline float3 srgb2lin(float3 srgb) { 76 | return srgb <= 0.04045 ? srgb / 12.92 : pow((srgb + 0.055) / 1.055, 2.4); 77 | } 78 | 79 | inline float3 lin2srgb(float3 lin) { 80 | return lin <= 0.0031308 ? lin * 12.92 : 1.055 * pow(lin, 0.416667) - 0.055; 81 | } 82 | 83 | inline float3 bt2020to709(float3 bt2020) { // in linear space 84 | return float3( 85 | bt2020.r * 1.6605 + bt2020.g * -0.5876 + bt2020.b * -0.0728, 86 | bt2020.r * -0.1246 + bt2020.g * 1.1329 + bt2020.b * -0.0083, 87 | bt2020.r * -0.0182 + bt2020.g * -0.1006 + bt2020.b * 1.1187); 88 | } 89 | 90 | float4 main(float2 tex : TEXCOORD0) : COLOR { 91 | float splitval = tex.x < 0.5 ? 0 : 1; 92 | tex.x = (tex.x < 0.5 ? tex.x : tex.x - 0.5) * 2.0; 93 | float3 pxval = tex2D(s0, tex).rgb; 94 | float3 lin = bt2020to709(pq2lin(pxval)); 95 | float3 highlight = lin - 1.0; 96 | float3 final = lin2srgb(splitval < 0.5 ? compress(lin) : highlight).rgbb; 97 | return fixClip(final).rgbb; 98 | } -------------------------------------------------------------------------------- /Shaders/HDR to SDR (vibrant).hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: HDR to SDR with a different, sometimes better looking compressor 8 | */ 9 | 10 | // Configuration --------------------------------------------------------------- 11 | const static float peakLuminance = 250.0; // Peak playback screen luminance in nits 12 | const static float maxCLL = 10000.0; // Maximum content light level in nits 13 | const static float minMDL = 0.0; // Minimum mastering display luminance in nits 14 | const static float maxMDL = 1000.0; // Maximum mastering display luminance in nits 15 | const static float kneeLuminance = 50.0; // Largest uncompressed luminance in nits 16 | // ----------------------------------------------------------------------------- 17 | 18 | // Precalculated values 19 | const static float linGain = maxCLL / peakLuminance * (maxMDL - minMDL) / maxMDL; 20 | const static float blackPoint = minMDL / maxMDL; 21 | const static float knee = kneeLuminance / peakLuminance; 22 | 23 | // PQ constants 24 | const static float m1inv = 16384 / 2610.0; 25 | const static float m2inv = 32 / 2523.0; 26 | const static float c1 = 3424 / 4096.0; 27 | const static float c2 = 2413 / 128.0; 28 | const static float c3 = 2392 / 128.0; 29 | 30 | sampler s0; 31 | 32 | inline float minGain(float3 pixel) { 33 | return min(pixel.r, min(pixel.g, pixel.b)); 34 | } 35 | 36 | inline float midGain(float3 pixel) { 37 | return pixel.r < pixel.g ? 38 | (pixel.r < pixel.b ? 39 | min(pixel.g, pixel.b) : // min = r 40 | min(pixel.r, pixel.g)) : // min = b 41 | (pixel.g < pixel.b ? 42 | min(pixel.r, pixel.b) : // min = g 43 | min(pixel.r, pixel.g)); // min = b 44 | } 45 | 46 | inline float maxGain(float3 pixel) { 47 | return max(pixel.r, max(pixel.g, pixel.b)); 48 | } 49 | 50 | inline float luma(float3 pixel) { 51 | return 0.2126 * pixel.r + 0.7152 * pixel.g + 0.0722 * pixel.b; 52 | } 53 | 54 | inline float3 compress(float3 pixel) { // in linear space 55 | float3 dry = pixel * linGain + blackPoint; 56 | float lm = luma(dry); 57 | float t = pow(saturate((lm - knee) / (linGain - knee)), 0.5); 58 | return dry * (1 - t) + pixel * t; 59 | } 60 | 61 | inline float3 fixClip(float3 pixel) { 62 | // keep the (mid - min) / (max - min) ratio 63 | float preMin = minGain(pixel); 64 | float preMid = midGain(pixel); 65 | float preMax = maxGain(pixel); 66 | float3 clip = saturate(pixel); 67 | float postMin = minGain(clip); 68 | float postMid = midGain(clip); 69 | float postMax = maxGain(clip); 70 | float ratio = (preMid - preMin) / (preMax - preMin); 71 | float newMid = ratio * (postMax - postMin) + postMin; 72 | return float3(clip.r != postMid ? clip.r : newMid, 73 | clip.g != postMid ? clip.g : newMid, 74 | clip.b != postMid ? clip.b : newMid); 75 | } 76 | 77 | inline float3 pq2lin(float3 pq) { // Returns luminance in nits 78 | float3 p = pow(pq, m2inv); 79 | float3 d = max(p - c1, 0) / (c2 - c3 * p); 80 | return pow(d, m1inv); 81 | } 82 | 83 | inline float3 srgb2lin(float3 srgb) { 84 | return srgb <= 0.04045 ? srgb / 12.92 : pow((srgb + 0.055) / 1.055, 2.4); 85 | } 86 | 87 | inline float3 lin2srgb(float3 lin) { 88 | return lin <= 0.0031308 ? lin * 12.92 : 1.055 * pow(lin, 0.416667) - 0.055; 89 | } 90 | 91 | inline float3 bt2020to709(float3 bt2020) { // in linear space 92 | return float3( 93 | bt2020.r * 1.6605 + bt2020.g * -0.5876 + bt2020.b * -0.0728, 94 | bt2020.r * -0.1246 + bt2020.g * 1.1329 + bt2020.b * -0.0083, 95 | bt2020.r * -0.0182 + bt2020.g * -0.1006 + bt2020.b * 1.1187); 96 | } 97 | 98 | float4 main(float2 tex : TEXCOORD0) : COLOR { 99 | float3 pxval = tex2D(s0, tex).rgb; 100 | float3 lin = bt2020to709(pq2lin(pxval)); 101 | float3 final = lin2srgb(compress(lin)); 102 | return fixClip(final).rgbb; 103 | } -------------------------------------------------------------------------------- /Shaders/Screen file.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | _______ _____ __ __ ____ __ 3 | / ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__ 4 | / / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/ 5 | / /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,< 6 | \____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_| 7 | http://en.sbence.hu/ Shader: 6-point single projector geometry correction 8 | */ 9 | 10 | // Projector configuration ----------------------------------------------------- 11 | const static float chipAspect = 1.778; // width / height 12 | // Circular lens distortion correction ----------------------------------------- 13 | const static float lensCorrection = 0; // negative numbers distort inwards 14 | // Projection offset correction ------------------------------------------------ 15 | const static float horizontalCorrection = 1.0; // fixes projetor is to the side 16 | const static float verticalCorrection = 1.0; // fixes elevated projector 17 | // Corner offsets (inwards, ratio, relative to full frame) --------------------- 18 | const static float topLeftDown = 0.0; 19 | const static float topLeftRight = 0.0; 20 | const static float topRightDown = 0.0; 21 | const static float topRightLeft = 0.0; 22 | const static float bottomLeftUp = 0.00; 23 | const static float bottomLeftRight = 0.01; 24 | const static float bottomRightUp = 0.0; 25 | const static float bottomRightLeft = 0.01; 26 | // Barrel correction ----------------------------------------------------------- 27 | const static float topBarrel = 0.015; 28 | const static float bottomBarrel = 0.01; 29 | const static float barrelCurviness = 2.0; 30 | // ----------------------------------------------------------------------------- 31 | 32 | // Precalculated values 33 | const static float lensDistortClamp = 1.0 / (1 + 0.5 * sqrt(2) * lensCorrection); 34 | const static float topWidth = 1.0 + topLeftRight + topRightLeft; 35 | const static float leftHeight = 1.0 + topLeftDown + bottomLeftUp; 36 | const static float rightHeight = 1.0 + topRightDown + bottomRightUp; 37 | const static float barrelThroat = 1.0 + topBarrel + bottomBarrel; 38 | 39 | sampler s0 : register(s0); 40 | float4 p0 : register(c0); 41 | 42 | #define width (p0[0]) 43 | #define height (p0[1]) 44 | 45 | inline float4 getTex(float2 tex) { 46 | return tex.x >= 0 && tex.x <= 1 && tex.y >=0 && tex.y <= 1 ? tex2D(s0, tex) : 0; 47 | } 48 | 49 | float4 main(float2 tex : TEXCOORD0) : COLOR { 50 | float heightCorrection = height / 1080; // MPC-HC reports 2160 pixel height when playing UHD on 1080p 51 | tex.y *= heightCorrection; 52 | 53 | // Lens distortion 54 | float cx = tex.x - 0.5, cy = tex.y - 0.5, r = sqrt(cx * cx + cy * cy), 55 | mul = (1 + r * lensCorrection) * lensDistortClamp; 56 | tex.x = cx * mul + 0.5; 57 | tex.y = cy * mul + 0.5; 58 | 59 | // Projection offset warp 60 | tex.x = tex.x >= 0 ? pow(tex.x, horizontalCorrection) : -1; 61 | tex.y = tex.y >= 0 ? pow(tex.y, verticalCorrection) : -1; 62 | 63 | // Barrel 64 | float centerDist = pow(abs(tex.x - 0.5) * 2.0, barrelCurviness); 65 | float centerness = 1.0 - centerDist; 66 | float barrelScale = centerDist + centerness * barrelThroat; 67 | float barrelMargin = centerness * topBarrel; 68 | tex.y = barrelScale * tex.y - barrelMargin; 69 | 70 | float heightDown = tex.y; 71 | float heightUp = 1.0 - tex.y; 72 | float widthRight = tex.x; 73 | float widthLeft = 1.0 - tex.x; 74 | 75 | // Aspect ratio 76 | float videoAspect = width / height; 77 | float aspectCorrection = chipAspect / videoAspect; 78 | float fixBLR = bottomLeftRight * aspectCorrection; 79 | float fixBRL = bottomRightLeft * aspectCorrection; 80 | float bottomWidth = 1.0 + fixBLR + fixBRL; 81 | 82 | // Horizontal edge warps 83 | float widthScale = heightUp * topWidth + heightDown * bottomWidth; 84 | float widthMargin = heightUp * topLeftRight + heightDown * fixBLR; 85 | tex.x = widthScale * widthRight - widthMargin; 86 | 87 | // Vertical edge warps 88 | float heightScale = widthLeft * leftHeight + widthRight * rightHeight; 89 | float heightMargin = widthLeft * topLeftDown + widthRight * topRightDown; 90 | tex.y = heightScale * heightDown - heightMargin; 91 | 92 | tex.y /= heightCorrection; 93 | 94 | // Anti-aliased output with standard 8x MSAA pattern 95 | float2 px = float2(1.0 / width, 1.0 / height); // pixel size 96 | float4 aa1 = getTex(tex + float2(px.x * 0.1, px.y * -0.3)); 97 | float4 aa2 = getTex(tex + float2(px.x * -0.1, px.y * 0.3)); 98 | float4 aa3 = getTex(tex + float2(px.x * 0.5, px.y * 0.1)); 99 | float4 aa4 = getTex(tex + float2(px.x * -0.3, px.y * -0.5)); 100 | float4 aa5 = getTex(tex + float2(px.x * -0.5, px.y * 0.5)); 101 | float4 aa6 = getTex(tex + float2(px.x * -0.7, px.y * -0.1)); 102 | float4 aa7 = getTex(tex + float2(px.x * 0.3, px.y * 0.7)); 103 | float4 aa8 = getTex(tex + float2(px.x * 0.7, px.y * -0.7)); 104 | 105 | return (aa1 + aa2 + aa3 + aa4 + aa5 + aa6 + aa7 + aa8) * 0.125; 106 | } 107 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Cinema Shader Pack 2 | HLSL shaders for projection corrections and dual-projector 3D/HDR. 3 | 4 | ## Table of contents 5 | 1. How to use 6 | 2. Shader categories 7 | 3. HDR tutorial 8 | 4. Licence 9 | 10 | ## 1. How to use 11 | Copy the contents of the Shaders folder to the Shaders folder of a media player 12 | that supports HLSL, like MPC-HC. Go to the shader settings and add the selected 13 | ones as post-resize shaders. 14 | 15 | Some shaders can be configured. Open them with any text editor and modify the 16 | values under *Configuration* if it's present. 17 | 18 | ## 2. Shader categories 19 | The supplied shaders can be grouped by the order they should be applied on the 20 | video. Only use the selected shaders in the order they appear here. Each group 21 | has different usage rules. Any group can be skipped. 22 | 23 | 1. Splitters
24 | Splitters create an image pair that can be dual-projected. Only one splitter can be applied in the shader chain. 25 | * [HDR to SDR + overexposure](./Shaders/HDR%20to%20SDR%20+%20overexposure.hlsl): Try to get the SDR part of HDR content with overexposure as SBS 3D 26 | * [Resolution demo](./Shaders/Resolution%20demo.hlsl): Shows half resolution 4:2:0, 4:4:4, full resolution 4:2:0, and 4:4:4 in order 27 | 2. Split state corrections
28 | These shaders process already split videos like 3D content, for multiple properties. 29 | * [Dual projector convergence - OU](./Shaders/Dual%20projector%20convergence%20-%20OU.hlsl): Simple projector convergence for over-under dual projection (3D or HDR) 30 | * [Dual projector convergence - SBS](./Shaders/Dual%20projector%20convergence%20-%20SBS.hlsl): Simple projector convergence for side-by-side dual projection (3D or HDR) 31 | * [Flip eyes - OU](./Shaders/Flip%20eyes%20-%20OU.hlsl): Flip left/right eye image for over-under 3D content 32 | * [Flip eyes - SBS](./Shaders/Flip%20eyes%20-%20SBS.hlsl): Flip left/right eye image for side-by-side 3D content 33 | * [Parallax - OU](./Shaders/Parallax%20-%20OU.hlsl): Parallax correction for over-under 3D content 34 | * [Parallax - SBS](./Shaders/Parallax%20-%20SBS.hlsl): Parallax correction for side-by-side 3D content 35 | 3. Mergers
36 | Mergers combine split images. Only one merger for the given source and target format can be applied in the shader chain. 37 | * [3D to 2D - OU](./Shaders/3D%20to%202D%20-%20OU.hlsl): Left eye retain for half-size over-under 3D content 38 | * [3D to 2D - SBS](./Shaders/3D%20to%202D%20-%20SBS.hlsl): Left eye retain for half-size side-by-side 3D content 39 | * [Anaglyph 3D - OU to red-blue](./Shaders/Anaglyph%203D%20-%20OU%20to%20red-blue.hlsl): Prepare over-under 3D content for red-blue glasses 40 | * [Anaglyph 3D - OU to red-cyan](./Shaders/Anaglyph%203D%20-%20OU%20to%20red-cyan.hlsl): Prepare over-under 3D content for red-cyan glasses 41 | * [Anaglyph 3D - OU to red-green](./Shaders/Anaglyph%203D%20-%20OU%20to%20red-green.hlsl): Prepare over-under 3D content for red-green glasses 42 | * [Anaglyph 3D - OU to trioscopic](./Shaders/Anaglyph%203D%20-%20OU%20to%20trioscopic.hlsl): Prepare over-under 3D content for trioscopic glasses 43 | * [Anaglyph 3D - SBS to red-blue](./Shaders/Anaglyph%203D%20-%20SBS%20to%20red-blue.hlsl): Prepare side-by-side 3D content for red-blue glasses 44 | * [Anaglyph 3D - SBS to red-cyan](./Shaders/Anaglyph%203D%20-%20SBS%20to%20red-cyan.hlsl): Prepare side-by-side 3D content for red-cyan glasses 45 | * [Anaglyph 3D - SBS to red-green](./Shaders/Anaglyph%203D%20-%20SBS%20to%20red-green.hlsl): Prepare side-by-side 3D content for red-green glasses 46 | * [Anaglyph 3D - SBS to trioscopic](./Shaders/Anaglyph%203D%20-%20SBS%20to%20trioscopic.hlsl): Prepare side-by-side 3D content for trioscopic glasses 47 | 4. Corrections
48 | Single-projector or merged image corrections for multiple properties. 49 | * [Black bar filler](./Shaders/Black%20bar%20filler.hlsl): Fill black bars by cylindrically warping the image 50 | * [Bottomizer](./Shaders/Bottomizer.hlsl): Move wide content to the bottom of the frame 51 | * [HDR to SDR](./Shaders/HDR%20to%20SDR.hlsl): Try to get the SDR part of HDR content 52 | * [HDR to SDR (vibrant)](./Shaders/HDR%20to%20SDR%20(vibrant).hlsl): HDR to SDR with a different, sometimes better looking compressor 53 | * [HDR to SDR (S-Log)](./Shaders/HDR%20to%20SDR%20(S-Log).hlsl): Try to get the SDR part of S-Log HDR content 54 | * [Gamma correction](./Shaders/Gamma%20correction.hlsl): Simple gamma correction 55 | * [Reframe](./Shaders/Reframe.hlsl): Keep content in the screen's largest given area by ratio 56 | * [Screen file](./Shaders/Screen%20file.hlsl): 6-point single projector geometry correction 57 | * [Spot correction](./Shaders/Spot%20correction.hlsl): Corrects spots with incorrect colors 58 | 5. Warpers
59 | Specific splitters for special setups, including triple projection. 60 | * [ScreenXizer - Cinerama](./Shaders/ScreenXizer%20-%20Cinerama.hlsl): Warp screen edges to side screens with cylinder wrapping 61 | * [ScreenXizer - Cubemap](./Shaders/ScreenXizer%20-%20Cubemap.hlsl): Warp screen edges to side screens with cube wrapping 62 | 63 | ## 3. HDR tutorial 64 | The *HDR to SDR* shader works for both SDR conversion and limited to full HDR 65 | content display. The default configuration values are fine for regular displays, 66 | but you can set it up to actual HDR light values, even to luminance levels not 67 | supported by today's standards, making this shader future-proof. To get the most 68 | out of your screen, push the light output to the maximum and set the peak 69 | luminance accordingly. If you don't have a luminance meter, just set it to the 70 | largest value where the shadows look right. 71 | 72 | ## 4. Licence 73 | The source code is given to you for free, but without any warranty. It is not 74 | guaranteed to work, and the developer is not responsible for any damages from 75 | the use of the software. You are allowed to make any modifications, and release 76 | them for free. If you release a modified version, you have to link this 77 | repository as its source. You are not allowed to sell any part of the original 78 | or the modified version. You are also not allowed to show advertisements in the 79 | modified software. If you include these code or any part of the original version 80 | in any other project, these terms still apply. 81 | --------------------------------------------------------------------------------