20 #ifndef ANTKEEPER_RENDER_MATERIAL_PASS_HPP
21 #define ANTKEEPER_RENDER_MATERIAL_PASS_HPP
31 #include <unordered_map>
57 struct shader_cache_entry
59 std::unique_ptr<gl::shader_program> shader_program;
62 std::vector<std::function<void()>> shader_command_buffer;
65 std::vector<std::function<void()>> geometry_command_buffer;
68 std::unordered_map<
const material*, std::vector<std::function<void()>>> material_command_buffers;
72 std::unordered_map<std::size_t, shader_cache_entry> shader_cache;
82 void evaluate_lighting(
const render::context& ctx, std::uint32_t layer_mask);
88 void build_shader_command_buffer(std::vector<std::function<
void()>>& command_buffer,
const gl::shader_program& shader_program)
const;
89 void build_geometry_command_buffer(std::vector<std::function<
void()>>& command_buffer,
const gl::shader_program& shader_program)
const;
90 void build_material_command_buffer(std::vector<std::function<
void()>>& command_buffer,
const gl::shader_program& shader_program,
const material& material)
const;
101 float camera_exposure;
106 std::size_t light_probe_count;
109 std::vector<math::fvec3> point_light_colors;
110 std::vector<math::fvec3> point_light_positions;
111 std::size_t point_light_count;
114 std::vector<math::fvec3> directional_light_colors;
115 std::vector<math::fvec3> directional_light_directions;
116 std::size_t directional_light_count;
119 std::vector<const gl::texture_2d*> directional_shadow_maps;
120 std::vector<math::fvec4> directional_shadow_splits;
121 std::vector<float> directional_shadow_fade_ranges;
122 std::vector<std::span<const math::fmat4>> directional_shadow_matrices;
123 std::size_t directional_shadow_count;
126 std::vector<math::fvec3> spot_light_colors;
127 std::vector<math::fvec3> spot_light_positions;
128 std::vector<math::fvec3> spot_light_directions;
129 std::vector<math::fvec2> spot_light_cutoffs;
130 std::size_t spot_light_count;
133 std::vector<math::fvec3> rectangle_light_colors;
134 std::vector<math::fvec3> rectangle_light_corners;
135 std::size_t rectangle_light_count;
138 std::shared_ptr<gl::texture_2d> ltc_lut_1;
139 std::shared_ptr<gl::texture_2d> ltc_lut_2;
142 std::shared_ptr<gl::texture_2d> brdf_lut;
147 unsigned int frame{0};
154 std::span<const math::fmat4> matrix_palette;
157 std::size_t lighting_state_hash;
159 std::shared_ptr<render::material> fallback_material;
Graphics pipeline interface.
Shader program which can be linked to shader objects and executed.
Template used to for generating one or more shader variants from a single source.
Renders scene objects using their material-specified shaders and properties.
void set_fallback_material(std::shared_ptr< render::material > fallback)
Sets the material to be used when a render operation is missing a material. If no fallback material i...
void set_mouse_position(const math::fvec2 &position)
void render(render::context &ctx) override
material_pass(gl::pipeline *pipeline, const gl::framebuffer *framebuffer, resource_manager *resource_manager)
A material is associated with exactly one shader program and contains a set of material properties wh...
Manages the loading, caching, and saving of resources.
@ position
Vertex position (vec3)
material_blend_mode
Material blend modes.
n by m column-major matrix.