Changing a brush model's shader from game/cgame code?

Locked
JPL
Posts: 13
Joined: Sun Nov 11, 2007 1:17 am

Changing a brush model's shader from game/cgame code?

Post by JPL »

I have a custom entity type whose visual state I want to change when a particular event happens. However, the entity is made of brush geometry (like a func_door) and it's not practical in this case to use an MD3 instead. Unfortunately, brush model entities lack some of the features MD3 models do. My code for rendering the client entity looks something like this:

Code: Select all

refEntity_t			ent;

memset (&ent, 0, sizeof(ent));
VectorCopy( cent->lerpOrigin, ent.origin);
AnglesToAxis( cent->lerpAngles, ent.axis );

ent.hModel = cgs.inlineDrawModel[s1->modelindex];
ent.customShader = cgs.media.quadShader;
This produces a properly rendered model, but with the shader(s) specified in the map file, not by the code. Whereas if I do the same thing but use an MD3 for the refEntity's hModel, the customShader I specify shows up properly.

So I'm wondering if there is any way at all to change the shader for a specific instance of an entity. This is different from the "remap shader" entity tags level designers can use; that's no good to me because it changes every usage of that shader in the level.

It seems quite possible in theory, but in practice it would require building something new into the renderer code, then building a bridge from that to the game/cgame code (much like trap_R_RemapShader does for that feature). Is there an easier way to do it than this?
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Changing a brush model's shader from game/cgame code?

Post by ^misantropia^ »

No, I'm afraid. The vanilla engine doesn't facilitate this, so if you want to be able to do this from the (c)game, you can't avoid adding a new trap.
JPL
Posts: 13
Joined: Sun Nov 11, 2007 1:17 am

Re: Changing a brush model's shader from game/cgame code?

Post by JPL »

I'm not using the vanilla Q3 engine in this case. Regardless, I figured that's what would be involved.

For anyone who's investigating this sort of thing in the future, I was able to use refEntity's shaderRGBA to modify the overall color of the existing shader of the brush model... which in a few narrow cases (flat surfaces of color) actually works reasonably.
Locked