Setting a model's shader time

Locked
User avatar
Eraser
Posts: 19177
Joined: Fri Dec 01, 2000 8:00 am

Setting a model's shader time

Post by Eraser »

I've been fiddling around with trying to apply a specific shader (with an
"alphagen wave sin" stage) to dead bodies so that the bodies disappear (fade out) instead of sinking into the floor (or, as is the case with my mod where they suddenly disappear, which is even worse).

I've added this bit of code to player_die() in g_combat.c:

Code: Select all

self->s.time = level.time;
Where when someone dies, a timestamp is saved and transmitted to the client. On the client, in the CG_Players() function (in the file of the same name). I do this:

Code: Select all

if ( cent->currentState.eFlags & EF_DEAD ) {
    legs.customShader = cgs.media.deadBotShader;
    legs.shaderTime = cent->currentState.time;
}
(note: the same is done for torso and head as well)
I assumed that legs.shaderTime would properly set the starting point of the shader animation (the fade out) but it doesn't. It appears that this isn't the case, as the starting point of my alphagen sine differs every time I shoot an enemy (sometimes even inverted to how I want it, causing the body to suddenly disappear and fade into view). I've checked and cent->currentState.time does match the server-side level.time.

Does anyone know if I'm doing something wrong or if the shaderTime is bugged or something? I would love to be able to reliably set the starting point in the wave of my shader.
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Setting a model's shader time

Post by ^misantropia^ »

Code: Select all

legs.shaderTime = cent->currentState.time;
Should read:

Code: Select all

legs.shaderTime = cent->currentState.time / 1000.0f;
That's probably not the real problem though. A sine wave is continuous and periodic. IIRC, Q3A essentially does `start = shaderTime % period` so you'll start out at some random point of the envelope.
User avatar
Eraser
Posts: 19177
Joined: Fri Dec 01, 2000 8:00 am

Re: Setting a model's shader time

Post by Eraser »

Hm yeah I was afraid it wouldn't be that easy.
I just made the bots sink into the floor again. That's better than them just disappearing.
Locked