mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 06:18:52 +02:00
Renamed outline to highlight
This commit is contained in:
parent
84be026e0b
commit
3cc445ff02
23 changed files with 403 additions and 402 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -64,6 +64,7 @@ gvr-interface/libs/*
|
||||||
# ignore files for various dev environments
|
# ignore files for various dev environments
|
||||||
TAGS
|
TAGS
|
||||||
*.sw[po]
|
*.sw[po]
|
||||||
|
*.qmlc
|
||||||
|
|
||||||
# ignore node files for the console
|
# ignore node files for the console
|
||||||
node_modules
|
node_modules
|
||||||
|
|
|
@ -88,7 +88,7 @@ ContextOverlayInterface::ContextOverlayInterface() {
|
||||||
void ContextOverlayInterface::initializeSelectionToSceneHandler(SelectionToSceneHandler& handler, const QString& selectionName, render::Transaction& transaction) {
|
void ContextOverlayInterface::initializeSelectionToSceneHandler(SelectionToSceneHandler& handler, const QString& selectionName, render::Transaction& transaction) {
|
||||||
handler.initialize(selectionName);
|
handler.initialize(selectionName);
|
||||||
connect(_selectionScriptingInterface.data(), &SelectionScriptingInterface::selectedItemsListChanged, &handler, &SelectionToSceneHandler::selectedItemsListChanged);
|
connect(_selectionScriptingInterface.data(), &SelectionScriptingInterface::selectedItemsListChanged, &handler, &SelectionToSceneHandler::selectedItemsListChanged);
|
||||||
transaction.resetSelectionOutline(selectionName.toStdString());
|
transaction.resetSelectionHighlight(selectionName.toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
static const uint32_t MOUSE_HW_ID = 0;
|
static const uint32_t MOUSE_HW_ID = 0;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Outline.slf
|
// Highlight.slf
|
||||||
// Add outline effect based on two zbuffers : one containing the total scene z and another
|
// Add highlight effect based on two zbuffers : one containing the total scene z and another
|
||||||
// with the z of only the objects to be outlined.
|
// with the z of only the objects to be outlined.
|
||||||
// This is the version without the fill effect inside the silhouette.
|
// This is the version without the fill effect inside the silhouette.
|
||||||
//
|
//
|
||||||
|
@ -9,5 +9,5 @@
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
<@include Outline.slh@>
|
<@include Highlight.slh@>
|
||||||
<$main(0)$>
|
<$main(0)$>
|
|
@ -1,7 +1,7 @@
|
||||||
<@include gpu/Config.slh@>
|
<@include gpu/Config.slh@>
|
||||||
<$VERSION_HEADER$>
|
<$VERSION_HEADER$>
|
||||||
<!
|
<!
|
||||||
// Outline.slh
|
// Highlight.slh
|
||||||
// fragment shader
|
// fragment shader
|
||||||
//
|
//
|
||||||
// Created by Olivier Prat on 9/7/17.
|
// Created by Olivier Prat on 9/7/17.
|
||||||
|
@ -13,14 +13,14 @@
|
||||||
<@include DeferredTransform.slh@>
|
<@include DeferredTransform.slh@>
|
||||||
<$declareDeferredFrameTransform()$>
|
<$declareDeferredFrameTransform()$>
|
||||||
|
|
||||||
<@include Outline_shared.slh@>
|
<@include Highlight_shared.slh@>
|
||||||
|
|
||||||
uniform outlineParamsBuffer {
|
uniform highlightParamsBuffer {
|
||||||
OutlineParameters params;
|
HighlightParameters params;
|
||||||
};
|
};
|
||||||
|
|
||||||
uniform sampler2D sceneDepthMap;
|
uniform sampler2D sceneDepthMap;
|
||||||
uniform sampler2D outlinedDepthMap;
|
uniform sampler2D highlightedDepthMap;
|
||||||
|
|
||||||
in vec2 varTexCoord0;
|
in vec2 varTexCoord0;
|
||||||
out vec4 outFragColor;
|
out vec4 outFragColor;
|
||||||
|
@ -35,20 +35,20 @@ void main(void) {
|
||||||
// We offset by half a texel to be centered on the depth sample. If we don't do this
|
// We offset by half a texel to be centered on the depth sample. If we don't do this
|
||||||
// the blur will have a different width between the left / right sides and top / bottom
|
// the blur will have a different width between the left / right sides and top / bottom
|
||||||
// sides of the silhouette
|
// sides of the silhouette
|
||||||
float outlinedDepth = texture(outlinedDepthMap, varTexCoord0).x;
|
float highlightedDepth = texture(highlightedDepthMap, varTexCoord0).x;
|
||||||
float intensity = 0.0;
|
float intensity = 0.0;
|
||||||
|
|
||||||
if (outlinedDepth < FAR_Z) {
|
if (highlightedDepth < FAR_Z) {
|
||||||
// We're not on the far plane so we are on the outlined object, thus no outline to do!
|
// We're not on the far plane so we are on the highlighted object, thus no outline to do!
|
||||||
<@if IS_FILLED@>
|
<@if IS_FILLED@>
|
||||||
// But we need to fill the interior
|
// But we need to fill the interior
|
||||||
float sceneDepth = texture(sceneDepthMap, varTexCoord0).x;
|
float sceneDepth = texture(sceneDepthMap, varTexCoord0).x;
|
||||||
// Transform to linear depth for better precision
|
// Transform to linear depth for better precision
|
||||||
outlinedDepth = -evalZeyeFromZdb(outlinedDepth);
|
highlightedDepth = -evalZeyeFromZdb(highlightedDepth);
|
||||||
sceneDepth = -evalZeyeFromZdb(sceneDepth);
|
sceneDepth = -evalZeyeFromZdb(sceneDepth);
|
||||||
|
|
||||||
// Are we occluded?
|
// Are we occluded?
|
||||||
intensity = sceneDepth < (outlinedDepth-LINEAR_DEPTH_BIAS) ? params._occludedFillOpacity : params._unoccludedFillOpacity;
|
intensity = sceneDepth < (highlightedDepth-LINEAR_DEPTH_BIAS) ? params._occludedFillOpacity : params._unoccludedFillOpacity;
|
||||||
<@else@>
|
<@else@>
|
||||||
discard;
|
discard;
|
||||||
<@endif@>
|
<@endif@>
|
||||||
|
@ -70,8 +70,8 @@ void main(void) {
|
||||||
for (x=0 ; x<params._blurKernelSize ; x++) {
|
for (x=0 ; x<params._blurKernelSize ; x++) {
|
||||||
if (uv.x>=0.0 && uv.x<=1.0)
|
if (uv.x>=0.0 && uv.x<=1.0)
|
||||||
{
|
{
|
||||||
outlinedDepth = texture(outlinedDepthMap, uv).x;
|
highlightedDepth = texture(highlightedDepthMap, uv).x;
|
||||||
intensity += (outlinedDepth < FAR_Z) ? 1.0 : 0.0;
|
intensity += (highlightedDepth < FAR_Z) ? 1.0 : 0.0;
|
||||||
weight += 1.0;
|
weight += 1.0;
|
||||||
}
|
}
|
||||||
uv.x += deltaUv.x;
|
uv.x += deltaUv.x;
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// OutlineEffect.cpp
|
// HighlightEffect.cpp
|
||||||
// render-utils/src/
|
// render-utils/src/
|
||||||
//
|
//
|
||||||
// Created by Olivier Prat on 08/08/17.
|
// Created by Olivier Prat on 08/08/17.
|
||||||
|
@ -8,7 +8,7 @@
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
#include "OutlineEffect.h"
|
#include "HighlightEffect.h"
|
||||||
|
|
||||||
#include "GeometryCache.h"
|
#include "GeometryCache.h"
|
||||||
|
|
||||||
|
@ -25,18 +25,19 @@
|
||||||
#include "surfaceGeometry_copyDepth_frag.h"
|
#include "surfaceGeometry_copyDepth_frag.h"
|
||||||
#include "debug_deferred_buffer_vert.h"
|
#include "debug_deferred_buffer_vert.h"
|
||||||
#include "debug_deferred_buffer_frag.h"
|
#include "debug_deferred_buffer_frag.h"
|
||||||
#include "Outline_frag.h"
|
#include "Highlight_frag.h"
|
||||||
#include "Outline_filled_frag.h"
|
#include "Highlight_filled_frag.h"
|
||||||
#include "Outline_aabox_vert.h"
|
#include "Highlight_aabox_vert.h"
|
||||||
|
#include "nop_frag.h"
|
||||||
|
|
||||||
using namespace render;
|
using namespace render;
|
||||||
|
|
||||||
#define OUTLINE_STENCIL_MASK 1
|
#define OUTLINE_STENCIL_MASK 1
|
||||||
|
|
||||||
OutlineRessources::OutlineRessources() {
|
HighlightRessources::HighlightRessources() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutlineRessources::update(const gpu::FramebufferPointer& primaryFrameBuffer) {
|
void HighlightRessources::update(const gpu::FramebufferPointer& primaryFrameBuffer) {
|
||||||
auto newFrameSize = glm::ivec2(primaryFrameBuffer->getSize());
|
auto newFrameSize = glm::ivec2(primaryFrameBuffer->getSize());
|
||||||
|
|
||||||
// If the buffer size changed, we need to delete our FBOs and recreate them at the
|
// If the buffer size changed, we need to delete our FBOs and recreate them at the
|
||||||
|
@ -55,64 +56,64 @@ void OutlineRessources::update(const gpu::FramebufferPointer& primaryFrameBuffer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutlineRessources::allocateColorBuffer(const gpu::FramebufferPointer& primaryFrameBuffer) {
|
void HighlightRessources::allocateColorBuffer(const gpu::FramebufferPointer& primaryFrameBuffer) {
|
||||||
_colorFrameBuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("primaryWithStencil"));
|
_colorFrameBuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("primaryWithStencil"));
|
||||||
_colorFrameBuffer->setRenderBuffer(0, primaryFrameBuffer->getRenderBuffer(0));
|
_colorFrameBuffer->setRenderBuffer(0, primaryFrameBuffer->getRenderBuffer(0));
|
||||||
_colorFrameBuffer->setDepthStencilBuffer(_depthStencilTexture, _depthStencilTexture->getTexelFormat());
|
_colorFrameBuffer->setDepthStencilBuffer(_depthStencilTexture, _depthStencilTexture->getTexelFormat());
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutlineRessources::allocateDepthBuffer(const gpu::FramebufferPointer& primaryFrameBuffer) {
|
void HighlightRessources::allocateDepthBuffer(const gpu::FramebufferPointer& primaryFrameBuffer) {
|
||||||
auto depthFormat = gpu::Element(gpu::SCALAR, gpu::UINT32, gpu::DEPTH_STENCIL);
|
auto depthFormat = gpu::Element(gpu::SCALAR, gpu::UINT32, gpu::DEPTH_STENCIL);
|
||||||
_depthStencilTexture = gpu::TexturePointer(gpu::Texture::createRenderBuffer(depthFormat, _frameSize.x, _frameSize.y));
|
_depthStencilTexture = gpu::TexturePointer(gpu::Texture::createRenderBuffer(depthFormat, _frameSize.x, _frameSize.y));
|
||||||
_depthFrameBuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("outlineDepth"));
|
_depthFrameBuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("highlightDepth"));
|
||||||
_depthFrameBuffer->setDepthStencilBuffer(_depthStencilTexture, depthFormat);
|
_depthFrameBuffer->setDepthStencilBuffer(_depthStencilTexture, depthFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
gpu::FramebufferPointer OutlineRessources::getDepthFramebuffer() {
|
gpu::FramebufferPointer HighlightRessources::getDepthFramebuffer() {
|
||||||
assert(_depthFrameBuffer);
|
assert(_depthFrameBuffer);
|
||||||
return _depthFrameBuffer;
|
return _depthFrameBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
gpu::TexturePointer OutlineRessources::getDepthTexture() {
|
gpu::TexturePointer HighlightRessources::getDepthTexture() {
|
||||||
return _depthStencilTexture;
|
return _depthStencilTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
gpu::FramebufferPointer OutlineRessources::getColorFramebuffer() {
|
gpu::FramebufferPointer HighlightRessources::getColorFramebuffer() {
|
||||||
assert(_colorFrameBuffer);
|
assert(_colorFrameBuffer);
|
||||||
return _colorFrameBuffer;
|
return _colorFrameBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
OutlineSharedParameters::OutlineSharedParameters() {
|
HighlightSharedParameters::HighlightSharedParameters() {
|
||||||
_outlineIds.fill(render::OutlineStyleStage::INVALID_INDEX);
|
_highlightIds.fill(render::HighlightStage::INVALID_INDEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
float OutlineSharedParameters::getBlurPixelWidth(const render::OutlineStyle& style, int frameBufferHeight) {
|
float HighlightSharedParameters::getBlurPixelWidth(const render::HighlightStyle& style, int frameBufferHeight) {
|
||||||
return ceilf(style.width * frameBufferHeight / 400.0f);
|
return ceilf(style.outlineWidth * frameBufferHeight / 400.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
PrepareDrawOutline::PrepareDrawOutline() {
|
PrepareDrawHighlight::PrepareDrawHighlight() {
|
||||||
_ressources = std::make_shared<OutlineRessources>();
|
_ressources = std::make_shared<HighlightRessources>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrepareDrawOutline::run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs) {
|
void PrepareDrawHighlight::run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs) {
|
||||||
auto destinationFrameBuffer = inputs;
|
auto destinationFrameBuffer = inputs;
|
||||||
|
|
||||||
_ressources->update(destinationFrameBuffer);
|
_ressources->update(destinationFrameBuffer);
|
||||||
outputs = _ressources;
|
outputs = _ressources;
|
||||||
}
|
}
|
||||||
|
|
||||||
gpu::PipelinePointer DrawOutlineMask::_stencilMaskPipeline;
|
gpu::PipelinePointer DrawHighlightMask::_stencilMaskPipeline;
|
||||||
gpu::PipelinePointer DrawOutlineMask::_stencilMaskFillPipeline;
|
gpu::PipelinePointer DrawHighlightMask::_stencilMaskFillPipeline;
|
||||||
gpu::BufferPointer DrawOutlineMask::_boundsBuffer;
|
gpu::BufferPointer DrawHighlightMask::_boundsBuffer;
|
||||||
|
|
||||||
DrawOutlineMask::DrawOutlineMask(unsigned int outlineIndex,
|
DrawHighlightMask::DrawHighlightMask(unsigned int highlightIndex,
|
||||||
render::ShapePlumberPointer shapePlumber, OutlineSharedParametersPointer parameters) :
|
render::ShapePlumberPointer shapePlumber, HighlightSharedParametersPointer parameters) :
|
||||||
_outlineIndex{ outlineIndex },
|
_highlightIndex{ highlightIndex },
|
||||||
_shapePlumber { shapePlumber },
|
_shapePlumber { shapePlumber },
|
||||||
_sharedParameters{ parameters } {
|
_sharedParameters{ parameters } {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawOutlineMask::run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs) {
|
void DrawHighlightMask::run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs) {
|
||||||
assert(renderContext->args);
|
assert(renderContext->args);
|
||||||
assert(renderContext->args->hasViewFrustum());
|
assert(renderContext->args->hasViewFrustum());
|
||||||
auto& inShapes = inputs.get0();
|
auto& inShapes = inputs.get0();
|
||||||
|
@ -130,8 +131,8 @@ void DrawOutlineMask::run(const render::RenderContextPointer& renderContext, con
|
||||||
fillState->setColorWriteMask(false, false, false, false);
|
fillState->setColorWriteMask(false, false, false, false);
|
||||||
fillState->setCullMode(gpu::State::CULL_FRONT);
|
fillState->setCullMode(gpu::State::CULL_FRONT);
|
||||||
|
|
||||||
auto vs = gpu::Shader::createVertex(std::string(Outline_aabox_vert));
|
auto vs = gpu::Shader::createVertex(std::string(Highlight_aabox_vert));
|
||||||
auto ps = gpu::StandardShaderLib::getDrawWhitePS();
|
auto ps = gpu::Shader::createPixel(std::string(nop_frag));
|
||||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||||
|
|
||||||
gpu::Shader::BindingSet slotBindings;
|
gpu::Shader::BindingSet slotBindings;
|
||||||
|
@ -145,12 +146,12 @@ void DrawOutlineMask::run(const render::RenderContextPointer& renderContext, con
|
||||||
_boundsBuffer = std::make_shared<gpu::Buffer>(sizeof(render::ItemBound));
|
_boundsBuffer = std::make_shared<gpu::Buffer>(sizeof(render::ItemBound));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto outlineStage = renderContext->_scene->getStage<render::OutlineStyleStage>(render::OutlineStyleStage::getName());
|
auto highlightStage = renderContext->_scene->getStage<render::HighlightStage>(render::HighlightStage::getName());
|
||||||
auto outlineId = _sharedParameters->_outlineIds[_outlineIndex];
|
auto highlightId = _sharedParameters->_highlightIds[_highlightIndex];
|
||||||
|
|
||||||
if (!inShapes.empty() && !render::OutlineStyleStage::isIndexInvalid(outlineId)) {
|
if (!inShapes.empty() && !render::HighlightStage::isIndexInvalid(highlightId)) {
|
||||||
auto ressources = inputs.get1();
|
auto ressources = inputs.get1();
|
||||||
auto& outline = outlineStage->getOutline(outlineId);
|
auto& highlight = highlightStage->getHighlight(highlightId);
|
||||||
|
|
||||||
RenderArgs* args = renderContext->args;
|
RenderArgs* args = renderContext->args;
|
||||||
ShapeKey::Builder defaultKeyBuilder;
|
ShapeKey::Builder defaultKeyBuilder;
|
||||||
|
@ -219,62 +220,62 @@ void DrawOutlineMask::run(const render::RenderContextPointer& renderContext, con
|
||||||
batch.setViewTransform(viewMat);
|
batch.setViewTransform(viewMat);
|
||||||
|
|
||||||
// Draw stencil mask with object bounding boxes
|
// Draw stencil mask with object bounding boxes
|
||||||
const auto outlineWidthLoc = _stencilMaskPipeline->getProgram()->getUniforms().findLocation("outlineWidth");
|
const auto highlightWidthLoc = _stencilMaskPipeline->getProgram()->getUniforms().findLocation("outlineWidth");
|
||||||
const auto sqrt3 = 1.74f;
|
const auto sqrt3 = 1.74f;
|
||||||
const float blurPixelWidth = 2.0f * sqrt3 * OutlineSharedParameters::getBlurPixelWidth(outline._style, args->_viewport.w);
|
const float blurPixelWidth = 2.0f * sqrt3 * HighlightSharedParameters::getBlurPixelWidth(highlight._style, args->_viewport.w);
|
||||||
const auto framebufferSize = ressources->getSourceFrameSize();
|
const auto framebufferSize = ressources->getSourceFrameSize();
|
||||||
|
|
||||||
auto stencilPipeline = outline._style.isFilled() ? _stencilMaskFillPipeline : _stencilMaskPipeline;
|
auto stencilPipeline = highlight._style.isFilled() ? _stencilMaskFillPipeline : _stencilMaskPipeline;
|
||||||
batch.setPipeline(stencilPipeline);
|
batch.setPipeline(stencilPipeline);
|
||||||
batch.setResourceBuffer(0, _boundsBuffer);
|
batch.setResourceBuffer(0, _boundsBuffer);
|
||||||
batch._glUniform2f(outlineWidthLoc, blurPixelWidth / framebufferSize.x, blurPixelWidth / framebufferSize.y);
|
batch._glUniform2f(highlightWidthLoc, blurPixelWidth / framebufferSize.x, blurPixelWidth / framebufferSize.y);
|
||||||
static const int NUM_VERTICES_PER_CUBE = 36;
|
static const int NUM_VERTICES_PER_CUBE = 36;
|
||||||
batch.draw(gpu::TRIANGLES, NUM_VERTICES_PER_CUBE * (gpu::uint32) itemBounds.size(), 0);
|
batch.draw(gpu::TRIANGLES, NUM_VERTICES_PER_CUBE * (gpu::uint32) itemBounds.size(), 0);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Outline rect should be null as there are no outlined shapes
|
// Highlight rect should be null as there are no highlighted shapes
|
||||||
outputs = glm::ivec4(0, 0, 0, 0);
|
outputs = glm::ivec4(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gpu::PipelinePointer DrawOutline::_pipeline;
|
gpu::PipelinePointer DrawHighlight::_pipeline;
|
||||||
gpu::PipelinePointer DrawOutline::_pipelineFilled;
|
gpu::PipelinePointer DrawHighlight::_pipelineFilled;
|
||||||
|
|
||||||
DrawOutline::DrawOutline(unsigned int outlineIndex, OutlineSharedParametersPointer parameters) :
|
DrawHighlight::DrawHighlight(unsigned int highlightIndex, HighlightSharedParametersPointer parameters) :
|
||||||
_outlineIndex{ outlineIndex },
|
_highlightIndex{ highlightIndex },
|
||||||
_sharedParameters{ parameters } {
|
_sharedParameters{ parameters } {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawOutline::run(const render::RenderContextPointer& renderContext, const Inputs& inputs) {
|
void DrawHighlight::run(const render::RenderContextPointer& renderContext, const Inputs& inputs) {
|
||||||
auto outlineFrameBuffer = inputs.get1();
|
auto highlightFrameBuffer = inputs.get1();
|
||||||
auto outlineRect = inputs.get3();
|
auto highlightRect = inputs.get3();
|
||||||
|
|
||||||
if (outlineFrameBuffer && outlineRect.z>0 && outlineRect.w>0) {
|
if (highlightFrameBuffer && highlightRect.z>0 && highlightRect.w>0) {
|
||||||
auto sceneDepthBuffer = inputs.get2();
|
auto sceneDepthBuffer = inputs.get2();
|
||||||
const auto frameTransform = inputs.get0();
|
const auto frameTransform = inputs.get0();
|
||||||
auto outlinedDepthTexture = outlineFrameBuffer->getDepthTexture();
|
auto highlightedDepthTexture = highlightFrameBuffer->getDepthTexture();
|
||||||
auto destinationFrameBuffer = outlineFrameBuffer->getColorFramebuffer();
|
auto destinationFrameBuffer = highlightFrameBuffer->getColorFramebuffer();
|
||||||
auto framebufferSize = glm::ivec2(outlinedDepthTexture->getDimensions());
|
auto framebufferSize = glm::ivec2(highlightedDepthTexture->getDimensions());
|
||||||
|
|
||||||
if (sceneDepthBuffer) {
|
if (sceneDepthBuffer) {
|
||||||
auto args = renderContext->args;
|
auto args = renderContext->args;
|
||||||
|
|
||||||
auto outlineStage = renderContext->_scene->getStage<render::OutlineStyleStage>(render::OutlineStyleStage::getName());
|
auto highlightStage = renderContext->_scene->getStage<render::HighlightStage>(render::HighlightStage::getName());
|
||||||
auto outlineId = _sharedParameters->_outlineIds[_outlineIndex];
|
auto highlightId = _sharedParameters->_highlightIds[_highlightIndex];
|
||||||
if (!render::OutlineStyleStage::isIndexInvalid(outlineId)) {
|
if (!render::HighlightStage::isIndexInvalid(highlightId)) {
|
||||||
auto& outline = outlineStage->getOutline(_sharedParameters->_outlineIds[_outlineIndex]);
|
auto& highlight = highlightStage->getHighlight(_sharedParameters->_highlightIds[_highlightIndex]);
|
||||||
auto pipeline = getPipeline(outline._style);
|
auto pipeline = getPipeline(highlight._style);
|
||||||
{
|
{
|
||||||
auto& shaderParameters = _configuration.edit();
|
auto& shaderParameters = _configuration.edit();
|
||||||
|
|
||||||
shaderParameters._color = outline._style.color;
|
shaderParameters._color = highlight._style.color;
|
||||||
shaderParameters._intensity = outline._style.intensity * (outline._style.glow ? 2.0f : 1.0f);
|
shaderParameters._intensity = highlight._style.outlineIntensity * (highlight._style.isOutlineSmooth ? 2.0f : 1.0f);
|
||||||
shaderParameters._unoccludedFillOpacity = outline._style.unoccludedFillOpacity;
|
shaderParameters._unoccludedFillOpacity = highlight._style.unoccludedFillOpacity;
|
||||||
shaderParameters._occludedFillOpacity = outline._style.occludedFillOpacity;
|
shaderParameters._occludedFillOpacity = highlight._style.occludedFillOpacity;
|
||||||
shaderParameters._threshold = outline._style.glow ? 1.0f : 1e-3f;
|
shaderParameters._threshold = highlight._style.isOutlineSmooth ? 1.0f : 1e-3f;
|
||||||
shaderParameters._blurKernelSize = std::min(7, std::max(2, (int)floorf(outline._style.width * 3 + 0.5f)));
|
shaderParameters._blurKernelSize = std::min(7, std::max(2, (int)floorf(highlight._style.outlineWidth * 3 + 0.5f)));
|
||||||
// Size is in normalized screen height. We decide that for outline width = 1, this is equal to 1/400.
|
// Size is in normalized screen height. We decide that for highlight width = 1, this is equal to 1/400.
|
||||||
auto size = outline._style.width / 400.0f;
|
auto size = highlight._style.outlineWidth / 400.0f;
|
||||||
shaderParameters._size.x = (size * framebufferSize.y) / framebufferSize.x;
|
shaderParameters._size.x = (size * framebufferSize.y) / framebufferSize.x;
|
||||||
shaderParameters._size.y = size;
|
shaderParameters._size.y = size;
|
||||||
}
|
}
|
||||||
|
@ -289,10 +290,10 @@ void DrawOutline::run(const render::RenderContextPointer& renderContext, const I
|
||||||
batch.setModelTransform(gpu::Framebuffer::evalSubregionTexcoordTransform(framebufferSize, args->_viewport));
|
batch.setModelTransform(gpu::Framebuffer::evalSubregionTexcoordTransform(framebufferSize, args->_viewport));
|
||||||
batch.setPipeline(pipeline);
|
batch.setPipeline(pipeline);
|
||||||
|
|
||||||
batch.setUniformBuffer(OUTLINE_PARAMS_SLOT, _configuration);
|
batch.setUniformBuffer(HIGHLIGHT_PARAMS_SLOT, _configuration);
|
||||||
batch.setUniformBuffer(FRAME_TRANSFORM_SLOT, frameTransform->getFrameTransformBuffer());
|
batch.setUniformBuffer(FRAME_TRANSFORM_SLOT, frameTransform->getFrameTransformBuffer());
|
||||||
batch.setResourceTexture(SCENE_DEPTH_SLOT, sceneDepthBuffer->getPrimaryDepthTexture());
|
batch.setResourceTexture(SCENE_DEPTH_MAP_SLOT, sceneDepthBuffer->getPrimaryDepthTexture());
|
||||||
batch.setResourceTexture(OUTLINED_DEPTH_SLOT, outlinedDepthTexture);
|
batch.setResourceTexture(HIGHLIGHTED_DEPTH_MAP_SLOT, highlightedDepthTexture);
|
||||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -300,7 +301,7 @@ void DrawOutline::run(const render::RenderContextPointer& renderContext, const I
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const gpu::PipelinePointer& DrawOutline::getPipeline(const render::OutlineStyle& style) {
|
const gpu::PipelinePointer& DrawHighlight::getPipeline(const render::HighlightStyle& style) {
|
||||||
if (!_pipeline) {
|
if (!_pipeline) {
|
||||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||||
state->setDepthTest(gpu::State::DepthTest(false, false));
|
state->setDepthTest(gpu::State::DepthTest(false, false));
|
||||||
|
@ -308,19 +309,19 @@ const gpu::PipelinePointer& DrawOutline::getPipeline(const render::OutlineStyle&
|
||||||
state->setStencilTest(true, 0, gpu::State::StencilTest(OUTLINE_STENCIL_MASK, 0xFF, gpu::EQUAL));
|
state->setStencilTest(true, 0, gpu::State::StencilTest(OUTLINE_STENCIL_MASK, 0xFF, gpu::EQUAL));
|
||||||
|
|
||||||
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
|
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
|
||||||
auto ps = gpu::Shader::createPixel(std::string(Outline_frag));
|
auto ps = gpu::Shader::createPixel(std::string(Highlight_frag));
|
||||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||||
|
|
||||||
gpu::Shader::BindingSet slotBindings;
|
gpu::Shader::BindingSet slotBindings;
|
||||||
slotBindings.insert(gpu::Shader::Binding("outlineParamsBuffer", OUTLINE_PARAMS_SLOT));
|
slotBindings.insert(gpu::Shader::Binding("highlightParamsBuffer", HIGHLIGHT_PARAMS_SLOT));
|
||||||
slotBindings.insert(gpu::Shader::Binding("deferredFrameTransformBuffer", FRAME_TRANSFORM_SLOT));
|
slotBindings.insert(gpu::Shader::Binding("deferredFrameTransformBuffer", FRAME_TRANSFORM_SLOT));
|
||||||
slotBindings.insert(gpu::Shader::Binding("sceneDepthMap", SCENE_DEPTH_SLOT));
|
slotBindings.insert(gpu::Shader::Binding("sceneDepthMap", SCENE_DEPTH_MAP_SLOT));
|
||||||
slotBindings.insert(gpu::Shader::Binding("outlinedDepthMap", OUTLINED_DEPTH_SLOT));
|
slotBindings.insert(gpu::Shader::Binding("highlightedDepthMap", HIGHLIGHTED_DEPTH_MAP_SLOT));
|
||||||
gpu::Shader::makeProgram(*program, slotBindings);
|
gpu::Shader::makeProgram(*program, slotBindings);
|
||||||
|
|
||||||
_pipeline = gpu::Pipeline::create(program, state);
|
_pipeline = gpu::Pipeline::create(program, state);
|
||||||
|
|
||||||
ps = gpu::Shader::createPixel(std::string(Outline_filled_frag));
|
ps = gpu::Shader::createPixel(std::string(Highlight_filled_frag));
|
||||||
program = gpu::Shader::createProgram(vs, ps);
|
program = gpu::Shader::createProgram(vs, ps);
|
||||||
gpu::Shader::makeProgram(*program, slotBindings);
|
gpu::Shader::makeProgram(*program, slotBindings);
|
||||||
_pipelineFilled = gpu::Pipeline::create(program, state);
|
_pipelineFilled = gpu::Pipeline::create(program, state);
|
||||||
|
@ -328,33 +329,33 @@ const gpu::PipelinePointer& DrawOutline::getPipeline(const render::OutlineStyle&
|
||||||
return style.isFilled() ? _pipelineFilled : _pipeline;
|
return style.isFilled() ? _pipelineFilled : _pipeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugOutline::DebugOutline() {
|
DebugHighlight::DebugHighlight() {
|
||||||
_geometryDepthId = DependencyManager::get<GeometryCache>()->allocateID();
|
_geometryDepthId = DependencyManager::get<GeometryCache>()->allocateID();
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugOutline::~DebugOutline() {
|
DebugHighlight::~DebugHighlight() {
|
||||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
if (geometryCache) {
|
if (geometryCache) {
|
||||||
geometryCache->releaseID(_geometryDepthId);
|
geometryCache->releaseID(_geometryDepthId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugOutline::configure(const Config& config) {
|
void DebugHighlight::configure(const Config& config) {
|
||||||
_isDisplayEnabled = config.viewMask;
|
_isDisplayEnabled = config.viewMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugOutline::run(const render::RenderContextPointer& renderContext, const Inputs& input) {
|
void DebugHighlight::run(const render::RenderContextPointer& renderContext, const Inputs& input) {
|
||||||
const auto outlineRessources = input.get0();
|
const auto highlightRessources = input.get0();
|
||||||
const auto outlineRect = input.get1();
|
const auto highlightRect = input.get1();
|
||||||
|
|
||||||
if (_isDisplayEnabled && outlineRessources && outlineRect.z>0 && outlineRect.w>0) {
|
if (_isDisplayEnabled && highlightRessources && highlightRect.z>0 && highlightRect.w>0) {
|
||||||
assert(renderContext->args);
|
assert(renderContext->args);
|
||||||
assert(renderContext->args->hasViewFrustum());
|
assert(renderContext->args->hasViewFrustum());
|
||||||
RenderArgs* args = renderContext->args;
|
RenderArgs* args = renderContext->args;
|
||||||
|
|
||||||
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
|
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
|
||||||
batch.setViewportTransform(args->_viewport);
|
batch.setViewportTransform(args->_viewport);
|
||||||
batch.setFramebuffer(outlineRessources->getColorFramebuffer());
|
batch.setFramebuffer(highlightRessources->getColorFramebuffer());
|
||||||
|
|
||||||
const auto geometryBuffer = DependencyManager::get<GeometryCache>();
|
const auto geometryBuffer = DependencyManager::get<GeometryCache>();
|
||||||
|
|
||||||
|
@ -369,7 +370,7 @@ void DebugOutline::run(const render::RenderContextPointer& renderContext, const
|
||||||
const glm::vec4 color(1.0f, 1.0f, 1.0f, 1.0f);
|
const glm::vec4 color(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
batch.setPipeline(getDepthPipeline());
|
batch.setPipeline(getDepthPipeline());
|
||||||
batch.setResourceTexture(0, outlineRessources->getDepthTexture());
|
batch.setResourceTexture(0, highlightRessources->getDepthTexture());
|
||||||
const glm::vec2 bottomLeft(-1.0f, -1.0f);
|
const glm::vec2 bottomLeft(-1.0f, -1.0f);
|
||||||
const glm::vec2 topRight(1.0f, 1.0f);
|
const glm::vec2 topRight(1.0f, 1.0f);
|
||||||
geometryBuffer->renderQuad(batch, bottomLeft, topRight, color, _geometryDepthId);
|
geometryBuffer->renderQuad(batch, bottomLeft, topRight, color, _geometryDepthId);
|
||||||
|
@ -379,7 +380,7 @@ void DebugOutline::run(const render::RenderContextPointer& renderContext, const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugOutline::initializePipelines() {
|
void DebugHighlight::initializePipelines() {
|
||||||
static const std::string VERTEX_SHADER{ debug_deferred_buffer_vert };
|
static const std::string VERTEX_SHADER{ debug_deferred_buffer_vert };
|
||||||
static const std::string FRAGMENT_SHADER{ debug_deferred_buffer_frag };
|
static const std::string FRAGMENT_SHADER{ debug_deferred_buffer_frag };
|
||||||
static const std::string SOURCE_PLACEHOLDER{ "//SOURCE_PLACEHOLDER" };
|
static const std::string SOURCE_PLACEHOLDER{ "//SOURCE_PLACEHOLDER" };
|
||||||
|
@ -417,7 +418,7 @@ void DebugOutline::initializePipelines() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const gpu::PipelinePointer& DebugOutline::getDepthPipeline() {
|
const gpu::PipelinePointer& DebugHighlight::getDepthPipeline() {
|
||||||
if (!_depthPipeline) {
|
if (!_depthPipeline) {
|
||||||
initializePipelines();
|
initializePipelines();
|
||||||
}
|
}
|
||||||
|
@ -425,44 +426,44 @@ const gpu::PipelinePointer& DebugOutline::getDepthPipeline() {
|
||||||
return _depthPipeline;
|
return _depthPipeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectionToOutline::run(const render::RenderContextPointer& renderContext, Outputs& outputs) {
|
void SelectionToHighlight::run(const render::RenderContextPointer& renderContext, Outputs& outputs) {
|
||||||
auto outlineStage = renderContext->_scene->getStage<render::OutlineStyleStage>(render::OutlineStyleStage::getName());
|
auto highlightStage = renderContext->_scene->getStage<render::HighlightStage>(render::HighlightStage::getName());
|
||||||
|
|
||||||
outputs.clear();
|
outputs.clear();
|
||||||
_sharedParameters->_outlineIds.fill(render::OutlineStyleStage::INVALID_INDEX);
|
_sharedParameters->_highlightIds.fill(render::HighlightStage::INVALID_INDEX);
|
||||||
|
|
||||||
for (auto i = 0; i < OutlineSharedParameters::MAX_OUTLINE_COUNT; i++) {
|
for (auto i = 0; i < HighlightSharedParameters::MAX_HIGHLIGHT_COUNT; i++) {
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
stream << "contextOverlayHighlightList";
|
stream << "contextOverlayHighlightList";
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
stream << i;
|
stream << i;
|
||||||
}
|
}
|
||||||
auto selectionName = stream.str();
|
auto selectionName = stream.str();
|
||||||
auto outlineId = outlineStage->getOutlineIdBySelection(selectionName);
|
auto highlightId = highlightStage->getHighlightIdBySelection(selectionName);
|
||||||
if (!render::OutlineStyleStage::isIndexInvalid(outlineId)) {
|
if (!render::HighlightStage::isIndexInvalid(highlightId)) {
|
||||||
_sharedParameters->_outlineIds[outputs.size()] = outlineId;
|
_sharedParameters->_highlightIds[outputs.size()] = highlightId;
|
||||||
outputs.emplace_back(selectionName);
|
outputs.emplace_back(selectionName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExtractSelectionName::run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs) {
|
void ExtractSelectionName::run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs) {
|
||||||
if (_outlineIndex < inputs.size()) {
|
if (_highlightIndex < inputs.size()) {
|
||||||
outputs = inputs[_outlineIndex];
|
outputs = inputs[_highlightIndex];
|
||||||
} else {
|
} else {
|
||||||
outputs.clear();
|
outputs.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawOutlineTask::DrawOutlineTask() {
|
DrawHighlightTask::DrawHighlightTask() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawOutlineTask::configure(const Config& config) {
|
void DrawHighlightTask::configure(const Config& config) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawOutlineTask::build(JobModel& task, const render::Varying& inputs, render::Varying& outputs) {
|
void DrawHighlightTask::build(JobModel& task, const render::Varying& inputs, render::Varying& outputs) {
|
||||||
const auto items = inputs.getN<Inputs>(0).get<RenderFetchCullSortTask::BucketList>();
|
const auto items = inputs.getN<Inputs>(0).get<RenderFetchCullSortTask::BucketList>();
|
||||||
const auto sceneFrameBuffer = inputs.getN<Inputs>(1);
|
const auto sceneFrameBuffer = inputs.getN<Inputs>(1);
|
||||||
const auto primaryFramebuffer = inputs.getN<Inputs>(2);
|
const auto primaryFramebuffer = inputs.getN<Inputs>(2);
|
||||||
|
@ -477,53 +478,53 @@ void DrawOutlineTask::build(JobModel& task, const render::Varying& inputs, rende
|
||||||
|
|
||||||
initMaskPipelines(*shapePlumber, state);
|
initMaskPipelines(*shapePlumber, state);
|
||||||
}
|
}
|
||||||
auto sharedParameters = std::make_shared<OutlineSharedParameters>();
|
auto sharedParameters = std::make_shared<HighlightSharedParameters>();
|
||||||
|
|
||||||
const auto outlineSelectionNames = task.addJob<SelectionToOutline>("SelectionToOutline", sharedParameters);
|
const auto highlightSelectionNames = task.addJob<SelectionToHighlight>("SelectionToHighlight", sharedParameters);
|
||||||
|
|
||||||
// Prepare for outline group rendering.
|
// Prepare for highlight group rendering.
|
||||||
const auto outlineRessources = task.addJob<PrepareDrawOutline>("PrepareOutline", primaryFramebuffer);
|
const auto highlightRessources = task.addJob<PrepareDrawHighlight>("PrepareHighlight", primaryFramebuffer);
|
||||||
render::Varying outline0Rect;
|
render::Varying highlight0Rect;
|
||||||
|
|
||||||
for (auto i = 0; i < OutlineSharedParameters::MAX_OUTLINE_COUNT; i++) {
|
for (auto i = 0; i < HighlightSharedParameters::MAX_HIGHLIGHT_COUNT; i++) {
|
||||||
const auto selectionName = task.addJob<ExtractSelectionName>("ExtractSelectionName", outlineSelectionNames, i);
|
const auto selectionName = task.addJob<ExtractSelectionName>("ExtractSelectionName", highlightSelectionNames, i);
|
||||||
const auto groupItems = addSelectItemJobs(task, selectionName, items);
|
const auto groupItems = addSelectItemJobs(task, selectionName, items);
|
||||||
const auto outlinedItemIDs = task.addJob<render::MetaToSubItems>("OutlineMetaToSubItemIDs", groupItems);
|
const auto highlightedItemIDs = task.addJob<render::MetaToSubItems>("HighlightMetaToSubItemIDs", groupItems);
|
||||||
const auto outlinedItems = task.addJob<render::IDsToBounds>("OutlineMetaToSubItems", outlinedItemIDs);
|
const auto highlightedItems = task.addJob<render::IDsToBounds>("HighlightMetaToSubItems", highlightedItemIDs);
|
||||||
|
|
||||||
// Sort
|
// Sort
|
||||||
const auto sortedPipelines = task.addJob<render::PipelineSortShapes>("OutlinePipelineSort", outlinedItems);
|
const auto sortedPipelines = task.addJob<render::PipelineSortShapes>("HighlightPipelineSort", highlightedItems);
|
||||||
const auto sortedBounds = task.addJob<render::DepthSortShapes>("OutlineDepthSort", sortedPipelines);
|
const auto sortedBounds = task.addJob<render::DepthSortShapes>("HighlightDepthSort", sortedPipelines);
|
||||||
|
|
||||||
// Draw depth of outlined objects in separate buffer
|
// Draw depth of highlighted objects in separate buffer
|
||||||
std::string name;
|
std::string name;
|
||||||
{
|
{
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
stream << "OutlineMask" << i;
|
stream << "HighlightMask" << i;
|
||||||
name = stream.str();
|
name = stream.str();
|
||||||
}
|
}
|
||||||
const auto drawMaskInputs = DrawOutlineMask::Inputs(sortedBounds, outlineRessources).asVarying();
|
const auto drawMaskInputs = DrawHighlightMask::Inputs(sortedBounds, highlightRessources).asVarying();
|
||||||
const auto outlinedRect = task.addJob<DrawOutlineMask>(name, drawMaskInputs, i, shapePlumber, sharedParameters);
|
const auto highlightedRect = task.addJob<DrawHighlightMask>(name, drawMaskInputs, i, shapePlumber, sharedParameters);
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
outline0Rect = outlinedRect;
|
highlight0Rect = highlightedRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw outline
|
// Draw highlight
|
||||||
{
|
{
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
stream << "OutlineEffect" << i;
|
stream << "HighlightEffect" << i;
|
||||||
name = stream.str();
|
name = stream.str();
|
||||||
}
|
}
|
||||||
const auto drawOutlineInputs = DrawOutline::Inputs(deferredFrameTransform, outlineRessources, sceneFrameBuffer, outlinedRect).asVarying();
|
const auto drawHighlightInputs = DrawHighlight::Inputs(deferredFrameTransform, highlightRessources, sceneFrameBuffer, highlightedRect).asVarying();
|
||||||
task.addJob<DrawOutline>(name, drawOutlineInputs, i, sharedParameters);
|
task.addJob<DrawHighlight>(name, drawHighlightInputs, i, sharedParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debug outline
|
// Debug highlight
|
||||||
const auto debugInputs = DebugOutline::Inputs(outlineRessources, const_cast<const render::Varying&>(outline0Rect)).asVarying();
|
const auto debugInputs = DebugHighlight::Inputs(highlightRessources, const_cast<const render::Varying&>(highlight0Rect)).asVarying();
|
||||||
task.addJob<DebugOutline>("OutlineDebug", debugInputs);
|
task.addJob<DebugHighlight>("HighlightDebug", debugInputs);
|
||||||
}
|
}
|
||||||
|
|
||||||
const render::Varying DrawOutlineTask::addSelectItemJobs(JobModel& task, const render::Varying& selectionName,
|
const render::Varying DrawHighlightTask::addSelectItemJobs(JobModel& task, const render::Varying& selectionName,
|
||||||
const RenderFetchCullSortTask::BucketList& items) {
|
const RenderFetchCullSortTask::BucketList& items) {
|
||||||
const auto& opaques = items[RenderFetchCullSortTask::OPAQUE_SHAPE];
|
const auto& opaques = items[RenderFetchCullSortTask::OPAQUE_SHAPE];
|
||||||
const auto& transparents = items[RenderFetchCullSortTask::TRANSPARENT_SHAPE];
|
const auto& transparents = items[RenderFetchCullSortTask::TRANSPARENT_SHAPE];
|
||||||
|
@ -542,7 +543,7 @@ const render::Varying DrawOutlineTask::addSelectItemJobs(JobModel& task, const r
|
||||||
|
|
||||||
#include "model_shadow_frag.h"
|
#include "model_shadow_frag.h"
|
||||||
|
|
||||||
void DrawOutlineTask::initMaskPipelines(render::ShapePlumber& shapePlumber, gpu::StatePointer state) {
|
void DrawHighlightTask::initMaskPipelines(render::ShapePlumber& shapePlumber, gpu::StatePointer state) {
|
||||||
auto modelVertex = gpu::Shader::createVertex(std::string(model_shadow_vert));
|
auto modelVertex = gpu::Shader::createVertex(std::string(model_shadow_vert));
|
||||||
auto modelPixel = gpu::Shader::createPixel(std::string(model_shadow_frag));
|
auto modelPixel = gpu::Shader::createPixel(std::string(model_shadow_frag));
|
||||||
gpu::ShaderPointer modelProgram = gpu::Shader::createProgram(modelVertex, modelPixel);
|
gpu::ShaderPointer modelProgram = gpu::Shader::createProgram(modelVertex, modelPixel);
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// OutlineEffect.h
|
// HighlightEffect.h
|
||||||
// render-utils/src/
|
// render-utils/src/
|
||||||
//
|
//
|
||||||
// Created by Olivier Prat on 08/08/17.
|
// Created by Olivier Prat on 08/08/17.
|
||||||
|
@ -9,19 +9,19 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef hifi_render_utils_OutlineEffect_h
|
#ifndef hifi_render_utils_HighlightEffect_h
|
||||||
#define hifi_render_utils_OutlineEffect_h
|
#define hifi_render_utils_HighlightEffect_h
|
||||||
|
|
||||||
#include <render/Engine.h>
|
#include <render/Engine.h>
|
||||||
#include <render/OutlineStyleStage.h>
|
#include <render/HighlightStage.h>
|
||||||
#include <render/RenderFetchCullSortTask.h>
|
#include <render/RenderFetchCullSortTask.h>
|
||||||
|
|
||||||
#include "DeferredFramebuffer.h"
|
#include "DeferredFramebuffer.h"
|
||||||
#include "DeferredFrameTransform.h"
|
#include "DeferredFrameTransform.h"
|
||||||
|
|
||||||
class OutlineRessources {
|
class HighlightRessources {
|
||||||
public:
|
public:
|
||||||
OutlineRessources();
|
HighlightRessources();
|
||||||
|
|
||||||
gpu::FramebufferPointer getDepthFramebuffer();
|
gpu::FramebufferPointer getDepthFramebuffer();
|
||||||
gpu::TexturePointer getDepthTexture();
|
gpu::TexturePointer getDepthTexture();
|
||||||
|
@ -44,131 +44,131 @@ protected:
|
||||||
void allocateDepthBuffer(const gpu::FramebufferPointer& primaryFrameBuffer);
|
void allocateDepthBuffer(const gpu::FramebufferPointer& primaryFrameBuffer);
|
||||||
};
|
};
|
||||||
|
|
||||||
using OutlineRessourcesPointer = std::shared_ptr<OutlineRessources>;
|
using HighlightRessourcesPointer = std::shared_ptr<HighlightRessources>;
|
||||||
|
|
||||||
class OutlineSharedParameters {
|
class HighlightSharedParameters {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MAX_OUTLINE_COUNT = 8
|
MAX_HIGHLIGHT_COUNT = 8
|
||||||
};
|
};
|
||||||
|
|
||||||
OutlineSharedParameters();
|
HighlightSharedParameters();
|
||||||
|
|
||||||
std::array<render::OutlineStyleStage::Index, MAX_OUTLINE_COUNT> _outlineIds;
|
std::array<render::HighlightStage::Index, MAX_HIGHLIGHT_COUNT> _highlightIds;
|
||||||
|
|
||||||
static float getBlurPixelWidth(const render::OutlineStyle& style, int frameBufferHeight);
|
static float getBlurPixelWidth(const render::HighlightStyle& style, int frameBufferHeight);
|
||||||
};
|
};
|
||||||
|
|
||||||
using OutlineSharedParametersPointer = std::shared_ptr<OutlineSharedParameters>;
|
using HighlightSharedParametersPointer = std::shared_ptr<HighlightSharedParameters>;
|
||||||
|
|
||||||
class PrepareDrawOutline {
|
class PrepareDrawHighlight {
|
||||||
public:
|
public:
|
||||||
using Inputs = gpu::FramebufferPointer;
|
using Inputs = gpu::FramebufferPointer;
|
||||||
using Outputs = OutlineRessourcesPointer;
|
using Outputs = HighlightRessourcesPointer;
|
||||||
using JobModel = render::Job::ModelIO<PrepareDrawOutline, Inputs, Outputs>;
|
using JobModel = render::Job::ModelIO<PrepareDrawHighlight, Inputs, Outputs>;
|
||||||
|
|
||||||
PrepareDrawOutline();
|
PrepareDrawHighlight();
|
||||||
|
|
||||||
void run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs);
|
void run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
OutlineRessourcesPointer _ressources;
|
HighlightRessourcesPointer _ressources;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SelectionToOutline {
|
class SelectionToHighlight {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
using Outputs = std::vector<std::string>;
|
using Outputs = std::vector<std::string>;
|
||||||
using JobModel = render::Job::ModelO<SelectionToOutline, Outputs>;
|
using JobModel = render::Job::ModelO<SelectionToHighlight, Outputs>;
|
||||||
|
|
||||||
SelectionToOutline(OutlineSharedParametersPointer parameters) : _sharedParameters{ parameters } {}
|
SelectionToHighlight(HighlightSharedParametersPointer parameters) : _sharedParameters{ parameters } {}
|
||||||
|
|
||||||
void run(const render::RenderContextPointer& renderContext, Outputs& outputs);
|
void run(const render::RenderContextPointer& renderContext, Outputs& outputs);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
OutlineSharedParametersPointer _sharedParameters;
|
HighlightSharedParametersPointer _sharedParameters;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ExtractSelectionName {
|
class ExtractSelectionName {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
using Inputs = SelectionToOutline::Outputs;
|
using Inputs = SelectionToHighlight::Outputs;
|
||||||
using Outputs = std::string;
|
using Outputs = std::string;
|
||||||
using JobModel = render::Job::ModelIO<ExtractSelectionName, Inputs, Outputs>;
|
using JobModel = render::Job::ModelIO<ExtractSelectionName, Inputs, Outputs>;
|
||||||
|
|
||||||
ExtractSelectionName(unsigned int outlineIndex) : _outlineIndex{ outlineIndex } {}
|
ExtractSelectionName(unsigned int highlightIndex) : _highlightIndex{ highlightIndex } {}
|
||||||
|
|
||||||
void run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs);
|
void run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
unsigned int _outlineIndex;
|
unsigned int _highlightIndex;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DrawOutlineMask {
|
class DrawHighlightMask {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
using Inputs = render::VaryingSet2<render::ShapeBounds, OutlineRessourcesPointer>;
|
using Inputs = render::VaryingSet2<render::ShapeBounds, HighlightRessourcesPointer>;
|
||||||
using Outputs = glm::ivec4;
|
using Outputs = glm::ivec4;
|
||||||
using JobModel = render::Job::ModelIO<DrawOutlineMask, Inputs, Outputs>;
|
using JobModel = render::Job::ModelIO<DrawHighlightMask, Inputs, Outputs>;
|
||||||
|
|
||||||
DrawOutlineMask(unsigned int outlineIndex, render::ShapePlumberPointer shapePlumber, OutlineSharedParametersPointer parameters);
|
DrawHighlightMask(unsigned int highlightIndex, render::ShapePlumberPointer shapePlumber, HighlightSharedParametersPointer parameters);
|
||||||
|
|
||||||
void run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs);
|
void run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
unsigned int _outlineIndex;
|
unsigned int _highlightIndex;
|
||||||
render::ShapePlumberPointer _shapePlumber;
|
render::ShapePlumberPointer _shapePlumber;
|
||||||
OutlineSharedParametersPointer _sharedParameters;
|
HighlightSharedParametersPointer _sharedParameters;
|
||||||
|
|
||||||
static gpu::BufferPointer _boundsBuffer;
|
static gpu::BufferPointer _boundsBuffer;
|
||||||
static gpu::PipelinePointer _stencilMaskPipeline;
|
static gpu::PipelinePointer _stencilMaskPipeline;
|
||||||
static gpu::PipelinePointer _stencilMaskFillPipeline;
|
static gpu::PipelinePointer _stencilMaskFillPipeline;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DrawOutline {
|
class DrawHighlight {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
using Inputs = render::VaryingSet4<DeferredFrameTransformPointer, OutlineRessourcesPointer, DeferredFramebufferPointer, glm::ivec4>;
|
using Inputs = render::VaryingSet4<DeferredFrameTransformPointer, HighlightRessourcesPointer, DeferredFramebufferPointer, glm::ivec4>;
|
||||||
using Config = render::Job::Config;
|
using Config = render::Job::Config;
|
||||||
using JobModel = render::Job::ModelI<DrawOutline, Inputs, Config>;
|
using JobModel = render::Job::ModelI<DrawHighlight, Inputs, Config>;
|
||||||
|
|
||||||
DrawOutline(unsigned int outlineIndex, OutlineSharedParametersPointer parameters);
|
DrawHighlight(unsigned int highlightIndex, HighlightSharedParametersPointer parameters);
|
||||||
|
|
||||||
void run(const render::RenderContextPointer& renderContext, const Inputs& inputs);
|
void run(const render::RenderContextPointer& renderContext, const Inputs& inputs);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
#include "Outline_shared.slh"
|
#include "Highlight_shared.slh"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
SCENE_DEPTH_SLOT = 0,
|
SCENE_DEPTH_MAP_SLOT = 0,
|
||||||
OUTLINED_DEPTH_SLOT,
|
HIGHLIGHTED_DEPTH_MAP_SLOT,
|
||||||
|
|
||||||
OUTLINE_PARAMS_SLOT = 0,
|
HIGHLIGHT_PARAMS_SLOT = 0,
|
||||||
FRAME_TRANSFORM_SLOT,
|
FRAME_TRANSFORM_SLOT,
|
||||||
};
|
};
|
||||||
|
|
||||||
using OutlineConfigurationBuffer = gpu::StructBuffer<OutlineParameters>;
|
using HighlightConfigurationBuffer = gpu::StructBuffer<HighlightParameters>;
|
||||||
|
|
||||||
static const gpu::PipelinePointer& getPipeline(const render::OutlineStyle& style);
|
static const gpu::PipelinePointer& getPipeline(const render::HighlightStyle& style);
|
||||||
|
|
||||||
static gpu::PipelinePointer _pipeline;
|
static gpu::PipelinePointer _pipeline;
|
||||||
static gpu::PipelinePointer _pipelineFilled;
|
static gpu::PipelinePointer _pipelineFilled;
|
||||||
|
|
||||||
unsigned int _outlineIndex;
|
unsigned int _highlightIndex;
|
||||||
OutlineParameters _parameters;
|
HighlightParameters _parameters;
|
||||||
OutlineSharedParametersPointer _sharedParameters;
|
HighlightSharedParametersPointer _sharedParameters;
|
||||||
OutlineConfigurationBuffer _configuration;
|
HighlightConfigurationBuffer _configuration;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DebugOutlineConfig : public render::Job::Config {
|
class DebugHighlightConfig : public render::Job::Config {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool viewMask MEMBER viewMask NOTIFY dirty)
|
Q_PROPERTY(bool viewMask MEMBER viewMask NOTIFY dirty)
|
||||||
|
|
||||||
|
@ -180,14 +180,14 @@ signals:
|
||||||
void dirty();
|
void dirty();
|
||||||
};
|
};
|
||||||
|
|
||||||
class DebugOutline {
|
class DebugHighlight {
|
||||||
public:
|
public:
|
||||||
using Inputs = render::VaryingSet2<OutlineRessourcesPointer, glm::ivec4>;
|
using Inputs = render::VaryingSet2<HighlightRessourcesPointer, glm::ivec4>;
|
||||||
using Config = DebugOutlineConfig;
|
using Config = DebugHighlightConfig;
|
||||||
using JobModel = render::Job::ModelI<DebugOutline, Inputs, Config>;
|
using JobModel = render::Job::ModelI<DebugHighlight, Inputs, Config>;
|
||||||
|
|
||||||
DebugOutline();
|
DebugHighlight();
|
||||||
~DebugOutline();
|
~DebugHighlight();
|
||||||
|
|
||||||
void configure(const Config& config);
|
void configure(const Config& config);
|
||||||
void run(const render::RenderContextPointer& renderContext, const Inputs& inputs);
|
void run(const render::RenderContextPointer& renderContext, const Inputs& inputs);
|
||||||
|
@ -202,14 +202,14 @@ private:
|
||||||
void initializePipelines();
|
void initializePipelines();
|
||||||
};
|
};
|
||||||
|
|
||||||
class DrawOutlineTask {
|
class DrawHighlightTask {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
using Inputs = render::VaryingSet4<RenderFetchCullSortTask::BucketList, DeferredFramebufferPointer, gpu::FramebufferPointer, DeferredFrameTransformPointer>;
|
using Inputs = render::VaryingSet4<RenderFetchCullSortTask::BucketList, DeferredFramebufferPointer, gpu::FramebufferPointer, DeferredFrameTransformPointer>;
|
||||||
using Config = render::Task::Config;
|
using Config = render::Task::Config;
|
||||||
using JobModel = render::Task::ModelI<DrawOutlineTask, Inputs, Config>;
|
using JobModel = render::Task::ModelI<DrawHighlightTask, Inputs, Config>;
|
||||||
|
|
||||||
DrawOutlineTask();
|
DrawHighlightTask();
|
||||||
|
|
||||||
void configure(const Config& config);
|
void configure(const Config& config);
|
||||||
void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs);
|
void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs);
|
||||||
|
@ -221,6 +221,6 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_render_utils_OutlineEffect_h
|
#endif // hifi_render_utils_HighlightEffect_h
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Outline_filled.slf
|
// Highlight_filled.slf
|
||||||
// Add outline effect based on two zbuffers : one containing the total scene z and another
|
// Add highlight effect based on two zbuffers : one containing the total scene z and another
|
||||||
// with the z of only the objects to be outlined.
|
// with the z of only the objects to be outlined.
|
||||||
// This is the version with the fill effect inside the silhouette.
|
// This is the version with the fill effect inside the silhouette.
|
||||||
//
|
//
|
||||||
|
@ -9,5 +9,5 @@
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
<@include Outline.slh@>
|
<@include Highlight.slh@>
|
||||||
<$main(1)$>
|
<$main(1)$>
|
|
@ -1,4 +1,4 @@
|
||||||
// glsl / C++ compatible source as interface for Outline
|
// glsl / C++ compatible source as interface for highlight
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
# define TVEC2 glm::vec2
|
# define TVEC2 glm::vec2
|
||||||
# define TVEC3 glm::vec3
|
# define TVEC3 glm::vec3
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
# define TVEC4 vec4
|
# define TVEC4 vec4
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct OutlineParameters
|
struct HighlightParameters
|
||||||
{
|
{
|
||||||
TVEC3 _color;
|
TVEC3 _color;
|
||||||
float _intensity;
|
float _intensity;
|
|
@ -42,7 +42,7 @@
|
||||||
#include "ToneMappingEffect.h"
|
#include "ToneMappingEffect.h"
|
||||||
#include "SubsurfaceScattering.h"
|
#include "SubsurfaceScattering.h"
|
||||||
#include "DrawHaze.h"
|
#include "DrawHaze.h"
|
||||||
#include "OutlineEffect.h"
|
#include "HighlightEffect.h"
|
||||||
|
|
||||||
#include <gpu/StandardShaderLib.h>
|
#include <gpu/StandardShaderLib.h>
|
||||||
|
|
||||||
|
@ -183,15 +183,15 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
|
||||||
const auto toneMappingInputs = ToneMappingDeferred::Inputs(lightingFramebuffer, primaryFramebuffer).asVarying();
|
const auto toneMappingInputs = ToneMappingDeferred::Inputs(lightingFramebuffer, primaryFramebuffer).asVarying();
|
||||||
task.addJob<ToneMappingDeferred>("ToneMapping", toneMappingInputs);
|
task.addJob<ToneMappingDeferred>("ToneMapping", toneMappingInputs);
|
||||||
|
|
||||||
const auto outlineRangeTimer = task.addJob<BeginGPURangeTimer>("BeginOutlineRangeTimer", "Outline");
|
const auto outlineRangeTimer = task.addJob<BeginGPURangeTimer>("BeginHighlightRangeTimer", "Highlight");
|
||||||
// Select items that need to be outlined
|
// Select items that need to be outlined
|
||||||
const auto selectionBaseName = "contextOverlayHighlightList";
|
const auto selectionBaseName = "contextOverlayHighlightList";
|
||||||
const auto selectedItems = addSelectItemJobs(task, selectionBaseName, metas, opaques, transparents);
|
const auto selectedItems = addSelectItemJobs(task, selectionBaseName, metas, opaques, transparents);
|
||||||
|
|
||||||
const auto outlineInputs = DrawOutlineTask::Inputs(items.get0(), deferredFramebuffer, primaryFramebuffer, deferredFrameTransform).asVarying();
|
const auto outlineInputs = DrawHighlightTask::Inputs(items.get0(), deferredFramebuffer, primaryFramebuffer, deferredFrameTransform).asVarying();
|
||||||
task.addJob<DrawOutlineTask>("DrawOutline", outlineInputs);
|
task.addJob<DrawHighlightTask>("DrawHighlight", outlineInputs);
|
||||||
|
|
||||||
task.addJob<EndGPURangeTimer>("OutlineRangeTimer", outlineRangeTimer);
|
task.addJob<EndGPURangeTimer>("HighlightRangeTimer", outlineRangeTimer);
|
||||||
|
|
||||||
{ // DEbug the bounds of the rendered items, still look at the zbuffer
|
{ // DEbug the bounds of the rendered items, still look at the zbuffer
|
||||||
task.addJob<DrawBounds>("DrawMetaBounds", metas);
|
task.addJob<DrawBounds>("DrawMetaBounds", metas);
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "BackgroundStage.h"
|
#include "BackgroundStage.h"
|
||||||
#include "HazeStage.h"
|
#include "HazeStage.h"
|
||||||
#include <render/TransitionStage.h>
|
#include <render/TransitionStage.h>
|
||||||
#include <render/OutlineStyleStage.h>
|
#include <render/HighlightStage.h>
|
||||||
#include "DeferredLightingEffect.h"
|
#include "DeferredLightingEffect.h"
|
||||||
|
|
||||||
void UpdateSceneTask::build(JobModel& task, const render::Varying& input, render::Varying& output) {
|
void UpdateSceneTask::build(JobModel& task, const render::Varying& input, render::Varying& output) {
|
||||||
|
@ -23,7 +23,7 @@ void UpdateSceneTask::build(JobModel& task, const render::Varying& input, render
|
||||||
task.addJob<BackgroundStageSetup>("BackgroundStageSetup");
|
task.addJob<BackgroundStageSetup>("BackgroundStageSetup");
|
||||||
task.addJob<HazeStageSetup>("HazeStageSetup");
|
task.addJob<HazeStageSetup>("HazeStageSetup");
|
||||||
task.addJob<render::TransitionStageSetup>("TransitionStageSetup");
|
task.addJob<render::TransitionStageSetup>("TransitionStageSetup");
|
||||||
task.addJob<render::OutlineStyleStageSetup>("OutlineStyleStageSetup");
|
task.addJob<render::HighlightStageSetup>("HighlightStageSetup");
|
||||||
|
|
||||||
task.addJob<DefaultLightingSetup>("DefaultLightingSetup");
|
task.addJob<DefaultLightingSetup>("DefaultLightingSetup");
|
||||||
|
|
||||||
|
|
46
libraries/render/src/render/HighlightStage.cpp
Normal file
46
libraries/render/src/render/HighlightStage.cpp
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
#include "HighlightStage.h"
|
||||||
|
|
||||||
|
using namespace render;
|
||||||
|
|
||||||
|
std::string HighlightStage::_name("Highlight");
|
||||||
|
|
||||||
|
HighlightStage::Index HighlightStage::addHighlight(const std::string& selectionName, const HighlightStyle& style) {
|
||||||
|
Highlight outline{ selectionName, style };
|
||||||
|
Index id;
|
||||||
|
|
||||||
|
id = _highlights.newElement(outline);
|
||||||
|
_activeHighlightIds.push_back(id);
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HighlightStage::removeHighlight(Index index) {
|
||||||
|
HighlightIdList::iterator idIterator = std::find(_activeHighlightIds.begin(), _activeHighlightIds.end(), index);
|
||||||
|
if (idIterator != _activeHighlightIds.end()) {
|
||||||
|
_activeHighlightIds.erase(idIterator);
|
||||||
|
}
|
||||||
|
if (!_highlights.isElementFreed(index)) {
|
||||||
|
_highlights.freeElement(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Index HighlightStage::getHighlightIdBySelection(const std::string& selectionName) const {
|
||||||
|
for (auto outlineId : _activeHighlightIds) {
|
||||||
|
const auto& outline = _highlights.get(outlineId);
|
||||||
|
if (outline._selectionName == selectionName) {
|
||||||
|
return outlineId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return INVALID_INDEX;
|
||||||
|
}
|
||||||
|
|
||||||
|
HighlightStageSetup::HighlightStageSetup() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void HighlightStageSetup::run(const render::RenderContextPointer& renderContext) {
|
||||||
|
if (!renderContext->_scene->getStage(HighlightStage::getName())) {
|
||||||
|
auto stage = std::make_shared<HighlightStage>();
|
||||||
|
renderContext->_scene->resetStage(HighlightStage::getName(), stage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
77
libraries/render/src/render/HighlightStage.h
Normal file
77
libraries/render/src/render/HighlightStage.h
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
//
|
||||||
|
// HighlightStage.h
|
||||||
|
|
||||||
|
// Created by Olivier Prat on 07/07/2017.
|
||||||
|
// Copyright 2017 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_render_utils_HighlightStage_h
|
||||||
|
#define hifi_render_utils_HighlightStage_h
|
||||||
|
|
||||||
|
#include "Stage.h"
|
||||||
|
#include "Engine.h"
|
||||||
|
#include "IndexedContainer.h"
|
||||||
|
#include "HighlightStyle.h"
|
||||||
|
|
||||||
|
namespace render {
|
||||||
|
|
||||||
|
// Highlight stage to set up HighlightStyle-related effects
|
||||||
|
class HighlightStage : public Stage {
|
||||||
|
public:
|
||||||
|
|
||||||
|
class Highlight {
|
||||||
|
public:
|
||||||
|
|
||||||
|
Highlight(const std::string& selectionName, const HighlightStyle& style) : _selectionName{ selectionName }, _style{ style } { }
|
||||||
|
|
||||||
|
std::string _selectionName;
|
||||||
|
HighlightStyle _style;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
static const std::string& getName() { return _name; }
|
||||||
|
|
||||||
|
using Index = render::indexed_container::Index;
|
||||||
|
static const Index INVALID_INDEX{ render::indexed_container::INVALID_INDEX };
|
||||||
|
using HighlightIdList = render::indexed_container::Indices;
|
||||||
|
|
||||||
|
static bool isIndexInvalid(Index index) { return index == INVALID_INDEX; }
|
||||||
|
|
||||||
|
bool checkHighlightId(Index index) const { return _highlights.checkIndex(index); }
|
||||||
|
|
||||||
|
const Highlight& getHighlight(Index index) const { return _highlights.get(index); }
|
||||||
|
Highlight& editHighlight(Index index) { return _highlights.edit(index); }
|
||||||
|
|
||||||
|
Index addHighlight(const std::string& selectionName, const HighlightStyle& style = HighlightStyle());
|
||||||
|
Index getHighlightIdBySelection(const std::string& selectionName) const;
|
||||||
|
void removeHighlight(Index index);
|
||||||
|
|
||||||
|
HighlightIdList::iterator begin() { return _activeHighlightIds.begin(); }
|
||||||
|
HighlightIdList::iterator end() { return _activeHighlightIds.end(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
using Highlights = render::indexed_container::IndexedVector<Highlight>;
|
||||||
|
|
||||||
|
static std::string _name;
|
||||||
|
|
||||||
|
Highlights _highlights;
|
||||||
|
HighlightIdList _activeHighlightIds;
|
||||||
|
};
|
||||||
|
using HighlightStagePointer = std::shared_ptr<HighlightStage>;
|
||||||
|
|
||||||
|
class HighlightStageSetup {
|
||||||
|
public:
|
||||||
|
using JobModel = render::Job::Model<HighlightStageSetup>;
|
||||||
|
|
||||||
|
HighlightStageSetup();
|
||||||
|
void run(const RenderContextPointer& renderContext);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif // hifi_render_utils_HighlightStage_h
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// OutlineStyle.h
|
// HighlightStyle.h
|
||||||
|
|
||||||
// Created by Olivier Prat on 11/06/2017.
|
// Created by Olivier Prat on 11/06/2017.
|
||||||
// Copyright 2017 High Fidelity, Inc.
|
// Copyright 2017 High Fidelity, Inc.
|
||||||
|
@ -8,8 +8,8 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef hifi_render_utils_OutlineStyle_h
|
#ifndef hifi_render_utils_HighlightStyle_h
|
||||||
#define hifi_render_utils_OutlineStyle_h
|
#define hifi_render_utils_HighlightStyle_h
|
||||||
|
|
||||||
#include <glm/vec3.hpp>
|
#include <glm/vec3.hpp>
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
namespace render {
|
namespace render {
|
||||||
|
|
||||||
// This holds the configuration for a particular outline style
|
// This holds the configuration for a particular outline style
|
||||||
class OutlineStyle {
|
class HighlightStyle {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool isFilled() const {
|
bool isFilled() const {
|
||||||
|
@ -26,14 +26,13 @@ namespace render {
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 color{ 1.f, 0.7f, 0.2f };
|
glm::vec3 color{ 1.f, 0.7f, 0.2f };
|
||||||
float width{ 2.0f };
|
float outlineWidth{ 2.0f };
|
||||||
float intensity{ 0.9f };
|
float outlineIntensity{ 0.9f };
|
||||||
float unoccludedFillOpacity{ 0.0f };
|
float unoccludedFillOpacity{ 0.0f };
|
||||||
float occludedFillOpacity{ 0.0f };
|
float occludedFillOpacity{ 0.0f };
|
||||||
bool glow{ false };
|
bool isOutlineSmooth{ false };
|
||||||
std::string selectionName;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // hifi_render_utils_OutlineStyle_h
|
#endif // hifi_render_utils_HighlightStyle_h
|
|
@ -1,46 +0,0 @@
|
||||||
#include "OutlineStyleStage.h"
|
|
||||||
|
|
||||||
using namespace render;
|
|
||||||
|
|
||||||
std::string OutlineStyleStage::_name("OutlineStyle");
|
|
||||||
|
|
||||||
OutlineStyleStage::Index OutlineStyleStage::addOutline(const std::string& selectionName, const OutlineStyle& style) {
|
|
||||||
Outline outline{ selectionName, style };
|
|
||||||
Index id;
|
|
||||||
|
|
||||||
id = _outlines.newElement(outline);
|
|
||||||
_activeOutlineIds.push_back(id);
|
|
||||||
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutlineStyleStage::removeOutline(Index index) {
|
|
||||||
OutlineIdList::iterator idIterator = std::find(_activeOutlineIds.begin(), _activeOutlineIds.end(), index);
|
|
||||||
if (idIterator != _activeOutlineIds.end()) {
|
|
||||||
_activeOutlineIds.erase(idIterator);
|
|
||||||
}
|
|
||||||
if (!_outlines.isElementFreed(index)) {
|
|
||||||
_outlines.freeElement(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Index OutlineStyleStage::getOutlineIdBySelection(const std::string& selectionName) const {
|
|
||||||
for (auto outlineId : _activeOutlineIds) {
|
|
||||||
const auto& outline = _outlines.get(outlineId);
|
|
||||||
if (outline._selectionName == selectionName) {
|
|
||||||
return outlineId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return INVALID_INDEX;
|
|
||||||
}
|
|
||||||
|
|
||||||
OutlineStyleStageSetup::OutlineStyleStageSetup() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutlineStyleStageSetup::run(const render::RenderContextPointer& renderContext) {
|
|
||||||
if (!renderContext->_scene->getStage(OutlineStyleStage::getName())) {
|
|
||||||
auto stage = std::make_shared<OutlineStyleStage>();
|
|
||||||
renderContext->_scene->resetStage(OutlineStyleStage::getName(), stage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,77 +0,0 @@
|
||||||
//
|
|
||||||
// OutlineStyleStage.h
|
|
||||||
|
|
||||||
// Created by Olivier Prat on 07/07/2017.
|
|
||||||
// Copyright 2017 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef hifi_render_utils_outlinestage_h
|
|
||||||
#define hifi_render_utils_outlinestage_h
|
|
||||||
|
|
||||||
#include "Stage.h"
|
|
||||||
#include "Engine.h"
|
|
||||||
#include "IndexedContainer.h"
|
|
||||||
#include "OutlineStyle.h"
|
|
||||||
|
|
||||||
namespace render {
|
|
||||||
|
|
||||||
// OutlineStyle stage to set up OutlineStyle-related effects
|
|
||||||
class OutlineStyleStage : public Stage {
|
|
||||||
public:
|
|
||||||
|
|
||||||
class Outline {
|
|
||||||
public:
|
|
||||||
|
|
||||||
Outline(const std::string& selectionName, const OutlineStyle& style) : _selectionName{ selectionName }, _style{ style } { }
|
|
||||||
|
|
||||||
std::string _selectionName;
|
|
||||||
OutlineStyle _style;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
static const std::string& getName() { return _name; }
|
|
||||||
|
|
||||||
using Index = render::indexed_container::Index;
|
|
||||||
static const Index INVALID_INDEX{ render::indexed_container::INVALID_INDEX };
|
|
||||||
using OutlineIdList = render::indexed_container::Indices;
|
|
||||||
|
|
||||||
static bool isIndexInvalid(Index index) { return index == INVALID_INDEX; }
|
|
||||||
|
|
||||||
bool checkOutlineId(Index index) const { return _outlines.checkIndex(index); }
|
|
||||||
|
|
||||||
const Outline& getOutline(Index OutlineStyleId) const { return _outlines.get(OutlineStyleId); }
|
|
||||||
Outline& editOutline(Index OutlineStyleId) { return _outlines.edit(OutlineStyleId); }
|
|
||||||
|
|
||||||
Index addOutline(const std::string& selectionName, const OutlineStyle& style = OutlineStyle());
|
|
||||||
Index getOutlineIdBySelection(const std::string& selectionName) const;
|
|
||||||
void removeOutline(Index index);
|
|
||||||
|
|
||||||
OutlineIdList::iterator begin() { return _activeOutlineIds.begin(); }
|
|
||||||
OutlineIdList::iterator end() { return _activeOutlineIds.end(); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
using Outlines = render::indexed_container::IndexedVector<Outline>;
|
|
||||||
|
|
||||||
static std::string _name;
|
|
||||||
|
|
||||||
Outlines _outlines;
|
|
||||||
OutlineIdList _activeOutlineIds;
|
|
||||||
};
|
|
||||||
using OutlineStyleStagePointer = std::shared_ptr<OutlineStyleStage>;
|
|
||||||
|
|
||||||
class OutlineStyleStageSetup {
|
|
||||||
public:
|
|
||||||
using JobModel = render::Job::Model<OutlineStyleStageSetup>;
|
|
||||||
|
|
||||||
OutlineStyleStageSetup();
|
|
||||||
void run(const RenderContextPointer& renderContext);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif // hifi_render_utils_outlinestage_h
|
|
|
@ -14,7 +14,7 @@
|
||||||
#include <gpu/Batch.h>
|
#include <gpu/Batch.h>
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
#include "TransitionStage.h"
|
#include "TransitionStage.h"
|
||||||
#include "OutlineStyleStage.h"
|
#include "HighlightStage.h"
|
||||||
|
|
||||||
using namespace render;
|
using namespace render;
|
||||||
|
|
||||||
|
@ -55,16 +55,16 @@ void Transaction::resetSelection(const Selection& selection) {
|
||||||
_resetSelections.emplace_back(selection);
|
_resetSelections.emplace_back(selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transaction::resetSelectionOutline(const std::string& selectionName, const OutlineStyle& style) {
|
void Transaction::resetSelectionHighlight(const std::string& selectionName, const HighlightStyle& style) {
|
||||||
_outlineResets.emplace_back(OutlineReset{ selectionName, style });
|
_highlightResets.emplace_back(HighlightReset{ selectionName, style });
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transaction::removeOutlineFromSelection(const std::string& selectionName) {
|
void Transaction::removeHighlightFromSelection(const std::string& selectionName) {
|
||||||
_outlineRemoves.emplace_back(selectionName);
|
_highlightRemoves.emplace_back(selectionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transaction::querySelectionOutline(const std::string& selectionName, SelectionOutlineQueryFunc func) {
|
void Transaction::querySelectionHighlight(const std::string& selectionName, SelectionHighlightQueryFunc func) {
|
||||||
_outlineQueries.emplace_back(OutlineQuery{ selectionName, func });
|
_highlightQueries.emplace_back(HighlightQuery{ selectionName, func });
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transaction::merge(const Transaction& transaction) {
|
void Transaction::merge(const Transaction& transaction) {
|
||||||
|
@ -75,9 +75,9 @@ void Transaction::merge(const Transaction& transaction) {
|
||||||
_addedTransitions.insert(_addedTransitions.end(), transaction._addedTransitions.begin(), transaction._addedTransitions.end());
|
_addedTransitions.insert(_addedTransitions.end(), transaction._addedTransitions.begin(), transaction._addedTransitions.end());
|
||||||
_queriedTransitions.insert(_queriedTransitions.end(), transaction._queriedTransitions.begin(), transaction._queriedTransitions.end());
|
_queriedTransitions.insert(_queriedTransitions.end(), transaction._queriedTransitions.begin(), transaction._queriedTransitions.end());
|
||||||
_reAppliedTransitions.insert(_reAppliedTransitions.end(), transaction._reAppliedTransitions.begin(), transaction._reAppliedTransitions.end());
|
_reAppliedTransitions.insert(_reAppliedTransitions.end(), transaction._reAppliedTransitions.begin(), transaction._reAppliedTransitions.end());
|
||||||
_outlineResets.insert(_outlineResets.end(), transaction._outlineResets.begin(), transaction._outlineResets.end());
|
_highlightResets.insert(_highlightResets.end(), transaction._highlightResets.begin(), transaction._highlightResets.end());
|
||||||
_outlineRemoves.insert(_outlineRemoves.end(), transaction._outlineRemoves.begin(), transaction._outlineRemoves.end());
|
_highlightRemoves.insert(_highlightRemoves.end(), transaction._highlightRemoves.begin(), transaction._highlightRemoves.end());
|
||||||
_outlineQueries.insert(_outlineQueries.end(), transaction._outlineQueries.begin(), transaction._outlineQueries.end());
|
_highlightQueries.insert(_highlightQueries.end(), transaction._highlightQueries.begin(), transaction._highlightQueries.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -193,9 +193,9 @@ void Scene::processTransactionFrame(const Transaction& transaction) {
|
||||||
resetSelections(transaction._resetSelections);
|
resetSelections(transaction._resetSelections);
|
||||||
}
|
}
|
||||||
|
|
||||||
resetOutlines(transaction._outlineResets);
|
resetHighlights(transaction._highlightResets);
|
||||||
removeOutlines(transaction._outlineRemoves);
|
removeHighlights(transaction._highlightRemoves);
|
||||||
queryOutlines(transaction._outlineQueries);
|
queryHighlights(transaction._highlightQueries);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::resetItems(const Transaction::Resets& transactions) {
|
void Scene::resetItems(const Transaction::Resets& transactions) {
|
||||||
|
@ -336,44 +336,44 @@ void Scene::queryTransitionItems(const Transaction::TransitionQueries& transacti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::resetOutlines(const Transaction::OutlineResets& transactions) {
|
void Scene::resetHighlights(const Transaction::HighlightResets& transactions) {
|
||||||
auto outlineStage = getStage<OutlineStyleStage>(OutlineStyleStage::getName());
|
auto outlineStage = getStage<HighlightStage>(HighlightStage::getName());
|
||||||
|
|
||||||
for (auto& transaction : transactions) {
|
for (auto& transaction : transactions) {
|
||||||
const auto& selectionName = std::get<0>(transaction);
|
const auto& selectionName = std::get<0>(transaction);
|
||||||
const auto& newStyle = std::get<1>(transaction);
|
const auto& newStyle = std::get<1>(transaction);
|
||||||
auto outlineId = outlineStage->getOutlineIdBySelection(selectionName);
|
auto outlineId = outlineStage->getHighlightIdBySelection(selectionName);
|
||||||
|
|
||||||
if (OutlineStyleStage::isIndexInvalid(outlineId)) {
|
if (HighlightStage::isIndexInvalid(outlineId)) {
|
||||||
outlineStage->addOutline(selectionName, newStyle);
|
outlineStage->addHighlight(selectionName, newStyle);
|
||||||
} else {
|
} else {
|
||||||
outlineStage->editOutline(outlineId)._style = newStyle;
|
outlineStage->editHighlight(outlineId)._style = newStyle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::removeOutlines(const Transaction::OutlineRemoves& transactions) {
|
void Scene::removeHighlights(const Transaction::HighlightRemoves& transactions) {
|
||||||
auto outlineStage = getStage<OutlineStyleStage>(OutlineStyleStage::getName());
|
auto outlineStage = getStage<HighlightStage>(HighlightStage::getName());
|
||||||
|
|
||||||
for (auto& selectionName : transactions) {
|
for (auto& selectionName : transactions) {
|
||||||
auto outlineId = outlineStage->getOutlineIdBySelection(selectionName);
|
auto outlineId = outlineStage->getHighlightIdBySelection(selectionName);
|
||||||
|
|
||||||
if (!OutlineStyleStage::isIndexInvalid(outlineId)) {
|
if (!HighlightStage::isIndexInvalid(outlineId)) {
|
||||||
outlineStage->removeOutline(outlineId);
|
outlineStage->removeHighlight(outlineId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::queryOutlines(const Transaction::OutlineQueries& transactions) {
|
void Scene::queryHighlights(const Transaction::HighlightQueries& transactions) {
|
||||||
auto outlineStage = getStage<OutlineStyleStage>(OutlineStyleStage::getName());
|
auto outlineStage = getStage<HighlightStage>(HighlightStage::getName());
|
||||||
|
|
||||||
for (auto& transaction : transactions) {
|
for (auto& transaction : transactions) {
|
||||||
const auto& selectionName = std::get<0>(transaction);
|
const auto& selectionName = std::get<0>(transaction);
|
||||||
const auto& func = std::get<1>(transaction);
|
const auto& func = std::get<1>(transaction);
|
||||||
auto outlineId = outlineStage->getOutlineIdBySelection(selectionName);
|
auto outlineId = outlineStage->getHighlightIdBySelection(selectionName);
|
||||||
|
|
||||||
if (!OutlineStyleStage::isIndexInvalid(outlineId)) {
|
if (!HighlightStage::isIndexInvalid(outlineId)) {
|
||||||
func(&outlineStage->editOutline(outlineId)._style);
|
func(&outlineStage->editHighlight(outlineId)._style);
|
||||||
} else {
|
} else {
|
||||||
func(nullptr);
|
func(nullptr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "Stage.h"
|
#include "Stage.h"
|
||||||
#include "Selection.h"
|
#include "Selection.h"
|
||||||
#include "Transition.h"
|
#include "Transition.h"
|
||||||
#include "OutlineStyle.h"
|
#include "HighlightStyle.h"
|
||||||
|
|
||||||
namespace render {
|
namespace render {
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class Transaction {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef std::function<void(ItemID, const Transition*)> TransitionQueryFunc;
|
typedef std::function<void(ItemID, const Transition*)> TransitionQueryFunc;
|
||||||
typedef std::function<void(OutlineStyle const*)> SelectionOutlineQueryFunc;
|
typedef std::function<void(HighlightStyle const*)> SelectionHighlightQueryFunc;
|
||||||
|
|
||||||
Transaction() {}
|
Transaction() {}
|
||||||
~Transaction() {}
|
~Transaction() {}
|
||||||
|
@ -63,9 +63,9 @@ public:
|
||||||
// Selection transactions
|
// Selection transactions
|
||||||
void resetSelection(const Selection& selection);
|
void resetSelection(const Selection& selection);
|
||||||
|
|
||||||
void resetSelectionOutline(const std::string& selectionName, const OutlineStyle& style = OutlineStyle());
|
void resetSelectionHighlight(const std::string& selectionName, const HighlightStyle& style = HighlightStyle());
|
||||||
void removeOutlineFromSelection(const std::string& selectionName);
|
void removeHighlightFromSelection(const std::string& selectionName);
|
||||||
void querySelectionOutline(const std::string& selectionName, SelectionOutlineQueryFunc func);
|
void querySelectionHighlight(const std::string& selectionName, SelectionHighlightQueryFunc func);
|
||||||
|
|
||||||
void merge(const Transaction& transaction);
|
void merge(const Transaction& transaction);
|
||||||
|
|
||||||
|
@ -81,9 +81,9 @@ protected:
|
||||||
using TransitionQuery = std::tuple<ItemID, TransitionQueryFunc>;
|
using TransitionQuery = std::tuple<ItemID, TransitionQueryFunc>;
|
||||||
using TransitionReApply = ItemID;
|
using TransitionReApply = ItemID;
|
||||||
using SelectionReset = Selection;
|
using SelectionReset = Selection;
|
||||||
using OutlineReset = std::tuple<std::string, OutlineStyle>;
|
using HighlightReset = std::tuple<std::string, HighlightStyle>;
|
||||||
using OutlineRemove = std::string;
|
using HighlightRemove = std::string;
|
||||||
using OutlineQuery = std::tuple<std::string, SelectionOutlineQueryFunc>;
|
using HighlightQuery = std::tuple<std::string, SelectionHighlightQueryFunc>;
|
||||||
|
|
||||||
using Resets = std::vector<Reset>;
|
using Resets = std::vector<Reset>;
|
||||||
using Removes = std::vector<Remove>;
|
using Removes = std::vector<Remove>;
|
||||||
|
@ -92,9 +92,9 @@ protected:
|
||||||
using TransitionQueries = std::vector<TransitionQuery>;
|
using TransitionQueries = std::vector<TransitionQuery>;
|
||||||
using TransitionReApplies = std::vector<TransitionReApply>;
|
using TransitionReApplies = std::vector<TransitionReApply>;
|
||||||
using SelectionResets = std::vector<SelectionReset>;
|
using SelectionResets = std::vector<SelectionReset>;
|
||||||
using OutlineResets = std::vector<OutlineReset>;
|
using HighlightResets = std::vector<HighlightReset>;
|
||||||
using OutlineRemoves = std::vector<OutlineRemove>;
|
using HighlightRemoves = std::vector<HighlightRemove>;
|
||||||
using OutlineQueries = std::vector<OutlineQuery>;
|
using HighlightQueries = std::vector<HighlightQuery>;
|
||||||
|
|
||||||
Resets _resetItems;
|
Resets _resetItems;
|
||||||
Removes _removedItems;
|
Removes _removedItems;
|
||||||
|
@ -103,9 +103,9 @@ protected:
|
||||||
TransitionQueries _queriedTransitions;
|
TransitionQueries _queriedTransitions;
|
||||||
TransitionReApplies _reAppliedTransitions;
|
TransitionReApplies _reAppliedTransitions;
|
||||||
SelectionResets _resetSelections;
|
SelectionResets _resetSelections;
|
||||||
OutlineResets _outlineResets;
|
HighlightResets _highlightResets;
|
||||||
OutlineRemoves _outlineRemoves;
|
HighlightRemoves _highlightRemoves;
|
||||||
OutlineQueries _outlineQueries;
|
HighlightQueries _highlightQueries;
|
||||||
};
|
};
|
||||||
typedef std::queue<Transaction> TransactionQueue;
|
typedef std::queue<Transaction> TransactionQueue;
|
||||||
|
|
||||||
|
@ -203,9 +203,9 @@ protected:
|
||||||
void transitionItems(const Transaction::TransitionAdds& transactions);
|
void transitionItems(const Transaction::TransitionAdds& transactions);
|
||||||
void reApplyTransitions(const Transaction::TransitionReApplies& transactions);
|
void reApplyTransitions(const Transaction::TransitionReApplies& transactions);
|
||||||
void queryTransitionItems(const Transaction::TransitionQueries& transactions);
|
void queryTransitionItems(const Transaction::TransitionQueries& transactions);
|
||||||
void resetOutlines(const Transaction::OutlineResets& transactions);
|
void resetHighlights(const Transaction::HighlightResets& transactions);
|
||||||
void removeOutlines(const Transaction::OutlineRemoves& transactions);
|
void removeHighlights(const Transaction::HighlightRemoves& transactions);
|
||||||
void queryOutlines(const Transaction::OutlineQueries& transactions);
|
void queryHighlights(const Transaction::HighlightQueries& transactions);
|
||||||
|
|
||||||
void collectSubItems(ItemID parentId, ItemIDs& subItems) const;
|
void collectSubItems(ItemID parentId, ItemIDs& subItems) const;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// debugOutline.js
|
// debugHighlight.js
|
||||||
// developer/utilities/render
|
// developer/utilities/render
|
||||||
//
|
//
|
||||||
// Olivier Prat, created on 08/08/2017.
|
// Olivier Prat, created on 08/08/2017.
|
||||||
|
@ -10,9 +10,9 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
// Set up the qml ui
|
// Set up the qml ui
|
||||||
var qml = Script.resolvePath('outline.qml');
|
var qml = Script.resolvePath('highlight.qml');
|
||||||
var window = new OverlayWindow({
|
var window = new OverlayWindow({
|
||||||
title: 'Outline',
|
title: 'Highlight',
|
||||||
source: qml,
|
source: qml,
|
||||||
width: 400,
|
width: 400,
|
||||||
height: 400,
|
height: 400,
|
||||||
|
@ -54,7 +54,7 @@ var end2 = {
|
||||||
visible: true
|
visible: true
|
||||||
}
|
}
|
||||||
|
|
||||||
var outlineGroupIndex = 0
|
var highlightGroupIndex = 0
|
||||||
var isSelectionAddEnabled = false
|
var isSelectionAddEnabled = false
|
||||||
var isSelectionEnabled = false
|
var isSelectionEnabled = false
|
||||||
var renderStates = [{name: "test", end: end}];
|
var renderStates = [{name: "test", end: end}];
|
||||||
|
@ -72,18 +72,18 @@ var ray = LaserPointers.createLaserPointer({
|
||||||
function getSelectionName() {
|
function getSelectionName() {
|
||||||
var selectionName = "contextOverlayHighlightList"
|
var selectionName = "contextOverlayHighlightList"
|
||||||
|
|
||||||
if (outlineGroupIndex>0) {
|
if (highlightGroupIndex>0) {
|
||||||
selectionName += outlineGroupIndex
|
selectionName += highlightGroupIndex
|
||||||
}
|
}
|
||||||
return selectionName
|
return selectionName
|
||||||
}
|
}
|
||||||
|
|
||||||
function fromQml(message) {
|
function fromQml(message) {
|
||||||
tokens = message.split(' ')
|
tokens = message.split(' ')
|
||||||
print("Received '"+message+"' from outline.qml")
|
print("Received '"+message+"' from hightlight.qml")
|
||||||
if (tokens[0]=="outline") {
|
if (tokens[0]=="highlight") {
|
||||||
outlineGroupIndex = parseInt(tokens[1])
|
highlightGroupIndex = parseInt(tokens[1])
|
||||||
print("Switching to outline group "+outlineGroupIndex)
|
print("Switching to highlight group "+highlightGroupIndex)
|
||||||
} else if (tokens[0]=="pick") {
|
} else if (tokens[0]=="pick") {
|
||||||
isSelectionEnabled = tokens[1]=='true'
|
isSelectionEnabled = tokens[1]=='true'
|
||||||
print("Ray picking set to "+isSelectionEnabled.toString())
|
print("Ray picking set to "+isSelectionEnabled.toString())
|
||||||
|
@ -143,7 +143,7 @@ function update(deltaTime) {
|
||||||
selectedID = prevID
|
selectedID = prevID
|
||||||
selectedType = prevType
|
selectedType = prevType
|
||||||
Selection.addToSelectedItemsList(selectionName, selectedType, selectedID)
|
Selection.addToSelectedItemsList(selectionName, selectedType, selectedID)
|
||||||
print("OUTLINE " + outlineGroupIndex + " picked type: " + result.type + ", id: " + result.objectID);
|
print("HIGHLIGHT " + highlightGroupIndex + " picked type: " + result.type + ", id: " + result.objectID);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (prevID != 0 && !isSelectionAddEnabled) {
|
if (prevID != 0 && !isSelectionAddEnabled) {
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// outline.qml
|
// highlight.qml
|
||||||
// developer/utilities/render
|
// developer/utilities/render
|
||||||
//
|
//
|
||||||
// Olivier Prat, created on 08/08/2017.
|
// Olivier Prat, created on 08/08/2017.
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
import QtQuick 2.7
|
import QtQuick 2.7
|
||||||
import QtQuick.Controls 1.4
|
import QtQuick.Controls 1.4
|
||||||
import QtQuick.Layouts 1.3
|
import QtQuick.Layouts 1.3
|
||||||
import "outlinePage"
|
import "highlightPage"
|
||||||
import "qrc:///qml/styles-uit"
|
import "qrc:///qml/styles-uit"
|
||||||
import "qrc:///qml/controls-uit" as HifiControls
|
import "qrc:///qml/controls-uit" as HifiControls
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ Rectangle {
|
||||||
color: hifi.colors.baseGray;
|
color: hifi.colors.baseGray;
|
||||||
anchors.margins: hifi.dimensions.contentMargin.x
|
anchors.margins: hifi.dimensions.contentMargin.x
|
||||||
|
|
||||||
property var debugConfig: Render.getConfig("RenderMainView.OutlineDebug")
|
property var debugConfig: Render.getConfig("RenderMainView.HighlightDebug")
|
||||||
signal sendToScript(var message);
|
signal sendToScript(var message);
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
|
@ -65,15 +65,15 @@ Rectangle {
|
||||||
height: 400
|
height: 400
|
||||||
|
|
||||||
onCurrentIndexChanged: {
|
onCurrentIndexChanged: {
|
||||||
sendToScript("outline "+currentIndex)
|
sendToScript("highlight "+currentIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
model: [ 0, 1, 2, 3 ]
|
model: [ 0, 1, 2, 3 ]
|
||||||
Tab {
|
Tab {
|
||||||
title: "Outl."+modelData
|
title: "Outl."+modelData
|
||||||
OutlinePage {
|
HighlightPage {
|
||||||
outlineIndex: modelData
|
highlightIndex: modelData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// outlinePage.qml
|
// highlightPage.qml
|
||||||
// developer/utilities/render
|
// developer/utilities/render
|
||||||
//
|
//
|
||||||
// Olivier Prat, created on 08/08/2017.
|
// Olivier Prat, created on 08/08/2017.
|
||||||
|
@ -17,8 +17,8 @@ import "qrc:///qml/controls-uit" as HifiControls
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: root
|
id: root
|
||||||
property var outlineIndex: 0
|
property var highlightIndex: 0
|
||||||
property var drawConfig: Render.getConfig("RenderMainView.OutlineEffect"+outlineIndex)
|
property var drawConfig: Render.getConfig("RenderMainView.HighlightEffect"+highlightIndex)
|
||||||
|
|
||||||
HifiConstants { id: hifi;}
|
HifiConstants { id: hifi;}
|
||||||
anchors.margins: hifi.dimensions.contentMargin.x
|
anchors.margins: hifi.dimensions.contentMargin.x
|
1
scripts/developer/utilities/render/highlightPage/qmldir
Normal file
1
scripts/developer/utilities/render/highlightPage/qmldir
Normal file
|
@ -0,0 +1 @@
|
||||||
|
HighlightPage 1.0 HighlightPage.qml
|
|
@ -1 +0,0 @@
|
||||||
OutlinePage 1.0 OutlinePage.qml
|
|
Loading…
Reference in a new issue