News:

One Minute Game Review by The Happy Friar: https://ugetube.com/@OneMinteGameReviews
Also on Rumble: https://rumble.com/c/c-1115371

idTech 4 (aka Doom 3 tech) Discord Server! https://discord.gg/9wtCGHa

Main Menu

how to remove shotgun barrel flash?

Started by calan, October 30, 2014, 11:56:55 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

calan

After searching and experimenting for a couple hours, I think I've discovered that the shotgun barrel flash is part of the animation model.

So... how can I remove the flash from the model (and the double barrel as well)? I want to use particles only for that effect....not whatever is coded into the models. I tried removing the -keep barrel eject shell flash from the .md5anim fire files commandline, and tried changing the "flash"  39 0 0 // body line....but neither worked. (I know my way around def and script files, but I'm not a modeling guy....so these were just shots in the dark).

*****

On a related subject, why are there three fire files (fire1.md5anim, fire2.md5anim, and fire3.md5anim)? They seem almost identical, and have the same number of frames and frame rate.

EDIT: Okay, I think I figured out my last question... to provide some randomness to the fire animation (one of the three is randomly selected in the code I assume?) I just set all three to "fire1.md5anim" in the model viewmodel_shotgun {} defnition for testing.

Old bastard but kid at heart...

calan

#1
I'm getting closer.   :)

I found the mesh file, and searched for "flash" in it. It looks like the last three meshes are for the flash, so I changed this:

shader "models/weapons/shotgun/shotgun_mflashb"

to this:

shader ""

...for all three.

My thought was that with no shader, the mesh simply wouldn't be rendered....which is partially true. Now I have a purple tag in place of the flash that says "No draw".

How do I get rid of that? Is there an empty (invisible) tga file that I could define as the shader for the flash?
Old bastard but kid at heart...

Ivan_the_B

Hi calan.
You are on the right track, but you shouldn't change the model itself.

You simply need to create a new skin to replace the material with nodraw.

skin calan/shotgun_nomflash {
models/weapons/shotgun/shotgun_mflashb textures/common/nodraw
}


and set the skin in the weapon def
"skin" "calan/shotgun_nomflash"


calan

#3
Ivan...

Where should I put the skin def? In my custom material file?

I figured out a hack for it, by creating a new shader that didn't do anything and then referencing that in the mesh file.... but it wasn't pretty. Your method looks much cleaner.

EDIT:

That doesn't seem to work. I get an error about a missing token on the nodraw.

Here is how I did it:

I made this shader that never does anything, although I don't know how to make it cleaner without the goofy if statement.


models/weapons/nomuzzleflash
{
{
if 2 < 1
blend add
map models/weapons/nomuzzleflash
}
}



And then in the "viewshotgun.md5mesh" file, I just changed the three flash meshes to use that new shader:


mesh {
// meshes: sgfx3mesh
// shader "models/weapons/shotgun/shotgun_mflashb"
shader "models/weapons/nomuzzleflash"

numverts 4
vert 0 ( 1 0 ) 2 1
        ...
        ...
        ...
}

etc
etc


It works fine, but is a bit ugly. :)
Old bastard but kid at heart...

Ivan_the_B

The skin approach does work.
That's how missiles are hidden on rocket launcher model.

Put the skin definition in a new .skin file inside a "skins" folder.

calan

Thanks Ivan...I'll give it another shot.

In the mean time, how can I get this to work, without having to include that if statement?


models/weapons/nomuzzleflash
{
{
if 2 < 1
blend add
map models/weapons/nomuzzleflash
}
}
Old bastard but kid at heart...

Ivan_the_B

You cannot create a material that does nothing.
The "if" trick you used was also used by ID in a couple of materials. You cannot get rid of it.
In your case anyway you don't need it this material at all. Just use nodraw.

calan

I still can't get it to work for some reason.

I created a folder called "skins" in the sikkmod folder (at the same level as def, script, particles, etc).. and in it is one file called "CAS.skin". That file contains the following:


