Issues with shadowing on FBO particle system

Hey Guys,

to preface my issue, I’m new to threejs and shader programming so there may be some nonsense in my current shaders that are a patchwork of multiple FBO particle systems I found on github and in some blog posts.

I’m currently developing a fbo particle system that is based on Edan Kwans The Spirit Scene but unfortunately a lot of the shader code is not compatible with the current threejs version.

My current goal is to get particle shadowing working and I was somewhat successful that it seems that particles receive shadows from other objects correctly. You can see my current scene here. If you move the light on the z-axis you can see the wall casts shadows correctly onto the particles.

Link to my code on github

The current issue I’m facing is that the self shadowing from other particles does not seem to work as intended. If the pointlight in my scene is outside of the sphere, some self shadowing should occur at the tangents of the sphere. Instead I get a funky circles as can be seen on the left in this screenshot:

Around the light circle the are a lot of particles that receive shadows although there is nothing in between the light source and the particle.

As I read in Edan Kwans Blog Post the shadow casting of particles in combination with point lights is achieved with the customDistanceMaterial but I did not find any documentation how this shader should look like with todays three version.

Another related question I’m having is about the normals of the particles. To get the shadows partially working like in my demo I had to define the objectNormal in my particles vertex shader. In Edan Kwans the spirit scene this seems not to be needed as seen here.
For my intended particle system normals should not matter how a particle is shadowed, because the particles should receive shadows from all directions.

It would be awesome if someone could point out some misconceptions I’m having and where I can find information on how to implement this properly.


So I updated my demo with a shadowmap viewer and that reveals that somehow the pointlights shadowcamera does not pick up particles in all directions. I dont know where the cause of this could be, any ideas?

If you move the light around you will get particles on other sides of the shadow cubemap but it seems the distancematerial only renders them if they have a certain angle to the lightposition.