Distance Fading brushes

Shunt McGuppin

L1: Registered
Jan 24, 2014
5
0
I want to make a brush that fades automatically when you get close enough to it. Is there a way I can do this with materials, or is this an entity property? I will be using custom textures on these brushes so it is not out of the question.
 

xzzy

aa
Jan 30, 2010
815
531
func_lod is intended for this purpose.

Be careful about using it on geometry players will interact with though, stickies won't stick to it.
 

Shunt McGuppin

L1: Registered
Jan 24, 2014
5
0
Thanks a lot. These are purely decorative, so there's no worry about that.

Will players pass through a func_lod?
 

Ravidge

Grand Vizier
aa
May 14, 2008
1,544
2,818
An example of a texture that fades when you get close to it is the respawn visualizer. Through vmt proxies.
 

YM

LVL100 YM
aa
Dec 5, 2007
7,135
6,056
wait, are we talking 100% oppacity when close, or 0% oppacity when close?

func_lod and the respawn vis are visble when close, but not far. The original question sounds the other way around to me, in which case you'd need a brush with a custom material proxy that fades the opposite way to the respawn vis texture.
 
T

The Asylum

If you're looking for a texture to fade relative to distance, copypasta this into your vmt:

"LightmappedGeneric"
{
"$basetexture" "yourfolder/yourtexture"
"$translucent" 1

"$playerdistance" "0"
"$distanceclamped" "0"
"$distanceinverted" "0"
"$teammatch" "0"
"$matchinverted" "0"
"$endalpha" "0"
"$one" "2"
"$fadedistance" "1600" (modify this to control when your texture fades)
$distancealpha 1

"Proxies"
{
"PlayerProximity"
{
"resultVar" "$playerdistance"
"scale" 1.0
}
"Clamp"
{
"srcVar1" "$playerdistance"
"min" "0"
"max" "$fadedistance"
"resultVar" "$distanceclamped"
}
"Subtract"
{
"srcVar1" "$fadedistance"
"srcVar2" "$distanceclamped"
"resultVar" "$distanceinverted"
}
"PlayerTeamMatch"
{
"resultVar" "$teammatch"
}
"Subtract"
{
"srcVar1" "$one"
"srcVar2" "$teammatch"
"resultVar" "$matchinverted"
}
"Divide"
{
"srcVar1" "$distanceinverted"
"srcVar2" "$fadedistance"
"resultVar" "$endalpha"
}
"Multiply"
{
"srcVar1" "$endalpha"
"srcVar2" "$matchinverted"
"resultVar" "$alpha"
}
}
}
 

Shunt McGuppin

L1: Registered
Jan 24, 2014
5
0
wait, are we talking 100% oppacity when close, or 0% oppacity when close?

func_lod and the respawn vis are visble when close, but not far. The original question sounds the other way around to me, in which case you'd need a brush with a custom material proxy that fades the opposite way to the respawn vis texture.

Yes, I want a texture that becomes invisible when you are close to it. It is for a sequence in my surf map where you are falling down a long corridor.


If you're looking for a texture to fade relative to distance, copypasta this into your vmt:

"LightmappedGeneric"
{
"$basetexture" "yourfolder/yourtexture"
"$translucent" 1

"$playerdistance" "0"
"$distanceclamped" "0"
"$distanceinverted" "0"
"$teammatch" "0"
"$matchinverted" "0"
"$endalpha" "0"
"$one" "2"
"$fadedistance" "1600" (modify this to control when your texture fades)
$distancealpha 1

"Proxies"
{
"PlayerProximity"
{
"resultVar" "$playerdistance"
"scale" 1.0
}
"Clamp"
{
"srcVar1" "$playerdistance"
"min" "0"
"max" "$fadedistance"
"resultVar" "$distanceclamped"
}
"Subtract"
{
"srcVar1" "$fadedistance"
"srcVar2" "$distanceclamped"
"resultVar" "$distanceinverted"
}
"PlayerTeamMatch"
{
"resultVar" "$teammatch"
}
"Subtract"
{
"srcVar1" "$one"
"srcVar2" "$teammatch"
"resultVar" "$matchinverted"
}
"Divide"
{
"srcVar1" "$distanceinverted"
"srcVar2" "$fadedistance"
"resultVar" "$endalpha"
}
"Multiply"
{
"srcVar1" "$endalpha"
"srcVar2" "$matchinverted"
"resultVar" "$alpha"
}
}
}

This looks awesome. This will fade when you are closer than 1600 units? obviously I'd have to modify it to fit the parameters of my textures.
 
T

The Asylum

Int he example, when you're over 1600 units away, it'll start to fade. The respawn room vis brush I copied it out of had it at something like 500 or so, idk it's been a long time
 

Pocket

Half a Lambert is better than one.
aa
Nov 14, 2009
4,694
2,579
So you can't control both the start and end points of the fade? Could be inconvenient...
 

Shunt McGuppin

L1: Registered
Jan 24, 2014
5
0
I think you are misunderstanding me. I am trying to make a brush that is visible above a certain distance, but will disappear when you are under a certain distance from it.
 

henke37

aa
Sep 23, 2011
2,075
515
@stevethepocket: Sure you can! It is just a little bit of math. This is nothing more than linearly scaling the distance to the player into the alpha value.

@The Asylum: Why did you leave in the parts that are obviously about the team filtering? Did you not even bother reading the full proxy setup?
 
T

The Asylum

@The Asylum: Why did you leave in the parts that are obviously about the team filtering? Did you not even bother reading the full proxy setup?

not really, im just your regular script kiddie
 

YM

LVL100 YM
aa
Dec 5, 2007
7,135
6,056
wwaaait wait wait wait.

func_areaportalwindow is -exactly- what you want here.

(as long as the brush you want to place completely plugs a hole)