Setting Gradient in a NodeMaterial

Here is a simple nme example of what I am doing - what am I doing wrong here?

If you plug the top rgba into the output from the vectormerger you se the perlin noise.

I just used the same method with my GLSL noise maker and it worked first time no problem! What is going on in NME???

I use node materials for some things because it is easier (!) then writing GLSL, but I have reference GLSL code for other stuff so I use that in places FYI.

I feel your pain dude :crazy_face: You are still struggling with this one.

The approach with refreshRate is always working for me. Did you try that one?

No it didn’t work - Its probably due to the way I have to make things work; the output texture of one process has to feed in to the input of another, and for some reason I can’t get it to wait until its rebuilt.

But I’ve changed tack now to the approach I outline above - using a gradient in a dynamic texture instead - which is fast and does not seem to need a rebuild when I change the gradient. It also works on GLSL, but not in NME. I’m pretty sure I’m doing exactly the same thing unless NME does some weird thing I don’t understand.

Its getting to the point I will have to use GLSL for everything because NME is just having too many issues and there is no useful docs.

I do not think the issues are NME related here.

Looking at your provided example, it looks totally normal to me at least from the current setup.

Here is your current noise:


Remapped to 0…1:


Keeping only Red and Green at 0.5:


Which once plugged into the gradient will fetch from white to black based on the red value:


Which part of this process is the one you do not expect so we can try to help addressing it ?

I didn’t use remap - in a later version of my example I add 1 to the noise and scale by 0.5; does that not take it between 0-1 ? I thought noise came out from -1 to 1 ?

I tried it with remap and go the same (wrong) result.

I’m going mad. and you didn’t send through a link to your whole graph so I can’t see what else is happening.

Why do you say wrong ? remap is identical to add and divide just using less nodes to help understanding better.

  1. noise only https://nme.babylonjs.com/#7LN51V#2
  2. remapped noise https://nme.babylonjs.com/#7LN51V#3
  3. converted to uv https://nme.babylonjs.com/#7LN51V#4
  4. passed in the gradient https://nme.babylonjs.com/#7LN51V#5

Which part is wrong for you ?

When I click on your last link I see this in the preview;

That should look like grey noise on the cube

This is because a cube has just a few vertices so the noise needs to run per fragment and not per vertex. Vertex is prioritized cause performance are obviously better. You can change it here in NME:

and it looks like this used as a material:

In Vertex https://playground.babylonjs.com/#WXIJXB#0
vs
In Fragment https://playground.babylonjs.com/#WXIJXB#1

It is explained in the doc here: Babylon.js docs

“Explained” is doing a lot of work here…

Thats it! I spent hours trying to fix this. I would never have found that without coming to this forum.

Ok after reading this through a few times I think I get it, I just did not expect it to work this way.