skin calan/shotgun_nomuzzleflash {
models/weapons/shotgun/shotgun_mflashb textures/common/nodraw
}


In "weapon_shotgun.def", I added this line:


"skin" "calan/shotgun_nomuzzleflash"


I removed my hack from the first mesh in "viewshotgun.md5mesh" to test the new skin, so it now reads as this:



...
...

mesh {
// meshes: sgfx3mesh
shader "models/weapons/shotgun/shotgun_mflashb"
// shader "models/weapons/nomuzzleflash"

numverts 4
vert 0 ( 1 0 ) 2 1
        ...
        ...
        ...
}


(The other two meshes still use my hack, so they are out of the picture for testing).

When I start the game and load a test map, the shotgun still has the cartoon muzzle flash. If I comment the first line and uncomment my hack line in the first mesh, the canned flash is gone. I don't see any warnings about my skin....so, What am I missing?

*****

Couple of questions:

1. Why did you include the "calan/" in front of the new skin name? Is it needed as a sub-folder?

2. The "viewshotgun.md5mesh" actually has three meshes for the flash, which in turn use three shaders; "models/weapons/shotgun/shotgun_mflashb", "models/weapons/shotgun/shotgun_mflash2", and "models/weapons/shotgun/shotgun_mflash". Do I need to create a new skin for each of those and assign them in the def file, or can all three go under one skin, like this:


skin calan/shotgun_nomuzzleflash {
models/weapons/shotgun/shotgun_mflashb textures/common/nodraw
models/weapons/shotgun/shotgun_mflash2 textures/common/nodraw
models/weapons/shotgun/shotgun_mflash textures/common/nodraw
}


Appreciate all your help!
Old bastard but kid at heart...

Ivan_the_B

I used the "calan/" prefix as a placeholder.
That piece of the name is not required, but I expect you to group all your custom skins with a meaningful prefix. Say "yourproject/weapons/...".
It's just a naming convention I got used to by looking at the original D3 files.

You can indeed put multiple lines in the same skin. In fact, it's rather common.
You need to include all the flash materials to hide them.
I cannot test your skin code because I'm at work, but it looks correct to me :D

calan

#9
Ok... I put the viewshotgun.md5mesh file back to default, and put this in my .skin file:


skin cas/shotgun_nomuzzleflash {
models/weapons/shotgun/shotgun_mflashb textures/common/nodraw
models/weapons/shotgun/shotgun_mflash2 textures/common/nodraw
models/weapons/shotgun/shotgun_mflash textures/common/nodraw
}


(using my initials instead of forum name)

This is in the weapon_shotgun.def file:


// cas - remove muzzle flash
"skin"     "cas/shotgun_nomuzzleflash"


Still not working. Uhggg....

EDIT:

Where is the nodraw shader defined? I wonder if that file is getting over-written somewhere?
Old bastard but kid at heart...

Ivan_the_B

nodraw is a standard D3 material.

The problem here (sorry I forgot this until now) is that all weapon scripts inherit from weapon_base.script, which has this nice function:

/*
=====================
weapon_base::UpdateSkin

Required by game code for when the skin needs to change (for example, when the player has a power up).  Implemented in subclasses.
Code is called is only guaranteed to execute for one frame, so any code should either set the weapon state or start a new thread.
=====================
*/
void weapon_base::UpdateSkin() {
if ( isInvisible() ) {
setSkin( getKey( "skin_invisible" ) );
} else {
setSkin( "" );
}
}

... that resets the skin to "" unless you have the invisibility powerup.
It's invoked when the weapon is selected and when the invisibility powerup is picked up.

You have to override the funtion in weapon_shotgun.script like this:

void weapon_shotgun::UpdateSkin() {
if ( isInvisible() ) {
setSkin( getKey( "skin_invisible" ) );
} else {
setSkin( getKey("skin") );
}
}


Now your skin will work :)

calan

Looks like that did the trick!

Thanks much Ivan. Feel free to jump on all my other posts that you haven't already.   :D
Old bastard but kid at heart...