Shader'S?


(VTX-aussie) #1

Hey, can anyone please explain how to add in Shaders toa model like in Quake 3? I would like to add the glowing effect…
I have made a PAK file containing the /textures/effects from the Quake PAK files but cant seem to mod them to ET.
i got this from quake source but still nothing.


	cgs.media.battleSuitShader = trap_R_RegisterShader("powerups/battleSuit" );
	cgs.media.battleWeaponShader = trap_R_RegisterShader("powerups/battleWeapon" );
	cgs.media.invisShader = trap_R_RegisterShader("powerups/invisibility" );

Can anyone tell me how to get it working

Thanks Aussie.


(VTX-aussie) #2

or how would it be possible to make the player appear to be on fire.?
Thanks alot aussie


(ensiform) #3

on fire checking in client game is usually the function CG_EntOnFire( centity_t *cent)

CG_AddRefEntityWithPowerups would be where you want for onfire, but for q3-style pws you want…


/*
===============
CG_PlayerPowerups
===============
*/
static void CG_PlayerPowerups( centity_t *cent, refEntity_t *torso ) {
	int		powerups;
	clientInfo_t	*ci;

	powerups = cent->currentState.powerups;
	if ( !powerups ) {
		return;
	}

	// quad gives a dlight
	if ( powerups & ( 1 << PW_QUAD ) ) {
		if ( cgs.gametype == GT_ACTF || cgs.gametype == GT_TEAM ) {
			if ( cgs.clientinfo[ cent->currentState.clientNum ].team == TEAM_RED ) {
				trap_R_AddLightToScene( cent->lerpOrigin, 200 + (rand()&31), 1, 0.2f, 0.2f );
			} else {
				trap_R_AddLightToScene( cent->lerpOrigin, 200 + (rand()&31), 0.2f, 0.2f, 1 );
			}
		}
	}
}

now in CG_Player… add the following:


// add powerups floating behind the player
CG_PlayerPowerups( cent, &torso );

note: that should go below this if statement:

	//
	// add the gun / barrel / flash
	//

for the weapons, it will get a bit more ugly… in cg_weapons.c find CG_AddPlayerWeapon

add this above it:

/*
========================
CG_AddWeaponWithPowerups
========================
*/
static void CG_AddWeaponWithPowerups( refEntity_t *gun, int powerups, int team ) {	
	// add powerup effects
	if ( powerups & ( 1 << PW_INVIS ) ) {
		gun->customShader = cgs.media.invisShader;
		trap_R_AddRefEntityToScene( gun );
	} else {
		trap_R_AddRefEntityToScene( gun );

		if ( powerups & ( 1 << PW_BATTLESUIT ) ) {
			gun->customShader = cgs.media.battleWeaponShader;
			trap_R_AddRefEntityToScene( gun );
		}
		if ( powerups & ( 1 << PW_QUAD ) ) {
			if (team == TEAM_RED) {
				gun->customShader = cgs.media.redquadWeaponShader;
			}
			else {
				gun->customShader = cgs.media.quadWeaponShader;
			}
			trap_R_AddRefEntityToScene( gun );
		}
		if ( powerups & ( 1 << PW_FLIGHT ) ) {
			gun->customShader = cgs.media.flightWeaponShader;
				trap_R_AddRefEntityToScene( gun );
		}
	}
}

remove the pws or add as needed…

now in CG_AddPlayerWeapon,

your gonna have to go looking in the q3 cg_weapons.c in that function for where that is defined… you want it for &gun as cent and &barrel for sure.


(No1_sonuk) #4

There are already on-fire shaders in RtCW at least - Can’t remember off-hand if ET has a flamer.


(ensiform) #5

yes ET has that but it works differently like i said.


(Jaquboss) #6

sad is that dlights wont work properly in ET , since it uses vertex lighting for them :frowning:
I say it becasue you need change trap_r_addLightToScene


(ensiform) #7

right, only jedi outcast and jedi academy fixed that i think. dlights are not real-time as they can only brighten areas that already have at least some light. when q3 goes gpl id like to see someone get real-time lighting at least for dlights…


(Jaquboss) #8

No ensiform , i mean that only ET uses vertex light and some strange functions to lit WORLD , all other Q3 games uses round lightmap…
I think that you want to implement per-pixel lighting , which isn’t in jedi games…


(ensiform) #9

dont understand, i didnt say jka had dynamic lighting but they did fix the dynamic lights so they light up dark places.

also, if ET uses vertex lighting how come it does lightmaps and such also ?