Animated textures - how to do it correct?
in
Programming Questions
•
3 years ago
I am trying to texturize some vertex objects with animated textures but it looks as if the different textures melts into eachother. The colors of the images gets 'sucked' up to the top of the screen.
The code I'm experimenting with is pretty straightforward.
Its a bunch of quads with separate textures rendered on top of eachother.
When i translate each quad horizontally it clearly shows that each texture has been corrupted.
Above is the image rendered as a texture on a vertex, below is the image rendered with image()
Any tips or ideas?
The code I'm experimenting with is pretty straightforward.
Its a bunch of quads with separate textures rendered on top of eachother.
- int numFrames = 11;
int frame = 0; - PImage[] images = new PImage[numFrames];
- void setup(){
- size(800, 600,P3D);
- frameRate(30);
- for(int i=0; i<numFrames; i++) {
- String imageName = "test/test"+nf(i,2)+".jpg"; // images have names like 'test02.jpg'
- images[i] = loadImage(imageName);
- }
- }
- void draw(){
- background(0);
- if(frame>=numFrames-1){
- frame = 0;
- }
- frame++;
- drawTexture();
- }
- void drawTexture(){
- translate(width/2, height/2, -500);
- beginShape(QUADS);
- textureMode(NORMAL);
- texture(images[frame]);
- vertex(0,0,0,0);
- vertex(0,images[frame].height,0,1);
- vertex(images[frame].width,images[frame].height,1,1);
- vertex(images[frame].width,0,1,1);
- endShape();
- }
When i translate each quad horizontally it clearly shows that each texture has been corrupted.
Above is the image rendered as a texture on a vertex, below is the image rendered with image()
Any tips or ideas?
1