mirror of
https://github.com/stenzek/duckstation.git
synced 2024-11-26 23:50:31 +00:00
Data: Add simple-brightness and simple-gamma shaders
This commit is contained in:
parent
49cea927f0
commit
82f00237af
36
data/shaders/simple-brightness.glsl
Normal file
36
data/shaders/simple-brightness.glsl
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
[configuration]
|
||||
|
||||
[OptionRangeFloat]
|
||||
GUIName = Brightness Scale
|
||||
OptionName = BRIGHTNESS_SCALE
|
||||
MinValue = 0.1
|
||||
MaxValue = 5.0
|
||||
StepAmount = 0.1
|
||||
DefaultValue = 1.0
|
||||
|
||||
[/configuration]
|
||||
*/
|
||||
|
||||
void main()
|
||||
{
|
||||
float4 color = Sample();
|
||||
float brightness_scale = GetOption(BRIGHTNESS_SCALE);
|
||||
|
||||
// rgb->yuv
|
||||
float3 yuv;
|
||||
yuv.r = dot(color.rgb, float3(0.299f, 0.587f, 0.114f));
|
||||
yuv.g = dot(color.rgb, float3(-0.14713f, -0.28886f, 0.436f));
|
||||
yuv.b = dot(color.rgb, float3(0.615f, -0.51499f, -0.10001f));
|
||||
|
||||
// apply brightness to y
|
||||
yuv.r = saturate(yuv.r * brightness_scale);
|
||||
|
||||
// yuv->rgb
|
||||
color.r = dot(yuv, float3(1.0f, 0.0f, 1.13983f));
|
||||
color.g = dot(yuv, float3(1.0f, -0.39465f, -0.58060f));
|
||||
color.b = dot(yuv, float3(1.0f, 2.03211f, 0.0f));
|
||||
color.rgb = saturate(color.rgb);
|
||||
|
||||
SetOutput(saturate(color));
|
||||
}
|
33
data/shaders/simple-gamma.glsl
Normal file
33
data/shaders/simple-gamma.glsl
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
[configuration]
|
||||
|
||||
[OptionRangeFloat]
|
||||
GUIName = Gamma In
|
||||
OptionName = GAMMA_IN
|
||||
MinValue = 0.1
|
||||
MaxValue = 10.0
|
||||
StepAmount = 0.1
|
||||
DefaultValue = 2.2
|
||||
|
||||
[OptionRangeFloat]
|
||||
GUIName = Gamma Out
|
||||
OptionName = GAMMA_OUT
|
||||
MinValue = 0.1
|
||||
MaxValue = 10.0
|
||||
StepAmount = 0.1
|
||||
DefaultValue = 2.2
|
||||
|
||||
[/configuration]
|
||||
*/
|
||||
|
||||
void main()
|
||||
{
|
||||
float4 color = Sample();
|
||||
float gamma_in = GetOption(GAMMA_IN);
|
||||
float gamma_out = 1.0f / GetOption(GAMMA_OUT);
|
||||
|
||||
color.rgb = pow(color.rgb, float3(gamma_in, gamma_in, gamma_in));
|
||||
color.rgb = pow(color.rgb, float3(gamma_out, gamma_out, gamma_out));
|
||||
|
||||
SetOutput(saturate(color));
|
||||
}
|
Loading…
Reference in New Issue
Block a user