diff --git a/libraries/render-utils/src/LightingModel.cpp b/libraries/render-utils/src/LightingModel.cpp index 5a251fc5e9..47af83da36 100644 --- a/libraries/render-utils/src/LightingModel.cpp +++ b/libraries/render-utils/src/LightingModel.cpp @@ -92,6 +92,15 @@ bool LightingModel::isAlbedoEnabled() const { return (bool)_parametersBuffer.get().enableAlbedo; } +void LightingModel::setMaterialTexturing(bool enable) { + if (enable != isMaterialTexturingEnabled()) { + _parametersBuffer.edit().enableMaterialTexturing = (float)enable; + } +} +bool LightingModel::isMaterialTexturingEnabled() const { + return (bool)_parametersBuffer.get().enableMaterialTexturing; +} + void LightingModel::setAmbientLight(bool enable) { if (enable != isAmbientLightEnabled()) { _parametersBuffer.edit().enableAmbientLight = (float)enable; @@ -150,6 +159,8 @@ void MakeLightingModel::configure(const Config& config) { _lightingModel->setSpecular(config.enableSpecular); _lightingModel->setAlbedo(config.enableAlbedo); + _lightingModel->setMaterialTexturing(config.enableMaterialTexturing); + _lightingModel->setAmbientLight(config.enableAmbientLight); _lightingModel->setDirectionalLight(config.enableDirectionalLight); _lightingModel->setPointLight(config.enablePointLight); @@ -160,5 +171,8 @@ void MakeLightingModel::configure(const Config& config) { void MakeLightingModel::run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, LightingModelPointer& lightingModel) { - lightingModel = _lightingModel; + lightingModel = _lightingModel; + + // make sure the enableTexturing flag of the render ARgs is in sync + renderContext->args->_enableTexturing = _lightingModel->isMaterialTexturingEnabled(); } \ No newline at end of file diff --git a/libraries/render-utils/src/LightingModel.h b/libraries/render-utils/src/LightingModel.h index 8f3ee9b7d6..45514654f2 100644 --- a/libraries/render-utils/src/LightingModel.h +++ b/libraries/render-utils/src/LightingModel.h @@ -49,6 +49,8 @@ public: void setAlbedo(bool enable); bool isAlbedoEnabled() const; + void setMaterialTexturing(bool enable); + bool isMaterialTexturingEnabled() const; void setAmbientLight(bool enable); bool isAmbientLightEnabled() const; @@ -88,9 +90,12 @@ protected: float enableSpotLight{ 1.0f }; float showLightContour{ 0.0f }; // false by default + float enableObscurance{ 1.0f }; - glm::vec2 spares{ 0.0f }; + float enableMaterialTexturing { 1.0f }; + + float spares{ 0.0f }; Parameters() {} }; @@ -117,6 +122,8 @@ class MakeLightingModelConfig : public render::Job::Config { Q_PROPERTY(bool enableSpecular MEMBER enableSpecular NOTIFY dirty) Q_PROPERTY(bool enableAlbedo MEMBER enableAlbedo NOTIFY dirty) + Q_PROPERTY(bool enableMaterialTexturing MEMBER enableMaterialTexturing NOTIFY dirty) + Q_PROPERTY(bool enableAmbientLight MEMBER enableAmbientLight NOTIFY dirty) Q_PROPERTY(bool enableDirectionalLight MEMBER enableDirectionalLight NOTIFY dirty) Q_PROPERTY(bool enablePointLight MEMBER enablePointLight NOTIFY dirty) @@ -136,13 +143,16 @@ public: bool enableScattering{ true }; bool enableDiffuse{ true }; bool enableSpecular{ true }; + bool enableAlbedo{ true }; + bool enableMaterialTexturing { true }; bool enableAmbientLight{ true }; bool enableDirectionalLight{ true }; bool enablePointLight{ true }; bool enableSpotLight{ true }; + bool showLightContour { false }; // false by default signals: diff --git a/libraries/render-utils/src/MeshPartPayload.cpp b/libraries/render-utils/src/MeshPartPayload.cpp index fa180a654a..3276efd529 100644 --- a/libraries/render-utils/src/MeshPartPayload.cpp +++ b/libraries/render-utils/src/MeshPartPayload.cpp @@ -129,7 +129,7 @@ void MeshPartPayload::bindMesh(gpu::Batch& batch) const { } } -void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::LocationsPointer locations) const { +void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::LocationsPointer locations, bool enableTextures) const { if (!_drawMaterial) { return; } @@ -148,7 +148,7 @@ void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::Locat } // Albedo - if (materialKey.isAlbedoMap()) { + if (enableTextures && materialKey.isAlbedoMap()) { auto itr = textureMaps.find(model::MaterialKey::ALBEDO_MAP); if (itr != textureMaps.end() && itr->second->isDefined()) { batch.setResourceTexture(ShapePipeline::Slot::ALBEDO, itr->second->getTextureView()); @@ -160,7 +160,7 @@ void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::Locat } // Roughness map - if (materialKey.isRoughnessMap()) { + if (enableTextures && materialKey.isRoughnessMap()) { auto itr = textureMaps.find(model::MaterialKey::ROUGHNESS_MAP); if (itr != textureMaps.end() && itr->second->isDefined()) { batch.setResourceTexture(ShapePipeline::Slot::MAP::ROUGHNESS, itr->second->getTextureView()); @@ -174,7 +174,7 @@ void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::Locat } // Normal map - if (materialKey.isNormalMap()) { + if (enableTextures && materialKey.isNormalMap()) { auto itr = textureMaps.find(model::MaterialKey::NORMAL_MAP); if (itr != textureMaps.end() && itr->second->isDefined()) { batch.setResourceTexture(ShapePipeline::Slot::MAP::NORMAL, itr->second->getTextureView()); @@ -188,7 +188,7 @@ void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::Locat } // Metallic map - if (materialKey.isMetallicMap()) { + if (enableTextures && materialKey.isMetallicMap()) { auto itr = textureMaps.find(model::MaterialKey::METALLIC_MAP); if (itr != textureMaps.end() && itr->second->isDefined()) { batch.setResourceTexture(ShapePipeline::Slot::MAP::METALLIC, itr->second->getTextureView()); @@ -202,7 +202,7 @@ void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::Locat } // Occlusion map - if (materialKey.isOcclusionMap()) { + if (enableTextures && materialKey.isOcclusionMap()) { auto itr = textureMaps.find(model::MaterialKey::OCCLUSION_MAP); if (itr != textureMaps.end() && itr->second->isDefined()) { batch.setResourceTexture(ShapePipeline::Slot::MAP::OCCLUSION, itr->second->getTextureView()); @@ -216,7 +216,7 @@ void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::Locat } // Scattering map - if (materialKey.isScatteringMap()) { + if (enableTextures && materialKey.isScatteringMap()) { auto itr = textureMaps.find(model::MaterialKey::SCATTERING_MAP); if (itr != textureMaps.end() && itr->second->isDefined()) { batch.setResourceTexture(ShapePipeline::Slot::MAP::SCATTERING, itr->second->getTextureView()); @@ -230,7 +230,7 @@ void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::Locat } // Emissive / Lightmap - if (materialKey.isLightmapMap()) { + if (enableTextures && materialKey.isLightmapMap()) { auto itr = textureMaps.find(model::MaterialKey::LIGHTMAP_MAP); if (itr != textureMaps.end() && itr->second->isDefined()) { @@ -238,7 +238,7 @@ void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::Locat } else { batch.setResourceTexture(ShapePipeline::Slot::MAP::EMISSIVE_LIGHTMAP, textureCache->getGrayTexture()); } - } else if (materialKey.isEmissiveMap()) { + } else if (enableTextures && materialKey.isEmissiveMap()) { auto itr = textureMaps.find(model::MaterialKey::EMISSIVE_MAP); if (itr != textureMaps.end() && itr->second->isDefined()) { @@ -271,7 +271,7 @@ void MeshPartPayload::render(RenderArgs* args) const { bindMesh(batch); // apply material properties - bindMaterial(batch, locations); + bindMaterial(batch, locations, args->_enableTexturing); if (args) { args->_details._materialSwitches++; @@ -588,7 +588,7 @@ void ModelMeshPartPayload::render(RenderArgs* args) const { bindMesh(batch); // apply material properties - bindMaterial(batch, locations); + bindMaterial(batch, locations, args->_enableTexturing); args->_details._materialSwitches++; diff --git a/libraries/render-utils/src/MeshPartPayload.h b/libraries/render-utils/src/MeshPartPayload.h index 7d0aeab2bd..1f3778c34a 100644 --- a/libraries/render-utils/src/MeshPartPayload.h +++ b/libraries/render-utils/src/MeshPartPayload.h @@ -51,7 +51,7 @@ public: // ModelMeshPartPayload functions to perform render void drawCall(gpu::Batch& batch) const; virtual void bindMesh(gpu::Batch& batch) const; - virtual void bindMaterial(gpu::Batch& batch, const render::ShapePipeline::LocationsPointer locations) const; + virtual void bindMaterial(gpu::Batch& batch, const render::ShapePipeline::LocationsPointer locations, bool enableTextures) const; virtual void bindTransform(gpu::Batch& batch, const render::ShapePipeline::LocationsPointer locations, RenderArgs::RenderMode renderMode) const; // Payload resource cached values diff --git a/libraries/shared/src/RenderArgs.h b/libraries/shared/src/RenderArgs.h index 851e065f20..b2c05b0548 100644 --- a/libraries/shared/src/RenderArgs.h +++ b/libraries/shared/src/RenderArgs.h @@ -122,6 +122,7 @@ public: gpu::Batch* _batch = nullptr; std::shared_ptr _whiteTexture; + bool _enableTexturing { true }; RenderDetails _details; }; diff --git a/scripts/developer/utilities/render/deferredLighting.qml b/scripts/developer/utilities/render/deferredLighting.qml index 26dbc1f2bc..0ac4cbc5b5 100644 --- a/scripts/developer/utilities/render/deferredLighting.qml +++ b/scripts/developer/utilities/render/deferredLighting.qml @@ -25,6 +25,7 @@ Column { "Lightmap:LightingModel:enableLightmap", "Background:LightingModel:enableBackground", "ssao:AmbientOcclusion:enabled", + "Textures:LightingModel:enableMaterialTexturing", ] CheckBox { text: modelData.split(":")[0]