Newton's Cradle + glowing spheres

Hi community!


It’s kind of a spin-off of the Newton’s Cradle from this topic: NIXIE 2022 (Selective Bloom) :slight_smile:
It’s all started with the wish to work with shadows. After getting that more or less acceptable result, I realized that I need something on the background. And the first thought was about glowing spheres. Lots of glowing spheres.
Having several hundreds of point lights in the scene would lead to disaster with performance.
The solution I came up is the using of a texture of RGBA, where the next parameters of a sphere are encoded: position (x, z), color, sphere radius.
The texture is shared between materials of the floor and of the instanced spheres (for the latter, I used InstancedBufferGeometry instead of InstancedMesh).
The texture has the size 32 x 32. To compute the glow from a sphere on the floor, in the shader, it takes in account the data from the nearest texels in the range -1…1 on both U and V. Thus, for each light it makes 9 interations. To set location of a sphere, there is only one iteration for the current texel.

PS It’s a proof-of-concept only, not the ultimate solution.


This is super cool, thanks for sharing!

Did you have to write a custom shader material to pass in this sphere-light-texture ?

The light from the spheres is NOT what is casting shadows, is it?

I used .onBeforeCompile() to modify shaders of the floor and the spheres.

1 Like

Correct. The shadow is caused by directional light. Spheres’ glow gives no shadows.