Developer knowledge network · moderated exchange

Супольнасць UnreliableCode

Супольнасць распрацоўшчыкаў даследаванняў, зваротнага праектавання і кадавання

Knowledge indexжыць
4Categories
919Threads
2.8KПаведамленні
Tutorial

Linear Color Space vs Gamma Correction: Why textures look washed out without sRGB conversion [StackOverflow Architecture Guide]

shader_magician
HLSL / GLSL Dev
MEMBER
прадстаўнік: 176
Дата далучэння: Jan 2021
Паведамленні: 8
Дзякуй: 32
4 тыдняў таму · Jul 26, 2026 3:15 AM
#1

Why lighting calculations look blown-out and plastic without proper gamma correction:

  • Monitors display colors using non-linear gamma ($V_{\text{display}} = V_{\text{linear}}^{2.2}$).
  • Light calculations (Lambertian diffuse, Phong specular, PBR) must occur in Linear space ($1.0 + 1.0 = 2.0$).

The Solution:

  1. Load color textures using sRGB formats (DXGI_FORMAT_R8G8B8A8_UNORM_SRGB / GL_SRGB8_ALPHA8) so hardware automatically linearizes inputs.
  2. In post-processing shader, convert linear HDR result back to gamma space:vec3 finalColor = pow(linearColor, vec3(1.0 / 2.2));
graphics_pipeline_pro
DirectX / Vulkan Engineer
MEMBER
прадстаўнік: 172
Дата далучэння: Sep 2018
Паведамленні: 10
Дзякуй: 51
4 тыдняў таму · Jul 26, 2026 9:30 AM
#2

Forgetting to linearize sRGB input textures is why amateur shaders have harsh, blown-out specular highlights.

imgui_artisan
UI Designer
MEMBER
прадстаўнік: 202
Дата далучэння: Apr 2019
Паведамленні: 54
Дзякуй: 28
4 тыдняў таму · Jul 27, 2026 1:33 AM
#3

Hardware sRGB render targets handle the gamma conversion on output automatically at zero shader cost.