How to apply sRGBEncoding on texture?

Hello guys, I wanna know how to apply sRGBEncoding to texture maps of GLB, right now normal, AO, roughness and all other texture maps are very dull in color and I wanna know how to sRGBEncoding for texture maps like my output is-


in the above it is very dull.

child.material.map.encoding = THREE.sRGBEncoding;
child.material.needsUpdate = true;

also tried

child.material.normalMap.encoding = THREE.sRGBEncoding;
child.material.needsUpdate = true;

above two lines give me an error of undefined. Is there any way how to fix this?

i believe the gltf loader automatically sets it up correctly, you shouldn’t have to do anything. but do put threejs itself into color management: three.js docs

so basically:

THREE.ColorManagement.legacyMode = false
renderer.outputEncoding = THREE.sRGBEncoding

it’s not unusualy to also use tonemapping, which reduces banding and improves colors

renderer.toneMapping = THREE.ACESFilmicToneMapping

with these three it should more or less look like in blender.

Property ‘ColorManagement’ does not exist on type 'typeof

it gives me an error

needs a modern three. they just recently merged it. even without, i think gltf loader will still take care of it. colormanagement just makes sure that everything else is correct, too.

I tried all things but texture map picking up raw color values I need to change that into sRGBEncoding but I don’t know how it works

In latest version that module itself is missing what is new alternative for it

.encoding has been replaced with .colorSpace in latest versions of three.js - setting .colorSpace = “srgb” is equal to setting encoding to SRGBEncoding previously

1 Like