Skip to content

Fix vertex colored flat shading#1289

Merged
ldcWV merged 16 commits intofacebookresearch:masterfrom
ldcWV:ldchen/vertex-coloring
Jun 7, 2021
Merged

Fix vertex colored flat shading#1289
ldcWV merged 16 commits intofacebookresearch:masterfrom
ldcWV:ldchen/vertex-coloring

Conversation

@ldcWV
Copy link
Copy Markdown
Contributor

@ldcWV ldcWV commented Jun 2, 2021

Motivation and Context

Currently, it is impossible to view a mesh that is flat shaded because this case is being handled incorrectly. Flat shaded meshes show up completely black. This PR fixes that issue.

Before:
Screen Shot 2021-06-04 at 12 56 16 PM

After:
Screen Shot 2021-06-04 at 12 59 13 PM

In addition, the property vertexColored is now removed from PhongMaterialData, as this is not technically a property of a material because it depends on the geometry of the mesh. It has now been changed to a flag for Drawable.

How Has This Been Tested

A flat shaded mesh was loaded into the viewer successfully. If more testing is necessary, please give suggestions.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have completed my CLA (see CONTRIBUTING)
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Jun 2, 2021
@ldcWV ldcWV requested a review from eundersander June 2, 2021 23:53
@ldcWV ldcWV requested a review from bigbike June 3, 2021 00:02
Copy link
Copy Markdown
Contributor

@bigbike bigbike left a comment

Choose a reason for hiding this comment

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

Have you tried to load any vertex colored mesh?
Post the result image in the comments, will you? :)

Comment thread src/esp/assets/ResourceManager.cpp Outdated
@ldcWV
Copy link
Copy Markdown
Contributor Author

ldcWV commented Jun 3, 2021

Screen Shot 2021-06-02 at 5 00 31 PM

Screenshot requested by @bigbike of a vertex colored mesh. Better before/after pictures will be uploaded later.

@bigbike
Copy link
Copy Markdown
Contributor

bigbike commented Jun 3, 2021

Interesting. This mesh is vertex colored mesh for the Replica dataset. We can display it before even without your change.

Can you try the "master" branch on this mesh? I suspect you can display it already.

@ldcWV
Copy link
Copy Markdown
Contributor Author

ldcWV commented Jun 3, 2021

Just tried it on the master branch, and it's all black:
Screen Shot 2021-06-03 at 8 52 48 AM

@eundersander
Copy link
Copy Markdown
Contributor

Interesting. This mesh is vertex colored mesh for the Replica dataset. We can display it before even without your change.

Context on this test model: I provided it to Lawrence. It is a GLB that I created (not the Replica source PLY). I agree that we'd like to see another vertex-colored test model here.

@erikwijmans
Copy link
Copy Markdown
Contributor

You'll need to add the HasVertexColor flag here

gfx::Drawable::Flags meshAttributeFlags{};

Comment thread src/esp/assets/ResourceManager.cpp Outdated
Comment thread src/esp/assets/ResourceManager.cpp
@ldcWV
Copy link
Copy Markdown
Contributor Author

ldcWV commented Jun 4, 2021

You'll need to add the HasVertexColor flag here

gfx::Drawable::Flags meshAttributeFlags{};

I pushed a change that does this, although I'm not sure if this is actually a good idea. It will apply to all instance meshes because currently, there's no way to determine whether it's actually supposed to be vertex colored or not (see the warning comment under the changed line). This is a bigger issue than this PR is trying to address.

@erikwijmans
Copy link
Copy Markdown
Contributor

Yep, not the job of this PR to address that issue, but currently we default to instance meshes have vertex coloring, so we shouldn't change that unintentionally.

@ldcWV ldcWV requested a review from bigbike June 4, 2021 21:18
Comment thread src/esp/assets/ResourceManager.cpp
Comment thread src/esp/assets/ResourceManager.cpp
@bigbike
Copy link
Copy Markdown
Contributor

bigbike commented Jun 4, 2021

Good job, @ldcWV !

I approved this PR but left a question for you to consider.

Also please wait the CI tests passes.

@Skylion007
Copy link
Copy Markdown
Contributor

Pull from master to fix the Habitat-Lab issue.

@bigbike
Copy link
Copy Markdown
Contributor

bigbike commented Jun 7, 2021

Wait. Why I cannot see any comments from @eundersander ? I received a lot of comments in email notification. But cannot see any here?

To answer the "invisible" question:
Yes, that model is purple. I confirm it. Sorry I happened to give him a model that looks a bit strange.

@ldcWV
Copy link
Copy Markdown
Contributor Author

ldcWV commented Jun 7, 2021

Wait. Why I cannot see any comments from @eundersander ? I received a lot of comments in email notification. But cannot see any here?

To answer the "invisible" question:
Yes, that model is purple. I confirm it. Sorry I happened to give him a model that looks a bit strange.

He replied to an already resolved conversation. The thread is the second one in your approval comments.

Copy link
Copy Markdown
Contributor

@eundersander eundersander left a comment

Choose a reason for hiding this comment

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

Nice work! LGTM!

@ldcWV ldcWV merged commit a743f4d into facebookresearch:master Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Do not delete this pull request or issue due to inactivity.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants