Q:Excuting shaders from some action


(Indloon) #1

Hello.

I played in ETforever mod,then there were a map and I was surprised of shader file what made Warbell HUD while playing to blue and with blur.

So this gave me idea.

Is it impossible to code in ET SDK that exec shader files in some actions,like if you reload,everything goes blur in screen and if reloading finishes,then it ends??

Regards
#Genert


(UJERebel) #2

I guess thats possible in your own mod…

  1. Reload already does something (reload… didnt see that one comming didnt you :wink: )
  2. Fullscreen shaders exist (sniper scope)

(Indloon) #3

Yeah.I forgotted to add ET:SDK to the title -.-

Well,I just need a example of it,just single line code…


(UJERebel) #4

I don’t have the sdk on my pc… but you should just check sniper scope function and the reload function, to add your new remake of the sniperscope function :stuck_out_tongue:


(Indloon) #5

Your idea is great :wink:

bg_misc.c has some nice shader examples in.

But in bg_pmove.c
there is following stuff:


if( reloadRequested && pm->ps->ammo[ammoWeap] && pm->ps->ammoclip[clipWeap] < GetAmmoTableData(weapon)->maxclip) {
				PM_BeginWeaponChange( weapon, weapAlts[weapon], !(pm->ps->ammo[ammoWeap]) ? qfalse : qtrue );
			}
			return;

And


/*
==============
PM_BeginWeaponReload
==============
*/
static void PM_BeginWeaponReload( int weapon ) {
	gitem_t* item;
	int reloadTime;

	// only allow reload if the weapon isn't already occupied (firing is okay)
	if(pm->ps->weaponstate != WEAPON_READY && pm->ps->weaponstate != WEAPON_FIRING )
		return;

	if(((weapon == WP_CARBINE) && pm->ps->ammoclip[WP_CARBINE] != 0) || ((weapon == WP_MOBILE_MG42 || weapon == WP_MOBILE_MG42_SET) && pm->ps->ammoclip[WP_MOBILE_MG42] != 0) || ((weapon == WP_GARAND || weapon == WP_GARAND_SCOPE) && pm->ps->ammoclip[WP_GARAND] != 0)) {
		return;	// Gordon: no reloading of the carbine until clip is empty
	}

	if((weapon <= WP_NONE || weapon > WP_DYNAMITE) && !(weapon >= WP_KAR98 && weapon < WP_NUM_WEAPONS))
		return;

	item = BG_FindItemForWeapon(weapon);
	if(!item) {
		return;
	}
	// Gordon: fixing reloading with a full clip
	if(pm->ps->ammoclip[item->giAmmoIndex] >= GetAmmoTableData(weapon)->maxclip) {
		return;
	}

	// no reload when you've got a chair in your hands
/*	if(pm->ps->eFlags & EF_MELEE_ACTIVE)
		return;*/

	// no reload when leaning (this includes manual and auto reloads)
	if(pm->ps->leanf)
		return;

	// (SA) easier check now that the animation system handles the specifics
	switch(weapon) {
		case WP_DYNAMITE:
		case WP_GRENADE_LAUNCHER:
		case WP_GRENADE_PINEAPPLE:
//		case WP_LANDMINE:
//		case WP_TRIPMINE:
		case WP_SMOKE_BOMB:
			break;

		default:
			// DHM - Nerve :: override current animation (so reloading after firing will work)
			if( pm->ps->eFlags & EF_PRONE ) {
				BG_AnimScriptEvent( pm->ps, pm->character->animModelInfo, ANIM_ET_RELOADPRONE, qfalse, qtrue );
			} else {
				BG_AnimScriptEvent( pm->ps, pm->character->animModelInfo, ANIM_ET_RELOAD, qfalse, qtrue );
			}
			break;
	}

    if( weapon != WP_MORTAR && weapon != WP_MORTAR_SET )
		PM_ContinueWeaponAnim(PM_ReloadAnimForWeapon(pm->ps->weapon));


	// okay to reload while overheating without tacking the reload time onto the end of the
	// current weaponTime (the reload time is partially absorbed into the overheat time)
	reloadTime = GetAmmoTableData(weapon)->reloadTime;
	if( pm->skill[SK_LIGHT_WEAPONS] >= 2 && BG_isLightWeaponSupportingFastReload( weapon ) ) {
		reloadTime *= .65f;
	}
	if( pm->ps->weaponstate == WEAPON_READY )
		pm->ps->weaponTime += reloadTime;
	else if( pm->ps->weaponTime < reloadTime)
		pm->ps->weaponTime += (reloadTime - pm->ps->weaponTime);

	pm->ps->weaponstate = WEAPON_RELOADING;
	PM_AddEvent( EV_FILL_CLIP );	// play reload sound
}

