Skip to content

Commit

Permalink
MAINT: remove distracting color values.
Browse files Browse the repository at this point in the history
  • Loading branch information
oddkiva committed Dec 9, 2023
1 parent 849ea3b commit ecae0c0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 25 deletions.
15 changes: 4 additions & 11 deletions cpp/examples/Shakti/Vulkan/hello_vulkan_image/Geometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
struct Vertex
{
Eigen::Vector2f pos;
Eigen::Vector3f color;
Eigen::Vector2f uv;

static auto get_binding_description() -> VkVertexInputBindingDescription
Expand All @@ -38,25 +37,19 @@ struct Vertex
-> std::vector<VkVertexInputAttributeDescription>
{
auto attribute_descriptions =
std::vector<VkVertexInputAttributeDescription>(3);
std::vector<VkVertexInputAttributeDescription>(2);

// Position
attribute_descriptions[0].binding = 0;
attribute_descriptions[0].location = 0;
attribute_descriptions[0].format = VK_FORMAT_R32G32_SFLOAT;
attribute_descriptions[0].offset = offsetof(Vertex, pos);

// Color
// UV texture coords
attribute_descriptions[1].binding = 0;
attribute_descriptions[1].location = 1;
attribute_descriptions[1].format = VK_FORMAT_R32G32B32_SFLOAT;
attribute_descriptions[1].offset = offsetof(Vertex, color);

// UV texture coords
attribute_descriptions[2].binding = 0;
attribute_descriptions[2].location = 2;
attribute_descriptions[2].format = VK_FORMAT_R32G32_SFLOAT;
attribute_descriptions[2].offset = offsetof(Vertex, uv);
attribute_descriptions[1].format = VK_FORMAT_R32G32_SFLOAT;
attribute_descriptions[1].offset = offsetof(Vertex, uv);

return attribute_descriptions;
}
Expand Down
12 changes: 6 additions & 6 deletions cpp/examples/Shakti/Vulkan/hello_vulkan_image/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ namespace fs = std::filesystem;
//! @brief The 4 vertices of the square.
// clang-format off
static auto vertices = std::vector<Vertex>{
{.pos = {-0.5f, -0.5f}, .color = {1.0f, 0.0f, 0.0f}, .uv = {0.f, 0.f}},
{.pos = { 0.5f, -0.5f}, .color = {0.0f, 1.0f, 0.0f}, .uv = {1.f, 0.f}},
{.pos = { 0.5f, 0.5f}, .color = {0.0f, 0.0f, 1.0f}, .uv = {1.f, 1.f}},
{.pos = {-0.5f, 0.5f}, .color = {1.0f, 1.0f, 1.0f}, .uv = {0.f, 1.f}}
{.pos = {-0.5f, -0.5f}, .uv = {0.f, 0.f}},
{.pos = { 0.5f, -0.5f}, .uv = {1.f, 0.f}},
{.pos = { 0.5f, 0.5f}, .uv = {1.f, 1.f}},
{.pos = {-0.5f, 0.5f}, .uv = {0.f, 1.f}}
};
// clang-format on

Expand Down Expand Up @@ -934,7 +934,7 @@ auto main(int argc, char** argv) -> int

if (argc < 2)
{
std::cerr << "PROGRAM USAGE: " << argv[0] << " VIDEO_PATH\n";
std::cerr << "USAGE: " << argv[0] << " VIDEO_PATH\n";
return 0;
}

Expand All @@ -948,7 +948,7 @@ auto main(int argc, char** argv) -> int

const auto program_dir_path = fs::absolute(fs::path(argv[0])).parent_path();
const auto video_path = fs::path(argv[1]);
static constexpr auto debug = false;
static constexpr auto debug = true;
auto triangle_renderer = VulkanImageRenderer{
window, //
app_name, //
Expand Down
5 changes: 2 additions & 3 deletions cpp/examples/Shakti/Vulkan/hello_vulkan_image/shader.frag
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@

layout(binding = 1) uniform sampler2D image;

layout(location = 0) in vec3 frag_color;
layout(location = 1) in vec2 tex_coords;
layout(location = 0) in vec2 tex_coords;

layout(location = 0) out vec4 out_color;

void main() {
out_color = vec4(frag_color, 1.0) * texture(image, tex_coords);
out_color = texture(image, tex_coords);
}
7 changes: 2 additions & 5 deletions cpp/examples/Shakti/Vulkan/hello_vulkan_image/shader.vert
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@ layout(set = 0, binding = 0) uniform ModelViewProjection {

// Vertex data.
layout(location = 0) in vec2 in_position;
layout(location = 1) in vec3 in_color;
layout(location = 2) in vec2 in_tex_coords;
layout(location = 1) in vec2 in_tex_coords;

// Forwarded data to the fragment shader.
layout(location = 0) out vec3 frag_color;
layout(location = 1) out vec2 tex_coords;
layout(location = 0) out vec2 tex_coords;

void main() {
gl_Position = mvp.projection * mvp.view * mvp.model * vec4(in_position, 0.0, 1.0);
frag_color = in_color;
tex_coords = in_tex_coords;
}

0 comments on commit ecae0c0

Please sign in to comment.