diff --git a/Renderer/Pipeline.cpp b/Renderer/Pipeline.cpp index c3c4e20..8b9bb42 100644 --- a/Renderer/Pipeline.cpp +++ b/Renderer/Pipeline.cpp @@ -92,7 +92,7 @@ GraphicsPipeline::GraphicsPipeline(vk::Device dev, const std::vector& sh const auto raster_info = vk::PipelineRasterizationStateCreateInfo { .depthClampEnable = vk::False, - .polygonMode = vk::PolygonMode::eLine, + .polygonMode = vk::PolygonMode::eFill, .cullMode = vk::CullModeFlagBits::eBack, .frontFace = vk::FrontFace::eCounterClockwise, .depthBiasEnable = vk::False, diff --git a/Scene/BSP.cpp b/Scene/BSP.cpp index 3be6f7d..0c04ae8 100644 --- a/Scene/BSP.cpp +++ b/Scene/BSP.cpp @@ -40,21 +40,16 @@ void BSP::load_indices(const glm::vec3& cam_pos) { visible_leafs.push_back(leaf); } - Log::debug("%zu visible leafs.\n", visible_leafs.size()); - for (const auto& leaf : visible_leafs) { -// Log::debug("Faces: %zu vs %zu\n", leaf.first_leaf_face_idx + leaf.n_leaf_faces, faces.size()); for (size_t i = 0; i < leaf.n_leaf_faces; i++) { auto idx = leaf_faces[leaf.first_leaf_face_idx + i].face_idx; if (present_faces.contains(idx)) continue; present_faces.insert(idx); -// Log::debug("Face idx: %zu (v.s. %zu)\n", idx, faces.size()); visible_faces.push_back(faces[idx]); } } - Log::debug("%zu visible faces.\n", visible_leafs.size()); for (auto& face : visible_faces) { switch (face.type) { diff --git a/Scene/BSP.hpp b/Scene/BSP.hpp index 8cffd8d..2541b67 100644 --- a/Scene/BSP.hpp +++ b/Scene/BSP.hpp @@ -147,7 +147,7 @@ namespace Q3BSP { }, { .location = 4, .binding = binding, - .format = vk::Format::eR8G8B8A8Uint, + .format = vk::Format::eR32Uint, .offset = offsetof(Vertex, color), } }; diff --git a/assets/shaders/bsp.frag b/assets/shaders/bsp.frag index 7d2d100..0d2766b 100644 --- a/assets/shaders/bsp.frag +++ b/assets/shaders/bsp.frag @@ -2,6 +2,7 @@ layout (location = 0) in vec3 norm; layout (location = 1) in vec2 texCoord; +layout (location = 2) in vec4 color; layout (location = 0) out vec4 FragColor; layout (set = 0, binding = 0) uniform Matrices { @@ -19,5 +20,5 @@ layout (set = 0, binding = 0) uniform Matrices { layout (set = 0, binding = 1) uniform sampler2D tex; void main() { - FragColor = vec4((abs(norm)*0.5+vec3(0.5)).r); + FragColor = color; } \ No newline at end of file diff --git a/assets/shaders/bsp.frag.spv b/assets/shaders/bsp.frag.spv index a3c305c..da67138 100644 Binary files a/assets/shaders/bsp.frag.spv and b/assets/shaders/bsp.frag.spv differ diff --git a/assets/shaders/bsp.vert b/assets/shaders/bsp.vert index ff973f1..4f93195 100644 --- a/assets/shaders/bsp.vert +++ b/assets/shaders/bsp.vert @@ -3,9 +3,11 @@ layout (location = 0) in vec3 aPos; layout (location = 1) in vec2 aTexCoord; layout (location = 2) in vec2 lightmapCoord; layout (location = 3) in vec3 aNorm; +layout (location = 4) in uint aColor; layout (location = 0) out vec3 norm; layout (location = 1) out vec2 texCoord; +layout (location = 2) out vec4 color; layout (set = 0, binding = 0) uniform Matrices { mat4 view; @@ -19,6 +21,16 @@ layout (set = 0, binding = 0) uniform Matrices { float tess_edge_size; }; +vec4 unpackABGR(uint packedABGR) { + float scale = 1.0 / 255.0; + float a = float((packedABGR >> 24) & 0xFF) * scale; + float b = float((packedABGR >> 16) & 0xFF) * scale; + float g = float((packedABGR >> 8) & 0xFF) * scale; + float r = float(packedABGR & 0xFF) * scale; + return vec4(r,g,b,a); +} + + void main() { mat4 zup_to_yup = mat4( 1.0, 0.0, 0.0, 0.0, @@ -30,4 +42,5 @@ void main() { gl_Position = proj * view * zup_to_yup * vec4(aPos, 1.0); texCoord = aTexCoord; norm = aNorm; + color = unpackABGR(aColor); } \ No newline at end of file diff --git a/assets/shaders/bsp.vert.spv b/assets/shaders/bsp.vert.spv index fb81d91..ff4549c 100644 Binary files a/assets/shaders/bsp.vert.spv and b/assets/shaders/bsp.vert.spv differ