X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmaterials%2Fpbrmaterial.cpp;h=5dc1b55c67f83b80779ae3e19f61dfe6523f845c;hb=ce3658993ce2f6b7527a04a36a5e1af349c6f2e9;hp=7e7bd5cf642dbf5e8c4f93284cea5e1173b47bf4;hpb=6b9338845dfee441cd18ad6c633e4feef8ad14e1;p=libs%2Fgl.git diff --git a/source/materials/pbrmaterial.cpp b/source/materials/pbrmaterial.cpp index 7e7bd5cf..5dc1b55c 100644 --- a/source/materials/pbrmaterial.cpp +++ b/source/materials/pbrmaterial.cpp @@ -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("_linear_clamp.samp")) { set_base_color(0.8f); set_metalness(0.0f); @@ -35,7 +36,7 @@ const Texture2D &PbrMaterial::get_or_create_fresnel_lookup() { Resources &resources = Resources::get_global(); - static const string name = "_pbr_env_fresnel_lookup.tex2d"; + static const string name = "_pbr_fresnel_lookup.tex2d"; Texture2D *fresnel_lookup = resources.find(name); if(fresnel_lookup) return *fresnel_lookup; @@ -53,8 +54,8 @@ const Texture2D &PbrMaterial::get_or_create_fresnel_lookup() const Mesh &mesh = resources.get("_fullscreen_quad.mesh"); Framebuffer fresnel_lookup_fbo; fresnel_lookup_fbo.attach(COLOR_ATTACHMENT0, *fresnel_lookup); - Bind bind_fbo(fresnel_lookup_fbo); Renderer renderer; + renderer.set_framebuffer(&fresnel_lookup_fbo); renderer.set_shader_program(&shprog, &shdata); mesh.draw(renderer); @@ -74,19 +75,6 @@ void PbrMaterial::fill_program_info(string &module_name, map &spec_ spec_values["use_emission_map"] = (emission.texture!=0); } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -void PbrMaterial::attach_textures_to(Texturing &texturing, ProgramData &tex_shdata) const -{ - attach_texture_to(base_color.texture, texturing, tex_shdata, "base_color_map"); - attach_texture_to(metalness.texture, texturing, tex_shdata, "metalness_map"); - attach_texture_to(roughness.texture, texturing, tex_shdata, "roughness_map"); - attach_texture_to(normal.texture, texturing, tex_shdata, "normal_map"); - attach_texture_to(occlusion.texture, texturing, tex_shdata, "occlusion_map"); - attach_texture_to(emission.texture, texturing, tex_shdata, "emission_map"); -} -#pragma GCC diagnostic pop - const Texture *PbrMaterial::get_texture(Tag tag) const { if(tag==texture_tags[0]) @@ -107,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;