How to use RayMarching node?


I have simple question: How does work RayMarching node in NME? Some demos/advices or something which can help start to use RayMarching node in materials?

This playground should help you get started:

Note, however, that you’ll need this PR deployed (or to use a version other than 6.2.0), because the PG uses the Triplanar block multiple times.

Babylon.js does not provide a ray marching node per se, as it would be difficult to meet all the needs with a single implementation, but we have updated existing nodes / added new nodes to be able to implement ray marching in the NME, as demonstrated in the PG above. The RayMarching block that you will find in the node material is a basic implementation that uses a custom block and can be extended as needed (export the material to a .json file to see how it was implemented).

Thank you!

I saw this PG on 5.71.1. But using and possibilities still is not clear for me) So i think i shall go a bit deeper and make some tests for better understanding

There’s not much going on, other than the ray marching node itself.

The changes we made in the existing nodes generated code only in the fragment shader and removed all code generated in the vertex shader: look for the Generate only fragment code switch on the PBRMetallicRoughness and Reflection blocks.

We also added the FragDepth block to allow explicit setting of fragment depth, and the ShadowMap block to generate the shadow map from the ray marching outputs.

1 Like

I made some very simple variations on the node the last time we were bug bashing, if you’d like to check it out:
Babylon.js Node Material Editor (
Babylon.js Node Material Editor (
Babylon.js Node Material Editor (

1 Like

@carolhmj @Evgeni_Popov

But why ray marching node in default setup looks like box and sphere which is merging sometimes?

I made some distortions)

That’s right, there are no custom SDF nodes, I don’t think this is in the roadmap, right @Evgeni_Popov ?

No, it’s not on the roadmap, we don’t plan to provide a full featured ray marching node nor SDF nodes.