Expand description
GPU density entities: a figure described by a handful of bones, rendered as millions of particles that never touch the CPU.
A GpuDensityEntityData is sixteen capsules with a radius, a density
weight and a colour, plus a few numbers about how the whole body behaves:
how much of it is still bound (hp), how it breathes, how tightly its
matter holds to the skeleton. That is all that crosses to the GPU each
frame: under a kilobyte.
Every particle is then derived in the vertex shader from its own instance index. A hash picks a bone in proportion to the bones’ weights, a point in that capsule, a phase for its jitter, and whether it is one of the ones that has come loose. Nothing is stored per particle, nothing is uploaded, and the count is whatever the GPU can draw: two million particles is one instanced draw call of two million quads.
Loose matter drifts away from the body and fades. Lower hp and more of
the body is loose, which is what damage looks like on something that is
made of matter rather than drawn.
This needs nothing past OpenGL 3.3: no compute, no storage buffers.
Structs§
- GpuBone
- One capsule of the skeleton, laid out for the shader.
- GpuDensity
Entity Data - Everything the GPU needs to draw one entity this frame.
- GpuDensity
Renderer - The GL side: one program, one quad, no per-particle data at all.
Constants§
- MAX_
BONES - The number of bones an entity carries. Fixed so the whole skeleton fits in one uniform array.
- MAX_
PARTICLES_ PER_ ENTITY - The most particles one entity is ever drawn with, whatever was asked for. Above this the draw is fill-bound on any GPU and the picture stops improving, because there are more particles than pixels.
Functions§
- particle_
alpha - The alpha of one particle, so that a body of any count sums to about the same brightness.
- particle_
pixels - The size of one particle on screen, in pixels, for a count. Fewer particles are drawn bigger so the body still reads as solid.