Fix dragon UV's to allow it to run without crashing
This commit is contained in:
parent
57496aea2c
commit
6e8e75d5b3
BIN
assets/textures/checkermap.png
Normal file
BIN
assets/textures/checkermap.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.0 MiB |
@ -44,8 +44,8 @@ namespace Global {
|
||||
extern VkImageView depthImageView;
|
||||
extern VkImage depthImage;
|
||||
extern VkDeviceMemory depthImageMemory;
|
||||
const std::string MODEL_PATH = "assets/models/viking_room.obj";
|
||||
const std::string TEXTURE_PATH = "assets/textures/viking_room.png";
|
||||
const std::string MODEL_PATH = "assets/models/StanfordDragon800k.obj";
|
||||
const std::string TEXTURE_PATH = "assets/textures/checkermap.png";
|
||||
|
||||
|
||||
|
||||
@ -95,7 +95,7 @@ namespace Global {
|
||||
};
|
||||
|
||||
const uint32_t WIDTH = 800;
|
||||
const uint32_t HEIGHT = 800;
|
||||
const uint32_t HEIGHT = 600;
|
||||
extern std::vector<Vertex> vertices;
|
||||
// Index buffer definition, showing which points to reuse.
|
||||
extern std::vector<uint32_t> indices;
|
||||
|
@ -203,7 +203,7 @@ namespace buffers_libs {
|
||||
ubo.model = glm::rotate(glm::mat4(1.0f), time * glm::radians(30.0f), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
// Modify the view transformation to look at the object from above at a 45 degree angle.
|
||||
// This takes the eye position, center position, and the up direction.
|
||||
ubo.view = glm::lookAt(glm::vec3(2.0f, 2.0f, 2.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
ubo.view = glm::lookAt(glm::vec3(2.0f, 2.0f, 3.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
// 45 degree field of view, set aspect ratio, and near and far clipping range.
|
||||
ubo.proj = glm::perspective(glm::radians(45.0f), device_libs::DeviceControl::getSwapChainExtent().width / (float) device_libs::DeviceControl::getSwapChainExtent().height, 0.1f, 10.0f);
|
||||
|
||||
|
@ -94,7 +94,7 @@ namespace graphics_pipeline {
|
||||
rasterizer.polygonMode = VK_POLYGON_MODE_FILL;
|
||||
rasterizer.lineWidth = 1.0f;
|
||||
// How to cull the faces, right here we cull the back faces and tell the rasterizer front facing vertices are ordered clockwise.
|
||||
rasterizer.cullMode = VK_CULL_MODE_BACK_BIT;
|
||||
rasterizer.cullMode = VK_CULL_MODE_NONE;
|
||||
rasterizer.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE;
|
||||
// Whether or not to add depth values. e.x. for shadow maps.
|
||||
rasterizer.depthBiasEnable = VK_FALSE;
|
||||
|
@ -30,7 +30,7 @@ namespace modellib {
|
||||
|
||||
auto& attrib = reader.GetAttrib();
|
||||
auto& shapes = reader.GetShapes();
|
||||
//auto& materials = reader.GetMaterials();
|
||||
auto& materials = reader.GetMaterials();
|
||||
|
||||
for (const auto& shape : shapes) {
|
||||
for (const auto& index : shape.mesh.indices) {
|
||||
@ -42,7 +42,10 @@ namespace modellib {
|
||||
attrib.vertices[3 * index.vertex_index + 2]
|
||||
};
|
||||
|
||||
//TODO: Major fix here, running anything but the viking room OBJ crashes on texcoord assignment!
|
||||
//TODO: Small fix here, handle if there are no UV's unwrapped for the model.
|
||||
// As of now, if it is not unwrapped, it segfaults on texCoord assignment.
|
||||
// Obviously we should always have UV's, but it shouldn't crash, just unwrap
|
||||
// in a default method.
|
||||
vertex.texCoord = {
|
||||
attrib.texcoords[2 * index.texcoord_index + 0],
|
||||
1.0f - attrib.texcoords[2 * index.texcoord_index + 1]
|
||||
|
Loading…
Reference in New Issue
Block a user