Some thoughts on real time texture switching...

I’ve just seen an update to the tutorials at http://www.tutorialsforblender3d.com which gives some infomation on the video texture module. There includes info on static image textures too.
Video Texture ImageFFmpeg: image
You don’t need to be an elite blender head to see how useful this could be to blender users. I’ve not tried to get it working myself yet so I don’t know the limitations or any problems, but it could be something people have been asking for in Belnder for a long time, but didn’t know how to do.

Possible uses inlcude:

  • more flexible implimentaion of spite based objects, (don’t have to use lib new and UV translate, or mesh switch between large numbers of prenamed meshes)
  • real time texture switching, such as showing damage or team decals
  • more flexible control over animated textures and perhaps better performance as instead of using a sinlge large sheet you could use a number of named files which are much much smaller.

I hope people get a chance to try it out and if you do, why not post some of your results or problems here.

Actually, for things like sprites, and general texture animation, it’s significantly more efficient to simply move UV coordinates around a single texture that contains all frames, then to actually replace the texture itself.

The texture module is better suited for things like in-game video, render to texture, and to display pixel data from some external application source.

To generate “frame data”, for sprite animations, I created Sprycle: http://www.youtube.com/watch?v=QuUfL7atbdw

And I also did a video tutorial for render to texture: http://www.youtube.com/watch?v=HgXAv9csJu0

Hopefully, someone will find that helpful, in addition to information already presented.

PS:

I would highly recommend using Module execution mode for all Python controllers; It provides a better organizational structure, and I’m pretty sure there are some performance benefits as well.

Initial thoughts:
I did get it working very easily, it seems to work very quickly, though I haven’t had a chance to benchmark it to see how it compares to other methods of switching an image.
You can also get the data (raw RGBA values) from the image, so it would be very useful for terrain generation and the like too.
It works in single texture mode, which is perfect for me and it also works in GLSL and multi texture.

Yes, I don’t have anything to do with the tutorial website, I just posted a link to it. Some of the things the author does seem strange from a coding point of view, like using divide by 2 in some examples instead of multiply by 0.5 (multiplication being faster than division but clearer for people to understand).

EDIT:
After checking the speed of the operation it’s not fast enough to change the image every frame unless you are using a very small image. Even small images had a visible drain on resources.

I think it’s best used for replacing textures to show damage changing team colors, or for importing images so you can use the data for heightmaps etc…

Anyway, an interesting set of uses for the code, worth investigating further.