Starting Animated Texture on First Frame?

So I’ve got an animated material for Garry’s Mod, specifically an overlay.
I used code on my entities to make the overlay start and stop at specific times on a player, problem is, the overlay will start on a random frame. Is there a way in the code or .vmt to start the animated texture on the first frame?
I don’t want to have to skip through multiple post processes every 0.1 second just to get the frames right. Any ideas?

DrawMaterialOverlay doesn’t interact with animated textures or expose the material it uses, so you’d have to homebrew it yourself.


local lastTexture = nil
local mat_Overlay = nil

local function AltDrawMaterialOverlay( texture, refractamount, first )
	if ( texture ~= lastTexture or mat_Overlay == nil ) then
		mat_Overlay = Material( texture )
		lastTexture = texture
	end
	
	if ( mat_Overlay == nil ) then return end
	
	if first then
		mat_Overlay:SetInt( "$frame", 0 )
	end

	render.UpdateScreenEffectTexture()

	// FIXME: Changing refract amount affects textures used in the map/models.
	mat_Overlay:SetFloat( "$envmap", 0 )
	mat_Overlay:SetFloat( "$envmaptint", 0 )
	mat_Overlay:SetFloat( "$refractamount", refractamount )
	mat_Overlay:SetInt( "$ignorez", 1 )

	render.SetMaterial( mat_Overlay )
	render.DrawScreenQuad()
	
end

AltDrawMaterialOverlay( "your overlay", refract, however you want to determine if we should reset the animation )

Something like that might work.