NodeMaterial Light overpowering the shader

I use Babylonjs 4.2.0-beta.11

I created shader in the online node material editor and it looks good:

But when I imported it to my scene it’s completely overpowered by the Light :confused:

I even downloaded the source of node editor to copy the light settings and I got the same over and over again.

when I turn my light from 1.2 intensity (like the preview in the editor has) to 0.001I got this:

and also my scene light is not coloring the water like the node editor is doing.

So do anyone has some ideas on how to solve this?

Do I need (in my scene) somehow connect scene Light with my nodeMaterial ?

Or what I’m doing wrong. I do everything like the YouTube videos are doing?

Is there any Light correction used in NodeEditor Preview that I do not know about?


Do you mind sharing a PG?

Unfortunately, I can’t share a PG. I do not create an open library at the moment.

The situation has something to do with the Light node in NME and how the light from your scene understands glossiness and gloss power. I did everything like youtube moon video did and it’s not working as intended.

I will try to do simple eversion.



So in the playground, it works fine:

But in my scene, I’m loading a model and I got extra some environmental texture?


And that was the problem :confused: I use this: SceneLoader.AppendAsync And I need to change it to not have a scene loaded just the mesh loaded. Cause the environment from the loaded scene takes over and overburn the whole thing.
I use a blender Exporter for my mesh and it also exported default scene lightning and the environment from Eveee I presume.

Anyway :slight_smile: Doing playground example really helped to solve my problem :slight_smile: I hope this will help someone not to duplicate my mistake :slight_smile:

I jumped to conclusion too fast. I still have environment with my Mesh loaded.

How to get rid of it?

This in my loaded scene is breaking it: environmentBRDFTexture

How do I load just the models no lightning And so on?

well this is the BRDF texture which is mandatory for gltf files. It is used for internal computation and it is always there.

What do you mean by having your environment? Can you share a screenshot?

So this was not my problem at all it turns out :slight_smile:

I was having my model scaled 100 times down and in code, after loading I was scaling it up back to 100%. This was probably creating error with the Light Mesh Position node in NodeMaterial and that’s it.

I scaled the model 100 times up in Blender exported it like that and problem was gone :slight_smile:

2 days waisted :confused: To find out that somebody did models in scale :confused:

Thank you for your time :slight_smile:

hahaha at least you found it so it is not completely a waste of time :wink:

1 Like


Now I got a new problem. While adding this Material all looks ok but the water is jumping :confused: I use Time node but when I load the Material in the editor again It’s fine.

So the code generated does not work nicely. Unless I load it again from the JSON file in the inspector. I put generated code it to function that return nodeMaterial and i use it on a mesh but…


Here on the animated gif, it’s smooth after I load it. After the load, it can stay as long as I want, and it’s nice. But after compile its jumping.

I do not see any way to wait until the shader is built or something. Cause that can be the reason. But also when I use time out and apply it after that’s also the same. What do I do wrong?

Also How to use NME generated shaders in Babylon? There is no clear Tutorial or info on what to put where. And mine do render without errors now but it’s empty.

Well they should be used in conjonction with a NodeMaterial. Maybe it could be simpler if you share a repro in the PG

Hi :slight_smile:

I want to thank you for your help with fixing the problem :slight_smile:

I was preparing a PG for you and I noticed one of my variables was changed to DeltaTime :slight_smile: So system Default instead Constance :slight_smile: I did not notice that but that was the problem :slight_smile:

So the lesson learned here is: You want somebody help. Make a PG before you ask a question on the forum :slight_smile:

But my second question is still valid :slight_smile:

I can’t make NodeMaterialEditor generated Shader out of my code to work with Babylon?

The code has different values in it :confused:

attribute vec3 position;
attribute vec3 normal;

uniform mat4 u_World;
uniform mat4 u_ViewProjection;
uniform vec3 u_cameraPosition;
uniform float u_Time;
uniform vec3 u_Color;
uniform vec3 u_Color1;

varying vec4 v_output1;
varying vec4 v_output2;
varying vec3 v_xyz1;


and not those once from:

So how to get this shader work as a ShaderMaterial and not NodeMaterial? Cause I predict it will be faster?

This is the core reason for asking for repro :smiley:

It will be exactly the same perf so go full steam with NodeMaterial

Yes but that can take my bundle size down. Will like to know how to use those generated Shaders in Shader Material cause it’s not working at liest for me It looks like the data generated is not quite what it should be?

you just have then to bind all the uniform like any shaders. The shader generated by NMaterial is the a working shader but it needs uniforms to work

Mine did not work. Where I can find a list of uniforms? Cause when I copied mine over I got nothing. Hole in the model. No error. Just a gap.

can you repro in the pg?

1 Like