Implement glTF COLOR_0 vertex color support in StandardMaterial and UnlitMaterial#618
Implement glTF COLOR_0 vertex color support in StandardMaterial and UnlitMaterial#618yss-ef wants to merge 2 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
footballhead
left a comment
There was a problem hiding this comment.
Thanks for the contribution!
However, I'm encountering a validation layer error on Linux. When I run vk_gltf_basic_materials with the validation layers enabled, I ecounter the following assertion:
*** VULKAN VALIDATION ERROR MESSAGE ***
Severity : ERROR
Type : [VALIDATION]
Objects : [0]: <UNNAMED OBJECT>
Message : vkCreateGraphicsPipelines(): pCreateInfos[0].pVertexInputState->pVertexAttributeDescriptions does not have a Location 4 but vertex shader has an input variable at that Location. (This can be valid if either the vertexAttributeRobustness or maintenance9 feature is enabled).
The Vulkan spec states: If the vertexAttributeRobustness feature is not enabled, and the maintenance9 feature is not enabled, and the pipeline is being created with vertex input state and pVertexInputState is not dynamic, then all variables with the Input storage class decorated with Location in the Vertex Execution Model OpEntryPoint must contain a location in VkVertexInputAttributeDescription::location (https://vulkan.lunarg.com/doc/view/1.4.335.0/linux/antora/spec/latest/chapters/pipelines.html#VUID-VkGraphicsPipelineCreateInfo-Input-07904)
The primary consumer of the scene loader is the gltf_basic_materials sample; I've added instructions for running it in #621. What results are you seeing?
| // Process vertex data | ||
| for (cgltf_size i = 0; i < gltflAccessors.pPositions->count; ++i) { | ||
| TriMeshVertexData vertexData = {}; | ||
| vertexData.color = glm::float3(1, 1, 1); |
There was a problem hiding this comment.
This file needs to be formatted with clang-format-16. Alternatively, the clang-format GitHub action includes a diff in its log that can be applied in order to format.
Description
Implement glTF COLOR_0 vertex color support in the scene renderer.
According to the glTF 2.0 specification (Section 3.9.2):
Previously, while GltfLoader would load the COLOR_0 accessor, the data was not being utilized by the
StandardMaterial or UnlitMaterial shaders. This PR enables the vertex color attribute across the scene
renderer's shader pipeline and applies it as a linear multiplier to the base color.
Problem
Vertex colors provided in glTF assets were being ignored during shading, resulting in incorrect
rendering for models that rely on COLOR_0 for tinting, baked effects, or specific material tests.
Solution
vertex input to the pixel shader.
input.Color.
glTF vertex color formats.
preventing unintended darkening.
Verification Results
These changes enable correct rendering for several glTF-Sample-Assets, including: