Custom ShaderMaterial for GPUParticleSystem?

I figure out GPUParticleSystem has ‘VertexShaderName’ property.
So i was about to replace that to my shader.
But i don’t know how to pass custom uniforms and add attributes to it.
Is my idea impossible?
Thank you.

you can store your shader in Effect.ShaderStore,
if your shader’s name is customGPU
you can save:
Effect.ShaderStore[‘customGPUVertexShader’] = your vertex shader
Effect.SHaderStore[‘customGPUFragmentShader’] = your vertex fragment
then create shaderMaterial
const material = new ShaderMaterial(name,scene,“customGPU”,option…)


Like this:

Then you can set your custom shadermaterial to particleSystem.
Notice that ParticleSystem use instance, you have to add instance include to your code, I think you should have a look for babylon’s shader

Thank you for replying.
I can’t understand well to add instance.
As far as I know, when i created a material, the material should be attached like this.
mesh.material = material.
Am I wrong?

And i tried to do that with Solid Particle System
like this:

const mesh = SPS.buildMesh()
mesh.material = material

InstanceMesh is created by meshA.createInstance(name), instance material is link to mesh.material, you can’t change material for each instance, if you want to change material for all instances (created by meshA), you can meshA.material = materialNew. Whole instances(created by meshA) will be renderred by materialNew

I think you can try it in PG, if you have a trouble with code, you can mark it , save pg and then paste it in forum. It is a fast way to find how it work wrong

If you want use your Material, you have to set useModelMaterial true,

if you want to buildMesh(), you can:
const mesh = SPS.buildMesh()
mesh.material = material,
When sps digest particle, sps will use your material, if useModelMaterial false, it will create a default material

Thank you Moriy.
I’m coding with PG to create example what i want.
Please wait for me.


Is it possible like this way with GPUParticleSystem?

1 Like

I am not sure how particle would help to draw smthg that looks organic like this ?

Maybe the fluid rendering tech from @Evgeni_Popov would work ?

As long as you are able to provide a list of 3D vertices (from a particle system or just raw values), fluid rendering will work :slight_smile:

1 Like

Thank you!!
Are there any PG examples?

There are some demos in the documentation:

And from this thread:


Great! Thank you!
I will try it.