Further shader compilation development.
This commit is contained in:
@@ -7,34 +7,21 @@
|
||||
|
||||
namespace zgl
|
||||
{
|
||||
class shader_data
|
||||
struct shader_data
|
||||
{
|
||||
private:
|
||||
explicit shader_data(GLuint shader_id, GLenum type);
|
||||
|
||||
public:
|
||||
|
||||
shader_data() = default;
|
||||
|
||||
[[nodiscard]] static std::error_code build_from(
|
||||
GLenum type,
|
||||
const std::string& source,
|
||||
shader_data& data
|
||||
);
|
||||
inline shader_data(GLuint id);
|
||||
|
||||
shader_data(const shader_data& other) = delete;
|
||||
shader_data& operator=(const shader_data& other) = delete;
|
||||
|
||||
shader_data(shader_data&& other) noexcept;
|
||||
shader_data& operator=(shader_data&& other) noexcept;
|
||||
inline shader_data(shader_data&& other) noexcept;
|
||||
inline shader_data& operator=(shader_data&& other) noexcept;
|
||||
|
||||
[[nodiscard]] shader_handle handle() const;
|
||||
inline ~shader_data();
|
||||
|
||||
~shader_data();
|
||||
|
||||
private:
|
||||
shader_handle m_handle{};
|
||||
GLenum m_type{ GL_INVALID_ENUM };
|
||||
shader_handle handle{};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -9,195 +9,60 @@
|
||||
#include "assets/dynamic_data_stores/dynamic_shader_source_store.hpp"
|
||||
#include "opengl/shader_program_lookup.hpp"
|
||||
#include "opengl/handles/shader_handle.hpp"
|
||||
#include "opengl/handles/shader_program_handle.hpp"
|
||||
#include "shader_program/metadata_type.hpp"
|
||||
#include "shader_program/features/mesh_features.hpp"
|
||||
#include "shader_program/features/point_cloud_features.hpp"
|
||||
#include "util/string_lookup.hpp"
|
||||
#include "shader_program/metadata_type.hpp"
|
||||
#include "shader_preprocessor.hpp"
|
||||
#include "opengl/metadata/shader_metadata.hpp"
|
||||
#include "opengl/data/shader_data.hpp"
|
||||
#include "opengl/handles/shader_handle_set.hpp"
|
||||
#include "opengl/shading/requirements/shader_requirements.hpp"
|
||||
#include "opengl/metadata/shader_set_metadata.hpp"
|
||||
#include "opengl/shading/requirements/shader_set_requirements.hpp"
|
||||
|
||||
namespace zgl
|
||||
{
|
||||
class shader_program_compiler
|
||||
{
|
||||
using shader_lookup_entry_type = std::pair<shader_metadata, shader_data>;
|
||||
|
||||
static constexpr auto gl_shader_types = std::array<GLenum, shading::stage::count>{
|
||||
GL_VERTEX_SHADER,
|
||||
GL_TESS_CONTROL_SHADER,
|
||||
GL_TESS_EVALUATION_SHADER,
|
||||
GL_GEOMETRY_SHADER,
|
||||
GL_FRAGMENT_SHADER
|
||||
};
|
||||
|
||||
|
||||
public:
|
||||
|
||||
void register_shader_sources(
|
||||
void preprocess(
|
||||
const dynamic_shader_source_store& shader_sources
|
||||
);
|
||||
|
||||
void compile_shaders(
|
||||
const dynamic_shader_source_store& shader_sources,
|
||||
std::span<const shader_program::metadata_type> required_capabilities,
|
||||
std::vector<shader_handle>& shader_handles
|
||||
std::span<const shading::shader_set_requirements> requirements,
|
||||
std::span<shader_set_metadata> metadata,
|
||||
std::span<shader_handle_set> shader_sets
|
||||
);
|
||||
|
||||
|
||||
protected:
|
||||
void tokenize_declarations(
|
||||
std::string_view source,
|
||||
std::vector<std::string_view> tokens,
|
||||
std::vector<std::size_t> declaration_token_counts,
|
||||
std::span<std::size_t> declaration_type_indices
|
||||
shader_handle find_shader(
|
||||
const shading::shader_requirements& requirements
|
||||
);
|
||||
|
||||
std::optional<shader_program::metadata_type> parse_metadata_from_tokens(
|
||||
std::span<const std::string_view> tokens,
|
||||
std::span<const std::size_t> declaration_token_counts,
|
||||
std::span<const std::size_t> declaration_type_indices
|
||||
);
|
||||
|
||||
[[nodiscard]] static bool parse_stage_declaration(
|
||||
std::span<const std::string_view> tokens,
|
||||
shader_program::metadata_type& metadata
|
||||
);
|
||||
|
||||
[[nodiscard]] static bool parse_geometry_declaration(
|
||||
std::span<const std::string_view> tokens,
|
||||
shader_program::metadata_type& metadata
|
||||
);
|
||||
|
||||
[[nodiscard]] static bool parse_features_declaration(
|
||||
std::span<const std::string_view> tokens,
|
||||
shader_program::metadata_type& metadata
|
||||
);
|
||||
|
||||
[[nodiscard]] static bool parse_static_enable_declaration(
|
||||
std::span<const std::string_view> tokens,
|
||||
shader_program::metadata_type& metadata
|
||||
);
|
||||
|
||||
[[nodiscard]] static bool parse_dynamic_enable_declaration(
|
||||
std::span<const std::string_view> tokens,
|
||||
shader_program::metadata_type& metadata
|
||||
);
|
||||
|
||||
template<typename T>
|
||||
static void parse_feature_tokens(
|
||||
std::span<const std::string_view> tokens,
|
||||
const ztu::string_lookup<T>& feature_lookup,
|
||||
T& features
|
||||
);
|
||||
|
||||
std::optional<dynamic_shader_source_store::id_type> zgl::shader_program_compiler::find_compatible_shader_source(
|
||||
shader_program::metadata_type& requirements
|
||||
);
|
||||
|
||||
template<typename T>
|
||||
void add_required_feature_defines(
|
||||
T toggle_flags,
|
||||
std::span<const std::string> defines,
|
||||
std::vector<const char*>& shader_strings
|
||||
bool compile_shader(
|
||||
GLenum shader_type,
|
||||
std::span<const char*> source_strings,
|
||||
shader_data& shader
|
||||
);
|
||||
|
||||
private:
|
||||
enum class metadata_declaration_type : std::size_t
|
||||
{
|
||||
stage = 0,
|
||||
geometry = 1,
|
||||
features = 2,
|
||||
static_enable = 3,
|
||||
dynamic_enable = 4,
|
||||
invalid = std::numeric_limits<std::size_t>::max()
|
||||
};
|
||||
shader_preprocessor m_preprocessor{};
|
||||
|
||||
inline static auto declaration_lookup = ztu::string_lookup<metadata_declaration_type>{
|
||||
{ "STAGE", metadata_declaration_type::stage },
|
||||
{ "GEOMETRY", metadata_declaration_type::geometry },
|
||||
{ "FEATURES", metadata_declaration_type::features },
|
||||
{ "STATIC_ENABLE", metadata_declaration_type::static_enable }
|
||||
{ "DYNAMIC_ENABLE", metadata_declaration_type::dynamic_enable }
|
||||
};
|
||||
|
||||
inline static auto stage_lookup = ztu::string_lookup<shader_program::stage::types>{
|
||||
{ "VERTEX", shader_program::stage::types::vertex },
|
||||
{ "GEOMETRY", shader_program::stage::types::geometry },
|
||||
{ "FRAGMENT", shader_program::stage::types::fragment },
|
||||
};
|
||||
|
||||
inline static auto geometry_lookup = ztu::string_lookup<shader_program::geometry::types>{
|
||||
{ "MESH", shader_program::geometry::types::mesh },
|
||||
{ "POINT_CLOUD", shader_program::geometry::types::point_cloud }
|
||||
};
|
||||
|
||||
inline static auto mesh_feature_lookup = []
|
||||
{
|
||||
using namespace shader_program::features::mesh;
|
||||
|
||||
auto lookup = ztu::string_lookup<flags>{};
|
||||
lookup.reserve(all.size());
|
||||
|
||||
constexpr auto all_flags = std::array{
|
||||
flags::face, flags::line, flags::point,
|
||||
flags::luminance, flags::color, flags::alpha,
|
||||
flags::lighting, flags::texture, flags::uniform_color
|
||||
};
|
||||
|
||||
for (const auto& [ define, flag ] : std::ranges::views::zip(defines, all_flags))
|
||||
{
|
||||
lookup.emplace(std::string(define), flag);
|
||||
}
|
||||
|
||||
return lookup;
|
||||
}();
|
||||
|
||||
inline static auto point_cloud_feature_lookup = []
|
||||
{
|
||||
using namespace shader_program::features::point_cloud;
|
||||
|
||||
auto lookup = ztu::string_lookup<flags>{};
|
||||
lookup.reserve(all.size());
|
||||
|
||||
constexpr auto all_flags = std::array{
|
||||
flags::square, flags::lighting, flags::luminance,
|
||||
flags::color, flags::alpha, flags::uniform_color,
|
||||
flags::rainbow
|
||||
};
|
||||
|
||||
for (const auto& [ define, flag ] : std::ranges::views::zip(defines, all_flags))
|
||||
{
|
||||
lookup.emplace(std::string(define), flag);
|
||||
}
|
||||
|
||||
return lookup;
|
||||
}();
|
||||
|
||||
inline static auto mesh_feature_defines = []
|
||||
{
|
||||
using namespace shader_program::features::mesh;
|
||||
|
||||
auto statements = std::array<std::string, all.size()>{};
|
||||
|
||||
std::ranges::transform(
|
||||
defines,
|
||||
statements.begin(),
|
||||
[](const auto& name) {
|
||||
return std::format("#define {}\n", name);
|
||||
}
|
||||
);
|
||||
|
||||
return statements;
|
||||
}();
|
||||
|
||||
inline static auto point_cloud_feature_defines = []
|
||||
{
|
||||
using namespace shader_program::features::point_cloud;
|
||||
|
||||
auto statements = std::array<std::string, all.size()>{};
|
||||
|
||||
std::ranges::transform(
|
||||
defines,
|
||||
statements.begin(),
|
||||
[](const auto& name) {
|
||||
return std::format("#define {}\n", name);
|
||||
}
|
||||
);
|
||||
|
||||
return statements;
|
||||
}();
|
||||
|
||||
|
||||
std::vector<std::pair<shader_program::metadata_type, dynamic_shader_source_store::id_type>> shader_lookup;
|
||||
std::vector<shading::shader_source_requirements> m_source_requirement_buffer{};
|
||||
std::vector<preprocessed_shader_source_metadata> m_preprocessed_shader_source_metadata_buffer;
|
||||
std::vector<const char*> m_source_strings_buffer;
|
||||
std::vector<shader_lookup_entry_type> m_shader_lookup;
|
||||
};
|
||||
}
|
||||
|
||||
110
include/opengl/data_uploaders/shader_preprocessor.hpp
Normal file
110
include/opengl/data_uploaders/shader_preprocessor.hpp
Normal file
@@ -0,0 +1,110 @@
|
||||
#pragma once
|
||||
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include "util/string_lookup.hpp"
|
||||
|
||||
#include "../metadata/shader_source_metadata.hpp"
|
||||
#include "opengl/shading/requirements/shader_source_requirements.hpp"
|
||||
#include "opengl/metadata/preprocessed_shader_source_metadata.hpp"
|
||||
|
||||
#include "assets/dynamic_data_stores/dynamic_shader_source_store.hpp"
|
||||
#include "opengl/shading/shader_source_set.hpp"
|
||||
|
||||
namespace zgl {
|
||||
|
||||
class shader_preprocessor {
|
||||
|
||||
public:
|
||||
void preprocess(
|
||||
const dynamic_shader_source_store& shader_sources
|
||||
);
|
||||
|
||||
void fetch_shader_sources(
|
||||
const dynamic_shader_source_store& shader_sources,
|
||||
std::span<const shading::shader_source_requirements> requirements,
|
||||
std::span<preprocessed_shader_source_metadata> metadata,
|
||||
std::vector<const char*>& shader_strings
|
||||
);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
void tokenize_declarations(std::string_view source);
|
||||
|
||||
std::optional<shader_source_metadata> parse_metadata_from_tokens();
|
||||
|
||||
[[nodiscard]] static bool parse_stage_declaration(
|
||||
std::span<const std::string_view> values,
|
||||
shader_source_metadata& metadata
|
||||
);
|
||||
|
||||
[[nodiscard]] static bool parse_geometry_declaration(
|
||||
std::span<const std::string_view> tokens,
|
||||
shader_source_metadata& metadata
|
||||
);
|
||||
|
||||
[[nodiscard]] static bool parse_features_declaration(
|
||||
std::span<const std::string_view> values,
|
||||
shader_source_metadata& metadata
|
||||
);
|
||||
|
||||
[[nodiscard]] static bool parse_static_enable_declaration(
|
||||
std::span<const std::string_view> values,
|
||||
shader_source_metadata& metadata
|
||||
);
|
||||
|
||||
[[nodiscard]] static bool parse_dynamic_enable_declaration(
|
||||
std::span<const std::string_view> values,
|
||||
shader_source_metadata& metadata
|
||||
);
|
||||
|
||||
template<typename T>
|
||||
static void parse_feature_tokens(
|
||||
std::span<const std::string_view> values,
|
||||
const ztu::string_lookup<T>& feature_lookup,
|
||||
T& features
|
||||
);
|
||||
|
||||
static void get_define_strings(
|
||||
shading::model_geometry::types geometry,
|
||||
shading::features::generic::type features,
|
||||
shading::features::generic::type& feature_count,
|
||||
std::vector<const char*>& defines
|
||||
);
|
||||
|
||||
private:
|
||||
inline static auto mesh_feature_defines = std::array{
|
||||
"#define FACE\n",
|
||||
"#define LINE\n",
|
||||
"#define POINT\n",
|
||||
"#define V_L\n",
|
||||
"#define V_RGB\n",
|
||||
"#define V_A\n",
|
||||
"#define LIGHTING\n",
|
||||
"#define TEXTURE\n",
|
||||
"#define U_RGBA\n",
|
||||
};
|
||||
|
||||
inline static auto point_cloud_feature_defines = std::array{
|
||||
"#define SQUARE\n",
|
||||
"#define LIGHTING\n",
|
||||
"#define V_L\n",
|
||||
"#define V_RGB\n",
|
||||
"#define V_A\n",
|
||||
"#define U_RGBA\n",
|
||||
"#define RAINBOW\n"
|
||||
};
|
||||
|
||||
std::vector<std::string_view> m_value_token_buffer;
|
||||
std::vector<std::size_t> m_declaration_token_count_buffer;
|
||||
std::array<std::size_t, 4> m_declaration_type_index_buffer;
|
||||
|
||||
using source_lookup_entry_type = std::pair<shader_source_metadata, dynamic_shader_source_store::id_type>;
|
||||
using source_lookup_type = std::vector<source_lookup_entry_type>;
|
||||
|
||||
source_lookup_type m_shader_source_lookup;
|
||||
};
|
||||
}
|
||||
@@ -3,13 +3,18 @@
|
||||
#include <unordered_map>
|
||||
#include "assets/dynamic_data_stores/dynamic_shader_source_store.hpp"
|
||||
#include "opengl/shader_program_lookup.hpp"
|
||||
#include "opengl/handles/shader_handle.hpp"
|
||||
#include "opengl/handles/shader_program_handle.hpp"
|
||||
#include "../metadata/shader_source_metadata.hpp"
|
||||
#include "shading/shader_program_requirements.hpp"
|
||||
|
||||
namespace zgl
|
||||
{
|
||||
|
||||
template<typename Capabilities>
|
||||
class shader_program_compiler
|
||||
{
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
|
||||
// compile shader programs for given requirements
|
||||
@@ -22,21 +27,24 @@ class shader_program_compiler
|
||||
const dynamic_shader_source_store& shader_sources
|
||||
);
|
||||
|
||||
void compile_shaders(
|
||||
void compile_shader_programs(
|
||||
const dynamic_shader_source_store& shader_sources,
|
||||
std::span<const shader_program::metadata_type> required_capabilities,
|
||||
std::vector<shader_handle>& shader_handles
|
||||
std::span<const shading::shader_program_metadata> requirements,
|
||||
std::vector<shader_program_handle>& shader_handles
|
||||
);
|
||||
|
||||
// create metadata for all sources
|
||||
|
||||
// get
|
||||
|
||||
ś
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
private:
|
||||
std::unordered_map<dynamic_shader_source_store::id_type, Capabilities> shader_capabilities;
|
||||
std::vector<shading::compiled_shader_metadata_type, shader_handle> shader_lookup;
|
||||
std::vector<shading::shader_program_metadata, shader_program_handle> shader_program_lookup;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
@@ -8,6 +8,11 @@ struct shader_handle
|
||||
{
|
||||
constexpr bool operator==(const shader_handle&) const = default;
|
||||
|
||||
GLuint shader_id{ 0 };
|
||||
constexpr bool valid() const
|
||||
{
|
||||
return id != 0;
|
||||
}
|
||||
|
||||
GLuint id{ 0 };
|
||||
};
|
||||
}
|
||||
13
include/opengl/handles/shader_handle_set.hpp
Normal file
13
include/opengl/handles/shader_handle_set.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include "shader_handle.hpp"
|
||||
#include "opengl/shading/shader_stage.hpp"
|
||||
|
||||
namespace zgl
|
||||
{
|
||||
|
||||
struct shader_handle_set
|
||||
{
|
||||
std::array<shader_handle, zgl::shading::stage::count> stages;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "opengl/shading/features/generic_features.hpp"
|
||||
|
||||
namespace zgl
|
||||
{
|
||||
struct preprocessed_shader_source_metadata
|
||||
{
|
||||
shading::features::generic::type static_enabled{};
|
||||
shading::features::generic::type dynamic_enable{};
|
||||
shading::features::generic::type string_count{};
|
||||
};
|
||||
}
|
||||
16
include/opengl/metadata/shader_metadata.hpp
Normal file
16
include/opengl/metadata/shader_metadata.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "opengl/shading/model_geometry.hpp"
|
||||
#include "opengl/shading/shader_stage.hpp"
|
||||
#include "opengl/shading/features/generic_features.hpp"
|
||||
|
||||
namespace zgl
|
||||
{
|
||||
struct shader_metadata
|
||||
{
|
||||
shading::model_geometry::types geometry;
|
||||
shading::stage::types stage;
|
||||
shading::features::generic::type static_enabled{};
|
||||
shading::features::generic::type dynamic_enable{};
|
||||
};
|
||||
}
|
||||
14
include/opengl/metadata/shader_set_metadata.hpp
Normal file
14
include/opengl/metadata/shader_set_metadata.hpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "opengl/shading/model_geometry.hpp"
|
||||
#include "opengl/shading/shader_stage.hpp"
|
||||
#include "opengl/shading/features/generic_features.hpp"
|
||||
|
||||
namespace zgl
|
||||
{
|
||||
struct shader_set_metadata
|
||||
{
|
||||
shading::features::generic::type static_enabled{};
|
||||
shading::features::generic::type dynamic_enable{};
|
||||
};
|
||||
}
|
||||
91
include/opengl/metadata/shader_source_metadata.hpp
Normal file
91
include/opengl/metadata/shader_source_metadata.hpp
Normal file
@@ -0,0 +1,91 @@
|
||||
#pragma once
|
||||
|
||||
#include <limits>
|
||||
#include <utility>
|
||||
|
||||
#include "../shading/model_geometry.hpp"
|
||||
#include "../shading/shader_stage.hpp"
|
||||
#include "../shading/features/mesh_features.hpp"
|
||||
#include "../shading/features/point_cloud_features.hpp"
|
||||
#include "../shading/features/generic_features.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
// TODO move implementation to .ipp file
|
||||
namespace zgl
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
struct shader_features_set
|
||||
{
|
||||
T features, static_enable, dynamic_enable;
|
||||
|
||||
template<typename U>
|
||||
[[nodiscard]] shader_features_set<U> cast() const noexcept
|
||||
{
|
||||
return {
|
||||
.features = static_cast<U>(features),
|
||||
.static_enable = static_cast<U>(static_enable),
|
||||
.dynamic_enable = static_cast<U>(dynamic_enable)
|
||||
};
|
||||
}
|
||||
|
||||
// TODO this may not compile
|
||||
[[nodiscard]] bool operator==(const shader_features_set& other) const noexcept = default;
|
||||
};
|
||||
|
||||
|
||||
struct shader_source_metadata
|
||||
{
|
||||
union combined_feature_set_type {
|
||||
shader_features_set<shading::features::mesh::flags> mesh;
|
||||
shader_features_set<shading::features::point_cloud::flags> point_cloud;
|
||||
};
|
||||
|
||||
using generic_feature_set_type = shader_features_set<shading::features::generic::type>;
|
||||
|
||||
shading::model_geometry::types geometry;
|
||||
combined_feature_set_type feature_set;
|
||||
shading::stage::types stage;
|
||||
|
||||
[[nodiscard]] generic_feature_set_type generic_feature_set() const noexcept
|
||||
{
|
||||
switch (geometry)
|
||||
{
|
||||
case shading::model_geometry::types::mesh:
|
||||
return feature_set.mesh.cast<shading::features::generic::type>();
|
||||
case shading::model_geometry::types::point_cloud:
|
||||
return feature_set.point_cloud.cast<shading::features::generic::type>();
|
||||
default:
|
||||
std::unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
void from_generic_feature_set(const generic_feature_set_type& generic_feature_set) noexcept
|
||||
{
|
||||
switch (geometry)
|
||||
{
|
||||
case shading::model_geometry::types::mesh:
|
||||
feature_set.mesh = generic_feature_set.cast<shading::features::mesh::flags>();
|
||||
case shading::model_geometry::types::point_cloud:
|
||||
feature_set.point_cloud = generic_feature_set.cast<shading::features::point_cloud::flags>();
|
||||
}
|
||||
std::unreachable();
|
||||
}
|
||||
|
||||
bool operator==(const shader_source_metadata& other) const noexcept
|
||||
{
|
||||
if (this->stage != other.stage)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this->geometry != other.geometry)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return this->generic_feature_set() == other.generic_feature_set();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
45
include/opengl/shading/attributes/mesh_attributes.hpp
Normal file
45
include/opengl/shading/attributes/mesh_attributes.hpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
|
||||
#include "opengl/shader_program_variable.hpp"
|
||||
|
||||
#include "util/enum_bitfield_operators.hpp"
|
||||
#include <array>
|
||||
#include <string_view>
|
||||
|
||||
namespace zgl::shading::attributes::mesh
|
||||
{
|
||||
|
||||
enum class flags : std::uint8_t
|
||||
{
|
||||
none = 0,
|
||||
position = 1 << 0,
|
||||
normal = 1 << 1,
|
||||
luminance = 1 << 2,
|
||||
color = 1 << 3,
|
||||
alpha = 1 << 4,
|
||||
tex_coord = 1 << 5
|
||||
};
|
||||
|
||||
constexpr inline auto position = shader_program_variable({ GL_FLOAT_VEC3, 0 }, "model_vertex_position");
|
||||
constexpr inline auto normal = shader_program_variable({ GL_FLOAT_VEC3, 1 }, "model_vertex_normal");
|
||||
constexpr inline auto luminance = shader_program_variable({ GL_FLOAT, 2 }, "model_vertex_l");
|
||||
constexpr inline auto color = shader_program_variable({ GL_FLOAT_VEC3, 2 }, "model_vertex_rgb");
|
||||
constexpr inline auto alpha = shader_program_variable({ GL_FLOAT, 3 }, "model_vertex_a");
|
||||
constexpr inline auto tex_coord = shader_program_variable({ GL_FLOAT_VEC2, 2 }, "model_vertex_tex_coord");
|
||||
|
||||
constexpr inline auto all = std::array{
|
||||
position, normal, luminance, color, alpha, tex_coord
|
||||
};
|
||||
|
||||
constexpr inline auto names = std::array<std::string_view, 6>{
|
||||
"position",
|
||||
"normal",
|
||||
"luminance",
|
||||
"color",
|
||||
"alpha",
|
||||
"tex_coord"
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
DEFINE_ENUM_BITFIELD_OPERATORS(zgl::shading::attributes::mesh::flags)
|
||||
42
include/opengl/shading/attributes/point_cloud_attributes.hpp
Normal file
42
include/opengl/shading/attributes/point_cloud_attributes.hpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include "opengl/shader_program_variable.hpp"
|
||||
#include <array>
|
||||
#include "util/enum_bitfield_operators.hpp"
|
||||
#include <string_view>
|
||||
|
||||
namespace zgl::shading::attributes::point_cloud
|
||||
{
|
||||
|
||||
enum class flags : std::uint8_t
|
||||
{
|
||||
none = 0,
|
||||
position = 1 << 0,
|
||||
normal = 1 << 1,
|
||||
luminance = 1 << 2,
|
||||
color = 1 << 2,
|
||||
alpha = 1 << 3
|
||||
};
|
||||
|
||||
constexpr inline auto position = shader_program_variable({ GL_FLOAT_VEC3, 0 }, "model_vertex_position");
|
||||
constexpr inline auto normal = shader_program_variable({ GL_FLOAT_VEC3, 1 }, "model_vertex_normal");
|
||||
constexpr inline auto luminance = shader_program_variable({ GL_FLOAT_VEC3, 1 }, "model_vertex_l");
|
||||
constexpr inline auto color = shader_program_variable({ GL_FLOAT_VEC3, 1 }, "model_vertex_rgb");
|
||||
constexpr inline auto alpha = shader_program_variable({ GL_FLOAT_VEC3, 1 }, "model_vertex_a");
|
||||
|
||||
constexpr inline auto all = std::array{
|
||||
position, normal, luminance, color, alpha
|
||||
};
|
||||
|
||||
constexpr inline auto names = std::array<std::string_view, 5>{
|
||||
"position",
|
||||
"normal",
|
||||
"luminance",
|
||||
"color",
|
||||
"alpha"
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
DEFINE_ENUM_BITFIELD_OPERATORS(zgl::shading::attributes::point_cloud::flags)
|
||||
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>
|
||||
>>;
|
||||
}
|
||||
@@ -1,14 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "assets/components/mesh_vertex_components.hpp"
|
||||
#include "assets/components/point_cloud_vertex_components.hpp"
|
||||
#include "assets/components/material_components.hpp"
|
||||
#include "shader_program/attributes/mesh_attributes.hpp"
|
||||
#include "shader_program/uniforms/mesh_uniforms.hpp"
|
||||
#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 shader_program::features::mesh
|
||||
namespace zgl::shading::features::mesh
|
||||
{
|
||||
|
||||
struct type
|
||||
@@ -119,16 +117,6 @@ constexpr inline auto names = std::array<std::string_view, 9>{
|
||||
"uniform_color"
|
||||
};
|
||||
|
||||
constexpr inline auto defines = std::array<std::string_view, 9>{
|
||||
"FACE",
|
||||
"LINE",
|
||||
"POINT",
|
||||
"V_L",
|
||||
"V_RGB",
|
||||
"V_A",
|
||||
"LIGHTING",
|
||||
"TEXTURE",
|
||||
"U_RGBA"
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
DEFINE_ENUM_BITFIELD_OPERATORS(zgl::shading::features::mesh::flags)
|
||||
@@ -1,14 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "shader_program/attributes/point_cloud_attributes.hpp"
|
||||
#include "shader_program/uniforms/point_cloud_uniforms.hpp"
|
||||
#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 shader_program::features::point_cloud
|
||||
namespace zgl::shading::features::point_cloud
|
||||
{
|
||||
|
||||
struct type
|
||||
@@ -98,15 +98,4 @@ constexpr inline auto names = std::array{
|
||||
"rainbow"
|
||||
};
|
||||
|
||||
constexpr inline auto defines = std::array{
|
||||
"SQUARE",
|
||||
"LIGHTING",
|
||||
"V_L",
|
||||
"V_RGB",
|
||||
"V_A",
|
||||
"U_RGBA",
|
||||
"RAINBOW"
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <array>
|
||||
#include <string_view>
|
||||
|
||||
namespace shader_program::geometry
|
||||
namespace zgl::shading::model_geometry
|
||||
{
|
||||
|
||||
enum class types : std::uint8_t
|
||||
@@ -13,6 +13,8 @@ enum class types : std::uint8_t
|
||||
point_cloud = 1
|
||||
};
|
||||
|
||||
inline constexpr std::size_t count = 2;
|
||||
|
||||
inline constexpr auto names = std::array<std::string_view, 2>{
|
||||
"mesh", "point_cloud"
|
||||
};
|
||||
@@ -0,0 +1,86 @@
|
||||
#pragma once
|
||||
|
||||
#include "model_geometry.hpp"
|
||||
#include "shader_stage.hpp"
|
||||
#include "features/mesh_features.hpp"
|
||||
#include "features/point_cloud_features.hpp"
|
||||
#include "features/generic_features.hpp"
|
||||
|
||||
namespace zgl::shading
|
||||
{
|
||||
|
||||
struct shader_program_requirements
|
||||
{
|
||||
|
||||
static constexpr auto geometry_bits = static_cast<std::size_t>(std::bit_width(model_geometry::names.size()));
|
||||
static constexpr auto feature_bits = sizeof(features::generic::type) * 8 - geometry_bits;
|
||||
|
||||
explicit shader_program_requirements(const features::mesh::flags mesh_features) :
|
||||
shader_program_requirements(model_geometry::types::mesh, static_cast<features::generic::type>(mesh_features)) {}
|
||||
|
||||
explicit shader_program_requirements(const features::point_cloud::flags point_cloud_features) :
|
||||
shader_program_requirements(model_geometry::types::point_cloud, static_cast<features::generic::type>(point_cloud_features)) {}
|
||||
|
||||
shader_program_requirements(const model_geometry::types geometry_type, const features::generic::type generic_features) :
|
||||
geometry_type{ geometry_type }, features{ generic_features } {}
|
||||
|
||||
|
||||
[[nodiscard]] auto operator<=>(const shader_program_requirements& other) const noexcept
|
||||
{
|
||||
return (
|
||||
std::tie(this->geometry_type, std::popcount(this->features)) <=>
|
||||
std::tie(other.geometry_type, std::popcount(other.features))
|
||||
);
|
||||
}
|
||||
|
||||
[[nodiscard]] bool operator==(const shader_program_requirements& other) const noexcept = default;
|
||||
|
||||
model_geometry::types geometry_type : geometry_bits;
|
||||
features::generic::type features : feature_bits;
|
||||
};
|
||||
|
||||
/*
|
||||
struct shader_program_metadata
|
||||
{
|
||||
using generic_feature_type = std::common_type_t<
|
||||
std::underlying_type_t<features::mesh::flags>,
|
||||
std::underlying_type_t<features::point_cloud::flags>
|
||||
>;
|
||||
|
||||
static constexpr auto geometry_bits = static_cast<std::size_t>(std::bit_width(geometry::names.size()));
|
||||
static constexpr auto feature_bits = sizeof(generic_feature_type) * 8 - geometry_bits;
|
||||
|
||||
explicit shader_program_metadata(const features::mesh::flags static_enabled, const features::mesh::flags dynamic_enable) :
|
||||
shader_program_metadata(
|
||||
geometry::types::mesh,
|
||||
static_cast<generic_feature_type>(static_enabled),
|
||||
static_cast<generic_feature_type>(dynamic_enable)
|
||||
) {}
|
||||
|
||||
explicit shader_program_metadata(const features::point_cloud::flags static_enabled, const features::point_cloud::flags dynamic_enable) :
|
||||
shader_program_metadata(
|
||||
geometry::types::point_cloud,
|
||||
static_cast<generic_feature_type>(static_enabled),
|
||||
static_cast<generic_feature_type>(dynamic_enable)
|
||||
) {}
|
||||
|
||||
shader_program_metadata(const geometry::types geometry_type, const generic_feature_type static_enabled, generic_feature_type dynamic_enable) :
|
||||
m_geometry_type{ geometry_type }, m_static_enabled{ static_enabled }, m_dynamic_enable{ dynamic_enable } {}
|
||||
|
||||
|
||||
[[nodiscard]] auto operator<=>(const shader_program_metadata& other) const noexcept
|
||||
{
|
||||
return (
|
||||
std::tie(this->m_geometry_type, std::popcount(this->m_static_enabled), std::popcount(this->m_dynamic_enable)) <=>
|
||||
std::tie(other.m_geometry_type, std::popcount(other.m_static_enabled), std::popcount(other.m_dynamic_enable))
|
||||
);
|
||||
}
|
||||
|
||||
[[nodiscard]] bool operator==(const shader_program_metadata& other) const noexcept = default;
|
||||
|
||||
geometry::types m_geometry_type : geometry_bits;
|
||||
generic_feature_type m_static_enabled : feature_bits;
|
||||
generic_feature_type m_dynamic_enable;
|
||||
};*/
|
||||
|
||||
};
|
||||
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "shader_source_requirements.hpp"
|
||||
|
||||
namespace zgl::shading
|
||||
{
|
||||
using shader_requirements = shader_source_requirements;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include "opengl/shading/features/generic_features.hpp"
|
||||
|
||||
namespace zgl::shading
|
||||
{
|
||||
|
||||
struct shader_set_requirements
|
||||
{
|
||||
model_geometry::types geometry;
|
||||
features::generic::type features;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "opengl/shading/model_geometry.hpp"
|
||||
#include "opengl/shading/shader_stage.hpp"
|
||||
#include "opengl/shading/features/generic_features.hpp"
|
||||
|
||||
|
||||
namespace zgl::shading
|
||||
{
|
||||
struct shader_source_requirements
|
||||
{
|
||||
model_geometry::types geometry;
|
||||
stage::types stage;
|
||||
features::generic::type features;
|
||||
};
|
||||
}
|
||||
70
include/opengl/shading/shader_metadata_language.hpp
Normal file
70
include/opengl/shading/shader_metadata_language.hpp
Normal file
@@ -0,0 +1,70 @@
|
||||
#pragma once
|
||||
|
||||
#include <cinttypes>
|
||||
#include <limits>
|
||||
#include "util/string_lookup.hpp"
|
||||
|
||||
#include "model_geometry.hpp"
|
||||
#include "shader_stage.hpp"
|
||||
#include "features/mesh_features.hpp"
|
||||
#include "features/point_cloud_features.hpp"
|
||||
|
||||
namespace zgl::shading::shader_metadata_language
|
||||
{
|
||||
enum class declaration_type : std::size_t
|
||||
{
|
||||
stage = 0,
|
||||
geometry = 1,
|
||||
features = 2,
|
||||
static_enable = 3,
|
||||
dynamic_enable = 4,
|
||||
invalid = std::numeric_limits<std::size_t>::max()
|
||||
};
|
||||
|
||||
inline constexpr auto declaration_prefix = std::string_view("\n#pragma ");
|
||||
inline constexpr auto title_separator = ':';
|
||||
inline constexpr auto value_separator = ' ';
|
||||
|
||||
inline auto declaration_lookup = ztu::string_lookup<declaration_type>{
|
||||
{ "STAGE", declaration_type::stage },
|
||||
{ "GEOMETRY", declaration_type::geometry },
|
||||
{ "FEATURES", declaration_type::features },
|
||||
{ "STATIC_ENABLE", declaration_type::static_enable },
|
||||
{ "DYNAMIC_ENABLE", declaration_type::dynamic_enable }
|
||||
};
|
||||
|
||||
inline auto stage_lookup = ztu::string_lookup<stage::types>{
|
||||
{ "VERTEX", stage::types::vertex },
|
||||
{ "TESSELATION_CONTROL", stage::types::tesselation_control },
|
||||
{ "TESSELATION_EVALUATION", stage::types::tesselation_evaluation },
|
||||
{ "GEOMETRY", stage::types::geometry },
|
||||
{ "FRAGMENT", stage::types::fragment },
|
||||
};
|
||||
|
||||
inline auto geometry_lookup = ztu::string_lookup<model_geometry::types>{
|
||||
{ "MESH", model_geometry::types::mesh },
|
||||
{ "POINT_CLOUD", model_geometry::types::point_cloud }
|
||||
};
|
||||
|
||||
inline auto mesh_feature_lookup = ztu::string_lookup<features::mesh::flags>{
|
||||
{ "FACE", features::mesh::flags::face },
|
||||
{ "LINE", features::mesh::flags::line },
|
||||
{ "POINT", features::mesh::flags::point },
|
||||
{ "V_L", features::mesh::flags::luminance },
|
||||
{ "V_RGB", features::mesh::flags::color },
|
||||
{ "V_A", features::mesh::flags::alpha },
|
||||
{ "LIGHTING", features::mesh::flags::lighting },
|
||||
{ "TEXTURE", features::mesh::flags::texture },
|
||||
{ "U_RGBA", features::mesh::flags::uniform_color }
|
||||
};
|
||||
|
||||
inline auto point_cloud_feature_lookup = ztu::string_lookup<features::point_cloud::flags>{
|
||||
{ "SQUARE", features::point_cloud::flags::square },
|
||||
{ "LIGHTING", features::point_cloud::flags::lighting },
|
||||
{ "V_L", features::point_cloud::flags::luminance },
|
||||
{ "V_RGB", features::point_cloud::flags::color },
|
||||
{ "V_A", features::point_cloud::flags::alpha },
|
||||
{ "U_RGBA", features::point_cloud::flags::uniform_color },
|
||||
{ "RAINBOW", features::point_cloud::flags::rainbow }
|
||||
};
|
||||
};
|
||||
15
include/opengl/shading/shader_set.hpp
Normal file
15
include/opengl/shading/shader_set.hpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "opengl/handles/shader_handle.hpp"
|
||||
|
||||
namespace zgl
|
||||
{
|
||||
struct shader_set
|
||||
{
|
||||
shader_handle vertex_shader;
|
||||
shader_handle tesselation_control_shader;
|
||||
shader_handle tesselation_evaluation_shader;
|
||||
shader_handle geometry_shader;
|
||||
shader_handle fragment_shader;
|
||||
};
|
||||
}
|
||||
21
include/opengl/shading/shader_source_set.hpp
Normal file
21
include/opengl/shading/shader_source_set.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "features/generic_features.hpp"
|
||||
|
||||
namespace zgl::shading
|
||||
{
|
||||
|
||||
struct shader_source_set
|
||||
{
|
||||
|
||||
struct compiled_shader_features_set
|
||||
{
|
||||
features::generic::type static_enabled;
|
||||
features::generic::type dynamic_enable;
|
||||
};
|
||||
|
||||
std::array<compiled_shader_features_set, stage::count> compiled_features{};
|
||||
std::array<std::uint8_t, stage::count> string_counts{};
|
||||
};
|
||||
|
||||
}
|
||||
31
include/opengl/shading/shader_stage.hpp
Normal file
31
include/opengl/shading/shader_stage.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <cinttypes>
|
||||
#include <array>
|
||||
#include <string_view>
|
||||
#include <GL/glew.h>
|
||||
|
||||
namespace zgl::shading::stage
|
||||
{
|
||||
|
||||
enum class types : std::uint8_t
|
||||
{
|
||||
vertex = 0,
|
||||
tesselation_control = 1,
|
||||
tesselation_evaluation = 2,
|
||||
geometry = 3,
|
||||
fragment = 4
|
||||
};
|
||||
|
||||
inline constexpr std::size_t count = 5;
|
||||
|
||||
|
||||
inline constexpr auto names = std::array<std::string_view, count>{
|
||||
"vertex",
|
||||
"tesselation_control",
|
||||
"tesselation_evaluation",
|
||||
"geometry",
|
||||
"fragment"
|
||||
};
|
||||
|
||||
}
|
||||
75
include/opengl/shading/uniforms/mesh_uniforms.hpp
Normal file
75
include/opengl/shading/uniforms/mesh_uniforms.hpp
Normal file
@@ -0,0 +1,75 @@
|
||||
#pragma once
|
||||
|
||||
#include "opengl/shader_program_variable.hpp"
|
||||
#include <array>
|
||||
#include "util/enum_bitfield_operators.hpp"
|
||||
|
||||
namespace zgl::shading::uniforms::mesh
|
||||
{
|
||||
|
||||
enum class flags : std::uint16_t
|
||||
{
|
||||
none = 0,
|
||||
mvp_matrix = 1 << 0,
|
||||
model_matrix = 1 << 1,
|
||||
point_size = 1 << 2,
|
||||
color = 1 << 3,
|
||||
tex = 1 << 4,
|
||||
view_pos = 1 << 5,
|
||||
point_light_direction = 1 << 6,
|
||||
point_light_color = 1 << 7,
|
||||
ambient_light_color = 1 << 8,
|
||||
ambient_filter = 1 << 9,
|
||||
diffuse_filter = 1 << 10,
|
||||
specular_filter = 1 << 11,
|
||||
shininess = 1 << 12
|
||||
};
|
||||
|
||||
constexpr inline auto mvp_matrix = shader_program_variable({ GL_FLOAT_MAT4, 0 }, "mvp_matrix");
|
||||
constexpr inline auto model_matrix = shader_program_variable({ GL_FLOAT_MAT4, 1 }, "model_matrix");
|
||||
constexpr inline auto point_size = shader_program_variable({ GL_FLOAT, 2 }, "point_size");
|
||||
constexpr inline auto tex = shader_program_variable({ GL_SAMPLER_2D, 3 }, "tex");
|
||||
constexpr inline auto color = shader_program_variable({ GL_FLOAT_VEC4, 4 }, "color");
|
||||
constexpr inline auto view_pos = shader_program_variable({ GL_FLOAT_VEC3, 5 }, "view_pos");
|
||||
constexpr inline auto point_light_direction = shader_program_variable({ GL_FLOAT_VEC3, 6 }, "point_light_direction");
|
||||
constexpr inline auto point_light_color = shader_program_variable({ GL_FLOAT_VEC3, 7 }, "point_light_color");
|
||||
constexpr inline auto ambient_light_color = shader_program_variable({ GL_FLOAT_VEC3, 8 }, "ambient_light_color");
|
||||
constexpr inline auto ambient_filter = shader_program_variable({ GL_FLOAT_VEC3, 9 }, "ambient_filter");
|
||||
constexpr inline auto diffuse_filter = shader_program_variable({ GL_FLOAT_VEC3, 10 }, "diffuse_filter");
|
||||
constexpr inline auto specular_filter = shader_program_variable({ GL_FLOAT_VEC3, 11 }, "specular_filter");
|
||||
constexpr inline auto shininess = shader_program_variable({ GL_FLOAT, 12 }, "shininess");
|
||||
|
||||
constexpr inline auto all = std::array{
|
||||
mvp_matrix,
|
||||
model_matrix,
|
||||
point_size,
|
||||
color,
|
||||
tex,
|
||||
view_pos,
|
||||
point_light_direction,
|
||||
point_light_color,
|
||||
ambient_light_color,
|
||||
ambient_filter,
|
||||
diffuse_filter,
|
||||
specular_filter,
|
||||
shininess
|
||||
};
|
||||
|
||||
constexpr inline auto names = std::array{
|
||||
"mvp_matrix",
|
||||
"model_matrix",
|
||||
"point_size",
|
||||
"color",
|
||||
"tex",
|
||||
"view_pos",
|
||||
"point_light_direction",
|
||||
"point_light_color",
|
||||
"ambient_light_color",
|
||||
"ambient_filter",
|
||||
"diffuse_filter",
|
||||
"specular_filter",
|
||||
"shininess"
|
||||
};
|
||||
}
|
||||
|
||||
DEFINE_ENUM_BITFIELD_OPERATORS(zgl::shading::uniforms::mesh::flags)
|
||||
52
include/opengl/shading/uniforms/point_cloud_uniforms.hpp
Normal file
52
include/opengl/shading/uniforms/point_cloud_uniforms.hpp
Normal file
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
#include "opengl/shader_program_variable.hpp"
|
||||
#include "util/enum_bitfield_operators.hpp"
|
||||
#include <array>
|
||||
|
||||
namespace zgl::shading::uniforms::point_cloud
|
||||
{
|
||||
|
||||
enum class flags : std::uint8_t
|
||||
{
|
||||
none = 0,
|
||||
mvp_matrix = 1 << 0,
|
||||
point_size = 1 << 1,
|
||||
color = 1 << 2,
|
||||
model_matrix = 1 << 3,
|
||||
camera_position = 1 << 4,
|
||||
rainbow_offset_y = 1 << 5,
|
||||
rainbow_scale_y = 1 << 6
|
||||
};
|
||||
|
||||
constexpr inline auto mvp_matrix = shader_program_variable({ GL_FLOAT_MAT4, 0 }, "mvp_matrix");
|
||||
constexpr inline auto point_size = shader_program_variable({ GL_FLOAT, 1 }, "point_size");
|
||||
constexpr inline auto color = shader_program_variable({ GL_FLOAT_VEC4, 2 }, "color");
|
||||
constexpr inline auto model_matrix = shader_program_variable({ GL_FLOAT_MAT4, 3 }, "model_matrix");
|
||||
constexpr inline auto camera_position = shader_program_variable({ GL_FLOAT_VEC3, 4 }, "camera_position");
|
||||
constexpr inline auto rainbow_offset_y = shader_program_variable({ GL_FLOAT, 5 }, "rainbow_offset_y");
|
||||
constexpr inline auto rainbow_scale_y = shader_program_variable({ GL_FLOAT, 6 }, "rainbow_scale_y");
|
||||
|
||||
constexpr inline auto all = std::array{
|
||||
mvp_matrix,
|
||||
point_size,
|
||||
color,
|
||||
model_matrix,
|
||||
camera_position,
|
||||
rainbow_offset_y,
|
||||
rainbow_scale_y
|
||||
};
|
||||
|
||||
constexpr inline auto names = std::array{
|
||||
"mvp_matrix",
|
||||
"point_size",
|
||||
"color",
|
||||
"model_matrix",
|
||||
"camera_position",
|
||||
"rainbow_offset_y",
|
||||
"rainbow_scale_y"
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
DEFINE_ENUM_BITFIELD_OPERATORS(zgl::shading::uniforms::point_cloud::flags)
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "assets/components/material_components.hpp"
|
||||
#include "assets/components/mesh_vertex_components.hpp"
|
||||
#include "shader_program/features/mesh_features.hpp"
|
||||
#include "shading/features/mesh_features.hpp"
|
||||
#include "util/enum_bitfield_operators.hpp"
|
||||
|
||||
#include <array>
|
||||
@@ -12,7 +12,7 @@ namespace rendering::requirements::mesh
|
||||
|
||||
struct type
|
||||
{
|
||||
shader_program::features::mesh::indices::type shader_program_requirement_index{};
|
||||
shading::features::mesh::indices::type shader_program_requirement_index{};
|
||||
components::mesh_vertex::flags vertex_requirements{
|
||||
components::mesh_vertex::flags::none
|
||||
};
|
||||
@@ -33,32 +33,32 @@ enum class flags : std::uint8_t
|
||||
};
|
||||
|
||||
constexpr inline auto position = type{
|
||||
.shader_program_requirement_index = shader_program::features::mesh::indices::position,
|
||||
.shader_program_requirement_index = shading::features::mesh::indices::position,
|
||||
.vertex_requirements = components::mesh_vertex::flags::position
|
||||
};
|
||||
|
||||
constexpr inline auto lit = type{
|
||||
.shader_program_requirement_index = shader_program::features::mesh::indices::lit,
|
||||
.shader_program_requirement_index = shading::features::mesh::indices::lit,
|
||||
.vertex_requirements = components::mesh_vertex::flags::normal,
|
||||
.material_requirements = components::material::flags::surface_properties
|
||||
};
|
||||
|
||||
constexpr inline auto point = type{
|
||||
.shader_program_requirement_index = shader_program::features::mesh::indices::point
|
||||
.shader_program_requirement_index = shading::features::mesh::indices::point
|
||||
};
|
||||
|
||||
constexpr inline auto textured = type{
|
||||
.shader_program_requirement_index = shader_program::features::mesh::indices::textured,
|
||||
.shader_program_requirement_index = shading::features::mesh::indices::textured,
|
||||
.vertex_requirements = components::mesh_vertex::flags::tex_coord,
|
||||
.material_requirements = components::material::flags::texture,
|
||||
};
|
||||
|
||||
constexpr inline auto uniform_color = type{
|
||||
.shader_program_requirement_index = shader_program::features::mesh::indices::uniform_color
|
||||
.shader_program_requirement_index = shading::features::mesh::indices::uniform_color
|
||||
};
|
||||
|
||||
constexpr inline auto uniform_alpha = type{
|
||||
.shader_program_requirement_index = shader_program::features::mesh::indices::uniform_alpha,
|
||||
.shader_program_requirement_index = shading::features::mesh::indices::uniform_alpha,
|
||||
.material_requirements = components::material::flags::transparency
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "assets/components/point_cloud_vertex_components.hpp"
|
||||
#include "shader_program/features/point_cloud_features.hpp"
|
||||
#include "shading/features/point_cloud_features.hpp"
|
||||
|
||||
#include <array>
|
||||
#include "util/enum_bitfield_operators.hpp"
|
||||
@@ -11,7 +11,7 @@ namespace rendering::requirements::point_cloud
|
||||
|
||||
struct type
|
||||
{
|
||||
shader_program::features::point_cloud::indices::type shader_program_requirement_index{};
|
||||
shading::features::point_cloud::indices::type shader_program_requirement_index{};
|
||||
components::point_cloud_vertex::flags vertex_requirements{
|
||||
components::point_cloud_vertex::flags::none
|
||||
};
|
||||
@@ -31,30 +31,30 @@ enum class flags : std::uint8_t
|
||||
|
||||
|
||||
constexpr inline auto position = type{
|
||||
.shader_program_requirement_index = shader_program::features::point_cloud::indices::position,
|
||||
.shader_program_requirement_index = shading::features::point_cloud::indices::position,
|
||||
.vertex_requirements = components::point_cloud_vertex::flags::position
|
||||
};
|
||||
|
||||
constexpr inline auto rainbow = type{
|
||||
.shader_program_requirement_index = shader_program::features::point_cloud::indices::rainbow
|
||||
.shader_program_requirement_index = shading::features::point_cloud::indices::rainbow
|
||||
};
|
||||
|
||||
constexpr inline auto vertex_color = type{
|
||||
.shader_program_requirement_index = shader_program::features::point_cloud::indices::vertex_color,
|
||||
.shader_program_requirement_index = shading::features::point_cloud::indices::vertex_color,
|
||||
.vertex_requirements = components::point_cloud_vertex::flags::color
|
||||
};
|
||||
|
||||
constexpr inline auto uniform_color = type{
|
||||
.shader_program_requirement_index = shader_program::features::point_cloud::indices::uniform_color
|
||||
.shader_program_requirement_index = shading::features::point_cloud::indices::uniform_color
|
||||
};
|
||||
|
||||
constexpr inline auto normal = type{
|
||||
.shader_program_requirement_index = shader_program::features::point_cloud::indices::normal,
|
||||
.shader_program_requirement_index = shading::features::point_cloud::indices::normal,
|
||||
.vertex_requirements = components::point_cloud_vertex::flags::normal
|
||||
};
|
||||
|
||||
constexpr inline auto reflectance = type{
|
||||
.shader_program_requirement_index = shader_program::features::point_cloud::indices::reflectance,
|
||||
.shader_program_requirement_index = shading::features::point_cloud::indices::reflectance,
|
||||
.vertex_requirements = components::point_cloud_vertex::flags::reflectance
|
||||
};
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "opengl/shader_program_variable.hpp"
|
||||
#include <array>
|
||||
#include "util/enum_bitfield_operators.hpp"
|
||||
#include <string_view>
|
||||
|
||||
namespace shader_program::attributes::mesh
|
||||
{
|
||||
|
||||
enum class flags : std::uint8_t
|
||||
{
|
||||
none = 0,
|
||||
position = 1 << 0,
|
||||
normal = 1 << 1,
|
||||
luminance = 1 << 2,
|
||||
color = 1 << 3,
|
||||
alpha = 1 << 4,
|
||||
tex_coord = 1 << 5
|
||||
};
|
||||
|
||||
constexpr inline auto position = zgl::shader_program_variable({ GL_FLOAT_VEC3, 0 }, "model_vertex_position");
|
||||
constexpr inline auto normal = zgl::shader_program_variable({ GL_FLOAT_VEC3, 1 }, "model_vertex_normal");
|
||||
constexpr inline auto luminance = zgl::shader_program_variable({ GL_FLOAT, 2 }, "model_vertex_l");
|
||||
constexpr inline auto color = zgl::shader_program_variable({ GL_FLOAT_VEC3, 2 }, "model_vertex_rgb");
|
||||
constexpr inline auto alpha = zgl::shader_program_variable({ GL_FLOAT, 3 }, "model_vertex_a");
|
||||
constexpr inline auto tex_coord = zgl::shader_program_variable({ GL_FLOAT_VEC2, 2 }, "model_vertex_tex_coord");
|
||||
|
||||
constexpr inline auto all = std::array{
|
||||
position, normal, luminance, color, alpha, tex_coord
|
||||
};
|
||||
|
||||
constexpr inline auto names = std::array<std::string_view, 6>{
|
||||
"position",
|
||||
"normal",
|
||||
"luminance",
|
||||
"color",
|
||||
"alpha",
|
||||
"tex_coord"
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
DEFINE_ENUM_BITFIELD_OPERATORS(shader_program::attributes::mesh::flags)
|
||||
@@ -1,42 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "opengl/shader_program_variable.hpp"
|
||||
#include <array>
|
||||
#include "util/enum_bitfield_operators.hpp"
|
||||
#include <string_view>
|
||||
|
||||
namespace shader_program::attributes::point_cloud
|
||||
{
|
||||
|
||||
enum class flags : std::uint8_t
|
||||
{
|
||||
none = 0,
|
||||
position = 1 << 0,
|
||||
normal = 1 << 1,
|
||||
luminance = 1 << 2,
|
||||
color = 1 << 2,
|
||||
alpha = 1 << 3
|
||||
};
|
||||
|
||||
constexpr inline auto position = zgl::shader_program_variable({ GL_FLOAT_VEC3, 0 }, "model_vertex_position");
|
||||
constexpr inline auto normal = zgl::shader_program_variable({ GL_FLOAT_VEC3, 1 }, "model_vertex_normal");
|
||||
constexpr inline auto luminance = zgl::shader_program_variable({ GL_FLOAT_VEC3, 1 }, "model_vertex_l");
|
||||
constexpr inline auto color = zgl::shader_program_variable({ GL_FLOAT_VEC3, 1 }, "model_vertex_rgb");
|
||||
constexpr inline auto alpha = zgl::shader_program_variable({ GL_FLOAT_VEC3, 1 }, "model_vertex_a");
|
||||
|
||||
constexpr inline auto all = std::array{
|
||||
position, normal, luminance, color, alpha
|
||||
};
|
||||
|
||||
constexpr inline auto names = std::array<std::string_view, 5>{
|
||||
"position",
|
||||
"normal",
|
||||
"luminance",
|
||||
"color",
|
||||
"alpha"
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
DEFINE_ENUM_BITFIELD_OPERATORS(shader_program::attributes::point_cloud::flags)
|
||||
@@ -1,185 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <limits>
|
||||
#include <utility>
|
||||
|
||||
#include "geometry.hpp"
|
||||
#include "stage.hpp"
|
||||
#include "features/mesh_features.hpp"
|
||||
#include "features/point_cloud_features.hpp"
|
||||
|
||||
// TODO move implementation to .ipp file
|
||||
namespace shader_program
|
||||
{
|
||||
|
||||
union combined_feature_type
|
||||
{
|
||||
features::mesh::flags mesh;
|
||||
features::point_cloud::flags point_cloud;
|
||||
|
||||
using generic_type = std::common_type_t<
|
||||
std::underlying_type_t<features::mesh::flags>,
|
||||
std::underlying_type_t<features::point_cloud::flags>
|
||||
>;
|
||||
|
||||
[[nodiscard]] generic_type generic(const geometry::types geometry) const noexcept
|
||||
{
|
||||
switch (geometry)
|
||||
{
|
||||
case geometry::types::mesh:
|
||||
return static_cast<generic_type>(mesh);
|
||||
case geometry::types::point_cloud:
|
||||
return static_cast<generic_type>(point_cloud);
|
||||
}
|
||||
std::unreachable();
|
||||
}
|
||||
|
||||
void from_generic(
|
||||
const geometry::types geometry,
|
||||
generic_type new_features
|
||||
) noexcept {
|
||||
switch (geometry)
|
||||
{
|
||||
case geometry::types::mesh:
|
||||
mesh = static_cast<features::mesh::flags>(new_features);
|
||||
case geometry::types::point_cloud:
|
||||
point_cloud = static_cast<features::point_cloud::flags>(new_features);
|
||||
}
|
||||
std::unreachable();
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct shader_features_set
|
||||
{
|
||||
T features, static_enable, dynamic_enable;
|
||||
|
||||
template<typename U>
|
||||
[[nodiscard]] shader_features_set<U> cast() const noexcept
|
||||
{
|
||||
return {
|
||||
.features = static_cast<U>(features),
|
||||
.static_enable = static_cast<U>(static_enable),
|
||||
.dynamic_enable = static_cast<U>(dynamic_enable)
|
||||
};
|
||||
}
|
||||
|
||||
[[nodiscard]] auto operator<=>(const shader_features_set& other) const noexcept requires std::unsigned_integral<T>
|
||||
{
|
||||
std::array<T, 6> pop_counts;
|
||||
|
||||
std::ranges::transform(
|
||||
{
|
||||
this->features, this->static_enable, this->dynamic_enable,
|
||||
other.features, other.static_enable, other.dynamic_enable
|
||||
},
|
||||
pop_counts.begin(),
|
||||
std::popcount<T>
|
||||
);
|
||||
|
||||
return (
|
||||
std::tie(pop_counts[0], pop_counts[1], pop_counts[2]) <=>
|
||||
std::tie(pop_counts[3], pop_counts[4], pop_counts[5])
|
||||
);
|
||||
}
|
||||
|
||||
[[nodiscard]] auto operator<=>(const shader_features_set& other) const noexcept requires std::is_enum_v<T>
|
||||
{
|
||||
using integer_type = std::underlying_type_t<T>;
|
||||
return this->cast<integer_type>() <=> other.cast<integer_type>();
|
||||
}
|
||||
|
||||
// TODO this may not compile
|
||||
[[nodiscard]] bool operator==(const shader_features_set& other) const noexcept = default;
|
||||
};
|
||||
|
||||
|
||||
struct metadata_type
|
||||
{
|
||||
union combined_feature_set_type {
|
||||
shader_features_set<features::mesh::flags> mesh;
|
||||
shader_features_set<features::point_cloud::flags> point_cloud;
|
||||
};
|
||||
|
||||
using generic_feature_type = std::common_type_t<
|
||||
std::underlying_type_t<features::mesh::flags>,
|
||||
std::underlying_type_t<features::point_cloud::flags>
|
||||
>;
|
||||
|
||||
using generic_feature_set_type = shader_features_set<generic_feature_type>;
|
||||
|
||||
stage::types stage;
|
||||
geometry::types geometry;
|
||||
combined_feature_set_type feature_set;
|
||||
|
||||
[[nodiscard]] generic_feature_set_type generic_feature_set() const noexcept
|
||||
{
|
||||
switch (geometry)
|
||||
{
|
||||
case geometry::types::mesh:
|
||||
return feature_set.mesh.cast<generic_feature_type>();
|
||||
case geometry::types::point_cloud:
|
||||
return feature_set.point_cloud.cast<generic_feature_type>();
|
||||
default:
|
||||
std::unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
void from_generic_feature_set(const generic_feature_set_type& generic_feature_set) noexcept
|
||||
{
|
||||
switch (geometry)
|
||||
{
|
||||
case geometry::types::mesh:
|
||||
feature_set.mesh = generic_feature_set.cast<features::mesh::flags>();
|
||||
case geometry::types::point_cloud:
|
||||
feature_set.point_cloud = generic_feature_set.cast<features::point_cloud::flags>();
|
||||
}
|
||||
std::unreachable();
|
||||
}
|
||||
|
||||
auto operator<=>(const metadata_type& other) const noexcept
|
||||
{
|
||||
if (this->stage != other.stage)
|
||||
{
|
||||
return this->stage <=> other.stage;
|
||||
}
|
||||
|
||||
if (this->geometry != other.geometry)
|
||||
{
|
||||
return this->geometry <=> other.geometry;
|
||||
}
|
||||
|
||||
return this->generic_feature_set() <=> other.generic_feature_set();
|
||||
}
|
||||
|
||||
bool operator==(const metadata_type& other) const noexcept
|
||||
{
|
||||
if (this->stage != other.stage)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this->geometry != other.geometry)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return this->generic_feature_set() == other.generic_feature_set();
|
||||
}
|
||||
|
||||
struct feature_ignorant_less
|
||||
{
|
||||
bool operator()(const metadata_type& a, const metadata_type& b) const
|
||||
{
|
||||
return (
|
||||
std::tie(a.stage, a.geometry) <
|
||||
std::tie(b.stage, a.geometry)
|
||||
);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
inline constexpr auto my_size = sizeof(metadata_type);
|
||||
inline constexpr auto ma_align = alignof(metadata_type);
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cinttypes>
|
||||
#include <array>
|
||||
#include <string_view>
|
||||
#include <GL/glew.h>
|
||||
|
||||
namespace shader_program::stage
|
||||
{
|
||||
|
||||
enum class types : std::uint8_t
|
||||
{
|
||||
vertex = 0,
|
||||
geometry = 1,
|
||||
fragment = 2
|
||||
};
|
||||
|
||||
inline constexpr auto names = std::array<std::string_view, 3>{
|
||||
"vertex", "geometry", "fragment"
|
||||
};
|
||||
|
||||
inline constexpr auto gl_enums = std::array<GLenum, 3>{
|
||||
GL_VERTEX_SHADER,
|
||||
GL_GEOMETRY_SHADER,
|
||||
GL_FRAGMENT_SHADER
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "opengl/shader_program_variable.hpp"
|
||||
#include <array>
|
||||
#include "util/enum_bitfield_operators.hpp"
|
||||
|
||||
namespace shader_program::uniforms::mesh
|
||||
{
|
||||
|
||||
enum class flags : std::uint16_t
|
||||
{
|
||||
none = 0,
|
||||
mvp_matrix = 1 << 0,
|
||||
model_matrix = 1 << 1,
|
||||
point_size = 1 << 2,
|
||||
color = 1 << 3,
|
||||
tex = 1 << 4,
|
||||
view_pos = 1 << 5,
|
||||
point_light_direction = 1 << 6,
|
||||
point_light_color = 1 << 7,
|
||||
ambient_light_color = 1 << 8,
|
||||
ambient_filter = 1 << 9,
|
||||
diffuse_filter = 1 << 10,
|
||||
specular_filter = 1 << 11,
|
||||
shininess = 1 << 12
|
||||
};
|
||||
|
||||
constexpr inline auto mvp_matrix = zgl::shader_program_variable({ GL_FLOAT_MAT4, 0 }, "mvp_matrix");
|
||||
constexpr inline auto model_matrix = zgl::shader_program_variable({ GL_FLOAT_MAT4, 1 }, "model_matrix");
|
||||
constexpr inline auto point_size = zgl::shader_program_variable({ GL_FLOAT, 2 }, "point_size");
|
||||
constexpr inline auto tex = zgl::shader_program_variable({ GL_SAMPLER_2D, 3 }, "tex");
|
||||
constexpr inline auto color = zgl::shader_program_variable({ GL_FLOAT_VEC4, 4 }, "color");
|
||||
constexpr inline auto view_pos = zgl::shader_program_variable({ GL_FLOAT_VEC3, 5 }, "view_pos");
|
||||
constexpr inline auto point_light_direction = zgl::shader_program_variable({ GL_FLOAT_VEC3, 6 }, "point_light_direction");
|
||||
constexpr inline auto point_light_color = zgl::shader_program_variable({ GL_FLOAT_VEC3, 7 }, "point_light_color");
|
||||
constexpr inline auto ambient_light_color = zgl::shader_program_variable({ GL_FLOAT_VEC3, 8 }, "ambient_light_color");
|
||||
constexpr inline auto ambient_filter = zgl::shader_program_variable({ GL_FLOAT_VEC3, 9 }, "ambient_filter");
|
||||
constexpr inline auto diffuse_filter = zgl::shader_program_variable({ GL_FLOAT_VEC3, 10 }, "diffuse_filter");
|
||||
constexpr inline auto specular_filter = zgl::shader_program_variable({ GL_FLOAT_VEC3, 11 }, "specular_filter");
|
||||
constexpr inline auto shininess = zgl::shader_program_variable({ GL_FLOAT, 12 }, "shininess");
|
||||
|
||||
constexpr inline auto all = std::array{
|
||||
mvp_matrix,
|
||||
model_matrix,
|
||||
point_size,
|
||||
color,
|
||||
tex,
|
||||
view_pos,
|
||||
point_light_direction,
|
||||
point_light_color,
|
||||
ambient_light_color,
|
||||
ambient_filter,
|
||||
diffuse_filter,
|
||||
specular_filter,
|
||||
shininess
|
||||
};
|
||||
|
||||
constexpr inline auto names = std::array{
|
||||
"mvp_matrix",
|
||||
"model_matrix",
|
||||
"point_size",
|
||||
"color",
|
||||
"tex",
|
||||
"view_pos",
|
||||
"point_light_direction",
|
||||
"point_light_color",
|
||||
"ambient_light_color",
|
||||
"ambient_filter",
|
||||
"diffuse_filter",
|
||||
"specular_filter",
|
||||
"shininess"
|
||||
};
|
||||
}
|
||||
|
||||
DEFINE_ENUM_BITFIELD_OPERATORS(shader_program::uniforms::mesh::flags)
|
||||
@@ -1,51 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "opengl/shader_program_variable.hpp"
|
||||
#include <array>
|
||||
|
||||
namespace shader_program::uniforms::point_cloud
|
||||
{
|
||||
|
||||
enum class flags : std::uint8_t
|
||||
{
|
||||
none = 0,
|
||||
mvp_matrix = 1 << 0,
|
||||
point_size = 1 << 1,
|
||||
color = 1 << 2,
|
||||
model_matrix = 1 << 3,
|
||||
camera_position = 1 << 4,
|
||||
rainbow_offset_y = 1 << 5,
|
||||
rainbow_scale_y = 1 << 6
|
||||
};
|
||||
|
||||
constexpr inline auto mvp_matrix = zgl::shader_program_variable({ GL_FLOAT_MAT4, 0 }, "mvp_matrix");
|
||||
constexpr inline auto point_size = zgl::shader_program_variable({ GL_FLOAT, 1 }, "point_size");
|
||||
constexpr inline auto color = zgl::shader_program_variable({ GL_FLOAT_VEC4, 2 }, "color");
|
||||
constexpr inline auto model_matrix = zgl::shader_program_variable({ GL_FLOAT_MAT4, 3 }, "model_matrix");
|
||||
constexpr inline auto camera_position = zgl::shader_program_variable({ GL_FLOAT_VEC3, 4 }, "camera_position");
|
||||
constexpr inline auto rainbow_offset_y = zgl::shader_program_variable({ GL_FLOAT, 5 }, "rainbow_offset_y");
|
||||
constexpr inline auto rainbow_scale_y = zgl::shader_program_variable({ GL_FLOAT, 6 }, "rainbow_scale_y");
|
||||
|
||||
constexpr inline auto all = std::array{
|
||||
mvp_matrix,
|
||||
point_size,
|
||||
color,
|
||||
model_matrix,
|
||||
camera_position,
|
||||
rainbow_offset_y,
|
||||
rainbow_scale_y
|
||||
};
|
||||
|
||||
constexpr inline auto names = std::array{
|
||||
"mvp_matrix",
|
||||
"point_size",
|
||||
"color",
|
||||
"model_matrix",
|
||||
"camera_position",
|
||||
"rainbow_offset_y",
|
||||
"rainbow_scale_y"
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
DEFINE_ENUM_BITFIELD_OPERATORS(shader_program::uniforms::point_cloud::flags)
|
||||
Reference in New Issue
Block a user