Technici4n / crowl

Rust voxel engine and game
MIT License
2 stars 0 forks source link

Incorrect gamma correction in textures (the textures appear lighter than they are) #1

Closed redeff closed 6 years ago

redeff commented 6 years ago

Here is a working version of the fragment shader, although I think there must be a way of adjusting the gamma configuration from inside of gfx

#version 150 core

in vec2 v_Uv;

uniform sampler2D t_Image;

out vec4 Target0;

float exponent = 2.0;

void main() {
    vec4 tex = texture(t_Image, v_Uv);
    Target0 = vec4(
        pow(tex.x, exponent),
        pow(tex.y, exponent),
        pow(tex.z, exponent),
        pow(tex.w, exponent)
    );
}
Technici4n commented 6 years ago

Thanks for pointing this out. I solved it by changing gfx's ColorFormat to sRGB.

Very helpful article on that: https://gamedevelopment.tutsplus.com/articles/gamma-correction-and-why-it-matters--gamedev-14466