From 133a8b7d5e85ff6468615e870d3713ca59c45bb9 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Wed, 11 Sep 2019 18:21:44 -0700 Subject: [PATCH] a bunch of changes to debug why... --- libraries/gl/src/gl/GLHelpers.cpp | 1 + .../src/graphics-scripting/Forward.h | 3 ++- .../GraphicsScriptingInterface.cpp | 12 +++++++++++ .../graphics-scripting/ScriptableModel.cpp | 7 +++++++ .../utilities/render/materialInspector.js | 2 +- tools/gpu-frame-player/src/RenderThread.cpp | 21 +++++++++++++++++-- tools/gpu-frame-player/src/RenderThread.h | 2 +- 7 files changed, 43 insertions(+), 5 deletions(-) diff --git a/libraries/gl/src/gl/GLHelpers.cpp b/libraries/gl/src/gl/GLHelpers.cpp index b2c98e91d3..ddb93e0fa0 100644 --- a/libraries/gl/src/gl/GLHelpers.cpp +++ b/libraries/gl/src/gl/GLHelpers.cpp @@ -287,6 +287,7 @@ const QSurfaceFormat& getDefaultOpenGLSurfaceFormat() { // Qt Quick may need a depth and stencil buffer. Always make sure these are available. format.setDepthBufferSize(DEFAULT_GL_DEPTH_BUFFER_BITS); format.setStencilBufferSize(DEFAULT_GL_STENCIL_BUFFER_BITS); + format.setColorSpace(QSurfaceFormat::ColorSpace::sRGBColorSpace); auto glversion = ::gl::getTargetVersion(); format.setMajorVersion(GL_GET_MAJOR_VERSION(glversion)); format.setMinorVersion(GL_GET_MINOR_VERSION(glversion)); diff --git a/libraries/graphics-scripting/src/graphics-scripting/Forward.h b/libraries/graphics-scripting/src/graphics-scripting/Forward.h index 428c08e9f6..6fa7362e84 100644 --- a/libraries/graphics-scripting/src/graphics-scripting/Forward.h +++ b/libraries/graphics-scripting/src/graphics-scripting/Forward.h @@ -63,6 +63,7 @@ namespace scriptable { * @property {Mat4|string} texCoordTransform1 * @property {string} lightmapParams * @property {string} materialParams + * @property {string} opacityMode * @property {boolean} defaultFallthrough */ class ScriptableMaterial { @@ -94,7 +95,7 @@ namespace scriptable { QString lightMap; QString scatteringMap; std::array texCoordTransforms; - + QString opacityMode; bool defaultFallthrough; std::unordered_map propertyFallthroughs; // not actually exposed to script diff --git a/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.cpp b/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.cpp index 45f8461a1a..a271affe49 100644 --- a/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.cpp +++ b/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.cpp @@ -420,6 +420,18 @@ namespace scriptable { obj.setProperty("opacityMap", material.opacityMap); } + + obj.setProperty("keys.isOpaque", material.key.isOpaque()); + obj.setProperty("keys.isOpacityMaskMap", material.key.isOpacityMaskMap()); + obj.setProperty("keys.isTexelOpaque", material.key.isTexelOpaque()); + obj.setProperty("keys.isSurfaceOpaque", material.key.isSurfaceOpaque()); + + if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::OPACITY_MASK_MAP_BIT)) { + obj.setProperty("opacityMapMode", FALLTHROUGH); + } else if (material.key.isGlossy()) { + obj.setProperty("opacityMapMode", material.opacityMode); + } + if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::OCCLUSION_MAP_BIT)) { obj.setProperty("occlusionMap", FALLTHROUGH); } else if (!material.occlusionMap.isEmpty()) { diff --git a/libraries/graphics-scripting/src/graphics-scripting/ScriptableModel.cpp b/libraries/graphics-scripting/src/graphics-scripting/ScriptableModel.cpp index e9cc7930ae..071272a382 100644 --- a/libraries/graphics-scripting/src/graphics-scripting/ScriptableModel.cpp +++ b/libraries/graphics-scripting/src/graphics-scripting/ScriptableModel.cpp @@ -41,6 +41,8 @@ scriptable::ScriptableMaterial& scriptable::ScriptableMaterial::operator=(const occlusionMap = material.occlusionMap; lightMap = material.lightMap; scatteringMap = material.scatteringMap; + opacityMode = material.opacityMode; + defaultFallthrough = material.defaultFallthrough; propertyFallthroughs = material.propertyFallthroughs; @@ -55,6 +57,9 @@ scriptable::ScriptableMaterial::ScriptableMaterial(const graphics::MaterialPoint name = material->getName().c_str(); model = material->getModel().c_str(); opacity = material->getOpacity(); + + opacityMode = (opacity < 1.0f ? "opacityVarAlpha" : "opaque"); + roughness = material->getRoughness(); metallic = material->getMetallic(); scattering = material->getScattering(); @@ -75,6 +80,8 @@ scriptable::ScriptableMaterial::ScriptableMaterial(const graphics::MaterialPoint albedoMap = map->getTextureSource()->getUrl().toString(); if (map->useAlphaChannel()) { opacityMap = albedoMap; + //opacityMode = (material->getKey().isOpacityMaskMap() ? "opacityMapAlphaMask" : "opacityMapAlphaBlend"); + opacityMode = (material->getKey().isOpacityMaskMap() ? "opacityMapAlphaMask" : "opacityMapAlphaBlend"); } } diff --git a/scripts/developer/utilities/render/materialInspector.js b/scripts/developer/utilities/render/materialInspector.js index 98d9f769fb..8a7d5ad7dd 100644 --- a/scripts/developer/utilities/render/materialInspector.js +++ b/scripts/developer/utilities/render/materialInspector.js @@ -128,7 +128,7 @@ function fromQml(message) { var SELECT_LIST = "luci_materialInspector_SelectionList"; Selection.enableListHighlight(SELECT_LIST, { - outlineUnoccludedColor: { red: 255, green: 255, blue: 255 } + outlineUnoccludedColor: { red: 125, green: 255, blue: 225 } }); function setSelectedObject(id, type) { Selection.clearSelectedItemsList(SELECT_LIST); diff --git a/tools/gpu-frame-player/src/RenderThread.cpp b/tools/gpu-frame-player/src/RenderThread.cpp index ff0d7630e5..27e76b5ad8 100644 --- a/tools/gpu-frame-player/src/RenderThread.cpp +++ b/tools/gpu-frame-player/src/RenderThread.cpp @@ -51,6 +51,12 @@ void RenderThread::initialize(QWindow* window) { _backend = _gpuContext->getBackend(); _context.doneCurrent(); _context.moveToThread(_thread); + + if (!_presentPipeline) { + gpu::ShaderPointer program = gpu::Shader::createProgram(shader::gpu::program::DrawTexture); + gpu::StatePointer state = gpu::StatePointer(new gpu::State()); + _presentPipeline = gpu::Pipeline::create(program, state); + } #else auto size = window->size(); _extent = vk::Extent2D{ (uint32_t)size.width(), (uint32_t)size.height() }; @@ -169,15 +175,26 @@ void RenderThread::renderFrame(gpu::FramePointer& frame) { } #ifdef USE_GL + static gpu::BatchPointer batch = nullptr; + if (!batch) { + batch = std::make_shared(); + batch->setPipeline(_presentPipeline); + batch->setFramebuffer(nullptr); + batch->setResourceTexture(0, frame->framebuffer->getRenderBuffer(0)); + batch->setViewportTransform(ivec4(uvec2(0), ivec2(0.5 * fboSize.x, 0.5*fboSize.y))); + batch->draw(gpu::TRIANGLE_STRIP, 4); + } + _gpuContext->executeBatch(*batch); + //glDisable(GL_FRAMEBUFFER_SRGB); //glClear(GL_COLOR_BUFFER_BIT); - glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo); + /* glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glBlitFramebuffer( 0, 0, fboSize.x, fboSize.y, 0, 0, windowSize.width(), windowSize.height(), GL_COLOR_BUFFER_BIT, GL_NEAREST); - +*/ (void)CHECK_GL_ERROR(); _context.swapBuffers(); _context.doneCurrent(); diff --git a/tools/gpu-frame-player/src/RenderThread.h b/tools/gpu-frame-player/src/RenderThread.h index 09eef56623..b090e1737f 100644 --- a/tools/gpu-frame-player/src/RenderThread.h +++ b/tools/gpu-frame-player/src/RenderThread.h @@ -57,7 +57,7 @@ public: uint32_t _externalTexture{ 0 }; void move(const glm::vec3& v); glm::mat4 _correction; - + gpu::PipelinePointer _presentPipeline; void resize(const QSize& newSize); void setup() override;