1. Hey there Guest,

    The game servers have moved to semi-dedicated hardware and IPs have changed. Please see front page server widget for up-to-date game server information.

Distance Fading brushes

Discussion in 'Mapping Questions & Discussion' started by Shunt McGuppin, Jun 14, 2014.

  1. Shunt McGuppin

    Shunt McGuppin L1: Registered

    Messages:
    5
    Positive Ratings:
    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.
     
  2. xzzy

    aa xzzy

    Messages:
    815
    Positive Ratings:
    500
    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.
     
    • Thanks Thanks x 1
  3. Shunt McGuppin

    Shunt McGuppin L1: Registered

    Messages:
    5
    Positive Ratings:
    0
    Thanks a lot. These are purely decorative, so there's no worry about that.

    Will players pass through a func_lod?
     
  4. Ravidge

    aa Ravidge Grand Vizier

    Messages:
    1,544
    Positive Ratings:
    2,517
    An example of a texture that fades when you get close to it is the respawn visualizer. Through vmt proxies.
     
  5. xzzy

    aa xzzy

    Messages:
    815
    Positive Ratings:
    500
    You can set them solid or not-solid in Hammer.
     
  6. YM

    aa YM LVL100 YM

    Messages:
    7,099
    Positive Ratings:
    5,920
    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.
     
  7. The Asylum

    aa The Asylum

    Messages:
    1,658
    Positive Ratings:
    586
    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"
    }
    }
    }
     
  8. Shunt McGuppin

    Shunt McGuppin L1: Registered

    Messages:
    5
    Positive Ratings:
    0
    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.


    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.
     
  9. The Asylum

    aa The Asylum

    Messages:
    1,658
    Positive Ratings:
    586
    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
     
  10. Pocket

    aa Pocket func_croc

    Messages:
    4,489
    Positive Ratings:
    2,377
    So you can't control both the start and end points of the fade? Could be inconvenient...
     
  11. Shunt McGuppin

    Shunt McGuppin L1: Registered

    Messages:
    5
    Positive Ratings:
    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.
     
  12. henke37

    aa henke37

    Messages:
    1,954
    Positive Ratings:
    465
    @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?
     
    • Thanks Thanks x 1
  13. The Asylum

    aa The Asylum

    Messages:
    1,658
    Positive Ratings:
    586
    not really, im just your regular script kiddie
     
  14. YM

    aa YM LVL100 YM

    Messages:
    7,099
    Positive Ratings:
    5,920
    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)