X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fambientocclusion.cpp;h=2378bcc78cb323e21439b01c601c8f5590a4ab3c;hp=3d56f3f0269c32cc128d8fc70b075547716e19d5;hb=9319f1c8ed99866966f20fbab952da673af2257e;hpb=b3caa9f93c865a54a5d338af1ef474ad383f8099 diff --git a/source/ambientocclusion.cpp b/source/ambientocclusion.cpp index 3d56f3f0..2378bcc7 100644 --- a/source/ambientocclusion.cpp +++ b/source/ambientocclusion.cpp @@ -21,7 +21,7 @@ AmbientOcclusion::AmbientOcclusion(unsigned w, unsigned h, float): texturing.attach(2, occlude_target.get_target_texture(RENDER_COLOR)); unsigned seed = 1; - rotate_lookup.storage(RGBA, 4, 4); + rotate_lookup.storage(RGBA, 4, 4, 1); rotate_lookup.set_filter(NEAREST); unsigned char data[64]; for(unsigned i=0; i<16; ++i) @@ -108,5 +108,30 @@ void AmbientOcclusion::render(Renderer &renderer, const Texture2D &color, const quad.draw(renderer); } + +AmbientOcclusion::Template::Template(): + n_samples(16), + occlusion_radius(0.5f), + darkness(1.0f) +{ } + +AmbientOcclusion *AmbientOcclusion::Template::create(unsigned width, unsigned height) const +{ + RefPtr ao = new AmbientOcclusion(width/size_divisor, height/size_divisor); + ao->set_n_samples(n_samples); + ao->set_occlusion_radius(occlusion_radius); + ao->set_darkness(darkness); + return ao.release(); +} + + +AmbientOcclusion::Template::Loader::Loader(Template &t): + DataFile::DerivedObjectLoader(t) +{ + add("darkness", &Template::darkness); + add("occlusion_radius", &Template::occlusion_radius); + add("samples", &Template::n_samples); +} + } // namespace GL } // namespace Msp