static void PM_ReloadClip( int weapon );

Here we could add the reloading shader.

Tbh,the scope is just an image,what will be opened while sending request there via bind.
Model->scope image == no shader =(


(Indloon) #6

bump

I still don’t know how to exec shaders??

too bad that cant use exec thisshader.shader


(UJERebel) #7

Maybe you could make your own image… with bumps like 0<->100 % alpha to simulate blur?

execute shaders => look at some tank script file, when a tank starts moving, the tires shader changes…

(just pointing you in a direction :slight_smile: check it out… dunno if it works :slight_smile: ))


(Indloon) #8

Yes,but thats in mapping:(

Mkm,seems that I must PM jRADs inbox full of my messages .d


(UJERebel) #9

Well, the script has to be excecuted?

Is there some place where you could find the script excecutor?

Or look at the hud maybe?


(Indloon) #10

Oh btw:D not sure but


    // no reload when leaning (this includes manual and auto reloads)
    if(pm->ps->leanf)
        return;

Remove this and you are able to reload while leaning :smiley:


(acQu) #11

[QUOTE=Genert;379810]Oh btw:D not sure but


    // no reload when leaning (this includes manual and auto reloads)
    if(pm->ps->leanf)
        return;

Remove this and you are able to reload while leaning :D[/QUOTE]

Pshhhhhhhh :wink:


(UJERebel) #12

How is the limbo opened? some shader there too?
And the compas shader maybe too…


(Indloon) #13

Compass reads the map card added by mapper.
Adds sprites(medic/voice icons).

And also objective.

Limbomenu uses images…

OOH WAIT.

Images!!!

Now I know how to do it!!!
Nullskillz posted about it very long time ago,but:

http://www.splashdamage.com/forums/showthread.php/9450-code-snippet-bloodsight

The main problem is about…it doesnt give the right result,you can make fake blur in image,but how it goes off and on is the problem.

And now I need for that shaders!!

So jRAD/digibob or who ever,plz say how to exec shader files in current action:D

EDIT:
In files there is:


gfx/binocblood/binocblood010
{
	nomipmaps
	nopicmip
	{
		map gfx/binocblood/binocblood010.tga
		blendfunc filter
	}
}

gfx/binocblood/binocblood020
{
	nomipmaps
	nopicmip
	{
		map gfx/binocblood/binocblood020.tga
		blendfunc filter
	}
}

gfx/binocblood/binocblood030
{
	nomipmaps
	nopicmip
	{
		map gfx/binocblood/binocblood030.tga
		blendfunc filter
	}
}

gfx/binocblood/binocblood040
{
	nomipmaps
	nopicmip
	{
		map gfx/binocblood/binocblood040.tga
		blendfunc filter
	}
}

gfx/binocblood/binocblood050
{
	nomipmaps
	nopicmip
	{
		map gfx/binocblood/binocblood050.tga
		blendfunc filter
	}
}

gfx/binocblood/binocblood060
{
	nomipmaps
	nopicmip
	{
		map gfx/binocblood/binocblood060.tga
		blendfunc filter
	}
}

gfx/binocblood/binocblood070
{
	nomipmaps
	nopicmip
	{
		map gfx/binocblood/binocblood070.tga
		blendfunc filter
	}
}

gfx/binocblood/binocblood080
{
	nomipmaps
	nopicmip
	{
		map gfx/binocblood/binocblood080.tga
		blendfunc filter
	}
}

gfx/binocblood/binocblood090
{
	nomipmaps
	nopicmip
	{
		map gfx/binocblood/binocblood090.tga
		blendfunc filter
	}
}

omg I well nerded :eek:


(UJERebel) #14

What do you need the shader for?


(Indloon) #15

Too manupulate with HUD:D

But seems that I got my anserw =)

I think…


(Indloon) #16

I followed http://www.splashdamage.com/forums/showthread.php/9450-code-snippet-bloodsight tutorial.

I complied,everything was fine.
I putted the gfx/shader to pakscape and created a pk3 file called Antiwolf.
I putted it with cgame,qgame and ui_ into Antiwolf folder,runned ET,selected Antiwolf mod.
Then went to Host Game->start server.
What I got?
NOTHING
Can someone say whats the problem :??
Here you can download it: http://genert.impact.pri.ee/genert_mod_problem.zip

The code is same,nothing hasnt changed,only added the codes what was said in Nullskillz thread.


(Indloon) #17

Hahah,I m so dumm:(

I forgotted to add cgame/ui to pk3 :mad:

Anyway,while testing I found nice stuff X:D

In bg_pmove.c
Replace PM_CalcLean(line 4408)
With this:


/*
==============
PM_CalcLean

==============
*/
void PM_UpdateLean(playerState_t *ps, usercmd_t *cmd, pmove_t *tpm) {
	int		leaning = 0;	// -1 left, 1 right
	float	leanofs = 0;

	if ( cmd->wbuttons & (WBUTTON_LEANLEFT | WBUTTON_LEANRIGHT)) { 
		if (ps->pm_type == PM_SPECTATOR ) {
			if (cmd->wbuttons & WBUTTON_LEANLEFT)
				leaning -= 1;
			if (cmd->wbuttons & WBUTTON_LEANRIGHT)
				leaning += 1;
		} else if ((!cmd->forwardmove && cmd->upmove <= 0)) {
			if (cmd->wbuttons & WBUTTON_LEANLEFT)
				leaning -= 1;
			if (cmd->wbuttons & WBUTTON_LEANRIGHT)
				leaning += 1;
		}
	}

	if ( BG_PlayerMounted(ps->eFlags) )
		leaning = 0;

	if (ps->eFlags & EF_FIRING)
		leaning = 1;

	if (ps->eFlags & EF_DEAD)
		leaning = 0;

	if ( ps->weaponstate == WEAPON_FIRING && ps->weapon == WP_DYNAMITE )
		leaning = 0; 

	if ( ps->eFlags & EF_PRONE || ps->weapon == WP_MORTAR_SET )
		leaning = 0;

	leanofs = ps->leanf;

	if (!leaning) {	
		if ( leanofs > 0 ) {
			leanofs -= (((float)pml.msec/(float)LEAN_TIME_FR)*LEAN_MAX);
			if ( leanofs < 0 )
				leanofs = 0;
		} else if ( leanofs < 0 ) {	
			leanofs += (((float)pml.msec/(float)LEAN_TIME_FR)*LEAN_MAX);
			if ( leanofs > 0 )
				leanofs = 0;
		}
	}

	if (leaning) {
		if (leaning > 0) { // right
			if (leanofs < LEAN_MAX)
				leanofs += (((float)pml.msec/(float)LEAN_TIME_TO)*LEAN_MAX);

			if (leanofs > LEAN_MAX)
				leanofs = LEAN_MAX;
		} else {			// left
			if (leanofs > -LEAN_MAX)
				leanofs -= (((float)pml.msec/(float)LEAN_TIME_TO)*LEAN_MAX);

			if (leanofs < -LEAN_MAX)
				leanofs = -LEAN_MAX;
		}
	} else {
	}

	ps->leanf = leanofs;

	if (leaning) {
		vec3_t		start, end, tmins, tmaxs, right;
		vec3_t		viewangles;
		trace_t		trace;

		VectorCopy( ps->origin, start );
		start[2] += ps->viewheight;

		VectorCopy( ps->viewangles, viewangles );
		viewangles[ROLL] += leanofs/2.0f;	// Lean_new
		AngleVectors( viewangles, NULL, right, NULL );
		VectorMA( start, leanofs, right, end );

		VectorSet( tmins, -8, -8, -7 );
		VectorSet( tmaxs, 8, 8, 4 );

		if ( pm )
			pm->trace (&trace, start, tmins, tmaxs, end, ps->clientNum, MASK_PLAYERSOLID);
		else
			tpm->trace (&trace, start, tmins, tmaxs, end, ps->clientNum, MASK_PLAYERSOLID);

		ps->leanf *= trace.fraction;
	}

	if (ps->leanf) {
		if (ps->pm_type != PM_SPECTATOR) {  //LeanShoot
			cmd->rightmove = 0;		
		}
	}
}

No complie/play and shot with thompson :smiley:


(Indloon) #18

Tbh stupid question.

But someone know where I can find fake blur image?

Since I don’t have Photoshop and I don’t like Captain Jack Sparrow.

Anyone?

P.s.t Oh,take a look at this:D