Further shader compilation development.
This commit is contained in:
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>
|
||||
>>;
|
||||
}
|
||||
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"
|
||||
};
|
||||
|
||||
}
|
||||
23
include/opengl/shading/model_geometry.hpp
Normal file
23
include/opengl/shading/model_geometry.hpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <cinttypes>
|
||||
#include <array>
|
||||
#include <string_view>
|
||||
|
||||
namespace zgl::shading::model_geometry
|
||||
{
|
||||
|
||||
enum class types : std::uint8_t
|
||||
{
|
||||
mesh = 0,
|
||||
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)
|
||||
Reference in New Issue
Block a user