Sky::Sky(Resources &resources, Renderable &r, const Light &s):
Effect(r),
sun(s),
+ transmittance_lookup(128, 64, (RENDER_COLOR, RGB16F)),
transmittance_shprog(resources.get<Program>("_sky_transmittance.glsl.shader")),
transmittance_lookup_dirty(true),
+ distant(256, 128, (RENDER_COLOR, RGB16F)),
distant_shprog(resources.get<Program>("_sky_distant.glsl.shader")),
fullscreen_mesh(resources.get<Mesh>("_fullscreen_quad.mesh")),
backdrop_shprog(resources.get<Program>("_sky_backdrop.glsl.shader")),
wrap_sampler(resources.get<Sampler>("_linear_clamp_v.samp")),
rendered(false)
{
- transmittance_lookup.storage(RGB16F, 128, 64, 1);
- transmittance_fbo.attach(COLOR_ATTACHMENT0, transmittance_lookup);
-
- distant.storage(RGB16F, 256, 128, 1);
- distant_fbo.attach(COLOR_ATTACHMENT0, distant);
-
shdata.uniform("n_steps", 50);
set_planet(Planet::earth());
if(transmittance_lookup_dirty)
{
transmittance_lookup_dirty = false;
- Bind bind_fbo(transmittance_fbo);
+ Bind bind_fbo(transmittance_lookup.get_framebuffer());
renderer.set_shader_program(&transmittance_shprog, &shdata);
fullscreen_mesh.draw(renderer);
}
- Bind bind_fbo(distant_fbo);
+ Bind bind_fbo(distant.get_framebuffer());
renderer.set_shader_program(&distant_shprog, &shdata);
- renderer.set_texture("transmittance_lookup", &transmittance_lookup, &sampler);
+ renderer.set_texture("transmittance_lookup", &transmittance_lookup.get_target_texture(0), &sampler);
fullscreen_mesh.draw(renderer);
renderable.setup_frame(renderer);
Renderer::Push push(renderer);
renderer.set_shader_program(&backdrop_shprog, &shdata);
- renderer.set_texture("distant", &distant, &wrap_sampler);
+ renderer.set_texture("distant", &distant.get_target_texture(0), &wrap_sampler);
fullscreen_mesh.draw(renderer);
}
#include "effect.h"
#include "framebuffer.h"
#include "programdata.h"
-#include "texture2d.h"
+#include "rendertarget.h"
namespace Msp {
namespace GL {
private:
const Light &sun;
- Texture2D transmittance_lookup;
+ RenderTarget transmittance_lookup;
const Program &transmittance_shprog;
- Framebuffer transmittance_fbo;
bool transmittance_lookup_dirty;
- Texture2D distant;
+ RenderTarget distant;
const Program &distant_shprog;
- Framebuffer distant_fbo;
const Mesh &fullscreen_mesh;
const Program &backdrop_shprog;
const Sampler &sampler;