How to get and set data from individual color channels of a texture

Hi all, I’m creating a simple scene to view PBR materials.
For this I load a normal- and a displacement map (and other 2K maps) from an external url.
From what i read in the manual, the bump/normal map’s alpha channel is used for parallax/displacement.
However, I can’t find anything in the manual on how i would get the data from one texture and access the alpha channel of the normal texture.
Is this where i would use a dynamic/procedural/RawTexture?
The meshes I’m testing on are low-poly, so mesh.applydisplacementmap is not what i’m looking for.
I’m also curious why this is the way bjs handles things instead of having an input for a separate displacement texture.
Sorry if this is a newbie question, but I’ve been stuck on this for a while :slight_smile:

Welcome aboard!

Babylon.js does not support displacement map in PBR materials, only a height map that can be used for parallax mapping (and that should go into the alpha channel of the bump texture as you said).

Maybe that would be something we could consider implementing (@sebavan ? @Deltakosh ?).


Ah, good to know I wasnt looking for some setting that was in plain sight.
Any suggestions on how to solve the texture channel conversion are still much appreciated, otherwise I’d have to convert them manually in an image editor.
On the same topic, I’ve found this vid explaining the differences between bump, normal, displacement and parallax mapping, very insightful.

I’m not sure I understand what you need to do. Is it that you want to create a texture C by getting some channels from texture A and other channel(s) from texture B? You could do it programmatically (you can get the pixels from a texture with Texture.readPixels and create a raw texture with that) or use the NME (node material editor) and choose “Procedural” as the mode:


Here’s the doc about procedural textures in the NME: Node Material Procedural Textures | Babylon.js Documentation


For anyone else who is dealing with this, I ‘solved’ my problem with this tool that someone wrote specifically for babylon:
You can convert collections of texture maps without too much effort.

1 Like