I first calculate the delta UV’s of the triangle (uv1 and uv2), and then use a formula found here.
OK so you are using the site I used to figure out that “in theory you can use any perpendicular vector” <- I chose to do that. Anyway I did find something.
You’re calculating the tangent wrong, this:
Vector3f tangent = new Vector3f(v1.x * uv2.y - v2.x * uv1.y * r, v1.y * uv2.y - v2.y * uv1.y * r, v1.z * uv2.y - v2.z * uv1.y * r)
Should be this:
Vector3f tangent = new Vector3f((v1.x * uv2.y - v2.x * uv1.y) * r, (v1.y * uv2.y - v2.y * uv1.y) * r, (v1.z * uv2.y - v2.z * uv1.y) * r)
Also, in regards to my first statement, in which I ignored choosing a proper vector, you might not be able to (probably can’t) cross the normal and tangent together.
Thank you for all your post and helping me, what a stupid mistake I made there :emo:
The results are starting to look good, now I only have to find a issue in my matrices, because the light rotates with camera (hard to explain what it does exactly)
It always helps to have a second pair of eyes take a look.
Hopefully you get it figured out. I took a look over your vert and frag shaders and they’re looking fine to me :-\