Add shader parameters to basic crt shaders.

This commit is contained in:
Hans-Kristian Arntzen 2016-08-01 22:11:09 +02:00
parent aa9b5d4a67
commit 39cae98850
4 changed files with 11 additions and 3 deletions

View file

@ -2,5 +2,7 @@ layout(std140, set = 0, binding = 1) uniform UBO
{
mat4 MVP;
vec4 SourceSize;
float OUT_GAMMA;
float BOOST;
} global;

View file

@ -1,8 +1,10 @@
#version 450
#include "parameters.inc"
layout(std140, set = 0, binding = 0) uniform UBO
{
mat4 MVP;
float GAMMA;
} global;
#pragma stage vertex
@ -23,7 +25,7 @@ layout(set = 0, binding = 2) uniform sampler2D Source;
vec3 gamma(vec3 v)
{
return pow(v, vec3(2.2));
return pow(v, vec3(global.GAMMA));
}
void main()

3
crt/parameters.inc Normal file
View file

@ -0,0 +1,3 @@
#pragma parameter OUT_GAMMA "Monitor Output Gamma" 2.2 1.8 2.4
#pragma parameter BOOST "Color Boost" 1.0 0.2 2.0 0.02
#pragma parameter GAMMA "CRT gamma" 2.5 2.0 3.0 0.02

View file

@ -1,6 +1,7 @@
#version 450
#include "common.inc"
#include "parameters.inc"
#pragma stage vertex
layout(location = 0) in vec4 Position;
@ -20,7 +21,7 @@ layout(set = 0, binding = 2) uniform sampler2D Source;
vec3 invgamma(vec3 v)
{
return pow(v, vec3(1.0 / 2.2));
return pow(clamp(v, vec3(0.0), vec3(1.0)), vec3(1.0 / global.OUT_GAMMA));
}
float luma(vec3 col)
@ -49,5 +50,5 @@ void main()
dist.y * l1 +
dist.z * l2;
FragColor = vec4(invgamma(color), 1.0);
FragColor = vec4(invgamma(global.BOOST * color), 1.0);
}