TF2 Alpha Texture Fade

Archmage MC

L2: Junior Member
Jun 17, 2011
61
1
I need a texture that, when triggered via an I/O input, has its alpha fade from 1 to 0 (opaque to invisible) over 10 seconds. doesn't matter what the texture is as long as it works on a brush. Brush can be world or entity, it doesn't matter. Please post a VMF or detail how you got this to work in your post.

I'll also try to make a VALVe development wiki article on this sort of thing for TF2 if it works and give you credit for it.
 

duppy

L1: Registered
Feb 16, 2012
35
8
I've been messing with materials lately, so I thought I'd try to figure this one out...which I believe I did.

The VMT, which I named "duppy/material_modify_test.vmt" looks like this:

Code:
"LightmappedGeneric"
{
	"$basetexture" "brick/brickwall001b"

	"$alpha" "1.0"

	"Proxies"
	{
		"MaterialModify"
		{
			"dummy" "0"
		}
	}
}

To test it out, I made a basic room, and added a material_modify_control entity...

PROPERTIES:
Name: myMaterialModifyControl
Parent: myFuncBrush
Material to Modify: duppy/material_modify_test
Material variable to modify: $alpha

Then I made a func_brush, and applied the texture "duppy/material_modify_test" to it. The func_brush entities properties are all defaults, except the name:

PROPERTIES:
Name: myFuncBrush

Then, in order to add an interactive component, I added some buttons. One button sets the alpha values to a specific value...I randomly chose 0.75. The other button does what you asked...it slowly fades the alpha value from 0.0 to 1.0 over a 10 second period.

Both buttons have default properties, but for the hell of it, I named them myButton1 and myButton2. For the first button I gave it an output of...

OUTPUT (first button):
My output name: OnDamage
Target entities named: myMaterialModifyControl
Via this input: SetMaterialVar
With parameter override: 0.75
After delay in seconds of: 0.0

OUTPUT (second button):
My output name: OnDamage
Target entities named: myMaterialModifyControl
Via this input: StartFloatLerp
With parameter override: 0.0 1.0 10 0
After delay in seconds of: 0.0

Note: the parameter format for StartFloatLerp is <Start Value> <End Value> <Transition Time> <Loop> ...so in this case, we're starting at 0.0, ending at 1.0 with a transition time of 10 seconds, and loop is set to 0 so it doesn't repeat. You can find that info here on the VDC material_modify_control page.

I believe that's it. You can download the vmf, vmt, and compiled bsp here to try it out yourself. When the map is loaded, just shoot either the green or blue button (note: green button takes 10 seconds, so be patient for it to fade in).

EDIT: oops, I just noticed you want it to go from 1.0 to 0.0 ....just flip the start and end values for StartFloatLerp. Should be 1.0 0.0 10 0. Also, If you play with the numbers some more, make sure to adjust the VMT $alpha value as well.
 
Last edited:

Freyja

aa
Jul 31, 2009
3,011
5,839
Archmage and I spent hours trying to get this to work through numerous methods, and it turns out there's a simple input to do just that.

As always, I guess. Thanks!