]> git.tdb.fi Git - libs/gl.git/blobdiff - source/materials/pbrmaterial.cpp
Remove collection-less constructor overloads from most loaders
[libs/gl.git] / source / materials / pbrmaterial.cpp
index 082218161dd3067846bf42463729323b2fa27f4d..ed94bf799f53179e17ad977c782d365272e88edc 100644 (file)
@@ -23,7 +23,8 @@ const Tag PbrMaterial::texture_tags[] =
 };
 
 PbrMaterial::PbrMaterial():
-       fresnel_lookup(get_or_create_fresnel_lookup())
+       fresnel_lookup(get_or_create_fresnel_lookup()),
+       fresnel_sampler(Resources::get_global().get<Sampler>("_linear_clamp.samp"))
 {
        set_base_color(0.8f);
        set_metalness(0.0f);
@@ -51,10 +52,10 @@ const Texture2D &PbrMaterial::get_or_create_fresnel_lookup()
        shdata.uniform("roughness", 0.0f);
 
        const Mesh &mesh = resources.get<Mesh>("_fullscreen_quad.mesh");
-       Framebuffer fresnel_lookup_fbo;
-       fresnel_lookup_fbo.attach(COLOR_ATTACHMENT0, *fresnel_lookup);
-       Bind bind_fbo(fresnel_lookup_fbo);
+       Framebuffer fresnel_lookup_fbo((COLOR_ATTACHMENT,RG8));
+       fresnel_lookup_fbo.attach(COLOR_ATTACHMENT, *fresnel_lookup);
        Renderer renderer;
+       renderer.set_framebuffer(&fresnel_lookup_fbo);
        renderer.set_shader_program(&shprog, &shdata);
        mesh.draw(renderer);
 
@@ -94,6 +95,14 @@ const Texture *PbrMaterial::get_texture(Tag tag) const
                return 0;
 }
 
+const Sampler *PbrMaterial::get_sampler(Tag tag) const
+{
+       if(tag==texture_tags[6])
+               return &fresnel_sampler;
+       else
+               return sampler;
+}
+
 void PbrMaterial::set_base_color(const Color &color)
 {
        base_color.value = color;
@@ -151,12 +160,6 @@ void PbrMaterial::set_emission_map(const Texture *tex)
 
 DataFile::Loader::ActionMap PbrMaterial::Loader::shared_actions;
 
-PbrMaterial::Loader::Loader(PbrMaterial &m):
-       DerivedObjectLoader<PbrMaterial, Material::PropertyLoader<PbrMaterial> >(m)
-{
-       set_actions(shared_actions);
-}
-
 PbrMaterial::Loader::Loader(PbrMaterial &m, Collection &c):
        DerivedObjectLoader<PbrMaterial, Material::PropertyLoader<PbrMaterial> >(m, c)
 {