How do I Force sRGB on a Texture when writing a custom shader?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By hidemat

In GODOT 4 3D, the StandardMaterial has an option called “Texture force sRGB”. When I enable it the colors in my texture display properly, otherwise they look washed. The problem is that I’m using a custom shader so that I can control the texture UVs. So, I was wondering if anyone know how to replicate this option in a custom shader?

:bust_in_silhouette: Reply From: Wakatta

Calculated as

albedo_tex.rgb = mix(pow((albedo_tex.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)),vec3(2.4)),albedo_tex.rgb.rgb * (1.0 / 12.92),lessThan(albedo_tex.rgb,vec3(0.04045)));

Oh. Thanks so much. That’s what I needed. わかった。

hidemat | 2023-02-28 03:02