mirror of
https://github.com/italicsjenga/slang-shaders.git
synced 2024-11-29 19:01:31 +11:00
Add shader parameters to basic crt shaders.
This commit is contained in:
parent
aa9b5d4a67
commit
39cae98850
|
@ -2,5 +2,7 @@ layout(std140, set = 0, binding = 1) uniform UBO
|
||||||
{
|
{
|
||||||
mat4 MVP;
|
mat4 MVP;
|
||||||
vec4 SourceSize;
|
vec4 SourceSize;
|
||||||
|
float OUT_GAMMA;
|
||||||
|
float BOOST;
|
||||||
} global;
|
} global;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
#version 450
|
#version 450
|
||||||
|
#include "parameters.inc"
|
||||||
|
|
||||||
layout(std140, set = 0, binding = 0) uniform UBO
|
layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
{
|
{
|
||||||
mat4 MVP;
|
mat4 MVP;
|
||||||
|
float GAMMA;
|
||||||
} global;
|
} global;
|
||||||
|
|
||||||
#pragma stage vertex
|
#pragma stage vertex
|
||||||
|
@ -23,7 +25,7 @@ layout(set = 0, binding = 2) uniform sampler2D Source;
|
||||||
|
|
||||||
vec3 gamma(vec3 v)
|
vec3 gamma(vec3 v)
|
||||||
{
|
{
|
||||||
return pow(v, vec3(2.2));
|
return pow(v, vec3(global.GAMMA));
|
||||||
}
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
|
|
3
crt/parameters.inc
Normal file
3
crt/parameters.inc
Normal 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
|
|
@ -1,6 +1,7 @@
|
||||||
#version 450
|
#version 450
|
||||||
|
|
||||||
#include "common.inc"
|
#include "common.inc"
|
||||||
|
#include "parameters.inc"
|
||||||
|
|
||||||
#pragma stage vertex
|
#pragma stage vertex
|
||||||
layout(location = 0) in vec4 Position;
|
layout(location = 0) in vec4 Position;
|
||||||
|
@ -20,7 +21,7 @@ layout(set = 0, binding = 2) uniform sampler2D Source;
|
||||||
|
|
||||||
vec3 invgamma(vec3 v)
|
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)
|
float luma(vec3 col)
|
||||||
|
@ -49,5 +50,5 @@ void main()
|
||||||
dist.y * l1 +
|
dist.y * l1 +
|
||||||
dist.z * l2;
|
dist.z * l2;
|
||||||
|
|
||||||
FragColor = vec4(invgamma(color), 1.0);
|
FragColor = vec4(invgamma(global.BOOST * color), 1.0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue