Skip to content
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

Fix setting normal map when not all submeshes have texcoords (ogre2) #976

Merged
merged 3 commits into from
Mar 1, 2024

Conversation

iche033
Copy link
Contributor

@iche033 iche033 commented Mar 1, 2024

🦟 Bug fix

Summary

Setting normal map to a a submesh could fail in ogre2 if the mesh contains other submeshes that do not have texture coordinates set. Ogre2 will fail to generate tangents (needed for normal maps) and throw an exception:

03:59:05: OGRE EXCEPTION(5:ItemIdentityException): Cannot locate an appropriate 2D texture coordinate set for all the vertex data in this mesh to create tangents from.  in Mesh::suggestTangentVectorBuildParams at ./OgreMain/src/OgreMesh.cpp (line 1913)

The fix is to generate texcoords for all submeshes when importing the common::SubMesh into ogre even if the common::SubMesh does not have any texcoords.

The alternative (ideal) fix is to update ogre to just skip generating tangents for those submeshes that do not have texcoords instead of throwing an exception.

Tested with the AnisotropyBarnLamp.glb model.

Before the fix, the whole metal part of the lamp mesh appears white. After the fix, the PBR textures are applied correctly:

Screenshot 2024-02-29 at 7 54 07 PM

The light bulb should be transparent so there's another bug somewhere else and that still needs to be fixed. For comparison, see the result rendered by threejs

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

@github-actions github-actions bot added the 🌱 garden Ignition Garden label Mar 1, 2024
Copy link
Contributor

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a minor comment about unsigned varirables

test/integration/mesh.cc Outdated Show resolved Hide resolved
test/integration/mesh.cc Outdated Show resolved Hide resolved
test/integration/mesh.cc Outdated Show resolved Hide resolved
Copy link

codecov bot commented Mar 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.68%. Comparing base (0305b34) to head (4985dbe).

Additional details and impacted files
@@                Coverage Diff                @@
##           gz-rendering7     #976       /-   ##
=================================================
  Coverage          77.61%   77.68%    0.06%     
=================================================
  Files                170      170              
  Lines              14726    14733        7     
=================================================
  Hits               11430    11445       15     
  Misses              3296     3288       -8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@iche033 iche033 merged commit f95826f into gz-rendering7 Mar 1, 2024
10 of 11 checks passed
@iche033 iche033 deleted the normal_map_texcoord_ogre2 branch March 1, 2024 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌱 garden Ignition Garden
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants