Added color unpacking, still have really weird issues to iron out

This commit is contained in:
connellpaxton 2024-02-18 19:46:47 -05:00
parent 87fbb1c603
commit f2e78fbf76
7 changed files with 17 additions and 8 deletions

View File

@ -92,7 +92,7 @@ GraphicsPipeline::GraphicsPipeline(vk::Device dev, const std::vector<Shader>& 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,

View File

@ -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) {

View File

@ -147,7 +147,7 @@ namespace Q3BSP {
}, {
.location = 4,
.binding = binding,
.format = vk::Format::eR8G8B8A8Uint,
.format = vk::Format::eR32Uint,
.offset = offsetof(Vertex, color),
}
};

View File

@ -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;
}

Binary file not shown.

View File

@ -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);
}

Binary file not shown.