a bunch of changes to debug why...

This commit is contained in:
Sam Gateau 2019-09-11 18:21:44 -07:00
parent 3e8a91e3ec
commit 133a8b7d5e
7 changed files with 43 additions and 5 deletions

View file

@ -287,6 +287,7 @@ const QSurfaceFormat& getDefaultOpenGLSurfaceFormat() {
// Qt Quick may need a depth and stencil buffer. Always make sure these are available. // Qt Quick may need a depth and stencil buffer. Always make sure these are available.
format.setDepthBufferSize(DEFAULT_GL_DEPTH_BUFFER_BITS); format.setDepthBufferSize(DEFAULT_GL_DEPTH_BUFFER_BITS);
format.setStencilBufferSize(DEFAULT_GL_STENCIL_BUFFER_BITS); format.setStencilBufferSize(DEFAULT_GL_STENCIL_BUFFER_BITS);
format.setColorSpace(QSurfaceFormat::ColorSpace::sRGBColorSpace);
auto glversion = ::gl::getTargetVersion(); auto glversion = ::gl::getTargetVersion();
format.setMajorVersion(GL_GET_MAJOR_VERSION(glversion)); format.setMajorVersion(GL_GET_MAJOR_VERSION(glversion));
format.setMinorVersion(GL_GET_MINOR_VERSION(glversion)); format.setMinorVersion(GL_GET_MINOR_VERSION(glversion));

View file

@ -63,6 +63,7 @@ namespace scriptable {
* @property {Mat4|string} texCoordTransform1 * @property {Mat4|string} texCoordTransform1
* @property {string} lightmapParams * @property {string} lightmapParams
* @property {string} materialParams * @property {string} materialParams
* @property {string} opacityMode
* @property {boolean} defaultFallthrough * @property {boolean} defaultFallthrough
*/ */
class ScriptableMaterial { class ScriptableMaterial {
@ -94,7 +95,7 @@ namespace scriptable {
QString lightMap; QString lightMap;
QString scatteringMap; QString scatteringMap;
std::array<glm::mat4, graphics::Material::NUM_TEXCOORD_TRANSFORMS> texCoordTransforms; std::array<glm::mat4, graphics::Material::NUM_TEXCOORD_TRANSFORMS> texCoordTransforms;
QString opacityMode;
bool defaultFallthrough; bool defaultFallthrough;
std::unordered_map<uint, bool> propertyFallthroughs; // not actually exposed to script std::unordered_map<uint, bool> propertyFallthroughs; // not actually exposed to script

View file

@ -420,6 +420,18 @@ namespace scriptable {
obj.setProperty("opacityMap", material.opacityMap); 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)) { if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::OCCLUSION_MAP_BIT)) {
obj.setProperty("occlusionMap", FALLTHROUGH); obj.setProperty("occlusionMap", FALLTHROUGH);
} else if (!material.occlusionMap.isEmpty()) { } else if (!material.occlusionMap.isEmpty()) {

View file

@ -41,6 +41,8 @@ scriptable::ScriptableMaterial& scriptable::ScriptableMaterial::operator=(const
occlusionMap = material.occlusionMap; occlusionMap = material.occlusionMap;
lightMap = material.lightMap; lightMap = material.lightMap;
scatteringMap = material.scatteringMap; scatteringMap = material.scatteringMap;
opacityMode = material.opacityMode;
defaultFallthrough = material.defaultFallthrough; defaultFallthrough = material.defaultFallthrough;
propertyFallthroughs = material.propertyFallthroughs; propertyFallthroughs = material.propertyFallthroughs;
@ -55,6 +57,9 @@ scriptable::ScriptableMaterial::ScriptableMaterial(const graphics::MaterialPoint
name = material->getName().c_str(); name = material->getName().c_str();
model = material->getModel().c_str(); model = material->getModel().c_str();
opacity = material->getOpacity(); opacity = material->getOpacity();
opacityMode = (opacity < 1.0f ? "opacityVarAlpha" : "opaque");
roughness = material->getRoughness(); roughness = material->getRoughness();
metallic = material->getMetallic(); metallic = material->getMetallic();
scattering = material->getScattering(); scattering = material->getScattering();
@ -75,6 +80,8 @@ scriptable::ScriptableMaterial::ScriptableMaterial(const graphics::MaterialPoint
albedoMap = map->getTextureSource()->getUrl().toString(); albedoMap = map->getTextureSource()->getUrl().toString();
if (map->useAlphaChannel()) { if (map->useAlphaChannel()) {
opacityMap = albedoMap; opacityMap = albedoMap;
//opacityMode = (material->getKey().isOpacityMaskMap() ? "opacityMapAlphaMask" : "opacityMapAlphaBlend");
opacityMode = (material->getKey().isOpacityMaskMap() ? "opacityMapAlphaMask" : "opacityMapAlphaBlend");
} }
} }

View file

@ -128,7 +128,7 @@ function fromQml(message) {
var SELECT_LIST = "luci_materialInspector_SelectionList"; var SELECT_LIST = "luci_materialInspector_SelectionList";
Selection.enableListHighlight(SELECT_LIST, { Selection.enableListHighlight(SELECT_LIST, {
outlineUnoccludedColor: { red: 255, green: 255, blue: 255 } outlineUnoccludedColor: { red: 125, green: 255, blue: 225 }
}); });
function setSelectedObject(id, type) { function setSelectedObject(id, type) {
Selection.clearSelectedItemsList(SELECT_LIST); Selection.clearSelectedItemsList(SELECT_LIST);

View file

@ -51,6 +51,12 @@ void RenderThread::initialize(QWindow* window) {
_backend = _gpuContext->getBackend(); _backend = _gpuContext->getBackend();
_context.doneCurrent(); _context.doneCurrent();
_context.moveToThread(_thread); _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 #else
auto size = window->size(); auto size = window->size();
_extent = vk::Extent2D{ (uint32_t)size.width(), (uint32_t)size.height() }; _extent = vk::Extent2D{ (uint32_t)size.width(), (uint32_t)size.height() };
@ -169,15 +175,26 @@ void RenderThread::renderFrame(gpu::FramePointer& frame) {
} }
#ifdef USE_GL #ifdef USE_GL
static gpu::BatchPointer batch = nullptr;
if (!batch) {
batch = std::make_shared<gpu::Batch>();
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); //glDisable(GL_FRAMEBUFFER_SRGB);
//glClear(GL_COLOR_BUFFER_BIT); //glClear(GL_COLOR_BUFFER_BIT);
glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo); /* glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glBlitFramebuffer( glBlitFramebuffer(
0, 0, fboSize.x, fboSize.y, 0, 0, fboSize.x, fboSize.y,
0, 0, windowSize.width(), windowSize.height(), 0, 0, windowSize.width(), windowSize.height(),
GL_COLOR_BUFFER_BIT, GL_NEAREST); GL_COLOR_BUFFER_BIT, GL_NEAREST);
*/
(void)CHECK_GL_ERROR(); (void)CHECK_GL_ERROR();
_context.swapBuffers(); _context.swapBuffers();
_context.doneCurrent(); _context.doneCurrent();

View file

@ -57,7 +57,7 @@ public:
uint32_t _externalTexture{ 0 }; uint32_t _externalTexture{ 0 };
void move(const glm::vec3& v); void move(const glm::vec3& v);
glm::mat4 _correction; glm::mat4 _correction;
gpu::PipelinePointer _presentPipeline;
void resize(const QSize& newSize); void resize(const QSize& newSize);
void setup() override; void setup() override;