From d63513ec140ff04ad9d8b7830266976c8430eae1 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 17 Apr 2019 20:42:00 +0200 Subject: [PATCH] - fix normal vectors on models --- src/rendering/vulkan/renderer/vk_renderpass.cpp | 8 +++++--- src/rendering/vulkan/renderer/vk_renderpass.h | 2 +- wadsrc/static/shaders/glsl/main.vp | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/rendering/vulkan/renderer/vk_renderpass.cpp b/src/rendering/vulkan/renderer/vk_renderpass.cpp index 53940d0447..111c1dc20e 100644 --- a/src/rendering/vulkan/renderer/vk_renderpass.cpp +++ b/src/rendering/vulkan/renderer/vk_renderpass.cpp @@ -71,11 +71,13 @@ int VkRenderPassManager::GetVertexFormat(int numBindingPoints, int numAttributes VkVertexFormat fmt; fmt.NumBindingPoints = numBindingPoints; fmt.Stride = stride; - fmt.UseVertexData = false; + fmt.UseVertexData = 0; for (int j = 0; j < numAttributes; j++) { if (attrs[j].location == VATTR_COLOR) - fmt.UseVertexData = true; + fmt.UseVertexData |= 1; + else if (attrs[j].location == VATTR_NORMAL) + fmt.UseVertexData |= 2; fmt.Attrs.push_back(attrs[j]); } VertexFormats.push_back(fmt); @@ -264,7 +266,7 @@ void VkRenderPassSetup::CreatePipeline(const VkRenderPassKey &key) VK_FORMAT_R32G32_SFLOAT, VK_FORMAT_R32_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, - VK_FORMAT_A2R10G10B10_SNORM_PACK32 + VK_FORMAT_A2B10G10R10_SNORM_PACK32 }; bool inputLocations[6] = { false, false, false, false, false, false }; diff --git a/src/rendering/vulkan/renderer/vk_renderpass.h b/src/rendering/vulkan/renderer/vk_renderpass.h index e8232dadfe..0294c93c39 100644 --- a/src/rendering/vulkan/renderer/vk_renderpass.h +++ b/src/rendering/vulkan/renderer/vk_renderpass.h @@ -60,7 +60,7 @@ public: int NumBindingPoints; size_t Stride; std::vector Attrs; - bool UseVertexData; + int UseVertexData; }; class VkRenderPassManager diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index f8de93ba06..86da9868a9 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -42,7 +42,7 @@ void main() vec4 eyeCoordPos = ViewMatrix * worldcoord; #ifdef HAS_UNIFORM_VERTEX_DATA - if (useVertexData == 0) + if ((useVertexData & 1) == 0) vColor = uVertexColor; else vColor = aColor; @@ -79,7 +79,7 @@ void main() } #ifdef HAS_UNIFORM_VERTEX_DATA - if (useVertexData == 0) + if ((useVertexData & 2) == 0) vWorldNormal = NormalModelMatrix * vec4(uVertexNormal.xyz, 1.0); else vWorldNormal = NormalModelMatrix * vec4(normalize(mix(aNormal.xyz, aNormal2.xyz, uInterpolationFactor)), 1.0);