mirror of
https://github.com/overte-org/overte.git
synced 2025-04-24 14:33:26 +02:00
First working version of outline working with selection interface.
This commit is contained in:
parent
b619b2311d
commit
700d4a4b43
5 changed files with 27 additions and 15 deletions
|
@ -66,11 +66,12 @@ gpu::TexturePointer OutlineFramebuffer::getDepthTexture() {
|
|||
}
|
||||
|
||||
void PrepareOutline::run(const render::RenderContextPointer& renderContext, const PrepareOutline::Inputs& inputs, PrepareOutline::Output& output) {
|
||||
auto outlinedItems = inputs.get0();
|
||||
auto outlinedOpaqueItems = inputs.get0();
|
||||
auto outlinedTransparentItems = inputs.get1();
|
||||
|
||||
if (!outlinedItems.empty()) {
|
||||
if (!outlinedOpaqueItems.empty() || !outlinedTransparentItems.empty()) {
|
||||
auto args = renderContext->args;
|
||||
auto deferredFrameBuffer = inputs.get1();
|
||||
auto deferredFrameBuffer = inputs.get2();
|
||||
auto frameSize = deferredFrameBuffer->getFrameSize();
|
||||
|
||||
if (!_outlineFramebuffer) {
|
||||
|
|
|
@ -44,7 +44,7 @@ class PrepareOutline {
|
|||
|
||||
public:
|
||||
|
||||
using Inputs = render::VaryingSet2<render::ItemBounds, DeferredFramebufferPointer>;
|
||||
using Inputs = render::VaryingSet3<render::ItemBounds, render::ItemBounds, DeferredFramebufferPointer>;
|
||||
// Output will contain outlined objects only z-depth texture and the input primary buffer but without the primary depth buffer
|
||||
using Output = OutlineFramebufferPointer;
|
||||
using JobModel = render::Job::ModelIO<PrepareOutline, Inputs, Output>;
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
#include "AntialiasingEffect.h"
|
||||
#include "ToneMappingEffect.h"
|
||||
#include "SubsurfaceScattering.h"
|
||||
#include "PickItemsJob.h"
|
||||
#include "OutlineEffect.h"
|
||||
|
||||
#include <gpu/StandardShaderLib.h>
|
||||
|
@ -96,16 +95,20 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
|
|||
task.addJob<PrepareStencil>("PrepareStencil", primaryFramebuffer);
|
||||
|
||||
// Select items that need to be outlined
|
||||
const auto outlinedOpaques = task.addJob<PickItemsJob>("PickOutlined", opaques,
|
||||
// Pick only shapes so exclude meta
|
||||
render::ItemKey::Builder().withTypeShape().build()._flags, render::ItemKey::Builder().withTypeMeta().build()._flags);
|
||||
const auto outlineSelectionName = "contextOverlayHighlightList";
|
||||
const auto outlinedOpaquesSelection = task.addJob<SelectItems>("SelectOutlinedOpaques", opaques, outlineSelectionName);
|
||||
const auto outlinedTransparentSelection = task.addJob<SelectItems>("SelectOutlinedTransparents", transparents, outlineSelectionName);
|
||||
const auto outlinedOpaqueItems = task.addJob<MetaToSubItems>("OutlinedOpaqueMetaToSubItems", outlinedOpaquesSelection);
|
||||
const auto outlinedTransparentItems = task.addJob<MetaToSubItems>("OutlinedTransparentMetaToSubItems", outlinedTransparentSelection);
|
||||
|
||||
// Render opaque outline objects first in DeferredBuffer
|
||||
const auto opaqueOutlineInputs = DrawStateSortDeferred::Inputs(outlinedOpaques, lightingModel).asVarying();
|
||||
task.addJob<DrawStateSortDeferred>("DrawOpaqueOutlined", opaqueOutlineInputs, shapePlumber);
|
||||
const auto outlineOpaqueInputs = DrawStateSortDeferred::Inputs(outlinedOpaqueItems, lightingModel).asVarying();
|
||||
const auto outlineTransparentInputs = DrawStateSortDeferred::Inputs(outlinedTransparentItems, lightingModel).asVarying();
|
||||
task.addJob<DrawStateSortDeferred>("DrawOpaqueOutlined", outlineOpaqueInputs, shapePlumber);
|
||||
task.addJob<DrawStateSortDeferred>("DrawTransparentOutlined", outlineTransparentInputs, shapePlumber);
|
||||
|
||||
// Retrieve z value of the outlined objects
|
||||
const auto outlinePrepareInputs = PrepareOutline::Inputs(outlinedOpaques, deferredFramebuffer).asVarying();
|
||||
const auto outlinePrepareInputs = PrepareOutline::Inputs(outlinedOpaqueItems, outlinedTransparentItems, deferredFramebuffer).asVarying();
|
||||
const auto outlinedFrameBuffer = task.addJob<PrepareOutline>("PrepareOutline", outlinePrepareInputs);
|
||||
|
||||
// Render opaque objects in DeferredBuffer
|
||||
|
|
|
@ -98,8 +98,9 @@ void SelectSortItems::run(const RenderContextPointer& renderContext, const ItemB
|
|||
}
|
||||
}
|
||||
|
||||
void MetaToSubItems::run(const RenderContextPointer& renderContext, const ItemBounds& inItems, ItemIDs& outItems) {
|
||||
void MetaToSubItems::run(const RenderContextPointer& renderContext, const ItemBounds& inItems, ItemBounds& outItems) {
|
||||
auto& scene = renderContext->_scene;
|
||||
ItemIDs outItemIds;
|
||||
|
||||
// Now we have a selection of items to render
|
||||
outItems.clear();
|
||||
|
@ -107,7 +108,14 @@ void MetaToSubItems::run(const RenderContextPointer& renderContext, const ItemBo
|
|||
for (auto idBound : inItems) {
|
||||
auto& item = scene->getItem(idBound.id);
|
||||
|
||||
item.fetchMetaSubItems(outItems);
|
||||
item.fetchMetaSubItems(outItemIds);
|
||||
}
|
||||
|
||||
// Transform Item IDs to ItemBounds
|
||||
for (auto id : outItemIds) {
|
||||
auto& item = scene->getItem(id);
|
||||
|
||||
outItems.emplace_back(ItemBound{ id, item.getBound() });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -135,11 +135,11 @@ namespace render {
|
|||
// From meta-Items, generate the sub-items
|
||||
class MetaToSubItems {
|
||||
public:
|
||||
using JobModel = Job::ModelIO<MetaToSubItems, ItemBounds, ItemIDs>;
|
||||
using JobModel = Job::ModelIO<MetaToSubItems, ItemBounds, ItemBounds>;
|
||||
|
||||
MetaToSubItems() {}
|
||||
|
||||
void run(const RenderContextPointer& renderContext, const ItemBounds& inItems, ItemIDs& outItems);
|
||||
void run(const RenderContextPointer& renderContext, const ItemBounds& inItems, ItemBounds& outItems);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue