Muzzleflash lighting: issues

Grab your favourite IDE and tinker with the innards of game engines

Muzzleflash lighting: issues

Postby OCASM on Sat Dec 01, 2012 7:10 am

I need some help.

I'm using the code from here:

c_baseanimating.cpp
Code: Select all
void C_BaseAnimating::ProcessMuzzleFlashEvent()
{
   // If we have an attachment, then stick a light on it.
   if ( muzzleflash_light.GetBool() )
   {
      //FIXME: We should really use a named attachment for this
      if ( m_Attachments.Count() > 0 )
      {   /* Original Muzzle-flash light code
                                          //Start muzzleflash mod code

         Vector vAttachment, vAng;
         QAngle angles;
         GetAttachment( 1, vAttachment, angles ); // set 1 instead "attachment"
 
         AngleVectors( angles, &vAng );
         vAttachment += vAng * 2;
 
         dlight_t *dl = effects->CL_AllocDlight ( index );
         dl->origin = vAttachment;
         dl->color.r = 255;
         dl->color.g = 192;
         dl->color.b = 64;
         dl->color.exponent = 7.5;
         dl->die = gpGlobals->curtime + 0.03f;
         dl->radius = random->RandomFloat( 64.0f, 96.0f );

         //End muzzleflash mod code
      }
   }
}




The issues shown in the video are as follows:

-First part of the video: This is how it's supposed to look. The muzzleflash lighting lasts but a brief moment with each shot, both on the NPC and on the environment. It looks correct on two conditions: either there's no "dl->color.exponent" in the code (though it's hardly bright enough) or the NPC is under the influence of 4 light_spot entities or more.

-Second part of the video: This is how it's NOT supposed to look. The problem is that the light affecting the NPC lasts too long. It should be just short flashes. It happens when I use "dl->color.exponent" in there or the NPC is affected by 3 light_spot entities or less.

-Third part of the video: Is there any way to block the dynamic light from going through walls? Clipping it somehow?

Thank you.
OCASM
Dumpling
Dumpling
 
Joined: Thu Nov 29, 2012 3:20 am

Re: Muzzleflash lighting: issues

Postby Gary on Sat Dec 01, 2012 3:35 pm

OCASM wrote:-Third part of the video: Is there any way to block the dynamic light from going through walls? Clipping it somehow?
.


Not easily. The best you might be able to do is a visibility check to disable the flash when ever it won't be in LOS. But that may cause other visual errors.

Another alternative is to use the flashlight system so muzzle flashes cast shadows. but that would get expensive quick.
Have a question related to modding or something I posted? Something that needs staff attention? I haven't been active lately, but feel free to PM me or message me on Steam(link below)

User avatar
Gary
Interlopers Staff
Interlopers Staff
 
Joined: Wed Dec 16, 2009 12:40 am
Location: USA, FL

Re: Muzzleflash lighting: issues

Postby OCASM on Wed Dec 05, 2012 1:37 am

Seems like there's no "simple" way to get it done after all. Env_projected textures are really expensive performance wise so they're not really an option.

Thank you for your answer, though.
OCASM
Dumpling
Dumpling
 
Joined: Thu Nov 29, 2012 3:20 am

Re: Muzzleflash lighting: issues

Postby IBeMad on Tue Jan 01, 2013 6:38 am

Oh ho ho.... I've encountered this very same bug before and I'm sure you going to love (hate) my solution (hack).

It seems that the model rendering system has some sort of light cache.

Instead of just turning off the dlight or letting it time out, I made the dlight's radius just big enough to hit the model, then set it's brightness (r g b exponent) to 1 1 1 1.

HAAAAAAAAAAAAAAAAACKS!
IBeMad
Member
Member
 
Joined: Sun Jan 22, 2012 5:18 pm

Re: Muzzleflash lighting: issues

Postby OCASM on Thu May 02, 2013 4:48 am

IBeMad wrote:Oh ho ho.... I've encountered this very same bug before and I'm sure you going to love (hate) my solution (hack).

It seems that the model rendering system has some sort of light cache.

Instead of just turning off the dlight or letting it time out, I made the dlight's radius just big enough to hit the model, then set it's brightness (r g b exponent) to 1 1 1 1.

HAAAAAAAAAAAAAAAAACKS!

Thanks for the reply. However, since I'm a noob with C++ I don't know how to drop the color values of dlight after a specific amount of time. I mean if I just set the value after the other instructions in the code it will obviously be done instantly and end result in-game is just a faint muzzle flash.

Care to give me a hand, please? ^^u
OCASM
Dumpling
Dumpling
 
Joined: Thu Nov 29, 2012 3:20 am

Return to Programming

Who is online

Users browsing this forum: No registered users