diff options
Diffstat (limited to 'model.cpp')
-rw-r--r-- | model.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
@@ -32,20 +32,26 @@ void Material::use( Sampler_Id sampler, Shader& shader ) { - auto bind = [&shader, &pb, sampler]( + int opt = 0; + auto bind = [&shader, &pb, &opt, sampler]( const char* name, + const char* optname, Texture_Id t ) { int loc = shader.descriptor_binding(name); if (loc >= 0) { - pb.texture(loc, t, sampler); + if (t) { + pb.texture(loc, t, sampler); + opt |= shader.opt_mask(shader_type_fragment, optname); + } } }; - bind("albedo", tex.albedo); - bind("ao", tex.ao); - bind("metal", tex.metal); - bind("rough", tex.rough); - bind("normal", tex.normal); + bind("albedo", "albedomap", tex.albedo); + bind("ao", "aomap", tex.ao); + bind("metal", "metalmap", tex.metal); + bind("rough", "roughmap", tex.rough); + bind("normal", "normalmap", tex.normal); + pb.option(shader_type_fragment, opt); } void Model_Loader::init(Device* device, Asset_Arena* shader_arena) { @@ -214,10 +220,8 @@ void Model::update_transforms() { } void Material_Loader::init( - Asset_Arena* texture_arena, - Texture_Id dt + Asset_Arena* texture_arena ) { - default_tex = dt; textures = texture_arena; } @@ -235,11 +239,11 @@ Asset* Material_Loader::load( return r; }; auto read_tex = [&](int len) { - if (!len) return default_tex; + if (!len) return Texture_Id(0); const char* name = read_name(len); auto t = (Texture*)textures->load(name); if (!t) - return default_tex; + return Texture_Id(0); return t->id; }; (void)filename; |