Skip to content

Commit

Permalink
fix update instance attribute failed under multipass for native engine (
Browse files Browse the repository at this point in the history
  • Loading branch information
xubing0906 authored May 10, 2023
1 parent 6cbad38 commit 0a207a5
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions native/cocos/scene/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,18 @@ void Model::updateAttributesAndBinding(index_t subModelIndex) {
updateWorldBoundDescriptors(subModelIndex, subModel->getWorldBoundDescriptorSet());
}

gfx::Shader *shader = subModel->getPasses()[0]->getShaderVariant(subModel->getPatches());
updateInstancedAttributes(shader->getAttributes(), subModel);
ccstd::vector<gfx::Attribute> attributes;
ccstd::unordered_map<ccstd::string, gfx::Attribute> attributeMap;
for (const auto &pass : subModel->getPasses()) {
gfx::Shader *shader = pass->getShaderVariant(subModel->getPatches());
for (const auto &attr : shader->getAttributes()) {
if (attributeMap.find(attr.name) == attributeMap.end()) {
attributes.push_back(attr);
attributeMap.insert({attr.name, attr});
}
}
}
updateInstancedAttributes(attributes, subModel);
}

void Model::updateInstancedAttributes(const ccstd::vector<gfx::Attribute> &attributes, SubModel *subModel) {
Expand Down

0 comments on commit 0a207a5

Please sign in to comment.