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

    • Ansome

      Finally got my PC back from the shop after my SSD got corrupted a week ago and damaged my motherboard. Scary stuff, but thank goodness it happened right after two months of FM development instead of wiping all my work before I could release it. New SSD, repaired Motherboard and BIOS, and we're ready to start working on my second FM with some added version control in the cloud just to be safe!
      · 1 reply
    • Petike the Taffer  »  DeTeEff

      I've updated the articles for your FMs and your author category at the wiki. Your newer nickname (DeTeEff) now comes first, and the one in parentheses is your older nickname (Fieldmedic). Just to avoid confusing people who played your FMs years ago and remember your older nickname. I've added a wiki article for your latest FM, Who Watches the Watcher?, as part of my current updating efforts. Unless I overlooked something, you have five different FMs so far.
      · 0 replies
    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 4 replies
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
×
×
  • Create New...