diff --git a/modules/fieldlinessequence/rendering/renderablestreamnodes.cpp b/modules/fieldlinessequence/rendering/renderablestreamnodes.cpp index b5921dcd7c..ca5c58eac7 100644 --- a/modules/fieldlinessequence/rendering/renderablestreamnodes.cpp +++ b/modules/fieldlinessequence/rendering/renderablestreamnodes.cpp @@ -299,6 +299,11 @@ namespace { "Include radius with cameraperspective", "If false, then nodes closer to the sun will not be larger regardless of distance to camera." }; + constexpr openspace::properties::Property::PropertyInfo perspectiveDistanceFactorInfo = { + "perspectiveDistanceFactor", + "Distance factor", + "This value decides how far away the camera must be to start impacting the nodesize" + }; enum class SourceFileType : int { Json = 0, Invalid @@ -404,6 +409,7 @@ RenderableStreamNodes::RenderableStreamNodes(const ghoul::Dictionary& dictionary , _pDrawingHollow(DrawingHollowInfo, false) , _pGaussianAlphaFilter(GaussiandAlphaFilterInfo, false) , _pRadiusPerspective(RadiusPerspectiveInfo, true) + , _pPerspectiveDistanceFactor(perspectiveDistanceFactorInfo, 6.f, 1.f, 20.f) { _dictionary = std::make_unique(dictionary); @@ -1153,10 +1159,12 @@ void RenderableStreamNodes::setupProperties() { _pEnhancemethod.addOption(static_cast(EnhanceMethod::test), "test"); _pCameraPerspectiveGroup.addProperty(_pCameraPerspective); + _pCameraPerspectiveGroup.addProperty(_pPerspectiveDistanceFactor); _pCameraPerspectiveGroup.addProperty(_pDrawingCircles); _pCameraPerspectiveGroup.addProperty(_pDrawingHollow); _pCameraPerspectiveGroup.addProperty(_pGaussianAlphaFilter); _pCameraPerspectiveGroup.addProperty(_pRadiusPerspective); + definePropertyCallbackFunctions(); // Set default @@ -1312,6 +1320,7 @@ void RenderableStreamNodes::render(const RenderData& data, RendererTasks&) { _shaderProgram->setUniform("drawHollow", _pDrawingHollow); _shaderProgram->setUniform("useGaussian", _pGaussianAlphaFilter); _shaderProgram->setUniform("usingRadiusPerspective", _pRadiusPerspective); + _shaderProgram->setUniform("PerspectiveDistanceFactor", _pPerspectiveDistanceFactor); //////// test for camera perspective: /* @@ -1340,11 +1349,11 @@ void RenderableStreamNodes::render(const RenderData& data, RendererTasks&) { } glm::dvec3 orthoUp = glm::normalize(glm::cross(cameraViewDirectionWorld, orthoRight)); */ - glm::vec3 cameraPos = data.camera.positionVec3(); + glm::vec3 cameraPos = data.camera.positionVec3() * data.modelTransform.rotation; //this gives the same referenceframe as the nodes and makes it possible to see the //the distance between the camera and the nodes. - cameraPos = cameraPos * data.modelTransform.rotation; + //cameraPos = cameraPos * data.modelTransform.rotation; _shaderProgram->setUniform("cameraPos", cameraPos); //glm::vec3 cameraPos = data.camera.unsynchedPositionVec3(); diff --git a/modules/fieldlinessequence/rendering/renderablestreamnodes.h b/modules/fieldlinessequence/rendering/renderablestreamnodes.h index d14359011b..170db36fed 100644 --- a/modules/fieldlinessequence/rendering/renderablestreamnodes.h +++ b/modules/fieldlinessequence/rendering/renderablestreamnodes.h @@ -281,6 +281,7 @@ private: properties::BoolProperty _pDrawingHollow; properties::BoolProperty _pGaussianAlphaFilter; properties::BoolProperty _pRadiusPerspective; + properties::FloatProperty _pPerspectiveDistanceFactor; // initialization std::vector _sourceFiles; diff --git a/modules/fieldlinessequence/shaders/streamnodes_vs.glsl b/modules/fieldlinessequence/shaders/streamnodes_vs.glsl index 2aabb7de06..19c0e077d3 100644 --- a/modules/fieldlinessequence/shaders/streamnodes_vs.glsl +++ b/modules/fieldlinessequence/shaders/streamnodes_vs.glsl @@ -98,6 +98,7 @@ uniform vec3 cameraPos; //uniform vec2 screenSize; uniform bool usingCameraPerspective; uniform bool usingRadiusPerspective; +uniform float PerspectiveDistanceFactor; // Inputs // Should be provided in meters @@ -394,7 +395,7 @@ void main() { rtemp = rValue; } - float maxdist = 600000000000.f; + float maxdist = 100000000000.f * PerspectiveDistanceFactor; float distancevec = distance(cameraPos, in_position.xyz); if(distancevec < maxdist){