Fix MikkTSpace triangle selection and coordinate mapping for 3DS models - #39
Fix MikkTSpace triangle selection and coordinate mapping for 3DS models#39moonwho101 wants to merge 3 commits into
Conversation
- Update userData.total_faces = face_i_count / 3 in Compute3DSModelNormals to select all triangles across all sub-objects for MikkTSpace tangent space generation. - Swap Y and Z coordinates in ThreeDSMikk_GetPosition to match DirectX 3DS model space coordinate layout. - Invert V texture coordinates in ThreeDSMikk_GetTexCoord to align with 3DS model texture mapping. Co-authored-by: moonwho101 <90150577+moonwho101@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
… TBN artifacts - Set userData.total_faces = face_i_count / 3 in Compute3DSModelNormals to select all triangles across all sub-objects for MikkTSpace tangent space generation. - Swap Y and Z coordinates in ThreeDSMikk_GetPosition and invert V in ThreeDSMikk_GetTexCoord to match DirectX 3DS model space. - Add degenerate tangent safeguards and TBN fallback vectors in NormalSampleToWorldSpace across HLSL shaders. - Synchronize T flip when N is inverted for double-sided triangles in ClosestHit. - Clamp perturbed/interpolated normals at grazing view angles (dot(N, V) >= 0.001f) to eliminate black rim lighting artifacts on 3DS models like coin.3ds. Co-authored-by: moonwho101 <90150577+moonwho101@users.noreply.github.com>
…artifacts - Set userData.total_faces = face_i_count / 3 in Compute3DSModelNormals to process all triangles across all sub-objects. - Negate face normals and tangents in Compute3DSModelNormals to account for 3DS winding order and normalize vertex normals before calling MikkTSpace. - Swap Y and Z coordinates in ThreeDSMikk_GetPosition and invert V in ThreeDSMikk_GetTexCoord to match DirectX 3DS model space. - Add degenerate tangent safeguards and TBN fallback vectors in NormalSampleToWorldSpace across HLSL shaders. - Synchronize T flip when N is inverted for double-sided triangles in ClosestHit. - Clamp perturbed/interpolated normals at grazing view angles (dot(N, V) >= 0.001f) to eliminate black rim lighting artifacts on 3DS models like coin.3ds. Co-authored-by: moonwho101 <90150577+moonwho101@users.noreply.github.com>
This change fixes the MikkTSpace tangent calculation for 3DS models by ensuring that:
userData.total_faces = face_i_count / 3.fvPosOut[1] = v.z,fvPosOut[2] = v.y) to match DirectX 3DS model space.ThreeDSMikk_GetTexCoordare inverted (1.0f - (t.y * sky)) to prevent inverted tangent vectors and shading artifacts.PR created automatically by Jules for task 4013187589097524509 started by @moonwho101