Jump to content
The Dark Mod Forums

Hiding FX at a distance


kingsal

Recommended Posts

Hello,

 

Is there an easy way to hide a func_emitter fx at a certain distance? Or better yet fade them in and out? Hide_distance doesn't seem to work.

I know locations will automatically disable fx and you can manually trigger func_emitters on and off. (but neither of those are practical in my case)

Link to comment
Share on other sites

Hide_distance doesn't seem to work.

 

 

I know that wasn't working at some point during the 2.05 development cycle, but I thought someone fixed it along the way so that it did?

 

edit: I was remembering this, although maybe it doesn't do what I thought: http://bugs.thedarkmod.com/view.php?id=4372

Link to comment
Share on other sites

Related:

 

http://forums.thedarkmod.com/topic/18293-hide-distance-for-particles/

 

I know that lod_bias works (I fixed that for func_emitter) but hide_distance is an open question...

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

Hmm I tried the LOD and it's still not hiding. Here are the spawnargs Im using.

// entity 1766
{
"classname" "func_emitter"
"name" "func_emitter_7"
"_color" "0.188 0.157 0.122"
"cycleTrigger" "0"
"model" "volta_fogSteamy_large.prt"
"origin" "-132 5601 -864"
"model_lod_1" "emtpy"
"hide_distance" "300"
"lod_1_distance" "300"
"dist_check_period" "1"
}
Edited by kingsal
Link to comment
Share on other sites

lod_bias (poorly named attribute) is for making stuff invisible if your Object Detail slider is on the low side.

 

hide_distance or LOD are for changing detail or making things invisible based on your distance to the entity.

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

Hm, I've not heard of port_dist. Sounds promising.

 

Also while on the topic, does the engine support fading particles at certain distances? Would that be handled in the material file?

Link to comment
Share on other sites

You can use distance based alpha-fading on particles whose materials have an alpha attribute:

 

http://wiki.thedarkmod.com/index.php?title=LOD

 

lod_fadein_range

lod_fadeout_range

 

http://wiki.thedarkmod.com/index.php?title=Alpha-fading

 

Limitations:

 

Unlit particles can fade to transparent using alpha keyword in the material.

Lit particles can selectively fade away parts of a material using alpha-test (see wiki above)

 

It may be possible to have lit materials fade to transparent using materials similar to the translucent ones here:

 

http://wiki.thedarkmod.com/index.php?title=Making_Semi-transparent_textures

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

Nbohr, I tried to test this following the wiki and I'm not getting any fading. What am I doing wrong here?

 

Plant_mesh_04 definitely has a shader with alpha. Does it need to be alpha blend and or test? How do I integrate the "alpha map growable" into my material?

entityDef fade_object
{
	"inherit"				"atdm:nature_base"
	"editor_displayFolder"	"test"

	"editor_color"			".4 0.8 0.1"
	"editor_usage"			"Don't use, base for all TDM LOD grass patches."

	"solid"					"0"
	"model"					"models/darkmod/nature/plant_mesh_04.lwo"


	// turn off shadows from this distance on
//	"lod_1_distance"		"250"
//	"model_lod_1"			""
//	"noshadows_lod_1"		"1"

	// hide it from this distance on (it is a small object, so can vanish fast)
	"hide_distance"			"1000"

	"lod_fadeout_range"		"600"

	// by default use more dense grass
}
Link to comment
Share on other sites

So, this would be a lit mesh and would require that you create a new material def for the plant material with alpha-test and you would need to create a growth map image.

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

Gotcha and the grow map alpha is the used as the alpha for the original diffuse or as the map for the alpha test? Does anyone have a working version of this?

Edited by kingsal
Link to comment
Share on other sites

The grow map acts as the alpha of the diffuse. Alpha-test uses a threshold to say "anything with less alpha than x is fully transparent, anything with more is fully opaque".

 

The cattails entity in the wiki uses this as well as some of our other vegetation:

 

http://wiki.thedarkmod.com/index.php?title=Alpha-fading

 

The difference here is that we are applying the material to a particle rather than a standard model but I'm pretty sure that the alpha scripting will

happen on any entity as long as the material and LOD settings are configured.

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

  • 1 year later...

I checked its defs already, it uses several lod stages, not alpha fading. I was able to reproduce it, but I wonder how a fluid alpha fading solution would work.

Oh right

Do you follow the tutorial @NB posted above? Do you use the alphaTest material flag?

If so, attach the test map for me to look at

Link to comment
Share on other sites

The courtyard in In The Black has a lamphaze that changes size with player distance: I hacked it together by piggybacking on the alpha-fading functionality. It's a func_static patch with the material named 'halo' in itb.mtr.

 

I think there was some kind of counterintuitive quirk in the way the LOD distance settings gave rise to the alpha value changes, but I've forgotten the details. Something like needing to set a hide distance even though I didn't want hiding, and finding the differences between hide/normal/fadeout/fadein ranges behaved unexpectedly. You can see I made hide and normal distances huge so they'd never take effect, and fadein range tiny, and I think there's a reason lod_fadeout_range == lod_1_distance but I've forgotten quite what happened when it wasn't:

"dist_check_period" "0.01"
"hide_distance" "30000000"
"lod_1_distance" "512"
"lod_fadein_range" "1"
"lod_fadeout_range" "512"
"lod_normal_distance" "30000000"
Edited by VanishedOne

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

Sorry if this is not really about TDM but i'm trying to do the same thing on my custom fhdoom engine and not having any success, I can't even make the Doom 3 burn away effect to work on my case, what it does is make the object instantly invisible, I blame that on my lack on knowledge on the subject of material shading.

 

This is the burn away material stage (modified slightly from Doom 3) but it doesn't do what i expected...

{	// blend away effect
		if	(parm7 > 0)	// only when dead
		// make a burned away alpha test for the normal skin
		blend	gl_zero, gl_one			// don't draw anything
		
		map textures/nature/red_strange_plant_blend.tga	// replace this with a monster-specific texture
		alphaTest 0.05 + 1.5 * (time - parm7)
	}    

Also how can you access the alpha value from the c++ code?

 

I know about

 

SetShaderParm(Flag, value);

 

But this only changes values based on the materials "parmx" material key

 

what i want is to access the value defined in front of the key "alphaTest" keyword;

 

I came up with the code below but the most impart part, getting the alpha value and changing it, is something that i don't know how to do.

renderEntity_t	*renderEnt;
idRenderModel	*renderModel;
const modelSurface_t	*surf;
const idMaterial	*shader;
const shaderStage_t     *sstage;
f32 alphaTest = 0;

renderEnt = GetRenderEntity();
renderModel = renderEnt->hModel;

if (renderModel == NULL) return;

for (int i = 0; i < renderModel->NumSurfaces(); ++i) {
    surf = renderModel->Surface(i);

    if (surf == NULL) continue;

    shader = surf->shader;

    if (shader == NULL) continue;

    for (int i = 0; i < shader->GetNumStages(); ++i) {
	sstage = shader->GetStage(i);
	
        if (sstage->hasAlphaTest) {

            // get current alpha test value
            
            // new alpha test value

	   break;
	}
	continue;
}

the sstage has the following member variable "sstage->alphaTestRegister" but instead of getting the 0.5 value of the alphaTest key i get the value 22.

 

What are stage registers and how I retrive the real alpha value? Can anyone help me?

Edited by HMart
Link to comment
Share on other sites

Nope, it's the base 0.5 value.

In that case 'alphatest parm3' might work. All LOD fading seems to do is modify parm3 according to distance, so what that does depends on how your material is set up, which is why I was able to use it for scaling. (And yes, it would be nice if the wiki said so.)

 

@HMart I don't know about the code, but doesn't D3 control burnaway partly through scripting?

float burnDelay = getFloatKey( "burnaway" );
	if ( burnDelay != 0 ) {
		preBurn();
		sys.wait( burnDelay );
		burn();
		startSound( "snd_burn", SND_CHANNEL_BODY, false );
	}

(From ai_monster_base.script)

  • Like 1

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 1 reply
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
    • Petike the Taffer

      Maybe a bit of advice ? In the FM series I'm preparing, the two main characters have the given names Toby and Agnes (it's the protagonist and deuteragonist, respectively), I've been toying with the idea of giving them family names as well, since many of the FM series have named protagonists who have surnames. Toby's from a family who were usually farriers, though he eventually wound up working as a cobbler (this serves as a daylight "front" for his night time thieving). Would it make sense if the man's popularly accepted family name was Farrier ? It's an existing, though less common English surname, and it directly refers to the profession practiced by his relatives. Your suggestions ?
      · 9 replies
    • nbohr1more

      Looks like the "Reverse April Fools" releases were too well hidden. Darkfate still hasn't acknowledge all the new releases. Did you play any of the new April Fools missions?
      · 5 replies
×
×
  • Create New...