-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fragment tangents/basis generates incorrect tangents. #4
Comments
The tangents are flipping sign on each triangle in the upper/lower hemispheres causing the discontinuity. The peak of the triangle seems to throw off the calculations, since he wide edges are smooth. |
I think the issue is that dpx/y are the flat planar polygon uses along with the interpolated vertex normal. dNx/y would be the interpolated plane, but could be zero if all normals point the same direction. |
Not totally sure if it's relevant, but have you seen the mikktspace algorithm? It seems to be the standard way of generating vertex tangents. |
I do, and that’s what most dcc apps use on the cpu side to generate a basis. This was more about looking at ways to compress and reconstruct the vertex data fed to the gpu. The original algorithm didn’t deal with any edge cases, and I consider normal + du/dv too costly. I could also reconstruct normals from tan/bitan which supports uv skew. Emil Perrson recommended that for JC3. |
Vertex Tangents - are nice and smooth with a seam down the middle
Fragment Tangents - no seam, and only the same in the middle of the sphere
I had to negate T in the shader to generate right-handed tangents.
It looks like the z slope and the vertical falloff throw off the calculations
Interpolated world pos, world vertex normal, and uv are passed into the call
Original shader passed -V = (worldPos - cameraPos), but with deltas the cameraPos drops out.
So passing worldPos should be the same.
The bitangents are almost identical with small banding at the top/bottom.
Vertex Tangents
Fragment Tangents
The text was updated successfully, but these errors were encountered: