11 #include <Eigen/Dense> 16 Eigen::Matrix4f view_matrix = Eigen::Matrix4f::Identity();
17 Eigen::Matrix4f projection_matrix = Eigen::Matrix4f::Identity();
18 static constexpr uint32_t SampleShadingFlag = 1;
19 static constexpr uint32_t TransparentSampleShadingFlag = 2;
23 enum class LightType : uint32_t {
28 ViewSpace = (1 << 20),
32 Eigen::Matrix4f pose = Eigen::Matrix4f::Identity();
33 Eigen::Vector3f color = Eigen::Vector3f::Zero();
35 Eigen::Vector3f position = Eigen::Vector3f::Zero();
36 float softness = 1.0f;
41 uint32_t light_count = 0;
45 Eigen::Vector4f color = Eigen::Vector4f(1, 1, 1, 1);
46 float roughness = 0.5f;
47 float metallic = 0.0f;
48 uint32_t color_texture = 0;
49 uint32_t normal_texture = 0;
52 uint8_t transparent =
false;
56 Eigen::Vector4f pose_x = Eigen::Vector4f(1, 0, 0, 0),
57 pose_y = Eigen::Vector4f(0, 1, 0, 0),
58 pose_z = Eigen::Vector4f(0, 0, 1, 0);
59 inline void setPose(
const Eigen::Matrix4f &matrix) {
60 pose_x = matrix.row(0);
61 pose_y = matrix.row(1);
62 pose_z = matrix.row(2);
64 inline void setPose(
const Eigen::Isometry3d &pose) {
65 setPose(pose.matrix().cast<
float>());
67 inline void setPose(
const Eigen::Affine3d &pose) {
68 setPose(pose.matrix().cast<
float>());
73 GLuint primitive_type = GL_TRIANGLES;
74 bool transparent =
false;
75 bool double_sided =
false;
82 GLuint vertex_array_object = 0;
83 size_t element_count = 0;
84 size_t first_instance = 0;
85 size_t instance_count = 0;
86 size_t material_index = 0;
91 std::vector<MaterialBlock, Eigen::aligned_allocator<MaterialBlock>>
93 std::vector<InstanceBlock, Eigen::aligned_allocator<InstanceBlock>>
95 std::vector<RenderCommand> _commands;
96 std::vector<LightBlock, Eigen::aligned_allocator<LightBlock>> _lights;
100 void push(
const std::shared_ptr<Mesh> &mesh,
const RenderOptions &options);
104 const std::shared_ptr<Mesh> &mesh,
114 const std::shared_ptr<Mesh> &mesh,
const IT &instance_begin,
115 const IT &instance_end,
119 for (
auto &instance = instance_begin; instance != instance_end;
121 push(mesh, *instance);
125 inline void push(
const LightBlock &light) { _lights.push_back(light); }