Node Material and scene.environmentTexture

Hello, and what is the preferred way to connect the scene environment to the PBR inputs of a node material?

In the following playground, the nme based pbr material does not receive lighting from the scene environment, but enabling the hemispheric light works.

Playground:
https://playground.babylonjs.com/#FEEK7G#31

NME:
https://nodematerial-editor.babylonjs.com/#5671U2#3

Correct PG:

https://playground.babylonjs.com/#FEEK7G#225

Adding @Evgeni_Popov who’s the master of the intersection between PBR and NME.

From what I can tell, I believe you’ll want to hook up the same Environment texture used in the scene to the reflection input of the PBR node. but @Evgeni_Popov can definitely correct me if I’m wrong here.

Basically you need a reflection block hooked in or you won t have reflection at all :slight_smile: https://playground.babylonjs.com/#FEEK7G#226

2 Likes

Hey, and thanks. That worked in the playground, but I’m still getting issues in a tree-shaken version.

Please take a look at the main scene which launches on npm start. It is using the same material and environment texture as this playground:

https://playground.babylonjs.com/#FEEK7G#227

No errors are being reported.

r

You might want the envTextureLoader instead of ddsTextureLoader ?

@sebavan it wasn’t related to the loaders.

@Evgeni_Popov can you confirm if this is expected behavior? I can receive light from direct sources, but not indirect.

When you get the node material (by calling ParseFromSnippetAsync) it is automatically built, and the reflection block is trying to get the environment texture from the scene. If it can’t find it, the reflection block is disabled.

So, you should either move the ParseFromSnippetAsync call after you set scene.environmentTexture or call nodeMaterial.build() after you have set the env texture.

1 Like

Thanks.