Jump to content

[PLUGIN] [0.25] Texture Animation Util


lo-fi

Recommended Posts

I read a forum post asking if there was a way to randomly animate textures, and it seemed like too cool a thing not to create.

So here is it: GitHub

It's really just a bare bones proof of concept, but basically it randomly changes the UV offset of the texture on a named GameObject. The speed and amount are both configurable independently in the U and V planes.

Config looks like this:


MODULE
{
name = TextureAnimateGeneric
ObjectName = WheelMesh //name of the GameObject you wish the texture to be animated on
smoothSpeed = 10 //float. controls how smoothly the changes are carried out
minSpeedU = 5 //integer. minimum number of frames before another change in U offset
maxSpeedU = 15
minSpeedV = 0
maxSpeedV = 30
minOffsetU = -0.1 //float. minimum offset to randomly generate for the U plane
maxOffsetU = 0.1 //maximum offset for U
minOffsetV = -0.1
maxOffsetV = 0.1
}

Continuous motion example:


MODULE
{
name = TextureAnimateGeneric
ObjectName = Track
additiveMode = true //set this to true if you want continuous animation over a tiling texture (conveyor belt, for example)
smoothSpeed = 5
minSpeedU = 0 //zero values for which plane you don't want movement in
maxSpeedU = 0
minSpeedV = 1 //in additive mode, set this to one and control the speed with how much offset you want each frame.
maxSpeedV = 1
minOffsetU = 0 //zero values for which plane you don't want movement in
maxOffsetU = 0
minOffsetV = 0.005 //it's the offset that actually does the movement.
maxOffsetV = 0.005
}

So you can have it as random or constant as you like. By setting the min and max values the same for any pair of values (minSpeedU and maxSpeedU, for example), you can achieve steady movement. It was a half hour project, and posted because quite a few people showed interest, so I'm sure it will want refining once people actually start playing around with it. What I'm _not_ going to do for this module is tie it to specific function (like engine throttle, for example). The license allows you to grab the code and use in your own project if you wish, or you can write a little module that fiddles with the public variables to achieve that; it's up to you. I've deliberately left is as generic and flexible as I can. Oh, and it moves the bump map to exactly the same placement as the diffuse/spec.

So what can you use it for? Well, engine effects, adding a bit of visual interest to emissives or self illuminated lighting... Conveyor belts and even the Knight Rider light strip have even been mentioned! Go see what you can do with it :D Questions, comments, pull requests/code improvements/extensions welcome.

If you want to use the pre-built .dll, please put it in GameData\CommunityUtils.

License: CC-BY-SA

Edited by lo-fi
Link to comment
Share on other sites

So for scrolling textures I would set all four offsets to 0?

I'd say only the Vs OR the Us, but not both..

correct me if I'm wrong..

@lo-fi: here's the force field you wanted to see :-D

Great work..

Q:

Would this license allow me to use the code in my plugin directly to remove the dependency?

I'm not that sure about CC-Details..

Edited by philotical
Link to comment
Share on other sites

This is cool. Had not thought of it. But isnt this also possible by keying the texture offset cycles to an animation inside unity? I havent tested. Nonetheless its really nice to be able to configure it at runtime

Yep, and that's probably the way to do it if you want a really specific motion, or something that starts and stops.

So for scrolling textures I would set all four offsets to 0?

Philotical nailed it, just zero the max and min for the offset you don't want to move

I'd say only the Vs OR the Us, but not both..

correct me if I'm wrong..

@lo-fi: here's the force field you wanted to see :-D

Great work..

Q:

Would this license allow me to use the code in my plugin directly to remove the dependency?

I'm not that sure about CC-Details..

Excellent, that's rather effective! :)

Yep, feel free to grab it and bung in your own source. The license basically says you're free to make derivative works however you like, so long as you license under the same terms and attribute the previous authors. It's designed to keep things open and freely usable.

Cheers guys, glad it's finding a few uses.

Link to comment
Share on other sites

This is cool. Had not thought of it. But isnt this also possible by keying the texture offset cycles to an animation inside unity? I havent tested. Nonetheless its really nice to be able to configure it at runtime
So for scrolling textures I would set all four offsets to 0?
I'd say only the Vs OR the Us, but not both..

correct me if I'm wrong..

@lo-fi: here's the force field you wanted to see :-D

Great work..

Q:

Would this license allow me to use the code in my plugin directly to remove the dependency?

I'm not that sure about CC-Details..

Oh, one thing if you're going to grab the code and use in your own plugin: please use a different class name for the module. Saves confusion if someone bundles the pre-built dll with the module name TextureAnimateGeneric. Will update OP shortly.

Link to comment
Share on other sites

Hold on I'm getting conflicting information. I want to scroll it like a caterpillar or a production line in a single direction (e.g. U) without any random movement.

So min and max offsets of U and V to 0.

Min and max V speed to 0

Min and max U speed to the same number.

Right?

Link to comment
Share on other sites

  • 4 weeks later...

I'll have to have a poke into how emissives actually work, will get back to you on that. It moves the texture offset on the material assigned to the named object, and covers diffuse, spec and bump. Emissive sounds like it's a bit different, so I'll see what I can dig out.

Link to comment
Share on other sites

Emissive always seems to add another level of complexity. For instance, when using KerbPaint, if you use anything other than the EmissiveBumpSpec shader, your emissive will fail to appear no matter how it's implemented (painted or not, just having that shader applied cuts the emissive out.)

Would be worth a try, however, to just add it to the list of types that it will animate and see what happens.

Edited by Gaalidas
Link to comment
Share on other sites

Interesting, thanks for the heads up. I've been looking at the emissives tutorial, and I'm still not sure how to access the material for the emissive to change it in the same way as the diff/spec and bump. Hopefully I don't have to dig into the shader (if I even can).

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...
  • 6 months later...
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...