Skip to content

Commit

Permalink
Actually fill the whole Dawntrail bone buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
redstrate committed Nov 3, 2024
1 parent 8535fec commit a3f3437
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions renderer/include/drawobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct DrawObject {

physis_MDL model;
std::vector<RenderPart> parts;
std::array<glm::mat4, 128> boneData;
std::array<glm::mat4, 768> boneData; // JOINT_MATRIX_SIZE_DAWNTRAIL
std::vector<RenderMaterial> materials;
glm::vec3 position;
bool skinned = false;
Expand All @@ -44,4 +44,4 @@ struct DrawObject {
uint16_t to_body_id = 101;

Buffer boneInfoBuffer;
};
};
11 changes: 3 additions & 8 deletions renderer/include/shaderstructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,8 @@ struct CameraParameter {
glm::vec4 m_LookAtVector;
};

struct JointMatrixArrayARR {
glm::mat3x4 g_JointMatrixArray[64];
};

struct JointMatrixArrayDawntrail {
glm::mat3x4 g_JointMatrixArray[768];
};
const int JOINT_MATRIX_SIZE_ARR = 64;
const int JOINT_MATRIX_SIZE_DAWNTRAIL = 768;

struct CameraLight {
glm::vec4 m_DiffuseSpecular;
Expand Down Expand Up @@ -106,4 +101,4 @@ struct AmbientParameters {
// Dawntrail, unknown purpose
struct ShaderTypeParameter {
glm::vec4 m[2044];
};
};
5 changes: 3 additions & 2 deletions renderer/src/gamerenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,13 @@ void GameRenderer::render(VkCommandBuffer commandBuffer, Camera &camera, Scene &

// copy bone data
{
const size_t bufferSize = sizeof(glm::mat3x4) * 64;
const int jointMatrixSize = m_dawntrailMode ? JOINT_MATRIX_SIZE_DAWNTRAIL : JOINT_MATRIX_SIZE_ARR;
const size_t bufferSize = sizeof(glm::mat3x4) * jointMatrixSize;
void *mapped_data = nullptr;
vkMapMemory(m_device.device, model.boneInfoBuffer.memory, 0, bufferSize, 0, &mapped_data);

std::vector<glm::mat3x4> newBoneData(model.boneData.size());
for (int i = 0; i < 64; i++) {
for (int i = 0; i < jointMatrixSize; i++) {
newBoneData[i] = glm::transpose(model.boneData[i]);
}

Expand Down
2 changes: 1 addition & 1 deletion renderer/src/rendermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ void RenderManager::reloadDrawObject(DrawObject &DrawObject, uint32_t lod)
DrawObject.parts.push_back(renderPart);
}

const size_t bufferSize = sizeof(glm::mat4) * 128;
const size_t bufferSize = sizeof(glm::mat4) * JOINT_MATRIX_SIZE_DAWNTRAIL;
DrawObject.boneInfoBuffer = m_device->createBuffer(bufferSize, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT);
}

Expand Down

0 comments on commit a3f3437

Please sign in to comment.