c++ - Gamma correction doesn't look properly corrected, is this linear? -


i want implement gamma correction opengl lighting, gamma correction applied, results not seem linear @ all.

i found opengl: gamma corrected image doesn't appear linear similar issue, hasn't yet received answer nor discussed actual diffuse lights.

as illustration, have following 4 light colors defined in linear space:

glm::vec3 lightcolors[] = {     glm::vec3(0.25),     glm::vec3(0.50),     glm::vec3(0.75),     glm::vec3(1.00) }; 

with each light source seperated , basic linear attenuation applied diffuse lighting equation following results:

wrong gamma

this fragment shader:

void main() {                vec3 lighting = vec3(0.0);     for(int = 0; < 4; ++i)         lighting += diffuse(normalize(fs_in.normal), fs_in.fragpos, lightpositions[i], lightcolors[i]);     // lighting = pow(lighting, vec3(1.0/2.2));     fragcolor = vec4(lighting, 1.0f); } 

not barely see difference in brightness gamma corrected lights, attenuation distorted gamma correction. far understanding goes, calculations (including attenuation) done in linear space , correcting gamma monitor should display correctly (as uncorrects again output). based on lighting colors, right-most circle should 4 times bright left circle , twice bright second circle doesn't seem case.

is i'm not sensitive enough perceive correct brightness differences or wrong?

something else tried output exact light colors onto default framebuffer without , gamma correction.

gamma output

left uncorrected, right gamma correction; red numbers indicating rgb intensity photoshop's color picker. know photoshop rgb values not represent final output image (as photoshop doens't read rgb values monitor outputs). left image intuitively seems better, based on rgb intensity values i'd right-most image indeed correctly gamma-corrected fragment shader; each of these intensities pass through monitor , enter eye correct intensity. instance, 0.75 intensity 0.88 gamma corrected becomes 0.88^2.2 = 0.75 output of monitor.

is right image indeed correct? , also, how comes actual lighting off compared other images?

the results getting expected.

you seem confuse physical radiometric radiance created display perceived brightness of human. latter nonlinear, , simple gamma model way approximate that. basically, monitor inverting nonlinear transformation of human eye, standard (nonlinear) rgb space perceived linearily - using rgb intensity 0.5 perceived half bright 1.0, , on.

if put colorimeter or spectrophotomer @ youe display when displaying gamma-corrected grayscale levels, see 0.73 step show 50% of luminance of white level in candela/m^2 (assuming display not deviate srgb model btw. not using gamma 2.2, linear segment in combination gamma 2.4 rest, 2.2 approximation).

now question is: want achieve? working in linear color space typically required if want physically accurate calculations. then, light source 50% of luminance of 1 not apper half bright human, , result got correct.

if want have a color space linear in percepted brightness, can skip gamma correction, srgb exaclty trying provide already. might need color calibration or small gamma adjustment correct deviations introduced display, if want exact results.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -