-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
Material Index not matched #662
Comments
Thanks for reporting and digging in as always! I suspect this is because the geometry has not changed, causing the static geometry generator to return "NO_CHANGE" meaning the material index buffer attribute is not changed - see here. I think the easy fix would be the following: // change this
if ( result.changeType !== NO_CHANGE ) {
updateMaterialIndexAttribute( geometry, materials, materials );
}
// to this
updateMaterialIndexAttribute( geometry, materials, materials ); So the material index is always updated. Would you be able to test that? A more optimal change would be to check if any of the materials have changed before regenerating. But that's a bit more complicated. |
first try that you suggest me, it fails so I tried workaround weird way(use group.materialIndex) three-gpu-pathtracer/src/core/WebGLPathTracer.js Lines 353 to 365 in d5b1f14
your suggestion + change of code below fix this issue //previous
if ( bvhChanged ) {
material.bvh.updateFrom( bvh );
material.attributesArray.updateFrom(
geometry.attributes.normal,
geometry.attributes.tangent,
geometry.attributes.uv,
geometry.attributes.color,
);
material.materialIndexAttribute.updateFrom( geometry.attributes.materialIndex );
}
//after
if ( bvhChanged ) {
material.bvh.updateFrom( bvh );
material.attributesArray.updateFrom(
geometry.attributes.normal,
geometry.attributes.tangent,
geometry.attributes.uv,
geometry.attributes.color,
);
}
//No matter of bvhChanged
material.materialIndexAttribute.updateFrom( geometry.attributes.materialIndex ); if you agree this fixed i'll open pr, always thanks for feedback @gkjohnson |
Good catch - a PR would be great. It could be improved further if the material list information were saved as a hash to check if the list of materials had actually been updated or not - but I'l leave it up to you if you want to look into that. |
I'll open a PR this week fixing this issue in this way. if hash improvement of material is not urgent I'll look into it |
Fixed in #664 |
Describe the bug
this model has all the same Materials (8 mesh but share 1 material, share 1 material(same uuid) is a key point of this bug)
Model
FYI) zip from mac
Blender_Smeg (2).glb.zip
Platform:
This bug causes here
three-gpu-pathtracer/src/core/utils/GeometryPreparationUtils.js
Line 46 in d5b1f14
sorry for ugly notes
indexOf, if all meshes share 1 materials(in this notes a) geometry.materialIndex attributes are all 0
and then material of mesh has changed(a -> b)
StaticGeometryGenerator, bvhChanged => no changes(because in this scenario no geometry changes) so materialIndex not updated, geometry reuse materialIndex 0 so nothing has been updated
so my sugestion is
before
after
always welcome any ideas & questions
The text was updated successfully, but these errors were encountered: