Jump to content


Photo

Hiding FX at a distance


28 replies to this topic

#1 kingsal

kingsal

    Member

  • Member
  • PipPip
  • 365 posts

Posted 03 May 2017 - 01:02 PM

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)



#2 Springheel

Springheel

    Creative Director (retired)

  • Admin
  • 37594 posts

Posted 03 May 2017 - 01:06 PM

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.thedarkm...iew.php?id=4372


TDM Missions:   A Score to Settle   *   A Reputation to Uphold   *   A New Job   *    A Matter of Hours
 
Video Series:   Springheel's Modules   *   Speedbuild Challenge   *   New Mappers Workshop  *   Building Traps

#3 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 9303 posts

Posted 03 May 2017 - 01:10 PM

Related:

 

http://forums.thedar...-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.c...ds/the-dark-mod

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

#4 kingsal

kingsal

    Member

  • Member
  • PipPip
  • 365 posts

Posted 03 May 2017 - 01:22 PM

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, 03 May 2017 - 01:23 PM.


#5 Bikerdude

Bikerdude

    Member

  • Banned
  • PipPipPipPipPip
  • 20320 posts

Posted 03 May 2017 - 01:55 PM

cant we use lod_bias (is that the right term)..? I used it in Sir Talbots...



#6 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 9303 posts

Posted 03 May 2017 - 02:01 PM

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.c...ds/the-dark-mod

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

#7 Bikerdude

Bikerdude

    Member

  • Banned
  • PipPipPipPipPip
  • 20320 posts

Posted 03 May 2017 - 02:06 PM

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...


  • nbohr1more likes this

#8 kingsal

kingsal

    Member

  • Member
  • PipPip
  • 365 posts

Posted 03 May 2017 - 02:28 PM

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?



#9 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 9303 posts

Posted 03 May 2017 - 02:45 PM

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

 

http://wiki.thedarkm...x.php?title=LOD

 

lod_fadein_range

lod_fadeout_range

 

http://wiki.thedarkm...le=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.thedarkm...parent_textures


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

http://www.indiedb.c...ds/the-dark-mod

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

#10 kingsal

kingsal

    Member

  • Member
  • PipPip
  • 365 posts

Posted 03 May 2017 - 02:53 PM

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



#11 kingsal

kingsal

    Member

  • Member
  • PipPip
  • 365 posts

Posted 03 May 2017 - 03:09 PM

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
}


#12 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 9303 posts

Posted 03 May 2017 - 03:27 PM

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.c...ds/the-dark-mod

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

#13 kingsal

kingsal

    Member

  • Member
  • PipPip
  • 365 posts

Posted 03 May 2017 - 03:38 PM

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, 03 May 2017 - 03:42 PM.


#14 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 9303 posts

Posted 03 May 2017 - 04:38 PM

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.thedarkm...le=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.c...ds/the-dark-mod

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

#15 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1830 posts

Posted 15 November 2018 - 04:44 PM

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?



#16 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 1974 posts

Posted 16 November 2018 - 09:55 AM

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



#17 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1830 posts

Posted 16 November 2018 - 10:14 AM

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.


  • duzenko likes this

#18 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 1974 posts

Posted 16 November 2018 - 02:36 PM

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



#19 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1830 posts

Posted 16 November 2018 - 02:52 PM

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.



#20 VanishedOne

VanishedOne

    Advanced Member

  • Member
  • PipPipPip
  • 897 posts

Posted 16 November 2018 - 03:18 PM

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, 16 November 2018 - 03:23 PM.

Some things I'm repeatedly thinking about...

- louder scream when you're dying


#21 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1830 posts

Posted 17 November 2018 - 02:01 AM

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



#22 VanishedOne

VanishedOne

    Advanced Member

  • Member
  • PipPipPip
  • 897 posts

Posted 17 November 2018 - 11:02 AM

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?


Some things I'm repeatedly thinking about...

- louder scream when you're dying


#23 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1830 posts

Posted 17 November 2018 - 12:00 PM

Nope, it's the base 0.5 value.



#24 HMart

HMart

    Advanced Member

  • Member
  • PipPipPip
  • 764 posts

Posted 17 November 2018 - 01:31 PM

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, 18 November 2018 - 11:45 AM.


#25 VanishedOne

VanishedOne

    Advanced Member

  • Member
  • PipPipPip
  • 897 posts

Posted 18 November 2018 - 11:13 AM

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)


  • Judith likes this

Some things I'm repeatedly thinking about...

- louder scream when you're dying




Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users