We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello :)
I have a problem with repeating textures in processing.
I want to draw a vertex and put a texture onto it.
I have a 10px*10px texture which should repeat in X and in Y.
The problem is that the texture repeats streched if the vertex has odd angles.
My code_example for this is:
PImage img;
void setup() {
size(400, 400, OPENGL);
textureMode(NORMAL);
textureWrap(REPEAT);
img = loadImage("tex/dirt.jpg");
noStroke();
}
void draw() {
beginShape(QUADS);
texture(img);
vertex(0, 0, 0, 0);
vertex(100, 0, 2, 0);
vertex(150, 200, 2, 2);
vertex(0, 150, 0, 2);
endShape();
}
As an example you can use this texture:
http://i4.luggagepros.com/skin/frontend/lp/default/images/swatches/advitleopd.jpg
My second idea to solve this problem is to just repeat the texture in photoshop and make a 1000*1000 pixel Texture and use the vertex as a "mask".
I hope you understand the problem :)
Answers
i think you have to change the texture co-ords (the 2, 0) to match the shape of the quad.
something like:
(untested)
Thank you very much :)
With your help i finally understand how the u / v coordinates work :)
that shape matching is what you want but you can get great results and do useful things by playing with the texture co-ords. for instance, the old unreal tournament used a 2d texture wrapped around a 3d figure and you could modify the graphic to re-skin the figure to your tastes
here's one, at the bottom here http://www.digisaur.net/games/2d_hellboy.htm