# Gamma Correction unavoidable

**URL:** https://discourse.vtk.org/t/gamma-correction-unavoidable/16155
**Category:** Support
**Tags:** rendering
**Created:** [November 24, 2025, 2:02pm UTC](https://discourse.vtk.org/t/gamma-correction-unavoidable/16155 "2025-11-24T14:02:56Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![killer3d](https://discourse.vtk.org/user_avatar/discourse.vtk.org/killer3d/32/9520_2.png) [@killer3d](https://discourse.vtk.org/u/killer3d)
#### Post date: [November 24, 2025, 2:02pm UTC](https://discourse.vtk.org/t/gamma-correction-unavoidable/16155/1 "2025-11-24T14:02:56Z")

</div>

[https://gitlab.kitware.com/vtk/vtk/-/issues/19849](https://gitlab.kitware.com/vtk/vtk/-/issues/19849)

In [https://github.com/Kitware/VTK/blob/master/Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx](https://github.com/Kitware/VTK/blob/master/Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx),

void main() { float gamma = 2.2;

```auto
// for each sample in the multi sample buffer...
ivec2 itexcoords = ivec2(floor(textureSize(tex) * texCoord));
vec3 accumulate = vec3(0.0,0.0,0.0);
float alpha = 0.0;

for (int i = 0; i < samplecount; i++)
{
  vec4 sampleValue = texelFetch(tex, itexcoords, i);
  // apply gamma correction and sum
  accumulate += pow(sampleValue.rgb, vec3(gamma));
  alpha += sampleValue.a;
}

// divide and reverse gamma correction
accumulate /= float(samplecount);
gl_FragData[0] = vec4(pow(accumulate, vec3(1.0/gamma)), alpha/float(samplecount));

```

}

is done if MSAA ON and regardless of SRGB How do I turn it off? I guess there is no way,

Can anyone fix it to do gamma correction only for SRGB?

---

<div class="post-metadata">

### Author: ![sankhesh](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sankhesh/32/73_2.png) [@sankhesh](https://discourse.vtk.org/u/sankhesh)
#### Post date: [November 24, 2025, 3:20pm UTC](https://discourse.vtk.org/t/gamma-correction-unavoidable/16155/2 "2025-11-24T15:20:30Z")

</div>

It appears that this may be a bug. It seems that when MultiSamples is enabled, the framebuffer color attachment is assumed to be in sRGB format. @killer3d, do you have a test case that confirms this? That would be helpful in validating this assumption and addressing the issue.

---

<div class="post-metadata">

### Author: ![killer3d](https://discourse.vtk.org/user_avatar/discourse.vtk.org/killer3d/32/9520_2.png) [@killer3d](https://discourse.vtk.org/u/killer3d)
#### Post date: [November 25, 2025, 2:35am UTC](https://discourse.vtk.org/t/gamma-correction-unavoidable/16155/3 "2025-11-25T02:35:47Z")

</div>

The test is very simple, By default SRGB is false on window, so even with the default settings of VTK, it always does Gamma correction in resolve shader.
