I'm trying to texture an icosphere with a tileable grass texture. I tried a couple of things I found on the internet, but none of those seemed to work. I tried to calculate the uv coordinates by converting the cartesian to barycentric with this alogrithm: http://adrianboeing.blogspot.de/2010/01/barycentric-coordinates.html. This is what happened:
The next thing I tried was a spherical mapping. I though of scaling the textures afterwards, but it didn't work anyway. I tried those two algorithms:
uv.setX((float) (0.5 - (FastMath.atan2(z, x) / (FastMath.PI * 2))));
uv.setY((float) (0.5 - (2 * (FastMath.asin(y) / (FastMath.PI * 2)))));
uv.setX(x / FastMath.sqrt((x * x) + (y * y) + (z * z)));
uv.setY(y / FastMath.sqrt((x * x) + (y * y) + (z * z)));
This is what happend this time (with the first algorithm, kinda smiliar outcome with the second one):
The last thing I tried was to just feed the uv coordinate buffer with the row (0|0), ( 1|0), (0|1). This is actually also what I tried first and I still wonder why it's not working. What happened this time looks sort of similiar to the first attempt in this post.
Some triangles look perfectly mapped, some seem to be streched over one axis?!
Right now I'm pretty lost, I've been trying this for 2 days now, thought and read a lot about the concepts of the buffers and uv coordinates but I just can't figure this out without any help. Every kind of help is appreciated