Centering a rotating texture

Werewolf

Probably not a real Werewolf
aa
Apr 12, 2011
873
309
I have been trying to make a rotating fan texture, and used the example code posted on the 'Dynamic Materials with Proxies' guide on nodraw.net to do so. However when I test it I find it is rotating around a point to the side, not the center.

Unless I am mistaken, it's fair to assume that $center is the parameter I need to edit which I have tried doing already. The setting on the guide has it at [-0.5 -0.5] and I have tried changing these values to the following vaules:
  • [-0.5 -0.5]
  • [0 0]
  • [1 1]
  • [-1 -1]
  • [160 160] (because the brush it is applied to is 320x320)
  • [-160 -160]
  • [256 256] (because the texture is 512x512)
  • -256 -256]
None of these have worked so I am out of ideas on this. Anyone got any ideas how I to do this? If it makes any difference I am using a 512x512 texture on a 320x320 circular brush

Here is my .vmt as it currently stands:
Code:
"LightmappedGeneric"
{
    "$basetexture" "custom/fan_spinning"
    "$surfaceprop" "metal"
    "$translucent" "1"
    "$envmap" "env_cubemap"

    "$angle" 0.0
    "$translate" "[0.0 0.0]"
    "$center" "[-1 -1]"

    "Proxies"
    {
        "LinearRamp"
        {
            "rate" 5
            "initialValue" 0.0
            "resultVar" "$angle"
        }

        "TextureTransform"
        {
            "translateVar" "$translate" // we don't need this, but it's not optional
            "rotateVar" "$angle"
            "centerVar" "$center"
            "resultVar" "$basetexturetransform"
        }
    }
}
 
Last edited:

Pocket

Half a Lambert is better than one.
aa
Nov 14, 2009
4,694
2,579
So it still gets the origin wrong if you try to use it on a brush? And doesn't do anything different no matter how you adjust the values?
 

Werewolf

Probably not a real Werewolf
aa
Apr 12, 2011
873
309
So it still gets the origin wrong if you try to use it on a brush? And doesn't do anything different no matter how you adjust the values?
I didn't try adjusting the values to be honest, but I did try placing my texture on face next to the same texture applied as a decal and an overlay, and the only one that didn't rotate properly was the one applied to the face.
 

Tumby

aa
May 12, 2013
1,084
1,192
Every material has it's origin point, and that origin point depends on the origin of the object it's placed. For any world brush, that is the world origin. Brush entities use their own origins. Point entities have some kind of UV space. This means decals, overlays and models. [0.5 0.5] is the center for those, as [0 0] is one corner and [1 1] is the other.

This means that, as long as you keep your texture on a worldbrush or func_detail, you will need to use very large values. Playing around with face orientation (oriented to face or world) as well as using negative stuff might be neccessary.
 

Werewolf

Probably not a real Werewolf
aa
Apr 12, 2011
873
309
Every material has it's origin point, and that origin point depends on the origin of the object it's placed. For any world brush, that is the world origin
I assumed that, but found it only rotated around the top-left corner of the texture, aka the [0 0]. That was on world brushes, func_detail and func_brush brushes. I tried the func_brush as I was experimenting weather the origin of that effected the rotation of the material and it does not.