X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmaterial.cpp;h=810ecd174d81fb407730b33b0488b456dcee4f86;hb=bc1675de82ea5c4a07bea4c5afa9c59c497464d2;hp=ef3662e964d8be98421e6e187256b0f028daa232;hpb=fd62e55d37716787fe909883a1b18e5b8128ec80;p=libs%2Fgl.git diff --git a/source/material.cpp b/source/material.cpp index ef3662e9..810ecd17 100644 --- a/source/material.cpp +++ b/source/material.cpp @@ -2,6 +2,7 @@ #include #include "basicmaterial.h" #include "gl.h" +#include "pbrmaterial.h" #include "resources.h" #include "texturing.h" #include "uniform.h" @@ -54,7 +55,7 @@ void Material::attach_texture_to(const Texture *tex, Texturing &texturing, Progr if(unit<0) throw runtime_error("no free texunit"); - texturing.attach(unit, *tex); + texturing.attach(unit, *tex, sampler); tex_shdata.uniform(name, unit); } @@ -64,12 +65,33 @@ Material::MaterialRegistry &Material::get_material_registry() static bool initialized = false; if(!initialized) { + initialized = true; registry.register_type("basic"); + registry.register_type("pbr"); } return registry; } +Material::Loader::Loader(Material &m): + CollectionObjectLoader(m, 0) +{ } + +Material::Loader::Loader(Material &m, Collection &c): + CollectionObjectLoader(m, &c) +{ } + +void Material::Loader::init_actions() +{ + add("sampler", &Loader::sampler); +} + +void Material::Loader::sampler(const std::string &name) +{ + obj.sampler = &get_collection().get(name); +} + + DataFile::Loader::ActionMap Material::GenericLoader::shared_actions; Material::GenericLoader::GenericLoader(DataFile::Collection *c):