Discontinuities in simplex noise

Am I doing this right? Are these discontinuities I’m seeing in the simplex noise block?

https://nodematerial-editor.babylonjs.com/#ND6Z9D#1

see 5.6

Glanced at the code for simplex block, don’t have my head around it yet. Wondering if maybe there should be an option for it to use a higher order smoothstep?

for comparison, another one showing the normal is smooth prior to perturbing w/ the bump.

https://nodematerial-editor.babylonjs.com/#ND6Z9D#2

Here is what the height scalar looks like.

https://nodematerial-editor.babylonjs.com/#ND6Z9D#3

what I’m trying to do is create a similar bump pattern by perturbing the normal.

https://nodematerial-editor.babylonjs.com/#ND6Z9D#4
https://nodematerial-editor.babylonjs.com/#ND6Z9D#1

both of these are identical nme graphs, but for some reason they get rendered differently. maybe it’s a bug? simply snapping the smooth normal in/out made this happen.

Adding @Pryme8 who wrote the noise nodes

I’ll take a look this afternoon.

1 Like

The bump block has “Transform as direction” checked in one case and not in the other case.

I’m not sure what the noise node would have to do with this though. Its purely driven by its input, now it is possible different clients might render it with different looks because its procedural but from what I am seeing here I would assume there is something different with the vector3 its sampling.

Is the derivative of the smooth step being used in the simplex noise continuous?

yes yes those are words…

hahaha Ok, hold on let me look.
Give me a few mins to whip up a test case to see.

https://playground.babylonjs.com/#9Z5WJ9
Here are all the axes in a 0-1 range, I’m not sure what derivative you are asking about as there is no smoothstep function in the script.
X


Y

Z

I’m not to sure what you are actually asking for to be honest. What specifically is not happening with the node material as a result of using the noise node? Are you trying to create a perturbed normal map from the noise? Sorry just trying to catch up fully and a lot of different questions where asked.

If you wanna do some reading on the actual magic in the numbers here is a clip from the code

//  This is a modified version of Stefan Gustavson's and Ian McEwan's work at http://github.com/ashima/webgl-noise
//  Modifications are...
//  - faster random number generation
//  - analytical final normalization
//  - space scaled can have an approx feature size of 1.0
//  - filter kernel changed to fix discontinuities at tetrahedron boundaries

I am merely the messenger sir.

1 Like

I’m not to sure what you are actually asking for to be honest. What specifically is not happening with the node material as a result of using the noise node? Are you trying to create a perturbed normal map from the noise? Sorry just trying to catch up fully and a lot of different questions where asked.

@Pryme8 Yes, I am trying to create a perturbed normal map from the noise. Though it isn’t really a map/texture, the intention is to calculate the perturbed normals on the fly using your Ashima noise.

With respect to discontinuities, most noise functions have a lerp/smoothstep function. Depending on how the noise is being used, having a continuous derivative of the lerp/smoothstep function can be important, when trying to avoid artifacts.

  • The choice of interpolating function in each dimension was 3 t 2 - 2 t 3, which contains nonzero values in its second derivative. This can cause visual artifacts when the derivative of noise is taken, such as when doing bump mapping.

I’m not to sure what you are actually asking for to be honest. What specifically is not happening with the node material as a result of using the noise node? Are you trying to create a perturbed normal map from the noise? Sorry just trying to catch up fully and a lot of different questions where asked.

@Pryme8 many thanks for the playground derivative check!

Starting to think there is something wrong w/ how I am perturbing normals. Any chance I could get an NME example which perturbs normals using the simplex block and the PBR block?

Here is my current attempt, which is clearly a failure.
https://nodematerial-editor.babylonjs.com/#ND6Z9D#5

Using color, here is the pattern I’m trying to create bumps from:
https://nodematerial-editor.babylonjs.com/#ND6Z9D#3

Or even a simpler NME example, like the image in Fig. 5-11 below, would be fantastic!

The bump block has “Transform as direction” checked in one case and not in the other case.

Thanks @Evgeni_Popov ! It must get reset when I disconnect/reconnect the node, which makes sense.

One tip: you can compare two node materials by comparing their .json files (that’s what I did to find the difference) :wink:

1 Like

One tip: you can compare two node materials by comparing their .json files (that’s what I did to find the difference)

@Evgeni_Popov I’ll do that next time, thanks!

Asking the big guns for help.

Think I see what’s happening, the lerp/smoothstep between mesh.position’s in the vertices is discontinuous. And until WebGPU comes out, don’t think there is any way to create a geometry shader.

https://nodematerial-editor.babylonjs.com/#WTQ3DG

Plane geometry looks fine. Other geometries look bad.

You won’t have geometry shaders even with WebGPU, it is not part of the spec and as I understood it it is not planned, there are too many problems with them and the current trend is to not use them. See https://www.reddit.com/r/GraphicsProgramming/comments/h8h3pb/so_whats_the_state_of_the_geometry_shader_these/

Instead, one are using compute shaders (that are part of WebGPU and now supported by Babylon.js - try this for eg, which will work only in Chrome or Edge Canary) and tesselation shaders (which are under investigation but I’m not sure at all there will be an extension for it - maybe we will have mesh shaders instead).

@Evgeni_Popov Having tesselation would be awesome.