Гамма-коррекция

This commit is contained in:
parent 4926e9a87f
commit 72f126943c
4 changed files with 24 additions and 3 deletions

View File

@ -10,6 +10,11 @@ layout(std140, binding = 1) uniform Material
in vec3 pos_local;
layout(std140, binding = 4) uniform gamma
{
float inv_gamma;
};
out vec4 color;
uniform float angle;
@ -19,7 +24,7 @@ void main()
{
float cosA = dot(normalize(pos_local), normalize(direction));
if (degrees(acos(cosA)) <= angle)
color = vec4(ka, 1);
color = vec4(pow(ka, vec3(inv_gamma)), 1);
else
discard;
}

View File

@ -41,6 +41,11 @@ uniform sampler2DArray sunShadowDepth;
uniform samplerCubeArray pointShadowDepth;
uniform sampler2D ssao;
layout(std140, binding = 4) uniform gamma
{
float inv_gamma;
};
out vec4 color;
void main()
@ -190,4 +195,7 @@ void main()
}
}
}
// Применение гамма-коррекции
color.rgb = pow(color.rgb, vec3(inv_gamma));
}

View File

@ -1,12 +1,17 @@
#version 330 core
#version 420 core
out vec4 FragColor;
in vec3 TexCoords;
uniform samplerCube skybox;
layout(std140, binding = 4) uniform gamma
{
float inv_gamma;
};
void main()
{
FragColor = texture(skybox, TexCoords);
FragColor.rgb = pow(texture(skybox, TexCoords).rgb, vec3(inv_gamma));
gl_FragDepth = 0.9999f;
}

View File

@ -425,6 +425,9 @@ int main(void)
const char* skybox_shader_names[] = {"skybox"};
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))