Jump to content
The Dark Mod Forums
Sign in to follow this  
kingsal

Hiding FX at a distance

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)

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

hmm, what about binding the func_emitter to another FS brush/patch that gets hidden at a certain distance..?

 

Hang on, I was able to hide rain patches using the port_dist & dist_check_period args... in some map I made a few years ago...

  • Like 1

Share this post


Link to post
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?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Thanks nbohr, I've tried this in the past but I must have missed something. Ill test it out and report back.

Share this post


Link to post
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
}

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

I've been working on similar thing lately, and I couldn't get alpha fading to work either. Does anyone have any working example of this?

Share this post


Link to post
Share on other sites

I've been working on similar thing lately, and I couldn't get alpha fading to work either. Does anyone have any working example of this?

The Animated Grass demo

Share this post


Link to post
Share on other sites

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.

  • Like 1

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Yes I did, but I did it in my WIP map, which is 1,6 gig with all the models and uncompressed textures. I'd have to make a separate project for this.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

I tried those, but again, these values don't seem to work. I tried both alphatest and translucent materials.

Share this post


Link to post
Share on other sites

I wouldn't expect translucent ones to work; apparently translucency is 'screen door' and doesn't involve alpha. As for alphatest ones, is the alphatest in the material set to shaderparm3 rather than an explicit value?

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
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.

Loading...
Sign in to follow this  

×
×
  • Create New...