mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 05:37:17 +02:00
USing a simpler halfTan test for culling
This commit is contained in:
parent
294fe51fde
commit
d97d655148
8 changed files with 24 additions and 20 deletions
|
@ -237,8 +237,14 @@ QString LODManager::getLODFeedbackText() {
|
||||||
bool LODManager::shouldRender(const RenderArgs* args, const AABox& bounds) {
|
bool LODManager::shouldRender(const RenderArgs* args, const AABox& bounds) {
|
||||||
// FIXME - eventually we want to use the render accuracy as an indicator for the level of detail
|
// FIXME - eventually we want to use the render accuracy as an indicator for the level of detail
|
||||||
// to use in rendering.
|
// to use in rendering.
|
||||||
float renderAccuracy = calculateRenderAccuracy(args->getViewFrustum().getPosition(), bounds, args->_sizeScale, args->_boundaryLevelAdjust);
|
// float renderAccuracy = calculateRenderAccuracy(args->getViewFrustum().getPosition(), bounds, args->_sizeScale, args->_boundaryLevelAdjust);
|
||||||
return (renderAccuracy > 0.0f);
|
// return (renderAccuracy > 0.0f);
|
||||||
|
|
||||||
|
auto pos = args->getViewFrustum().getPosition() - bounds.calcCenter();
|
||||||
|
auto dim = bounds.getDimensions();
|
||||||
|
auto halfTanSq = 0.25f * glm::dot(dim, dim) / glm::dot(pos, pos);
|
||||||
|
return (halfTanSq >= args->_solidAngleHalfTan * args->_solidAngleHalfTan);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void LODManager::setOctreeSizeScale(float sizeScale) {
|
void LODManager::setOctreeSizeScale(float sizeScale) {
|
||||||
|
@ -325,3 +331,6 @@ float LODManager::getSolidAngleHalfTan() const {
|
||||||
return getPerspectiveAccuracyAngleTan(_octreeSizeScale, _boundaryLevelAdjust);
|
return getPerspectiveAccuracyAngleTan(_octreeSizeScale, _boundaryLevelAdjust);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float LODManager::getSolidAngle() const {
|
||||||
|
return glm::degrees(2.0 * atan(getSolidAngleHalfTan()));
|
||||||
|
}
|
||||||
|
|
|
@ -70,6 +70,7 @@ class LODManager : public QObject, public Dependency {
|
||||||
Q_PROPERTY(float worldDetailQuality READ getWorldDetailQuality WRITE setWorldDetailQuality NOTIFY worldDetailQualityChanged)
|
Q_PROPERTY(float worldDetailQuality READ getWorldDetailQuality WRITE setWorldDetailQuality NOTIFY worldDetailQualityChanged)
|
||||||
|
|
||||||
Q_PROPERTY(float solidAngleHalfTan READ getSolidAngleHalfTan)
|
Q_PROPERTY(float solidAngleHalfTan READ getSolidAngleHalfTan)
|
||||||
|
Q_PROPERTY(float solidAngle READ getSolidAngle)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -187,6 +188,7 @@ public:
|
||||||
float getWorldDetailQuality() const;
|
float getWorldDetailQuality() const;
|
||||||
|
|
||||||
float getSolidAngleHalfTan() const;
|
float getSolidAngleHalfTan() const;
|
||||||
|
float getSolidAngle() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
|
|
@ -79,9 +79,3 @@ float getOrthographicAccuracySize(float octreeSizeScale, int boundaryLevelAdjust
|
||||||
const float smallestSize = 0.01f;
|
const float smallestSize = 0.01f;
|
||||||
return (smallestSize * MAX_VISIBILITY_DISTANCE_FOR_UNIT_ELEMENT) / boundaryDistanceForRenderLevel(boundaryLevelAdjust, octreeSizeScale);
|
return (smallestSize * MAX_VISIBILITY_DISTANCE_FOR_UNIT_ELEMENT) / boundaryDistanceForRenderLevel(boundaryLevelAdjust, octreeSizeScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isAngularSizeBigEnough(glm::vec3 position, const AACube& cube, float lodScaleFactor, float minDiameter) {
|
|
||||||
float distance = glm::distance(cube.calcCenter(), position) + MIN_VISIBLE_DISTANCE;
|
|
||||||
float angularDiameter = cube.getScale() / distance;
|
|
||||||
return angularDiameter > minDiameter * lodScaleFactor;
|
|
||||||
}
|
|
||||||
|
|
|
@ -39,6 +39,4 @@ const float MIN_ELEMENT_ANGULAR_DIAMETER = 0.0043301f; // radians
|
||||||
const float MIN_ENTITY_ANGULAR_DIAMETER = MIN_ELEMENT_ANGULAR_DIAMETER * SQRT_THREE;
|
const float MIN_ENTITY_ANGULAR_DIAMETER = MIN_ELEMENT_ANGULAR_DIAMETER * SQRT_THREE;
|
||||||
const float MIN_VISIBLE_DISTANCE = 0.0001f; // helps avoid divide-by-zero check
|
const float MIN_VISIBLE_DISTANCE = 0.0001f; // helps avoid divide-by-zero check
|
||||||
|
|
||||||
bool isAngularSizeBigEnough(glm::vec3 position, const AACube& cube, float lodScaleFactor, float minDiameter);
|
|
||||||
|
|
||||||
#endif // hifi_OctreeUtils_h
|
#endif // hifi_OctreeUtils_h
|
||||||
|
|
|
@ -62,8 +62,8 @@ void RenderShadowTask::build(JobModel& task, const render::Varying& input, rende
|
||||||
|
|
||||||
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 = FetchSpatialSelection::Inputs(shadowSelection, shadowCasterReceiverFilter).asVarying();
|
const auto selectionInputs = FilterSpatialSelection::Inputs(shadowSelection, shadowCasterReceiverFilter).asVarying();
|
||||||
const auto shadowItems = task.addJob<FetchSpatialSelection>("FetchShadowSelection", selectionInputs);
|
const auto shadowItems = task.addJob<FilterSpatialSelection>("FilterShadowSelection", selectionInputs);
|
||||||
|
|
||||||
// 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.
|
||||||
|
|
|
@ -445,7 +445,7 @@ void ApplyCullFunctorOnItemBounds::run(const RenderContextPointer& renderContext
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FetchSpatialSelection::run(const RenderContextPointer& renderContext,
|
void FilterSpatialSelection::run(const RenderContextPointer& renderContext,
|
||||||
const Inputs& inputs, ItemBounds& outItems) {
|
const Inputs& inputs, ItemBounds& outItems) {
|
||||||
assert(renderContext->args);
|
assert(renderContext->args);
|
||||||
auto& scene = renderContext->_scene;
|
auto& scene = renderContext->_scene;
|
||||||
|
|
|
@ -147,12 +147,12 @@ namespace render {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class FetchSpatialSelection {
|
class FilterSpatialSelection {
|
||||||
public:
|
public:
|
||||||
using Inputs = render::VaryingSet2<ItemSpatialTree::ItemSelection, ItemFilter>;
|
using Inputs = render::VaryingSet2<ItemSpatialTree::ItemSelection, ItemFilter>;
|
||||||
using JobModel = Job::ModelIO<FetchSpatialSelection, Inputs, ItemBounds>;
|
using JobModel = Job::ModelIO<FilterSpatialSelection, Inputs, ItemBounds>;
|
||||||
|
|
||||||
FetchSpatialSelection() {}
|
FilterSpatialSelection() {}
|
||||||
void run(const RenderContextPointer& renderContext, const Inputs& inputs, ItemBounds& outItems);
|
void run(const RenderContextPointer& renderContext, const Inputs& inputs, ItemBounds& outItems);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -160,15 +160,16 @@ Item {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
PlotPerf {
|
PlotPerf {
|
||||||
title: "Solid Angle Half Tan"
|
title: "Solid Angle"
|
||||||
height: parent.evalEvenHeight()
|
height: parent.evalEvenHeight()
|
||||||
object: LODManager
|
object: LODManager
|
||||||
valueScale: 1.0
|
valueScale: 1.0
|
||||||
valueUnit: ""
|
valueUnit: "deg"
|
||||||
|
//valueNumDigits: 0
|
||||||
plots: [
|
plots: [
|
||||||
{
|
{
|
||||||
prop: "solidAngleHalfTan",
|
prop: "solidAngle",
|
||||||
label: "SAHT",
|
label: "Solid Angle",
|
||||||
color: "#9999FF"
|
color: "#9999FF"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue