mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 08:36:26 +02:00
fix shadows!!
This commit is contained in:
parent
6156495345
commit
204c7a7391
5 changed files with 20 additions and 93 deletions
|
@ -97,8 +97,11 @@ void PolyLineEntityRenderer::buildPipelines() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemKey PolyLineEntityRenderer::getKey() {
|
ItemKey PolyLineEntityRenderer::getKey() {
|
||||||
// FIXME: implement isTransparent() for polylines and an opaque pipeline
|
auto builder = ItemKey::Builder::opaqueShape().withTypeMeta().withTagBits(getTagMask()).withLayer(getHifiRenderLayer());
|
||||||
auto builder = ItemKey::Builder::transparentShape().withTypeMeta().withTagBits(getTagMask()).withLayer(getHifiRenderLayer());
|
|
||||||
|
if (isTransparent()) {
|
||||||
|
builder.withTransparent();
|
||||||
|
}
|
||||||
|
|
||||||
if (_cullWithParent) {
|
if (_cullWithParent) {
|
||||||
builder.withSubMetaCulled();
|
builder.withSubMetaCulled();
|
||||||
|
|
|
@ -61,12 +61,12 @@ void RenderShadowTask::build(JobModel& task, const render::Varying& input, rende
|
||||||
const auto currentKeyLight = setupOutput.getN<RenderShadowSetup::Output>(4);
|
const auto currentKeyLight = setupOutput.getN<RenderShadowSetup::Output>(4);
|
||||||
// Fetch and cull the items from the scene
|
// Fetch and cull the items from the scene
|
||||||
|
|
||||||
static const auto shadowCasterReceiverFilter = ItemFilter::Builder::visibleWorldItems().withTypeShape().withOpaque().withoutLayered().withTagBits(tagBits, tagMask);
|
static const auto shadowCasterReceiverFilter = ItemFilter::Builder::visibleWorldItems().withOpaque().withoutLayered().withTagBits(tagBits, tagMask);
|
||||||
|
|
||||||
const auto fetchInput = FetchSpatialTree::Inputs(shadowCasterReceiverFilter, queryResolution).asVarying();
|
const auto fetchInput = FetchSpatialTree::Inputs(shadowCasterReceiverFilter, queryResolution).asVarying();
|
||||||
const auto shadowSelection = task.addJob<FetchSpatialTree>("FetchShadowTree", fetchInput);
|
const auto shadowSelection = task.addJob<FetchSpatialTree>("FetchShadowTree", fetchInput);
|
||||||
const auto selectionInputs = FilterSpatialSelection::Inputs(shadowSelection, shadowCasterReceiverFilter).asVarying();
|
const auto selectionInputs = CullSpatialSelection::Inputs(shadowSelection, shadowCasterReceiverFilter).asVarying();
|
||||||
const auto shadowItems = task.addJob<FilterSpatialSelection>("FilterShadowSelection", selectionInputs);
|
const auto shadowItems = task.addJob<CullSpatialSelection>("FilterShadowSelection", selectionInputs, nullptr, true, RenderDetails::SHADOW);
|
||||||
|
|
||||||
// Cull objects that are not visible in camera view. Hopefully the cull functor only performs LOD culling, not
|
// Cull objects that are not visible in camera view. Hopefully the cull functor only performs LOD culling, not
|
||||||
// frustum culling or this will make shadow casters out of the camera frustum disappear.
|
// frustum culling or this will make shadow casters out of the camera frustum disappear.
|
||||||
|
|
|
@ -172,7 +172,7 @@ void FetchSpatialTree::run(const RenderContextPointer& renderContext, const Inpu
|
||||||
void CullSpatialSelection::configure(const Config& config) {
|
void CullSpatialSelection::configure(const Config& config) {
|
||||||
_justFrozeFrustum = _justFrozeFrustum || (config.freezeFrustum && !_freezeFrustum);
|
_justFrozeFrustum = _justFrozeFrustum || (config.freezeFrustum && !_freezeFrustum);
|
||||||
_freezeFrustum = config.freezeFrustum;
|
_freezeFrustum = config.freezeFrustum;
|
||||||
_skipCulling = config.skipCulling;
|
_overrideSkipCulling = config.skipCulling;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CullSpatialSelection::run(const RenderContextPointer& renderContext,
|
void CullSpatialSelection::run(const RenderContextPointer& renderContext,
|
||||||
|
@ -209,7 +209,7 @@ void CullSpatialSelection::run(const RenderContextPointer& renderContext,
|
||||||
// filter individually against the _filter
|
// filter individually against the _filter
|
||||||
// visibility cull if partially selected ( octree cell contianing it was partial)
|
// visibility cull if partially selected ( octree cell contianing it was partial)
|
||||||
// distance cull if was a subcell item ( octree cell is way bigger than the item bound itself, so now need to test per item)
|
// distance cull if was a subcell item ( octree cell is way bigger than the item bound itself, so now need to test per item)
|
||||||
if (_skipCulling) {
|
if (_skipCulling || _overrideSkipCulling) {
|
||||||
// inside & fit items: filter only, culling is disabled
|
// inside & fit items: filter only, culling is disabled
|
||||||
{
|
{
|
||||||
PerformanceTimer perfTimer("insideFitItems");
|
PerformanceTimer perfTimer("insideFitItems");
|
||||||
|
@ -444,69 +444,3 @@ void ApplyCullFunctorOnItemBounds::run(const RenderContextPointer& renderContext
|
||||||
args->popViewFrustum();
|
args->popViewFrustum();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilterSpatialSelection::run(const RenderContextPointer& renderContext,
|
|
||||||
const Inputs& inputs, ItemBounds& outItems) {
|
|
||||||
assert(renderContext->args);
|
|
||||||
auto& scene = renderContext->_scene;
|
|
||||||
auto& inSelection = inputs.get0();
|
|
||||||
|
|
||||||
// Now we have a selection of items to render
|
|
||||||
outItems.clear();
|
|
||||||
outItems.reserve(inSelection.numItems());
|
|
||||||
|
|
||||||
const auto filter = inputs.get1();
|
|
||||||
if (!filter.selectsNothing()) {
|
|
||||||
// Now get the bound, and
|
|
||||||
// filter individually against the _filter
|
|
||||||
|
|
||||||
// inside & fit items: filter only
|
|
||||||
{
|
|
||||||
PerformanceTimer perfTimer("insideFitItems");
|
|
||||||
for (auto id : inSelection.insideItems) {
|
|
||||||
auto& item = scene->getItem(id);
|
|
||||||
if (filter.test(item.getKey())) {
|
|
||||||
ItemBound itemBound(id, item.getBound());
|
|
||||||
outItems.emplace_back(itemBound);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// inside & subcell items: filter only
|
|
||||||
{
|
|
||||||
PerformanceTimer perfTimer("insideSmallItems");
|
|
||||||
for (auto id : inSelection.insideSubcellItems) {
|
|
||||||
auto& item = scene->getItem(id);
|
|
||||||
if (filter.test(item.getKey())) {
|
|
||||||
ItemBound itemBound(id, item.getBound());
|
|
||||||
outItems.emplace_back(itemBound);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// partial & fit items: filter only
|
|
||||||
{
|
|
||||||
PerformanceTimer perfTimer("partialFitItems");
|
|
||||||
for (auto id : inSelection.partialItems) {
|
|
||||||
auto& item = scene->getItem(id);
|
|
||||||
if (filter.test(item.getKey())) {
|
|
||||||
ItemBound itemBound(id, item.getBound());
|
|
||||||
outItems.emplace_back(itemBound);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// partial & subcell items: filter only
|
|
||||||
{
|
|
||||||
PerformanceTimer perfTimer("partialSmallItems");
|
|
||||||
for (auto id : inSelection.partialSubcellItems) {
|
|
||||||
auto& item = scene->getItem(id);
|
|
||||||
if (filter.test(item.getKey())) {
|
|
||||||
ItemBound itemBound(id, item.getBound());
|
|
||||||
outItems.emplace_back(itemBound);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -100,26 +100,25 @@ namespace render {
|
||||||
};
|
};
|
||||||
|
|
||||||
class CullSpatialSelection {
|
class CullSpatialSelection {
|
||||||
bool _freezeFrustum{ false }; // initialized by Config
|
|
||||||
bool _justFrozeFrustum{ false };
|
|
||||||
bool _skipCulling{ false };
|
|
||||||
ViewFrustum _frozenFrustum;
|
|
||||||
public:
|
public:
|
||||||
using Config = CullSpatialSelectionConfig;
|
using Config = CullSpatialSelectionConfig;
|
||||||
using Inputs = render::VaryingSet2<ItemSpatialTree::ItemSelection, ItemFilter>;
|
using Inputs = render::VaryingSet2<ItemSpatialTree::ItemSelection, ItemFilter>;
|
||||||
using JobModel = Job::ModelIO<CullSpatialSelection, Inputs, ItemBounds, Config>;
|
using JobModel = Job::ModelIO<CullSpatialSelection, Inputs, ItemBounds, Config>;
|
||||||
|
|
||||||
CullSpatialSelection(CullFunctor cullFunctor, RenderDetails::Type type) :
|
CullSpatialSelection(CullFunctor cullFunctor, bool skipCulling, RenderDetails::Type type) :
|
||||||
_cullFunctor{ cullFunctor },
|
_cullFunctor(cullFunctor),
|
||||||
|
_skipCulling(skipCulling),
|
||||||
_detailType(type) {}
|
_detailType(type) {}
|
||||||
|
|
||||||
CullSpatialSelection(CullFunctor cullFunctor) :
|
|
||||||
_cullFunctor{ cullFunctor } {
|
|
||||||
}
|
|
||||||
|
|
||||||
CullFunctor _cullFunctor;
|
CullFunctor _cullFunctor;
|
||||||
|
bool _skipCulling { false };
|
||||||
RenderDetails::Type _detailType{ RenderDetails::OTHER };
|
RenderDetails::Type _detailType{ RenderDetails::OTHER };
|
||||||
|
|
||||||
|
bool _freezeFrustum { false }; // initialized by Config
|
||||||
|
bool _justFrozeFrustum { false };
|
||||||
|
bool _overrideSkipCulling { false };
|
||||||
|
ViewFrustum _frozenFrustum;
|
||||||
|
|
||||||
void configure(const Config& config);
|
void configure(const Config& config);
|
||||||
void run(const RenderContextPointer& renderContext, const Inputs& inputs, ItemBounds& outItems);
|
void run(const RenderContextPointer& renderContext, const Inputs& inputs, ItemBounds& outItems);
|
||||||
};
|
};
|
||||||
|
@ -147,15 +146,6 @@ namespace render {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class FilterSpatialSelection {
|
|
||||||
public:
|
|
||||||
using Inputs = render::VaryingSet2<ItemSpatialTree::ItemSelection, ItemFilter>;
|
|
||||||
using JobModel = Job::ModelIO<FilterSpatialSelection, Inputs, ItemBounds>;
|
|
||||||
|
|
||||||
FilterSpatialSelection() {}
|
|
||||||
void run(const RenderContextPointer& renderContext, const Inputs& inputs, ItemBounds& outItems);
|
|
||||||
};
|
|
||||||
|
|
||||||
class ApplyCullFunctorOnItemBounds {
|
class ApplyCullFunctorOnItemBounds {
|
||||||
public:
|
public:
|
||||||
using Inputs = render::VaryingSet2<ItemBounds, ViewFrustumPointer>;
|
using Inputs = render::VaryingSet2<ItemBounds, ViewFrustumPointer>;
|
||||||
|
|
|
@ -27,7 +27,7 @@ void RenderFetchCullSortTask::build(JobModel& task, const Varying& input, Varyin
|
||||||
const auto fetchInput = FetchSpatialTree::Inputs(filter, glm::ivec2(0,0)).asVarying();
|
const auto fetchInput = FetchSpatialTree::Inputs(filter, glm::ivec2(0,0)).asVarying();
|
||||||
const auto spatialSelection = task.addJob<FetchSpatialTree>("FetchSceneSelection", fetchInput);
|
const auto spatialSelection = task.addJob<FetchSpatialTree>("FetchSceneSelection", fetchInput);
|
||||||
const auto cullInputs = CullSpatialSelection::Inputs(spatialSelection, spatialFilter).asVarying();
|
const auto cullInputs = CullSpatialSelection::Inputs(spatialSelection, spatialFilter).asVarying();
|
||||||
const auto culledSpatialSelection = task.addJob<CullSpatialSelection>("CullSceneSelection", cullInputs, cullFunctor, RenderDetails::ITEM);
|
const auto culledSpatialSelection = task.addJob<CullSpatialSelection>("CullSceneSelection", cullInputs, cullFunctor, false, RenderDetails::ITEM);
|
||||||
|
|
||||||
// Layered objects are not culled
|
// Layered objects are not culled
|
||||||
const ItemFilter layeredFilter = ItemFilter::Builder::visibleWorldItems().withTagBits(tagBits, tagMask);
|
const ItemFilter layeredFilter = ItemFilter::Builder::visibleWorldItems().withTagBits(tagBits, tagMask);
|
||||||
|
|
Loading…
Reference in a new issue