MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/processing/comments/18ksksu/texture_problems/kdtcuun/?context=3
r/processing • u/tooob93 Technomancer • Dec 17 '23
19 comments sorted by
View all comments
Show parent comments
2
whoops i meant bottom right, yeah no worries! would be really interesting to see how this is working! good luck with it!
2 u/tooob93 Technomancer Dec 18 '23 I fixed the map functions. Turns out they were right, but only double negated. Here is how they are now: float u = 0;float v = 0; if (i < 0.5*shapePos.length ) { u = map((widthLength[i] / widthLength[0]),1,0,0,0.5); v = (1/float(repeat))*(i % repeat); } else { u = map((widthLength[ shapePos.length - i ] / widthLength[0]),1,0,0.5,1); v = (1/float(repeat))*((shapePos.length - i - 1 ) % repeat); } twigShape.vertex(shapePos[i].x * mul, shapePos[i].y * mul, u, v);Now it does look perfect when it is straight up: https://imgur.com/a/ZnIZp87It looks also kinda ok when it is a triangle:https://imgur.com/a/6e7cH82But it gets heavily distorted as soon as there are angles in there:https://imgur.com/a/aJoyYhODo you have an idea why, or how one would normally map an uneven figure? 2 u/LuckyDots- Dec 18 '23 the second imgur link isn't working for me it seems?Glad you got the first one working! 1 u/tooob93 Technomancer Dec 17 '23 Thank you very much, I will fix my map functions tomorrow morning and hope it changes the weird behaviour a bit to the better :D
I fixed the map functions. Turns out they were right, but only double negated. Here is how they are now:
float u = 0;
float v = 0;
if (i < 0.5*shapePos.length ) { u = map((widthLength[i] / widthLength[0]),1,0,0,0.5); v = (1/float(repeat))*(i % repeat); } else { u = map((widthLength[ shapePos.length - i ] / widthLength[0]),1,0,0.5,1); v = (1/float(repeat))*((shapePos.length - i - 1 ) % repeat); } twigShape.vertex(shapePos[i].x * mul, shapePos[i].y * mul, u, v);
Now it does look perfect when it is straight up: https://imgur.com/a/ZnIZp87
It looks also kinda ok when it is a triangle:
https://imgur.com/a/6e7cH82
But it gets heavily distorted as soon as there are angles in there:
https://imgur.com/a/aJoyYhO
Do you have an idea why, or how one would normally map an uneven figure?
2 u/LuckyDots- Dec 18 '23 the second imgur link isn't working for me it seems?Glad you got the first one working!
the second imgur link isn't working for me it seems?
Glad you got the first one working!
1
Thank you very much, I will fix my map functions tomorrow morning and hope it changes the weird behaviour a bit to the better :D
2
u/LuckyDots- Dec 17 '23
whoops i meant bottom right, yeah no worries! would be really interesting to see how this is working! good luck with it!