-
-
Notifications
You must be signed in to change notification settings - Fork 277
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
Support tangent space handedness #8871
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to pass on the unaltered W component of the tangent when transforming to world space? 🤔
:semantic-type :semantic-type-tangent | ||
:coordinate-space :coordinate-space-world | ||
:data-type :type-float | ||
:element-count 4}])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using world-space meshes, the tangents in :tangent-data
will be transformed by the renderable-data->world-direction-v4
function. Currently, this writes a zero for the W component when it calls the geom/transf-n4
function. I think we need to update geom/transf-n4
to pass along the unaltered W component.
It seems to me, we would need to do something similar on the engine side since we presumably transform the tangents using the normal matrix somewhere there as well, but I'm not seeing it in this PR? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The engine preserves the handedness in Rig.cpp in the "GenerateNormalData" function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Tangents are now produced as vec4 in the engine, where the fourth component is the handedness of the tangent vector. This can then be used to calculate the correct tangent space vectors in a shader:
vec3 bitangent = cross(normal, tangent.xyz * tangent.w);
Fixes #8733