X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fmaterials%2Fpbrmaterial.cpp;fp=source%2Fmaterials%2Fpbrmaterial.cpp;h=16c287b4e40f6ad97987ac517ba57315646dc711;hp=bc7104cc652d485350614b5737b32e6a42771f80;hb=842c817bb679a5a0abc05e8149e2e6e0ae1a0412;hpb=0912a8d73043961ab7a4d66cd2fbb13187483ffd diff --git a/source/materials/pbrmaterial.cpp b/source/materials/pbrmaterial.cpp index bc7104cc..16c287b4 100644 --- a/source/materials/pbrmaterial.cpp +++ b/source/materials/pbrmaterial.cpp @@ -14,28 +14,18 @@ PbrMaterial::PbrMaterial(): set_emission(0.0f); } -string PbrMaterial::create_program_source() const -{ - string source = "import cooktorrance;\n"; - if(base_color.texture) - source += "const bool use_base_color_map = true;\n"; - if(normal.texture) - source += "const bool use_normal_map = true;\n"; - if(metalness.texture) - source += "const bool use_metalness_map = true;\n"; - if(roughness.texture) - source += "const bool use_roughness_map = true;\n"; - if(occlusion.texture) - source += "const bool use_occlusion_map = true;\n"; - if(emission.texture || emission.value.r || emission.value.g || emission.value.b) - { - source += "const bool use_emission = true;\n"; - if(emission.texture) - source += "const bool use_emission_map = true;\n"; - } - if(receive_shadows) - source += "const bool use_shadow_map = true;\n"; - return source; +void PbrMaterial::fill_program_info(string &module_name, map &spec_values) const +{ + module_name = "cooktorrance.glsl"; + spec_values["use_base_color_map"] = (base_color.texture!=0); + spec_values["use_normal_map"] = (normal.texture!=0); + spec_values["use_metalness_map"] = (metalness.texture!=0); + spec_values["use_roughness_map"] = (roughness.texture!=0); + spec_values["use_occlusion_map"] = (occlusion.texture!=0); + bool use_emission = (emission.texture || emission.value.r || emission.value.g || emission.value.b); + spec_values["use_emission"] = use_emission; + spec_values["use_emission_map"] = (emission.texture!=0); + spec_values["use_shadow_map"] = receive_shadows; } void PbrMaterial::attach_textures_to(Texturing &texturing, ProgramData &tex_shdata) const