mirror of
https://github.com/lubosz/overte.git
synced 2025-04-19 17:03:43 +02:00
visible-perview
This commit is contained in:
parent
c1b7bc3ff8
commit
7a9740d258
11 changed files with 35 additions and 25 deletions
|
@ -2200,7 +2200,7 @@ void Application::initializeGL() {
|
|||
bool isDeferred = !QProcessEnvironment::systemEnvironment().contains(RENDER_FORWARD);
|
||||
_renderEngine->addJob<UpdateSceneTask>("UpdateScene");
|
||||
_renderEngine->addJob<SecondaryCameraRenderTask>("SecondaryCameraJob", cullFunctor);
|
||||
_renderEngine->addJob<RenderViewTask>("RenderMainView", cullFunctor, isDeferred);
|
||||
_renderEngine->addJob<RenderViewTask>("RenderMainView", cullFunctor, isDeferred, render::ItemKey::VISIBLE_MASK_0, render::ItemKey::VISIBLE_MASK_0);
|
||||
_renderEngine->load();
|
||||
_renderEngine->registerScene(_main3DScene);
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ using RenderArgsPointer = std::shared_ptr<RenderArgs>;
|
|||
|
||||
void MainRenderTask::build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor, bool isDeferred) {
|
||||
task.addJob<RenderShadowTask>("RenderShadowTask", cullFunctor);
|
||||
const auto items = task.addJob<RenderFetchCullSortTask>("FetchCullSort", cullFunctor);
|
||||
const auto items = task.addJob<RenderFetchCullSortTask>("FetchCullSort", cullFunctor, render::ItemKey::VISIBLE_MASK_1, render::ItemKey::VISIBLE_MASK_1);
|
||||
assert(items.canCast<RenderFetchCullSortTask::Output>());
|
||||
if (!isDeferred) {
|
||||
task.addJob<RenderForwardTask>("Forward", items);
|
||||
|
|
|
@ -247,7 +247,7 @@ void CauterizedModel::updateRenderItems() {
|
|||
data.updateTransformForCauterizedMesh(renderTransform);
|
||||
|
||||
data.setEnableCauterization(enableCauterization);
|
||||
data.setKey(isVisible, isLayeredInFront || isLayeredInHUD);
|
||||
data.setKey(isVisible, isLayeredInFront || isLayeredInHUD, enableCauterization);
|
||||
data.setLayer(isLayeredInFront, isLayeredInHUD);
|
||||
data.setShapeKey(invalidatePayloadShapeKey, isWireframe);
|
||||
});
|
||||
|
|
|
@ -389,13 +389,16 @@ void ModelMeshPartPayload::updateTransformForSkinnedMesh(const Transform& render
|
|||
_worldBound.transform(boundTransform);
|
||||
}
|
||||
|
||||
void ModelMeshPartPayload::setKey(bool isVisible, bool isLayered) {
|
||||
void ModelMeshPartPayload::setKey(bool isVisible, bool isLayered, bool isCauterized) {
|
||||
ItemKey::Builder builder;
|
||||
builder.withTypeShape();
|
||||
|
||||
if (!isVisible) {
|
||||
builder.withInvisible();
|
||||
}
|
||||
else if (isCauterized) {
|
||||
builder.withInvisible(0); // hide these items in the vibility mask #0
|
||||
}
|
||||
|
||||
if (isLayered) {
|
||||
builder.withLayered();
|
||||
|
|
|
@ -103,7 +103,7 @@ public:
|
|||
render::ShapeKey getShapeKey() const override; // shape interface
|
||||
void render(RenderArgs* args) override;
|
||||
|
||||
void setKey(bool isVisible, bool isLayered);
|
||||
void setKey(bool isVisible, bool isLayered, bool isCauterized = false);
|
||||
void setLayer(bool isLayeredInFront, bool isLayeredInHUD);
|
||||
void setShapeKey(bool invalidateShapeKey, bool isWireframe);
|
||||
|
||||
|
|
|
@ -264,7 +264,7 @@ void RenderShadowCascadeSetup::run(const render::RenderContextPointer& renderCon
|
|||
|
||||
const auto globalShadow = lightStage->getCurrentKeyShadow();
|
||||
if (globalShadow && _cascadeIndex<globalShadow->getCascadeCount()) {
|
||||
output.edit1() = ItemFilter::Builder::visibleWorldItems(0x08).withTypeShape().withOpaque().withoutLayered();
|
||||
output.edit1() = ItemFilter::Builder::visibleWorldItems(0x00, 0x00).withTypeShape().withOpaque().withoutLayered();
|
||||
|
||||
globalShadow->setKeylightCascadeFrustum(_cascadeIndex, args->getViewFrustum(), SHADOW_FRUSTUM_NEAR, SHADOW_FRUSTUM_FAR);
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "RenderDeferredTask.h"
|
||||
#include "RenderForwardTask.h"
|
||||
|
||||
void RenderViewTask::build(JobModel& task, const render::Varying& input, render::Varying& output, render::CullFunctor cullFunctor, bool isDeferred, uint8_t visibilityMask) {
|
||||
void RenderViewTask::build(JobModel& task, const render::Varying& input, render::Varying& output, render::CullFunctor cullFunctor, bool isDeferred, uint8_t visibilityMask, uint8_t visibilityMaskTouched) {
|
||||
// auto items = input.get<Input>();
|
||||
|
||||
// Shadows use an orthographic projection because they are linked to sunlights
|
||||
|
@ -30,7 +30,7 @@ void RenderViewTask::build(JobModel& task, const render::Varying& input, render:
|
|||
return true;
|
||||
});
|
||||
|
||||
const auto items = task.addJob<RenderFetchCullSortTask>("FetchCullSort", cullFunctor, visibilityMask);
|
||||
const auto items = task.addJob<RenderFetchCullSortTask>("FetchCullSort", cullFunctor, visibilityMask, visibilityMaskTouched);
|
||||
assert(items.canCast<RenderFetchCullSortTask::Output>());
|
||||
|
||||
if (isDeferred) {
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
|
||||
RenderViewTask() {}
|
||||
|
||||
void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor, bool isDeferred, uint8_t visibilityMask = 0xFF);
|
||||
void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor, bool isDeferred, uint8_t visibilityMask = 0xFF, uint8_t visibilityMaskTouched = 0x00);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -65,6 +65,10 @@ public:
|
|||
// Beware that the visibility mask is the oposite of what stored in the key vals.
|
||||
const static uint8_t NUM_VISIBLE_MASK_INDICES{ 4 };
|
||||
const static uint8_t VISIBLE_MASK_ALL{ 0x0F };
|
||||
const static uint8_t VISIBLE_MASK_0{ 0x01 };
|
||||
const static uint8_t VISIBLE_MASK_1{ 0x02 };
|
||||
const static uint8_t VISIBLE_MASK_2{ 0x04 };
|
||||
const static uint8_t VISIBLE_MASK_3{ 0x08 };
|
||||
|
||||
// The key is the Flags
|
||||
Flags _flags;
|
||||
|
@ -184,12 +188,15 @@ public:
|
|||
|
||||
Builder& withVisible(uint8_t maskIndex) { _value.reset(ItemKey::INVISIBLE0 + maskIndex); _mask.set(ItemKey::INVISIBLE0 + maskIndex); return (*this); }
|
||||
Builder& withInvisible(uint8_t maskIndex) { _value.set(ItemKey::INVISIBLE0 + maskIndex); _mask.set(ItemKey::INVISIBLE0 + maskIndex); return (*this); }
|
||||
Builder& withVisibilityMask(uint8_t mask) {
|
||||
Builder& withVisibilityMask(uint8_t mask, uint8_t touchBits) {
|
||||
for (int i = 0; i < ItemKey::NUM_VISIBLE_MASK_INDICES; i++) {
|
||||
if ((1 << i) && mask) {
|
||||
withVisible(i);
|
||||
} else {
|
||||
withInvisible(i);
|
||||
if ((1 << i) & touchBits) {
|
||||
if ((1 << i) & mask) {
|
||||
withVisible(i);
|
||||
}
|
||||
else {
|
||||
withInvisible(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (*this);
|
||||
|
@ -206,7 +213,7 @@ public:
|
|||
Builder& withNothing() { _value.reset(); _mask.reset(); return (*this); }
|
||||
|
||||
// Convenient standard keys that we will keep on using all over the place
|
||||
static Builder visibleWorldItems(uint8_t visibilityMask) { return Builder().withVisibilityMask(visibilityMask).withWorldSpace(); }
|
||||
static Builder visibleWorldItems(uint8_t visibilityMask, uint8_t visibilityMaskTouched) { return Builder().withVisibilityMask(visibilityMask, visibilityMaskTouched).withWorldSpace(); }
|
||||
static Builder opaqueShape() { return Builder().withTypeShape().withOpaque().withWorldSpace(); }
|
||||
static Builder transparentShape() { return Builder().withTypeShape().withTransparent().withWorldSpace(); }
|
||||
static Builder light() { return Builder().withTypeLight(); }
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
|
||||
using namespace render;
|
||||
|
||||
void RenderFetchCullSortTask::build(JobModel& task, const Varying& input, Varying& output, CullFunctor cullFunctor, uint8_t visibilityMask) {
|
||||
void RenderFetchCullSortTask::build(JobModel& task, const Varying& input, Varying& output, CullFunctor cullFunctor, uint8_t visibilityMask, uint8_t visibilityMaskTouched) {
|
||||
cullFunctor = cullFunctor ? cullFunctor : [](const RenderArgs*, const AABox&){ return true; };
|
||||
|
||||
// CPU jobs:
|
||||
// Fetch and cull the items from the scene
|
||||
const ItemFilter filter = ItemFilter::Builder::visibleWorldItems(visibilityMask).withoutLayered();
|
||||
const ItemFilter filter = ItemFilter::Builder::visibleWorldItems(visibilityMask, visibilityMaskTouched).withoutLayered();
|
||||
const auto spatialFilter = render::Varying(filter);
|
||||
const auto spatialSelection = task.addJob<FetchSpatialTree>("FetchSceneSelection", spatialFilter);
|
||||
const auto cullInputs = CullSpatialSelection::Inputs(spatialSelection, spatialFilter).asVarying();
|
||||
|
@ -40,15 +40,15 @@ void RenderFetchCullSortTask::build(JobModel& task, const Varying& input, Varyin
|
|||
const int META_BUCKET = 3;
|
||||
const int BACKGROUND_BUCKET = 2;
|
||||
MultiFilterItems<NUM_SPATIAL_FILTERS>::ItemFilterArray spatialFilters = { {
|
||||
ItemFilter::Builder::opaqueShape(),
|
||||
ItemFilter::Builder::transparentShape(),
|
||||
ItemFilter::Builder::light(),
|
||||
ItemFilter::Builder::meta()
|
||||
ItemFilter::Builder::opaqueShape().withVisibilityMask(visibilityMask, visibilityMaskTouched),
|
||||
ItemFilter::Builder::transparentShape().withVisibilityMask(visibilityMask, visibilityMaskTouched),
|
||||
ItemFilter::Builder::light().withVisibilityMask(visibilityMask, visibilityMaskTouched),
|
||||
ItemFilter::Builder::meta().withVisibilityMask(visibilityMask, visibilityMaskTouched)
|
||||
} };
|
||||
MultiFilterItems<NUM_NON_SPATIAL_FILTERS>::ItemFilterArray nonspatialFilters = { {
|
||||
ItemFilter::Builder::opaqueShape(),
|
||||
ItemFilter::Builder::transparentShape(),
|
||||
ItemFilter::Builder::background()
|
||||
ItemFilter::Builder::opaqueShape().withVisibilityMask(visibilityMask, visibilityMaskTouched),
|
||||
ItemFilter::Builder::transparentShape().withVisibilityMask(visibilityMask, visibilityMaskTouched),
|
||||
ItemFilter::Builder::background().withVisibilityMask(visibilityMask, visibilityMaskTouched)
|
||||
} };
|
||||
const auto filteredSpatialBuckets =
|
||||
task.addJob<MultiFilterItems<NUM_SPATIAL_FILTERS>>("FilterSceneSelection", culledSpatialSelection, spatialFilters)
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
|
||||
RenderFetchCullSortTask() {}
|
||||
|
||||
void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor, uint8_t visibilityMask = 0xFF);
|
||||
void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor, uint8_t visibilityMask = 0xFF, uint8_t visibilityMaskTouched = 0x00);
|
||||
};
|
||||
|
||||
#endif // hifi_RenderFetchCullSortTask_h
|
||||
|
|
Loading…
Reference in a new issue