A way to invert color of a specific channel

hi, very often I need to invert green (Y) channel in normal maps back and force only because of different 3d app renders models differently. This inverting option exist almost everywhere but I can’t find it in three js. Maybe I miss something?

Here’s best explanation of why this needs:



Basically it’ not the matter of API used to render normal map but mostly a matter of inverting of a green channel.

I’m not concidering changing the image itself. Also, this question discussed here without a resolution:

3ds max example:
image
Substance:
image
Corona render:
image

unreal engine:

Have you tried setting normalScale.y to -1 in MeshStandardMaterial

1 Like

nope, I never know it exists. will that invert a color of specific channel?
how I can use it for a material node? or map node?
I’m using phong material btw

Its in phong material also.

normalScale.xy basically gets multiplied to xy of the normal from the map. So setting it to -1 should invert it.

1 Like

thank you. seems like I can’t find a way to properly use it.
something like(?):

material.normalScale.set( 0.0, -1.0 );

yes, probably also set material.needsUpdate = true

I use

material.normalScale.set( 1, -1 );

but that doesn’t seem work. also I have
THREE.WebGLRenderer: Texture marked for update but image is undefined warning all the time with fbxloader()

I see this demo: three.js examples
and this source code: three.js/webgl_materials_displacementmap.html at 00a692864f541a3ec194d266e220efd597eb28fa · mrdoob/three.js · GitHub

but I can’t implement it to my code for some reason.

okay, I resolved update warning by this code:

var tex = material.map.clone();
tex.needsUpdate = true;

but normalScale still doesn’t work. any thoughts how to make it work?

okay, I resolved it with:

material.normalScale = new THREE.Vector2(-1, -1);

but for some reason now it ignores my

material.normalScale.setScalar(2.0);

so, increasing these parameters actually fixed the issue:

material.normalScale = new THREE.Vector2(-2.2, -2.2);

case closed. thank you :wink: