Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 86fd19d

Browse files
committed
Set the model vertex colors to white
When running the given examples I had an all black screen. I realized the shader was still multiplying the texture and vertex colors. An alternative solution would be to modify the fragment shader, but felt it was better to provide proper Vertex attributes.
1 parent 903687e commit 86fd19d

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

08_Loading_models.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ vertex.texCoord = {
207207
attrib.texcoords[2 * index.texcoord_index + 0],
208208
attrib.texcoords[2 * index.texcoord_index + 1]
209209
};
210+
211+
vertex.color = {1.0f, 1.0f, 1.0f};
210212
```
211213
212214
Unfortunately the `attrib.vertices` array is an array of `float` values instead

code/model_loading.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,8 @@ class HelloTriangleApplication {
10021002
1.0f - attrib.texcoords[2 * index.texcoord_index + 1]
10031003
};
10041004

1005+
vertex.color = {1.0f, 1.0f, 1.0f};
1006+
10051007
if (uniqueVertices.count(vertex) == 0) {
10061008
uniqueVertices[vertex] = vertices.size();
10071009
vertices.push_back(vertex);

0 commit comments

Comments
 (0)