Gamma Correction

Usage:

  1. Create a CanvasLayer and add a ColorRect as child.
  2. In the ColorRect  add a new ShaderMaterial.
  3. In the ShaderMaterial add a new Shader.
  4. Copy the script below into the Shader-Editor.

Documentation

  • gamma: Defines the gamma correction value. Default is 1.

Hint

This shader is written for Godot 4.

 

Shader code
shader_type canvas_item;

uniform sampler2D screen_texture : hint_screen_texture, filter_nearest_mipmap, repeat_enable;

uniform float gamma: hint_range(0.0, 2.0, 0.05) = 1.0;

void fragment() {
    vec4 color = texture(screen_texture, SCREEN_UV);
    color.rgb = pow(color.rgb, vec3(1.0 / gamma));
    COLOR = color;
}
Tags
canvaslayer, gamma, godot4, horror
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

More from Grau

Aberration Vignette – Phasmophobia effect

Gameboy Look

PS1/PSX PostProcessing

Related shaders

Gradient Color Correction for ViewportTextures

Colorblindness correction shader

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments