Unvanquished icon indicating copy to clipboard operation
Unvanquished copied to clipboard

Human buildable gibs self-reheat

Open RedSkyByte opened this issue 1 year ago • 3 comments

Gibs shader define glow intensity as a sine wave that seem to bear no relation to the lifetime of gibs.

https://github.com/user-attachments/assets/cb48465c-1fad-4024-a0d6-9224a679a197

RedSkyByte avatar Feb 21 '25 01:02 RedSkyByte

Particles do set the renderer entity shaderTime field which is "subtracted from refdef time to control effect start times". But in fact shaderTime is only used for deformVertexes effects; all other time-dependent shader effects [1] ignore it.

Should we have the renderer use shaderTime for those other things too? Maybe, but it could cause problems for particles that don't want to use individual time scales per particle. The majority of particle shaders specify entityMergable which means that a single set of entity parameters will be arbitrarily selected among all the entities using that shader. This would work poorly if the shader used the entity's time. For example a flame sprite using animMap and entityMergable has the animation cycle synchronized for all instances of the sprite; this improves renderer performance by batching draw calls together and avoiding texture switches. If animMap obeyed shaderTime, the animation might frequently jump to different frames out of sequence due to shaderTime being taken from any flame sprite entity at random. Ideally particles whose shaders use entityMergable would not set shaderTime, but the cgame doesn't know which ones they are; we would have to explicitly instruct it on a per-particle basis.

Instead we might use the undocumented feature for writing an arbitrary mathematical expression for the rgbgen (syntax rgb <expression>, or red <expression> blue <expression> green <expression>). That allows explicit use of both the refdef time and the shader time so we could compute the desired function.

[1] tcmod rotate, tcmod scroll, tcmod translate, tcmod turb, tcmod stretch, rgbgen wave, alphagen wave, animmap

slipher avatar Feb 21 '25 05:02 slipher

Renderer can use it with rgbGen entity.

VReaperV avatar Feb 21 '25 08:02 VReaperV

Renderer can use it with rgbGen entity.

That could also work. Particles can be configured with a linear change for the entity RGB. Currently (for no good reason) use of entity RGB is restricted to sprite-based particles, whereas the human buildable gibs use model-based particles. But we could just move that code out of the if. This will work assuming a linear progression instead of a sine wave is good enough.

slipher avatar Feb 21 '25 20:02 slipher