Гамма-коррекция
This commit is contained in:
parent
4926e9a87f
commit
72f126943c
|
@ -10,6 +10,11 @@ layout(std140, binding = 1) uniform Material
|
||||||
|
|
||||||
in vec3 pos_local;
|
in vec3 pos_local;
|
||||||
|
|
||||||
|
layout(std140, binding = 4) uniform gamma
|
||||||
|
{
|
||||||
|
float inv_gamma;
|
||||||
|
};
|
||||||
|
|
||||||
out vec4 color;
|
out vec4 color;
|
||||||
|
|
||||||
uniform float angle;
|
uniform float angle;
|
||||||
|
@ -19,7 +24,7 @@ void main()
|
||||||
{
|
{
|
||||||
float cosA = dot(normalize(pos_local), normalize(direction));
|
float cosA = dot(normalize(pos_local), normalize(direction));
|
||||||
if (degrees(acos(cosA)) <= angle)
|
if (degrees(acos(cosA)) <= angle)
|
||||||
color = vec4(ka, 1);
|
color = vec4(pow(ka, vec3(inv_gamma)), 1);
|
||||||
else
|
else
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
|
@ -41,6 +41,11 @@ uniform sampler2DArray sunShadowDepth;
|
||||||
uniform samplerCubeArray pointShadowDepth;
|
uniform samplerCubeArray pointShadowDepth;
|
||||||
uniform sampler2D ssao;
|
uniform sampler2D ssao;
|
||||||
|
|
||||||
|
layout(std140, binding = 4) uniform gamma
|
||||||
|
{
|
||||||
|
float inv_gamma;
|
||||||
|
};
|
||||||
|
|
||||||
out vec4 color;
|
out vec4 color;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
|
@ -190,4 +195,7 @@ void main()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Применение гамма-коррекции
|
||||||
|
color.rgb = pow(color.rgb, vec3(inv_gamma));
|
||||||
}
|
}
|
|
@ -1,12 +1,17 @@
|
||||||
#version 330 core
|
#version 420 core
|
||||||
out vec4 FragColor;
|
out vec4 FragColor;
|
||||||
|
|
||||||
in vec3 TexCoords;
|
in vec3 TexCoords;
|
||||||
|
|
||||||
uniform samplerCube skybox;
|
uniform samplerCube skybox;
|
||||||
|
|
||||||
|
layout(std140, binding = 4) uniform gamma
|
||||||
|
{
|
||||||
|
float inv_gamma;
|
||||||
|
};
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
FragColor = texture(skybox, TexCoords);
|
FragColor.rgb = pow(texture(skybox, TexCoords).rgb, vec3(inv_gamma));
|
||||||
gl_FragDepth = 0.9999f;
|
gl_FragDepth = 0.9999f;
|
||||||
}
|
}
|
|
@ -425,6 +425,9 @@ int main(void)
|
||||||
const char* skybox_shader_names[] = {"skybox"};
|
const char* skybox_shader_names[] = {"skybox"};
|
||||||
skyboxShader.bindTextures(skybox_shader_names, sizeof(skybox_shader_names)/sizeof(const char*));
|
skyboxShader.bindTextures(skybox_shader_names, sizeof(skybox_shader_names)/sizeof(const char*));
|
||||||
|
|
||||||
|
// Значение гамма-коррекции
|
||||||
|
float inv_gamma = 1/2.2;
|
||||||
|
UBO gamma(&inv_gamma, sizeof(inv_gamma), 4);
|
||||||
|
|
||||||
// Пока не произойдет событие запроса закрытия окна
|
// Пока не произойдет событие запроса закрытия окна
|
||||||
while(!glfwWindowShouldClose(window))
|
while(!glfwWindowShouldClose(window))
|
||||||
|
|
Loading…
Reference in New Issue