USing a simpler halfTan test for culling

This commit is contained in:
Sam Gateau 2018-08-26 23:17:29 -07:00
parent 294fe51fde
commit d97d655148
8 changed files with 24 additions and 20 deletions

View file

@ -237,8 +237,14 @@ QString LODManager::getLODFeedbackText() {
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
// to use in rendering.
float renderAccuracy = calculateRenderAccuracy(args->getViewFrustum().getPosition(), bounds, args->_sizeScale, args->_boundaryLevelAdjust);
return (renderAccuracy > 0.0f);
// float renderAccuracy = calculateRenderAccuracy(args->getViewFrustum().getPosition(), bounds, args->_sizeScale, args->_boundaryLevelAdjust);
// 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) {
@ -325,3 +331,6 @@ float LODManager::getSolidAngleHalfTan() const {
return getPerspectiveAccuracyAngleTan(_octreeSizeScale, _boundaryLevelAdjust);
}
float LODManager::getSolidAngle() const {
return glm::degrees(2.0 * atan(getSolidAngleHalfTan()));
}

View file

@ -70,6 +70,7 @@ class LODManager : public QObject, public Dependency {
Q_PROPERTY(float worldDetailQuality READ getWorldDetailQuality WRITE setWorldDetailQuality NOTIFY worldDetailQualityChanged)
Q_PROPERTY(float solidAngleHalfTan READ getSolidAngleHalfTan)
Q_PROPERTY(float solidAngle READ getSolidAngle)
public:
@ -187,6 +188,7 @@ public:
float getWorldDetailQuality() const;
float getSolidAngleHalfTan() const;
float getSolidAngle() const;
signals:

View file

@ -79,9 +79,3 @@ float getOrthographicAccuracySize(float octreeSizeScale, int boundaryLevelAdjust
const float smallestSize = 0.01f;
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;
}

View file

@ -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_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

View file

@ -62,8 +62,8 @@ void RenderShadowTask::build(JobModel& task, const render::Varying& input, rende
const auto fetchInput = FetchSpatialTree::Inputs(shadowCasterReceiverFilter, queryResolution).asVarying();
const auto shadowSelection = task.addJob<FetchSpatialTree>("FetchShadowTree", fetchInput);
const auto selectionInputs = FetchSpatialSelection::Inputs(shadowSelection, shadowCasterReceiverFilter).asVarying();
const auto shadowItems = task.addJob<FetchSpatialSelection>("FetchShadowSelection", selectionInputs);
const auto selectionInputs = FilterSpatialSelection::Inputs(shadowSelection, shadowCasterReceiverFilter).asVarying();
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
// frustum culling or this will make shadow casters out of the camera frustum disappear.

View file

@ -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) {
assert(renderContext->args);
auto& scene = renderContext->_scene;

View file

@ -147,12 +147,12 @@ namespace render {
};
class FetchSpatialSelection {
class FilterSpatialSelection {
public:
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);
};

View file

@ -160,15 +160,16 @@ Item {
]
}
PlotPerf {
title: "Solid Angle Half Tan"
title: "Solid Angle"
height: parent.evalEvenHeight()
object: LODManager
valueScale: 1.0
valueUnit: ""
valueUnit: "deg"
//valueNumDigits: 0
plots: [
{
prop: "solidAngleHalfTan",
label: "SAHT",
prop: "solidAngle",
label: "Solid Angle",
color: "#9999FF"
}
]