From 307243da8b83c1fd6e9ce3ff57d8a5ff24a92a2b Mon Sep 17 00:00:00 2001 From: samcake Date: Wed, 13 Jul 2016 11:04:53 -0700 Subject: [PATCH] cleaning compilation warnings and tuning the FBX material mapping pass --- libraries/fbx/src/FBXReader_Material.cpp | 20 ++++++++++++------- .../render-utils/src/FramebufferCache.cpp | 6 ++---- libraries/render-utils/src/LightingModel.cpp | 2 +- .../render-utils/src/RenderDeferredTask.cpp | 16 ++++++++++++++- tools/scribe/src/TextTemplate.cpp | 2 -- 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/libraries/fbx/src/FBXReader_Material.cpp b/libraries/fbx/src/FBXReader_Material.cpp index 48b210b88e..f68203a04b 100644 --- a/libraries/fbx/src/FBXReader_Material.cpp +++ b/libraries/fbx/src/FBXReader_Material.cpp @@ -261,13 +261,19 @@ void FBXReader::consolidateFBXMaterials(const QVariantHash& mapping) { if (materialMap.contains(material.name)) { QJsonObject materialOptions = materialMap.value(material.name).toObject(); - float scattering = materialOptions.contains("scattering") ? materialOptions.value("scattering").toDouble() : 1.0f; - QByteArray scatteringMap = materialOptions.value("scatteringMap").toVariant().toByteArray(); - qDebug() << "Replacing material:" << material.name << "with skin scattering effect. scattering:" << scattering << "scatteringMap:" << scatteringMap; - material._material->setScattering(scattering); - material.scatteringTexture = FBXTexture(); - material.scatteringTexture.name = material.name + ".scatteringMap"; - material.scatteringTexture.filename = scatteringMap; + qDebug() << "Mapping fbx material:" << material.name << " with HifiMaterial: " << materialOptions; + + if (materialOptions.contains("scattering")) { + float scattering = (float) materialOptions.value("scattering").toDouble(); + material._material->setScattering(scattering); + } + + if (materialOptions.contains("scatteringMap")) { + QByteArray scatteringMap = materialOptions.value("scatteringMap").toVariant().toByteArray(); + material.scatteringTexture = FBXTexture(); + material.scatteringTexture.name = material.name + ".scatteringMap"; + material.scatteringTexture.filename = scatteringMap; + } } if (material.opacity <= 0.0f) { diff --git a/libraries/render-utils/src/FramebufferCache.cpp b/libraries/render-utils/src/FramebufferCache.cpp index c8308ce3f0..5375de273a 100644 --- a/libraries/render-utils/src/FramebufferCache.cpp +++ b/libraries/render-utils/src/FramebufferCache.cpp @@ -43,13 +43,11 @@ void FramebufferCache::setFrameBufferSize(QSize frameBufferSize) { } void FramebufferCache::createPrimaryFramebuffer() { - auto colorFormat = gpu::Element::COLOR_SRGBA_32; - auto linearFormat = gpu::Element::COLOR_RGBA_32; + auto colorFormat = gpu::Element::COLOR_SRGBA_32; auto width = _frameBufferSize.width(); auto height = _frameBufferSize.height(); auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_POINT); - auto depthFormat = gpu::Element(gpu::SCALAR, gpu::UINT32, gpu::DEPTH_STENCIL); // Depth24_Stencil8 texel format _selfieFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create()); auto tex = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width * 0.5, height * 0.5, defaultSampler)); @@ -74,7 +72,7 @@ void FramebufferCache::resizeAmbientOcclusionBuffers() { auto height = _frameBufferSize.height() >> _AOResolutionLevel; auto colorFormat = gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGB); auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR); - auto depthFormat = gpu::Element(gpu::SCALAR, gpu::UINT32, gpu::DEPTH_STENCIL); // Depth24_Stencil8 texel format + // auto depthFormat = gpu::Element(gpu::SCALAR, gpu::UINT32, gpu::DEPTH_STENCIL); // Depth24_Stencil8 texel format _occlusionTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height, defaultSampler)); _occlusionFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create()); diff --git a/libraries/render-utils/src/LightingModel.cpp b/libraries/render-utils/src/LightingModel.cpp index 891b59a726..a09c290b8d 100644 --- a/libraries/render-utils/src/LightingModel.cpp +++ b/libraries/render-utils/src/LightingModel.cpp @@ -122,7 +122,7 @@ void LightingModel::setShowLightContour(bool enable) { } } bool LightingModel::isShowLightContourEnabled() const { - return (bool)(_parametersBuffer.get().showLightContour > 0.0); + return (bool)(_parametersBuffer.get().showLightContour > 0.0f); } MakeLightingModel::MakeLightingModel() { diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index d186b1ac1c..5299b395ca 100755 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -217,6 +217,8 @@ void DrawDeferred::run(const SceneContextPointer& sceneContext, const RenderCont gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { args->_batch = &batch; + + // Setup camera, projection and viewport for all items batch.setViewportTransform(args->_viewport); batch.setStateScissorRect(args->_viewport); @@ -228,6 +230,9 @@ void DrawDeferred::run(const SceneContextPointer& sceneContext, const RenderCont batch.setProjectionTransform(projMat); batch.setViewTransform(viewMat); + // Setup lighting model for all items; + batch.setUniformBuffer(render::ShapePipeline::Slot::LIGHTING_MODEL, lightingModel->getParametersBuffer()); + renderShapes(sceneContext, renderContext, _shapePlumber, inItems, _maxDrawn); args->_batch = nullptr; }); @@ -248,6 +253,8 @@ void DrawStateSortDeferred::run(const SceneContextPointer& sceneContext, const R gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { args->_batch = &batch; + + // Setup camera, projection and viewport for all items batch.setViewportTransform(args->_viewport); batch.setStateScissorRect(args->_viewport); @@ -259,6 +266,9 @@ void DrawStateSortDeferred::run(const SceneContextPointer& sceneContext, const R batch.setProjectionTransform(projMat); batch.setViewTransform(viewMat); + // Setup lighting model for all items; + batch.setUniformBuffer(render::ShapePipeline::Slot::LIGHTING_MODEL, lightingModel->getParametersBuffer()); + if (_stateSort) { renderStateSortShapes(sceneContext, renderContext, _shapePlumber, inItems, _maxDrawn); } else { @@ -315,6 +325,9 @@ void DrawOverlay3D::run(const SceneContextPointer& sceneContext, const RenderCon batch.setProjectionTransform(projMat); batch.setViewTransform(viewMat); + // Setup lighting model for all items; + batch.setUniformBuffer(render::ShapePipeline::Slot::LIGHTING_MODEL, lightingModel->getParametersBuffer()); + renderShapes(sceneContext, renderContext, _shapePlumber, inItems, _maxDrawn); args->_batch = nullptr; }); @@ -361,7 +374,8 @@ void DrawBackgroundDeferred::run(const SceneContextPointer& sceneContext, const assert(renderContext->args->hasViewFrustum()); const auto& inItems = inputs.get0(); - const auto& lightingModel = inputs.get1(); + // Not used yet + // const auto& lightingModel = inputs.get1(); RenderArgs* args = renderContext->args; doInBatch(args->_context, [&](gpu::Batch& batch) { diff --git a/tools/scribe/src/TextTemplate.cpp b/tools/scribe/src/TextTemplate.cpp index 1fad1eac02..89937c4da6 100755 --- a/tools/scribe/src/TextTemplate.cpp +++ b/tools/scribe/src/TextTemplate.cpp @@ -741,7 +741,6 @@ int TextTemplate::evalBlockGeneration(std::ostream& dst, const BlockPointer& blo std::vector< String > paramCache; paramCache.push_back(""); String val; - bool valIsVar = false; for (int i = 1; i < nbParams; i++) { val = block->command.arguments[i]; if ((val[0] == Tag::VAR) && (val[val.length()-1] == Tag::VAR)) { @@ -752,7 +751,6 @@ int TextTemplate::evalBlockGeneration(std::ostream& dst, const BlockPointer& blo } else { val = Tag::NULL_VAR; } - valIsVar = true; } Vars::iterator it = vars.find(funcBlock->command.arguments[i]);