Code cleanup, shader renaming

This commit is contained in:
Sascha Willems 2020-05-23 20:38:28 +02:00
parent 85106a6bb2
commit 3e59ce8d57
5 changed files with 25 additions and 38 deletions

View file

@ -56,23 +56,16 @@ public:
vks::VulkanDevice* vulkanDevice; vks::VulkanDevice* vulkanDevice;
VkQueue copyQueue; VkQueue copyQueue;
struct Vertex { /*
glm::vec3 pos; Base glTF structures, see gltfscene sample for details
glm::vec3 normal; */
glm::vec2 uv;
glm::vec3 color;
// Contains indices of the joints that effect this vertex
glm::vec4 jointIndices;
// Contains the weights that define how strongly this vertex is affected by above joints
glm::vec4 jointWeights;
};
struct { struct Vertices {
VkBuffer buffer; VkBuffer buffer;
VkDeviceMemory memory; VkDeviceMemory memory;
} vertices; } vertices;
struct { struct Indices {
int count; int count;
VkBuffer buffer; VkBuffer buffer;
VkDeviceMemory memory; VkDeviceMemory memory;
@ -120,15 +113,28 @@ public:
glm::mat4 getLocalMatrix(); glm::mat4 getLocalMatrix();
}; };
// A skin contains the joints and matrices applied during vertex skinning struct Vertex {
// @todo: Add link to spec glm::vec3 pos;
glm::vec3 normal;
glm::vec2 uv;
glm::vec3 color;
// Contains indices of the joints that effect this vertex
glm::vec4 jointIndices;
// Contains the weights that define how strongly this vertex is affected by above joints
glm::vec4 jointWeights;
};
/*
Skin structure
Spec: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
*/
struct Skin { struct Skin {
std::string name; std::string name;
Node* skeletonRoot = nullptr; Node* skeletonRoot = nullptr;
std::vector<glm::mat4> inverseBindMatrices; std::vector<glm::mat4> inverseBindMatrices;
std::vector<Node*> joints; std::vector<Node*> joints;
// POI: Store joint matrices in an SSBO // The join matrices for this skin are stored in an shader storage buffer
// @todo: proper comment
std::vector<glm::mat4> jointMatrices; std::vector<glm::mat4> jointMatrices;
vks::Buffer ssbo; vks::Buffer ssbo;
VkDescriptorSet descriptorSet; VkDescriptorSet descriptorSet;
@ -136,29 +142,22 @@ public:
/* /*
glTF animation channel Animation related structures
// @todo: Comment Spec: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations
*/ */
struct AnimationChannel { struct AnimationChannel {
std::string path; std::string path;
Node* node; Node* node;
uint32_t samplerIndex; uint32_t samplerIndex;
}; };
/*
glTF animation sampler
// @todo: Comment
*/
struct AnimationSampler { struct AnimationSampler {
std::string interpolation; std::string interpolation;
std::vector<float> inputs; std::vector<float> inputs;
std::vector<glm::vec4> outputsVec4; std::vector<glm::vec4> outputsVec4;
}; };
/*
glTF animation
// @todo: Comment
*/
struct Animation { struct Animation {
std::string name; std::string name;
std::vector<AnimationSampler> samplers; std::vector<AnimationSampler> samplers;
@ -172,21 +171,9 @@ public:
std::vector<Texture> textures; std::vector<Texture> textures;
std::vector<Material> materials; std::vector<Material> materials;
std::vector<Node*> nodes; std::vector<Node*> nodes;
// Store skins and animations
std::vector<Skin> skins; std::vector<Skin> skins;
std::vector<Animation> animations; std::vector<Animation> animations;
// POI: @todo: document
struct MeshData {
glm::mat4 jointMatrix[32]{};
};
struct ShaderData {
vks::Buffer buffer;
} shaderData;
VkDescriptorSet descriptorSet;
std::vector<MeshData> meshdata;
uint32_t activeAnimation = 0; uint32_t activeAnimation = 0;
~VulkanglTFModel(); ~VulkanglTFModel();