how to sprite texture offset frame using rand($PT)?

   2100   2   2
User Avatar
Member
46 posts
Joined: Jan. 2012
Offline
how to sprite texture offset frame using rand($PT)?
thx all advance!
User Avatar
Member
55 posts
Joined: Jan. 2006
Offline
without seeing your setup my first guess is something like this:

($F + int(fit01(rand($PT),0,23)))%24

That's if you have a sprite loop of 24 frames numbered

sprite.0.jpg
sprite.1.jpg

sprite.23.jpg

First you start with $F, that's the frame number. Then you offset it by an integer that is made by fitting the 0-1 range you get from the rand() expression into a 0-23 range. Finally you take all of that and modulus it by 24 (modulus function gives you the remainder when you divide by that number).

Beware that using $PT will use the point number and if your point count changes then most likely all the point numbers will change. There's ways around that, but it depends on your setup.
“If you can eat it raw you can't under cook it”
User Avatar
Member
46 posts
Joined: Jan. 2012
Offline
Hi kleer
you give me a nice example.
thank you!

I have another question,
how to passing the variable to the SHOP network.
or how can I control the texture source image offset expression on SOP?
  • Quick Links