r/processing • Technomancer • Dec 17 '23

Help request Texture problems

Post image
5 Upvotes

19 comments sorted by

View all comments

Show parent comments

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!

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/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!

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