diff --git a/libraries/fbx/src/FBXReader.cpp b/libraries/fbx/src/FBXReader.cpp index da240e826a..6268cb3d0a 100644 --- a/libraries/fbx/src/FBXReader.cpp +++ b/libraries/fbx/src/FBXReader.cpp @@ -934,7 +934,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS _textureContent.insert(filename, content); } } else if (object.name == "Material") { - FBXMaterial material(glm::vec3(1.0f, 1.0f, 1.0f), glm::vec3(1.0f), glm::vec3(), glm::vec2(0.f, 1.0f), 96.0f, 1.0f); + FBXMaterial material(glm::vec3(1.0f, 1.0f, 1.0f), glm::vec3(0.02f), glm::vec3(), glm::vec2(0.f, 1.0f), 96.0f, 1.0f); foreach (const FBXNode& subobject, object.children) { bool properties = false; QByteArray propertyName; diff --git a/libraries/fbx/src/FBXReader_Material.cpp b/libraries/fbx/src/FBXReader_Material.cpp index c29c64030e..7ba6e6d703 100644 --- a/libraries/fbx/src/FBXReader_Material.cpp +++ b/libraries/fbx/src/FBXReader_Material.cpp @@ -139,7 +139,9 @@ void FBXReader::consolidateFBXMaterials() { } else { material._material->setDiffuse(material.diffuseColor); } - material._material->setMetallic(glm::length(material.specularColor)); + + float metallic = std::max(material.specularColor.x, std::max(material.specularColor.y, material.specularColor.z)); + material._material->setMetallic(metallic); material._material->setGloss(material.shininess); if (material.opacity <= 0.0f) { diff --git a/libraries/gpu/src/gpu/GLBackend.cpp b/libraries/gpu/src/gpu/GLBackend.cpp index e8bc32d567..85381a3640 100644 --- a/libraries/gpu/src/gpu/GLBackend.cpp +++ b/libraries/gpu/src/gpu/GLBackend.cpp @@ -418,8 +418,10 @@ void GLBackend::resetStages() { #define DO_IT_NOW(call, offset) void Batch::_glActiveBindTexture(GLenum unit, GLenum target, GLuint texture) { - ADD_COMMAND_GL(glActiveBindTexture); + // clean the cache on the texture unit we are going to use + setResourceTexture(unit - GL_TEXTURE0, nullptr); + ADD_COMMAND_GL(glActiveBindTexture); _params.push_back(texture); _params.push_back(target); _params.push_back(unit); @@ -432,6 +434,7 @@ void GLBackend::do_glActiveBindTexture(Batch& batch, uint32 paramOffset) { glBindTexture( batch._params[paramOffset + 1]._uint, batch._params[paramOffset + 0]._uint); + (void) CHECK_GL_ERROR(); } diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index 7aee46b108..71dac8d0df 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -189,6 +189,7 @@ void Model::RenderPipelineLib::initLocations(gpu::ShaderPointer& program, Model: locations.emissiveParams = program->getUniforms().findLocation("emissiveParams"); locations.glowIntensity = program->getUniforms().findLocation("glowIntensity"); locations.normalFittingMapUnit = program->getTextures().findLocation("normalFittingMap"); + locations.diffuseTextureUnit = program->getTextures().findLocation("diffuseMap"); locations.normalTextureUnit = program->getTextures().findLocation("normalMap"); locations.specularTextureUnit = program->getTextures().findLocation("specularMap"); locations.emissiveTextureUnit = program->getTextures().findLocation("emissiveMap"); @@ -1625,7 +1626,6 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, int shape // Diffuse if (materialKey.isDiffuseMap()) { auto diffuseMap = textureMaps[model::MaterialKey::DIFFUSE_MAP]; - if (diffuseMap && diffuseMap->isDefined()) { batch.setResourceTexture(DIFFUSE_MAP_SLOT, diffuseMap->getTextureView()); diff --git a/libraries/render-utils/src/Model.h b/libraries/render-utils/src/Model.h index de760dc793..33a2e33316 100644 --- a/libraries/render-utils/src/Model.h +++ b/libraries/render-utils/src/Model.h @@ -344,6 +344,7 @@ private: int tangent; int alphaThreshold; int texcoordMatrices; + int diffuseTextureUnit; int normalTextureUnit; int specularTextureUnit; int emissiveTextureUnit;