Prevent looping an animated texture?

A Forum Thread for Team Fortress 2

Hello!

Does anyone know how to prevent an animated texture from looping in a .vmt?


Thanks in advance.
/DevBat

Posts

  • Zwip-Zwap Zapony avatar
    Zwip-Zwap Zapony username pic Joined 6y ago
    Offline
    4,209 points Ranked 1191st
    14 medals 1 legendary 1 rare
    • Returned 5000 times Medal icon
    • Returned 1000 times Medal icon
    • Reached 1,000 Points Medal icon
    • One month a member Medal icon
    • 6 months a member Medal icon
    • 1 year a member Medal icon
    2y
    I might (I probably) know how, but it'd help to see a VMT you'd like to do this with, and also if you explain what you'd like it for.
    *Insert User Title here*
  • DevBat avatar
    DevBat username pic Joined 7y ago
    ?
    740 points Ranked 6781st
    15 medals 1 rare
    • 6 years a member Medal icon
    • Became a Studio Leader Medal icon
    • One month a member Medal icon
    • 6 months a member Medal icon
    • 1 year a member Medal icon
    • 2 years a member Medal icon
    2y
    Posted by Zwip-Zwap Zapony

    I might (I probably) know how, but it'd help to see a VMT you'd like to do this with, and also if you explain what you'd like it for.
    Here's my .vmt:
    "UnlitGeneric"
    {
    "$basetexture" "mmm/chatbox/motzand1"
    "$nodecal" 1
    "$nolod" 1
    "$translucent" 1

    "Proxies"
    {
    "AnimatedTexture"
    {
    "animatedTextureVar" $basetexture
    "animatedTextureFrameNumVar" $frame
    "animatedTextureFrameRate" 20
    }
    }
    }
    This vmt is intended for a screen overlay.
    The overlay is sent to the player through a client_command entity when the player enter a trigger volume.

  • Zwip-Zwap Zapony avatar
    Zwip-Zwap Zapony username pic Joined 6y ago
    Offline
    4,209 points Ranked 1191st
    14 medals 1 legendary 1 rare
    • Returned 5000 times Medal icon
    • Returned 1000 times Medal icon
    • Reached 1,000 Points Medal icon
    • One month a member Medal icon
    • 6 months a member Medal icon
    • 1 year a member Medal icon
    2y
    Untested example VMT of a non-looping animated texture:
    UnlitGeneric
    {
    $BaseTexture mmm/chatbox/motzand1
    $NoDecal 1
    $NoLod 1
    $Translucent 1

    Proxies
    {
    LinearRamp
    {
    Rate 20
    InitialValue 0
    ResultVar $Frame
    }
    Clamp
    {
    Min 0
    Max 19
    SrcVar1 $Frame
    ResultVar $Frame
    }
    }
    The LinearRamp's "Rate" value should be the amount of frames per second (however, again, it's untested), and the Clamp's "Max" value should be the amount of frames you want it to play for, minus 1. (You can't have more frames here than the amount of frames in the VTF, but you can have less if you want.)
    *Insert User Title here*
  • DevBat avatar
    DevBat username pic Joined 7y ago
    ?
    740 points Ranked 6781st
    15 medals 1 rare
    • 6 years a member Medal icon
    • Became a Studio Leader Medal icon
    • One month a member Medal icon
    • 6 months a member Medal icon
    • 1 year a member Medal icon
    • 2 years a member Medal icon
    2y
    Posted by Zwip-Zwap Zapony

    Untested example VMT of a non-looping animated texture:
    UnlitGeneric
    {
    $BaseTexture mmm/chatbox/motzand1
    $NoDecal 1
    $NoLod 1
    $Translucent 1

    Proxies
    {
    LinearRamp
    {
    Rate 20
    InitialValue 0
    ResultVar $Frame
    }
    Clamp
    {
    Min 0
    Max 19
    SrcVar1 $Frame
    ResultVar $Frame
    }
    }
    The LinearRamp's "Rate" value should be the amount of frames per second (however, again, it's untested), and the Clamp's "Max" value should be the amount of frames you want it to play for, minus 1. (You can't have more frames here than the amount of frames in the VTF, but you can have less if you want.)
    Thank you for your reply! I just tested your solution, but it seems that the overlay does not work with LinearRamp.

    In most materials this would work since we can change stuff dynamically. The screen overlay stays static after it's been drawn and cannot change its starting values after it's been drawn. (Hence why AnimatedTexture works but not LinearRamp)

    I've read some similar threads which suggest to create multiple .vmts to change with I/O.

    But is this the only way?

    Just trying to optimizing the material as much as I can. : )

  • Zwip-Zwap Zapony avatar
    Zwip-Zwap Zapony username pic Joined 6y ago
    Offline
    4,209 points Ranked 1191st
    14 medals 1 legendary 1 rare
    • Returned 5000 times Medal icon
    • Returned 1000 times Medal icon
    • Reached 1,000 Points Medal icon
    • One month a member Medal icon
    • 6 months a member Medal icon
    • 1 year a member Medal icon
    2y
    You could try replacing the LinearRamp proxy with a basic AnimatedTexture proxy, while keeping in the Clamp proxy below it... but make sure to add a couple extra copies of the last frame at the end of the VTF (preferably enough for at least 0.2 seconds), so the client has to lag a lot for the animated texture variable to wrap around back to the start. If this doesn't work (provided you have more than 5 frames per second), there's not much else that would work, if anything at all.
    *Insert User Title here*
  • DevBat avatar
    DevBat username pic Joined 7y ago
    ?
    740 points Ranked 6781st
    15 medals 1 rare
    • 6 years a member Medal icon
    • Became a Studio Leader Medal icon
    • One month a member Medal icon
    • 6 months a member Medal icon
    • 1 year a member Medal icon
    • 2 years a member Medal icon
    2y
    Posted by Zwip-Zwap Zapony

    You could try replacing the LinearRamp proxy with a basic AnimatedTexture proxy, while keeping in the Clamp proxy below it... but make sure to add a couple extra copies of the last frame at the end of the VTF (preferably enough for at least 0.2 seconds), so the client has to lag a lot for the animated texture variable to wrap around back to the start. If this doesn't work (provided you have more than 5 frames per second), there's not much else that would work, if anything at all.
    I've thought about adding more frames, but due to file size constrains, (image is 1024x1024!) I cannot do that. I'll have to see if I can figure something out.

    Thanks for the help!

Embed

Share banner
Image URL:
HTML embed code:
BB embed code:
Markdown embed code:

Author

DevBat avatar
DevBat username pic Joined 7y ago
?
740 points Ranked 6781st
15 medals 1 rare
  • 6 years a member Medal icon
  • Became a Studio Leader Medal icon
  • One month a member Medal icon
  • 6 months a member Medal icon
  • 1 year a member Medal icon
  • 2 years a member Medal icon

DevBat avatar
DevBat
Sign up to access this!
Sign up to access this!
Sign up to access this!

Game

Sign up to access this!

Category

Attributes

Miscellaneous

Share

  • Share on Reddit
  • Share on Twitter
  • Share on Facebook
  • Share on Google+

Stats

  • 529 Views
  • 6 Posts
  • 2y Submitted

More from Submitter

WiPs by Submitter

bcp.crwdcntrl.net tracking pixel