How to use two normal maps per material?

Hello,

I want to use two normal maps for my mesh since one is related to the material itself and the other is related to the mesh. I tried to achieve this with a detailmap but I realized that this won’t work. I don’t need diffuse and roughness of the detailmap so red and blue channel are wasted and the green channel isn’t enough for my normal map.

So my question is how to use two different normal maps for the same material. One normal map should point to uv map 1 and the other normal map should point to uv map 2. Do I have to create a node material or is there another way? If yes, how to create the node material? It should be 100% the same like the regular pbr material but with the opportunity to add a second normal map.

I appreciate your help.

Thanks!

You are going to either use NME or a ShaderMaterial as this is not something supported out of the box

Since I have no clue how to do that with shaderMaterial I will go with NME.

I noticed that there is a normalBlend node that fits my needs perfectly. I gave it a try and it works so far: https://nme.babylonjs.com/#LWL6BV#19

I have still some questions though:

  1. I have a uv map for each of both normal maps. But my normal blend node goes to pertubNormal wich has only one uv map slot. I noticed that it works without connecting a uv map to pertubNormal. But after saving it automatically connects to uv map 1. How to handle two uv maps?

  2. The intensity of the normal maps can be adjusted in pertubNormal but only for both normal maps simultaneously. To be able to control the strength of each normal map I used lerpBlocks and set bumpStrength just to 1. Is that correct?

  3. I also try to combine two ambient occlusion maps. One from the red channel of metallicRoughnessTexture and one via grayscale from an additional texture. How to do that?

  4. Do I have to implement morph target and bones to my nodeMaterial or are the automatically handled? If I have to implement it, is there an example of the correct node structure?

Thank you!

Best

  1. You should actually merge both maps before by using BlendNormal node
  2. it is smart :wink:
  3. use two texture blocks and then use color merger block
  4. You have morph target block and Bone block :slight_smile:

Hey @Deltakosh

Thanks for you reply.

  1. I merged them by using blendNormal and connected the output to the perturbNormalBlock. But the pertubNormalBlock need a uv map. So I am confused because I use two normal maps with one uv map each but I have to connect one uv map to the perturbNormalBlock.

  1. I will stay with that solution :slight_smile:

  2. Unfortunately colorMerger outputs rgb but ambientOcclusion in PBRBlock just takes one channel. I am not sure how to connect it appropriately.

  3. These blocks are great. Morph target and bones are working :slight_smile:

https://nme.babylonjs.com/#LWL6BV#21

  1. The uv is just used to get a map to build the tangents when not provided. So you may simply want to make sure your mesh has tangents (along with normals). your uvs will be important to parse the normal maps and you are already doing it
  2. Then why not either working with a multiply between the two incoming red channels?
  1. Oh dear, tangents are working very very well. Thanks for the hint!!
  2. I will try that. Thanks.

First, thanks for the great material example you provided! It helped me a lot ot understand how the NME works.

Second, how did you manage to use second uv? Maybe it was available before? Right now, when I’m trying to switch between uv channels in the Mesh. UV node, it just throws an error…

Welcome to the forum !!!

Could you share a repro of your error ? this would help us troubleshoot


Thank you!

I’m trying to use 2nd UV channel in my material. But when I’m switching it on the node it throws an error (at the screen).
But if I’m using material, created 2 years ago with your NME with UV node already set to UV2 it works normally.

Maybe I’m doing something wrong? My goal is to use 2 UV channels: one for trim normal map and another for detail normal map.

@carolhmj and @Evgeni_Popov I am thinking it might be related to the option line component ???

Yep this should be fixed in the next release Remake OptionsLineComponent with custom options by carolhmj · Pull Request #13194 · BabylonJS/Babylon.js (github.com)

Got it!

Thanks, @sebavan @carolhmj !

1 Like