diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2023-10-02 19:51:10 -0400 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2023-10-02 19:51:10 -0400 |
| commit | 4899815c69894bba3eb1a6faa8ccbbc676751728 (patch) | |
| tree | e3d5895b35d060d193ec59ccdeaf65dfbad6e145 /src/entities.cpp | |
| parent | 2bdee2ce549b1306cafb1d657624eeed4cf7225a (diff) | |
instancing now works as intended
Diffstat (limited to 'src/entities.cpp')
| -rw-r--r-- | src/entities.cpp | 42 |
1 files changed, 13 insertions, 29 deletions
diff --git a/src/entities.cpp b/src/entities.cpp index 7263bbd..fd55970 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -97,11 +97,10 @@ void EntityType_Init() { // index += 1; // instance vertInputBD[index].binding = index; - vertInputBD[index].stride = sizeof(glm::vec3) * 3; + vertInputBD[index].stride = sizeof(glm::mat4); vertInputBD[index].inputRate = VK_VERTEX_INPUT_RATE_INSTANCE; - const long vertexAttrDescCount = 6; - long runningOffset = 0; + const long vertexAttrDescCount = 7; index = 0; VkVertexInputAttributeDescription vertAttrDesc[vertexAttrDescCount]; for (long i = 0; i < vertexAttrDescCount; ++i) { @@ -111,44 +110,28 @@ void EntityType_Init() { // model vertex vertAttrDesc[index].binding = 0; vertAttrDesc[index].format = VK_FORMAT_R32G32B32_SFLOAT; - vertAttrDesc[index].offset = runningOffset; - runningOffset += sizeof(glm::vec3); + vertAttrDesc[index].offset = 0; index += 1; // model normals vertAttrDesc[index].binding = 1; vertAttrDesc[index].format = VK_FORMAT_R32G32B32_SFLOAT; - vertAttrDesc[index].offset = runningOffset; - runningOffset += sizeof(glm::vec3); + vertAttrDesc[index].offset = 0; index += 1; // model UV vertAttrDesc[index].binding = 2; vertAttrDesc[index].format = VK_FORMAT_R32G32_SFLOAT; - vertAttrDesc[index].offset = runningOffset; - runningOffset += sizeof(glm::vec2); + vertAttrDesc[index].offset = 0; index += 1; - // instance pos - vertAttrDesc[index].binding = 3; - vertAttrDesc[index].format = VK_FORMAT_R32G32B32_SFLOAT; - vertAttrDesc[index].offset = runningOffset; - runningOffset += sizeof(glm::vec3); - index += 1; - - // instance rot - vertAttrDesc[index].binding = 3; - vertAttrDesc[index].format = VK_FORMAT_R32G32B32_SFLOAT; - vertAttrDesc[index].offset = runningOffset; - runningOffset += sizeof(glm::vec3); - index += 1; - - // instance scale - vertAttrDesc[index].binding = 3; - vertAttrDesc[index].format = VK_FORMAT_R32G32B32_SFLOAT; - vertAttrDesc[index].offset = runningOffset; - // runningOffset += sizeof(glm::vec3); - // index += 1; + // instPosRotScale + for (long i = 0; i < 4; ++i) { + vertAttrDesc[index].binding = 3; + vertAttrDesc[index].format = VK_FORMAT_R32G32B32A32_SFLOAT; + vertAttrDesc[index].offset = sizeof(glm::vec4) * i; + index += 1; + } // instance texture index // vertAttrDesc[index].binding = 3; @@ -717,6 +700,7 @@ void EntityType_Load(EntityType &et) { // 2023-09-27 - JCB // I don't know where else to put this grBinds.instanceFirstBinding = index; + grBinds.instanceBindingCount = 1; // no index += 1 because index just happens to be the right value here for // the binding index, whereas binding the IndexBuffer doesn't need a binding index. |
