Deferred renderer: support a background generation callback
This commit is contained in:
parent
57e8aa39af
commit
f10f301443
2 changed files with 19 additions and 0 deletions
|
|
@ -10,6 +10,7 @@
|
||||||
#include <psemek/geom/box.hpp>
|
#include <psemek/geom/box.hpp>
|
||||||
|
|
||||||
#include <psemek/util/pimpl.hpp>
|
#include <psemek/util/pimpl.hpp>
|
||||||
|
#include <psemek/util/function.hpp>
|
||||||
|
|
||||||
namespace psemek::gfx
|
namespace psemek::gfx
|
||||||
{
|
{
|
||||||
|
|
@ -95,6 +96,7 @@ namespace psemek::gfx
|
||||||
geom::camera const * camera;
|
geom::camera const * camera;
|
||||||
|
|
||||||
std::optional<color_3f> clear_color;
|
std::optional<color_3f> clear_color;
|
||||||
|
util::function<void()> background_generator;
|
||||||
|
|
||||||
color_3f ambient;
|
color_3f ambient;
|
||||||
std::vector<directional_light> directional_lights;
|
std::vector<directional_light> directional_lights;
|
||||||
|
|
|
||||||
|
|
@ -808,6 +808,7 @@ void main()
|
||||||
|
|
||||||
gfx::framebuffer g_framebuffer;
|
gfx::framebuffer g_framebuffer;
|
||||||
gfx::framebuffer occlusion_framebuffer;
|
gfx::framebuffer occlusion_framebuffer;
|
||||||
|
gfx::framebuffer bg_framebuffer;
|
||||||
gfx::texture_2d g_buffer_texture[4];
|
gfx::texture_2d g_buffer_texture[4];
|
||||||
gfx::texture_2d g_buffer_depth;
|
gfx::texture_2d g_buffer_depth;
|
||||||
|
|
||||||
|
|
@ -1183,8 +1184,11 @@ void main()
|
||||||
impl().g_framebuffer.depth(impl().g_buffer_depth);
|
impl().g_framebuffer.depth(impl().g_buffer_depth);
|
||||||
impl().occlusion_framebuffer.depth(impl().g_buffer_depth);
|
impl().occlusion_framebuffer.depth(impl().g_buffer_depth);
|
||||||
|
|
||||||
|
impl().bg_framebuffer.color(impl().g_buffer_texture[1]);
|
||||||
|
|
||||||
impl().g_framebuffer.assert_complete();
|
impl().g_framebuffer.assert_complete();
|
||||||
impl().occlusion_framebuffer.assert_complete();
|
impl().occlusion_framebuffer.assert_complete();
|
||||||
|
impl().bg_framebuffer.assert_complete();
|
||||||
|
|
||||||
impl().transparent_framebuffer.color(impl().g_buffer_texture[1]);
|
impl().transparent_framebuffer.color(impl().g_buffer_texture[1]);
|
||||||
impl().transparent_framebuffer.depth(impl().g_buffer_depth);
|
impl().transparent_framebuffer.depth(impl().g_buffer_depth);
|
||||||
|
|
@ -1307,6 +1311,19 @@ void main()
|
||||||
|
|
||||||
gl::ClearBufferfv(gl::COLOR, 1, buffer_1_clear);
|
gl::ClearBufferfv(gl::COLOR, 1, buffer_1_clear);
|
||||||
|
|
||||||
|
if (opts.background_generator)
|
||||||
|
{
|
||||||
|
impl().bg_framebuffer.bind();
|
||||||
|
|
||||||
|
gl::Enable(gl::DEPTH_TEST);
|
||||||
|
gl::DepthFunc(gl::LEQUAL);
|
||||||
|
gl::Disable(gl::BLEND);
|
||||||
|
|
||||||
|
opts.background_generator();
|
||||||
|
|
||||||
|
impl().g_framebuffer.bind();
|
||||||
|
}
|
||||||
|
|
||||||
gl::ClearDepth(1.f);
|
gl::ClearDepth(1.f);
|
||||||
gl::Clear(gl::DEPTH_BUFFER_BIT);
|
gl::Clear(gl::DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue