It’s kind of a spin-off of the Newton’s Cradle from this topic: NIXIE 2022 (Selective Bloom)
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
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.