I noticed that PBRMaterial (and NodeMaterial) normal map implementation seems to have black fringes around areas where the normal has been heavily affected by the normal map.
Here is how the
glTF-Sample-Models repository “NormalTangentTest” model looks like. See how there is a dark fringe around the right side normal mapped mesh, compared to the left side reference mesh that is pure geometry instead of normal map:
Here is a playground test model: https://playground.babylonjs.com/#BRN8WP#2
In my investigation I discovered that this seems to be related to how PBRMaterial also uses un-perturbed worldNormal for normal map calculation(?):
- See the same model replicated with NodeMaterial: Babylon.js Playground
- And now if I connect
PerturbNormalBlockoutput also directly to the
It all of a sudden looks identical to the reference:
I have always been wondering why PBRMetallicRoughness node needed 2 normal inputs, when only the perturbed normal (if available) should be used for any shading related calculations. But it apparently besides confusion, it also seems to cause this bug.