Filtering for node size depending on distance to camera

This commit is contained in:
Emilie
2020-07-21 15:47:50 +02:00
parent 63d1935485
commit e0d8722842
4 changed files with 68 additions and 43 deletions

View File

@@ -51,8 +51,8 @@ namespace openspace {
void render(const RenderData& data, RendererTasks& rendererTask) override;
void update(const UpdateData& data) override;
private:
std::string _identifier;
std::vector<float> _vertexArray;
glm::vec3 _normalizedVector;
@@ -86,7 +86,7 @@ namespace openspace {
properties::FloatProperty _pointSize;
properties::IntProperty _timeStep;
properties::FloatProperty _distanceFactor;
properties::BoolProperty _showLabel;
properties::BoolProperty _shouldFollowLight;
properties::FloatProperty _fadeDistance;

View File

@@ -259,6 +259,21 @@ namespace {
"temp",
"Temp"
};
constexpr openspace::properties::Property::PropertyInfo MaxNodeDistanceSizeInfo = {
"maxNodeDistanceSize",
"Max Node Distance Size",
"The maximum size of the nodes at a certin distance"
};
constexpr openspace::properties::Property::PropertyInfo MinNodeDistanceSizeInfo = {
"minNodeDistanceSize",
"Min Node Distance Size",
"The minimum size of the nodes at a certin distance"
};
constexpr openspace::properties::Property::PropertyInfo NodeDistanceThresholdInfo = {
"NodeDistanceThreshold",
"Node Distance Threshold",
"Threshold for where to interpolate between the max and min node distance"
};
enum class SourceFileType : int {
Json = 0,
Invalid
@@ -325,8 +340,8 @@ RenderableStreamNodes::RenderableStreamNodes(const ghoul::Dictionary& dictionary
glm::vec4(1.f))
, _pStreamGroup({ "Streams" })
, _pNodesamountGroup({ "NodeGroup" })
, _pNodeSize(NodeSizeInfo, 2.f, 1.f, 10.f)
, _pNodeSizeLargerFlux(NodeSizeLargerFluxInfo, 2.f, 1.f, 10.f)
, _pNodeSize(NodeSizeInfo, 1.f, 1.f, 10.f)
, _pNodeSizeLargerFlux(NodeSizeLargerFluxInfo, 1.f, 1.f, 10.f)
, _pLineWidth(LineWidthInfo, 4.f, 1.f, 20.f)
, _pColorTableRange(colorTableRangeInfo)
, _pDomainZ(DomainZInfo)
@@ -355,7 +370,10 @@ RenderableStreamNodes::RenderableStreamNodes(const ghoul::Dictionary& dictionary
, _pFlowSpeed(FlowSpeedInfo, 20, 0, 1000)
, _pFlowColoring(FlowColoringInfo, false)
, _scaleFactor(TempInfo1, 150.f, 1.f, 500.f)
, _pMinNodeDistanceSize(MinNodeDistanceSizeInfo, 1.f, 1.f, 5.f)
, _pMaxNodeDistanceSize(MaxNodeDistanceSizeInfo, 1.f, 1.f, 5.f)
, _pNodeDistanceThreshold(NodeDistanceThresholdInfo, 0.f, 0.f, 40.f)
{
_dictionary = std::make_unique<ghoul::Dictionary>(dictionary);
}
@@ -1059,6 +1077,9 @@ void RenderableStreamNodes::setupProperties() {
_pNodesamountGroup.addProperty(_pFluxNodeskipThreshold);
_pNodesamountGroup.addProperty(_pRadiusNodeSkipThreshold);
_pNodesamountGroup.addProperty(_pActiveStreamNumber);
_pNodesamountGroup.addProperty(_pMinNodeDistanceSize);
_pNodesamountGroup.addProperty(_pMaxNodeDistanceSize);
_pNodesamountGroup.addProperty(_pNodeDistanceThreshold);
_pEarthdistGroup.addProperty(_pDistancemethod);
_pEarthdistGroup.addProperty(_pDistanceThreshold);
@@ -1246,7 +1267,11 @@ void RenderableStreamNodes::render(const RenderData& data, RendererTasks&) {
global::windowDelegate.applicationTime() * -1
);
_shaderProgram->setUniform("flowColoring", _pFlowColoring);
_shaderProgram->setUniform("minNodeDistanceSize", _pMinNodeDistanceSize);
_shaderProgram->setUniform("maxNodeDistanceSize", _pMaxNodeDistanceSize);
_shaderProgram->setUniform("nodeDistanceThreshold", _pNodeDistanceThreshold);
//////// test for camera perspective:
glm::dmat4 modelMatrix =
@@ -1292,8 +1317,8 @@ void RenderableStreamNodes::render(const RenderData& data, RendererTasks&) {
glm::dmat4(data.camera.projectionMatrix()) * data.camera.combinedViewMatrix()
)
);
_shaderProgram->setUniform("minPointSize", 1.f); // in pixels
_shaderProgram->setUniform("maxPointSize", 100.f); // in pixels
//_shaderProgram->setUniform("minPointSize", 3.f); // in pixels
//_shaderProgram->setUniform("maxPointSize", 30.f); // in pixels
_shaderProgram->setUniform("up", glm::vec3(orthoUp));
_shaderProgram->setUniform("right", glm::vec3(orthoRight));

View File

@@ -220,8 +220,14 @@ private:
properties::FloatProperty _pNodeSize;
// Size of nodes for larger flux
properties::FloatProperty _pNodeSizeLargerFlux;
// Threshold from earth to decide the distance for which the nodeSize gets larger.
// Threshold from earth to decide the distance for which the nodeSize gets larger
properties::FloatProperty _pDistanceThreshold;
// Minimum size of nodes at a certin distance
properties::FloatProperty _pMinNodeDistanceSize;
// Maximum size of nodes at a certin distance
properties::FloatProperty _pMaxNodeDistanceSize;
// Threshold for where to interpolate between the max and min node distance
properties::FloatProperty _pNodeDistanceThreshold;
/// Line width for the line rendering part
properties::FloatProperty _pLineWidth;

View File

@@ -78,10 +78,11 @@ uniform double time;
//uniform float interestingStreams[4];
//speicific uniforms for cameraperspective:
// Speicific uniforms for cameraperspective
uniform float scaleFactor;
uniform float maxPointSize;
uniform float minPointSize;
uniform float minNodeDistanceSize;
uniform float maxNodeDistanceSize;
uniform float nodeDistanceThreshold;
uniform mat4 cameraViewProjectionMatrix;
uniform dmat4 modelMatrix;
@@ -379,8 +380,7 @@ void main() {
else{
vs_color = vec4(0);
}
/*
if(distance(in_position, camerapos) < 100000000000.f){
gl_PointSize = nodeSize * 5;
@@ -395,12 +395,12 @@ void main() {
float scaleMultiply = exp(scaleFactor * 0.10f);
vec3 scaledRight = vec3(0.f);
vec3 scaledUp = vec3(0.f);
//vec3 scaledRight = vec3(0.f);
//vec3 scaledUp = vec3(0.f);
vec3 normal = vec3(normalize(camerapos - dpos.xyz));
vec3 newRight = normalize(cross(cameraLookUp, normal));
vec3 newUp = cross(normal, newRight);
/////vec3 normal = vec3(normalize(camerapos - dpos.xyz));
/////vec3 newRight = normalize(cross(cameraLookUp, normal));
/////vec3 newUp = cross(normal, newRight);
double distCamera = length(camerapos - dpos.xyz);
float expVar = float(-distCamera) / pow(10.f, correctionSizeEndDistance);
@@ -415,9 +415,9 @@ void main() {
//vec2 sizes = abs(halfViewSize * (topRight - bottomLeft));
//float ta = 1.0f;
/*
if (sizes.x < 2.0f * minPointSize) {
float maxVar = 2.0f * minPointSize;
float minVar = minPointSize;
if (sizes.x < 2.0f * minNodeDistanceSize) {
float maxVar = 2.0f * minNodeDistanceSize;
float minVar = minNodeDistanceSize;
float var = (sizes.y + sizes.x);
ta = ( (var - minVar)/(maxVar - minVar) );
@@ -428,8 +428,8 @@ void main() {
}
*/
scaledRight = scaleMultiply * right * 0.5f;
scaledUp = scaleMultiply * up * 0.5f;
vec3 scaledRight = scaleMultiply * right * 0.5f;
vec3 scaledUp = scaleMultiply * up * 0.5f;
vec4 dposClip = cameraViewProjectionMatrix * vec4(dpos);
vec4 scaledRightClip = cameraViewProjectionMatrix * vec4(scaledRight, 0.0);
@@ -443,26 +443,23 @@ void main() {
float distancevec = distance(camerapos, in_position.xyz);
if(distancevec < maxdist){
float distScale = 1 - smoothstep(0, maxdist, distancevec);
/*
if(distScale <= 0.5f){
distScale += 0.5f;
float distScale = 1 - smoothstep(0, maxdist, distancevec);
float factorS = pow(distScale, 9) * 100.f;
float distMinScale = 1 - smoothstep(nodeDistanceThreshold, nodeDistanceThreshold, distancevec);
float factorX = pow(distMinScale, 9) * 80.f;
if(gl_PointSize * factorS > nodeDistanceThreshold){
gl_PointSize = factorS * maxNodeDistanceSize * 0.8;
}
else{
gl_PointSize = factorS * minNodeDistanceSize; //factorS * (maxNodeDistanceSize - minNodeDistanceSize);
}
}
else{
distScale += -0.5f;
}
*/
float factorS = pow(distScale, 9) * 80.f;
if(gl_PointSize * factorS > 30){
gl_PointSize = 30;
}
else{
gl_PointSize = gl_PointSize * factorS;
}
}
else{
gl_PointSize = 2.f;
gl_PointSize = 1.f;
}
//if(!firstrender){
//CheckdistanceMethod();
// }
@@ -485,7 +482,4 @@ void main() {
// vs_depth = gl_Position.w;
// if(distance(positionClipSpace.xyz, camerapos) < 0.f){
}