X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Feffects%2Fenvironmentmap.cpp;h=8770aba5f2e1fcf19a5de76599c0a5f77a7afb71;hb=bea2bcf1aa353b1dd8d1728931ef0508677bd2c6;hp=1cefde1be840649cab8dab4059366299116d5a10;hpb=ce3658993ce2f6b7527a04a36a5e1af349c6f2e9;p=libs%2Fgl.git diff --git a/source/effects/environmentmap.cpp b/source/effects/environmentmap.cpp index 1cefde1b..8770aba5 100644 --- a/source/effects/environmentmap.cpp +++ b/source/effects/environmentmap.cpp @@ -10,18 +10,6 @@ using namespace std; namespace Msp { namespace GL { -EnvironmentMap::EnvironmentMap(unsigned s, Renderable &r, Renderable &e): - Effect(r), - environment(e), - irradiance_shprog(Resources::get_global().get("_envmap_irradiance.glsl.shader")), - specular_shprog(Resources::get_global().get("_envmap_specular.glsl.shader")), - fullscreen_mesh(Resources::get_global().get("_fullscreen_quad.mesh")), - sampler(Resources::get_global().get("_linear_clamp.samp")), - mip_sampler(Resources::get_global().get("_mip_clamp.samp")) -{ - init(s, RGB8, 1); -} - EnvironmentMap::EnvironmentMap(unsigned s, PixelFormat f, Renderable &r, Renderable &e): Effect(r), environment(e), @@ -57,11 +45,12 @@ void EnvironmentMap::init(unsigned s, PixelFormat f, unsigned l) update_delay = 0; env_tex.storage(f, size, l); - depth_buf.storage(DEPTH_COMPONENT32F, size, size); + depth_buf.storage(DEPTH_COMPONENT32F, size, size, 1); for(unsigned i=0; i<6; ++i) { TextureCubeFace face = TextureCube::enumerate_faces(i); - faces[i].fbo.attach(COLOR_ATTACHMENT0, env_tex, face, 0); + faces[i].fbo.set_format((COLOR_ATTACHMENT,f, DEPTH_ATTACHMENT,DEPTH_COMPONENT32F)); + faces[i].fbo.attach(COLOR_ATTACHMENT, env_tex, face, 0); faces[i].fbo.attach(DEPTH_ATTACHMENT, depth_buf); faces[i].camera.set_look_direction(TextureCube::get_face_direction(face)); faces[i].camera.set_up_direction(TextureCube::get_t_direction(face)); @@ -71,13 +60,17 @@ void EnvironmentMap::init(unsigned s, PixelFormat f, unsigned l) } irradiance.storage(f, size/4, 1); - irradiance_fbo.attach_layered(COLOR_ATTACHMENT0, irradiance); + irradiance_fbo.set_format((COLOR_ATTACHMENT,f)); + irradiance_fbo.attach_layered(COLOR_ATTACHMENT, irradiance); if(l>1) { specular_fbos.resize(l-1); for(unsigned i=1; i face_matrices[6]; for(unsigned i=0; i<6; ++i)