Node Material Particle Shaders
Creating Particle Shaders
Starting with Babylon.js v4.2, you can now create particle shaders (to be used with a particle system) with the node material editor.
You simply need to change the mode to Particle:

Some blocks are made unavailable in this mode (they are hidden from the block list), as they have no meaning: the mesh, post process and animation blocks.
Also, in this mode, you can't create a vertex shader, only a fragment shader: the vertex shader is fixed and not updatable.
Note that everything is driven by the parameters of the particle system instance. For example, if the current particle system displayed in the preview area does not use "ramp gradients", the ParticleRampGradient block does nothing (it does not add ramp gradients to the shader); it's just a pass-through. The same goes for the ParticleBlendMultiply block. The exception is the ParticleTexture block, and only in the preview area of the node editor: if you provide a texture for this block, it will be used as the particle texture in the preview area; otherwise, the texture defined in the current particle system will be used. In any case, when using the material in a live program, the texture will always be the one defined by the ParticleSystem.particleTexture property.
The materials you create in Particle mode can also be used for GPU particle systems, subject to these restrictions:
- GPU particle systems don't support ramp gradients, so the
RampGradientBlockwon't do anything (you can still use it in your material, it will simply do nothing) - GPU particle systems don't support the
textureMaskproperty, so you should not use theParticleTextureMaskblock in materials targeted for GPU particle systems; otherwise, display artifacts will appear
When you have created your particle shader in the NME, you can link the material to a particle system instance by calling the NodeMaterial.createEffectForParticles method:
nodeMaterial.createEffectForParticles(particleSystem);PG: NME Particle Shaders Example
The full fragment shader used by default by the particle system can be recreated in the NME: NME Full Default Fragment Shader
As explained above, if you want to use this material for GPU particle systems, you should remove the use of the ParticleTextureMask block: NME Full Default Fragment Shader GPU Version