Quake3World.com Forums
     Programming Discussion
        Setting a model's shader time


Post new topicReply to topic
Login | Profile | | FAQ | Search | IRC




Print view Previous topic | Next topic 
Topic Starter Topic: Setting a model's shader time

Cool #9
Cool #9
Joined: 01 Dec 2000
Posts: 44138
PostPosted: 12-15-2011 05:18 AM           Profile   Send private message  E-mail  Edit post Reply with quote


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:
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:
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.




Top
                 

Mentor
Mentor
Joined: 12 Mar 2005
Posts: 3958
PostPosted: 12-15-2011 05:44 PM           Profile Send private message  E-mail  Edit post Reply with quote


Code:
legs.shaderTime = cent->currentState.time;

Should read:
Code:
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.




Top
                 

Cool #9
Cool #9
Joined: 01 Dec 2000
Posts: 44138
PostPosted: 12-18-2011 11:52 PM           Profile   Send private message  E-mail  Edit post Reply with quote


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.




Top
                 
Quake3World.com | Forum Index | Programming Discussion


Post new topic Reply to topic


cron
Quake3World.com
© ZeniMax. Zenimax, QUAKE III ARENA, Id Software and associated trademarks are trademarks of the ZeniMax group of companies. All rights reserved.
This is an unofficial fan website without any affiliation with or endorsement by ZeniMax.
All views and opinions expressed are those of the author.