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 instance color forwarding for PBR Instances #12333

Merged
merged 1 commit into from
Apr 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/dev/core/src/Materials/PBR/pbrBaseMaterial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1326,6 +1326,10 @@ export abstract class PBRBaseMaterial extends PushMaterial {
attribs.push(VertexBuffer.ColorKind);
}

if (defines.INSTANCESCOLOR) {
Copy link
Contributor

@Popov72 Popov72 Apr 23, 2022

Choose a reason for hiding this comment

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

This block of code is also missing in all materials of the material library (and maybe in some other materials, I know the fluent controls in 3D GUI are also using custom materials for eg).

I think it would be better to update the MaterialHelper.PrepareAttributesForInstances method to push VertexBuffer.ColorInstanceKind in the attribute list because this method is called each time instances/thin instances are supported by materials. This way, you won't have to update individually each material.

attribs.push(VertexBuffer.ColorInstanceKind);
}

MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
MaterialHelper.PrepareAttributesForInstances(attribs, defines);
MaterialHelper.PrepareAttributesForMorphTargets(attribs, mesh, defines);
Expand Down