Further shader compilation development.
This commit is contained in:
43
include/opengl/shading/features/combined_features.hpp
Normal file
43
include/opengl/shading/features/combined_features.hpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "opengl/shading/model_geometry.hpp"
|
||||
#include "mesh_features.hpp"
|
||||
#include "point_cloud_features.hpp"
|
||||
#include "generic_features.hpp"
|
||||
|
||||
namespace zgl::shading::features::combined
|
||||
{
|
||||
union type
|
||||
{
|
||||
features::mesh::flags mesh;
|
||||
features::point_cloud::flags point_cloud;
|
||||
|
||||
[[nodiscard]] features::generic::type to_generic(const model_geometry::types geometry) const noexcept
|
||||
{
|
||||
switch (geometry)
|
||||
{
|
||||
case model_geometry::types::mesh:
|
||||
return static_cast<features::generic::type>(mesh);
|
||||
case model_geometry::types::point_cloud:
|
||||
return static_cast<features::generic::type>(point_cloud);
|
||||
}
|
||||
std::unreachable();
|
||||
}
|
||||
|
||||
void from_generic(
|
||||
const model_geometry::types geometry,
|
||||
const features::generic::type new_features
|
||||
) noexcept {
|
||||
switch (geometry)
|
||||
{
|
||||
case model_geometry::types::mesh:
|
||||
mesh = static_cast<features::mesh::flags>(new_features);
|
||||
case model_geometry::types::point_cloud:
|
||||
point_cloud = static_cast<features::point_cloud::flags>(new_features);
|
||||
}
|
||||
std::unreachable();
|
||||
}
|
||||
};
|
||||
}
|
||||
12
include/opengl/shading/features/generic_features.hpp
Normal file
12
include/opengl/shading/features/generic_features.hpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "mesh_features.hpp"
|
||||
#include "point_cloud_features.hpp"
|
||||
|
||||
namespace zgl::shading::features::generic
|
||||
{
|
||||
using type = std::make_unsigned_t<std::common_type_t<
|
||||
std::underlying_type_t<features::mesh::flags>,
|
||||
std::underlying_type_t<features::point_cloud::flags>
|
||||
>>;
|
||||
}
|
||||
122
include/opengl/shading/features/mesh_features.hpp
Normal file
122
include/opengl/shading/features/mesh_features.hpp
Normal file
@@ -0,0 +1,122 @@
|
||||
#pragma once
|
||||
|
||||
#include "opengl/shading/attributes/mesh_attributes.hpp"
|
||||
#include "opengl/shading/uniforms/mesh_uniforms.hpp"
|
||||
#include "util/enum_bitfield_operators.hpp"
|
||||
#include <array>
|
||||
#include <string_view>
|
||||
|
||||
namespace zgl::shading::features::mesh
|
||||
{
|
||||
|
||||
struct type
|
||||
{
|
||||
attributes::mesh::flags attributes{
|
||||
attributes::mesh::flags::none
|
||||
};
|
||||
uniforms::mesh::flags uniforms{
|
||||
uniforms::mesh::flags::none
|
||||
};
|
||||
};
|
||||
|
||||
namespace indices
|
||||
{
|
||||
using type = ztu::u8;
|
||||
constexpr inline type face = 0;
|
||||
constexpr inline type line = 1;
|
||||
constexpr inline type point = 2;
|
||||
constexpr inline type luminance = 3;
|
||||
constexpr inline type color = 4;
|
||||
constexpr inline type alpha = 5;
|
||||
constexpr inline type lighting = 6;
|
||||
constexpr inline type texture = 7;
|
||||
constexpr inline type uniform_color = 8;
|
||||
}
|
||||
|
||||
enum class flags : std::uint16_t
|
||||
{
|
||||
none = 0,
|
||||
face = 1 << indices::face,
|
||||
line = 1 << indices::line,
|
||||
point = 1 << indices::point,
|
||||
luminance = 1 << indices::luminance,
|
||||
color = 1 << indices::color,
|
||||
alpha = 1 << indices::alpha,
|
||||
lighting = 1 << indices::lighting,
|
||||
texture = 1 << indices::texture,
|
||||
uniform_color = 1 << indices::uniform_color
|
||||
};
|
||||
|
||||
constexpr inline auto face = type{
|
||||
.attributes = attributes::mesh::flags::position,
|
||||
.uniforms = uniforms::mesh::flags::mvp_matrix
|
||||
};
|
||||
|
||||
constexpr inline auto line = type{
|
||||
.attributes = attributes::mesh::flags::position,
|
||||
.uniforms = uniforms::mesh::flags::mvp_matrix
|
||||
};
|
||||
|
||||
constexpr inline auto point = type{
|
||||
.attributes = attributes::mesh::flags::position,
|
||||
.uniforms = (
|
||||
uniforms::mesh::flags::mvp_matrix |
|
||||
uniforms::mesh::flags::point_size
|
||||
)
|
||||
};
|
||||
|
||||
constexpr inline auto luminance = type{
|
||||
.attributes = attributes::mesh::flags::luminance
|
||||
};
|
||||
|
||||
constexpr inline auto color = type{
|
||||
.attributes = attributes::mesh::flags::color
|
||||
};
|
||||
|
||||
constexpr inline auto alpha = type{
|
||||
.attributes = attributes::mesh::flags::alpha
|
||||
};
|
||||
|
||||
constexpr inline auto lighting = type{
|
||||
.attributes = attributes::mesh::flags::normal,
|
||||
.uniforms = (
|
||||
uniforms::mesh::flags::model_matrix |
|
||||
uniforms::mesh::flags::view_pos |
|
||||
uniforms::mesh::flags::point_light_direction |
|
||||
uniforms::mesh::flags::point_light_color |
|
||||
uniforms::mesh::flags::ambient_light_color |
|
||||
uniforms::mesh::flags::ambient_filter |
|
||||
uniforms::mesh::flags::diffuse_filter |
|
||||
uniforms::mesh::flags::specular_filter |
|
||||
uniforms::mesh::flags::shininess
|
||||
)
|
||||
};
|
||||
|
||||
constexpr inline auto texture = type{
|
||||
.attributes = attributes::mesh::flags::tex_coord,
|
||||
.uniforms = uniforms::mesh::flags::tex
|
||||
};
|
||||
|
||||
constexpr inline auto uniform_color = type{
|
||||
.uniforms = uniforms::mesh::flags::color
|
||||
};
|
||||
|
||||
constexpr inline auto all = std::array{
|
||||
face, line, point, luminance, color, alpha, lighting, texture, uniform_color
|
||||
};
|
||||
|
||||
constexpr inline auto names = std::array<std::string_view, 9>{
|
||||
"face",
|
||||
"line",
|
||||
"point",
|
||||
"luminance",
|
||||
"color",
|
||||
"alpha",
|
||||
"lighting",
|
||||
"texture",
|
||||
"uniform_color"
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
DEFINE_ENUM_BITFIELD_OPERATORS(zgl::shading::features::mesh::flags)
|
||||
101
include/opengl/shading/features/point_cloud_features.hpp
Normal file
101
include/opengl/shading/features/point_cloud_features.hpp
Normal file
@@ -0,0 +1,101 @@
|
||||
#pragma once
|
||||
|
||||
#include "opengl/shading/attributes/point_cloud_attributes.hpp"
|
||||
#include "opengl/shading/uniforms/point_cloud_uniforms.hpp"
|
||||
|
||||
#include "assets/components/mesh_vertex_components.hpp"
|
||||
#include "assets/components/point_cloud_vertex_components.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace zgl::shading::features::point_cloud
|
||||
{
|
||||
|
||||
struct type
|
||||
{
|
||||
attributes::point_cloud::flags attributes{
|
||||
attributes::point_cloud::flags::none
|
||||
};
|
||||
uniforms::point_cloud::flags uniforms{
|
||||
uniforms::point_cloud::flags::none
|
||||
};
|
||||
};
|
||||
|
||||
namespace indices
|
||||
{
|
||||
using type = ztu::u8;
|
||||
constexpr inline type square = 0;
|
||||
constexpr inline type lighting = 1;
|
||||
constexpr inline type luminance = 2;
|
||||
constexpr inline type color = 3;
|
||||
constexpr inline type alpha = 4;
|
||||
constexpr inline type uniform_color = 5;
|
||||
constexpr inline type rainbow = 6;
|
||||
}
|
||||
|
||||
enum class flags : std::uint8_t
|
||||
{
|
||||
none = 0,
|
||||
square = 1 << indices::square,
|
||||
lighting = 1 << indices::lighting,
|
||||
luminance = 1 << indices::luminance,
|
||||
color = 1 << indices::color,
|
||||
alpha = 1 << indices::alpha,
|
||||
uniform_color = 1 << indices::uniform_color,
|
||||
rainbow = 1 << indices::rainbow
|
||||
};
|
||||
|
||||
constexpr inline auto square = type{
|
||||
.attributes = attributes::point_cloud::flags::position,
|
||||
.uniforms = (
|
||||
uniforms::point_cloud::flags::mvp_matrix |
|
||||
uniforms::point_cloud::flags::point_size
|
||||
)
|
||||
};
|
||||
|
||||
constexpr inline auto lighting = type{
|
||||
.attributes = attributes::point_cloud::flags::normal,
|
||||
.uniforms = (
|
||||
uniforms::point_cloud::flags::model_matrix |
|
||||
uniforms::point_cloud::flags::camera_position
|
||||
)
|
||||
};
|
||||
|
||||
constexpr inline auto luminance = type{
|
||||
.attributes = attributes::point_cloud::flags::luminance
|
||||
};
|
||||
|
||||
constexpr inline auto color = type{
|
||||
.attributes = attributes::point_cloud::flags::color
|
||||
};
|
||||
|
||||
constexpr inline auto alpha = type{
|
||||
.attributes = attributes::point_cloud::flags::alpha
|
||||
};
|
||||
|
||||
constexpr inline auto uniform_color = type{
|
||||
.uniforms = uniforms::point_cloud::flags::color
|
||||
};
|
||||
|
||||
constexpr inline auto rainbow = type{
|
||||
.uniforms = (
|
||||
uniforms::point_cloud::flags::rainbow_offset_y |
|
||||
uniforms::point_cloud::flags::rainbow_scale_y
|
||||
)
|
||||
};
|
||||
|
||||
constexpr inline auto all = std::array{
|
||||
square, lighting, luminance, color, alpha, uniform_color, rainbow
|
||||
};
|
||||
|
||||
constexpr inline auto names = std::array{
|
||||
"square",
|
||||
"lighting",
|
||||
"luminance",
|
||||
"color",
|
||||
"alpha",
|
||||
"uniform_color",
|
||||
"rainbow"
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user