Added function to show selected streams + function for flow which extends over all nodes

It is now possible to show selected streams which is not dependent on flow. And flow is now no longer an enhance method, and extends over all the nodes. Also added small changes and code clean up
This commit is contained in:
Emilie
2020-07-24 11:46:58 +02:00
parent ee5e11796a
commit ebe1bad7d4
5 changed files with 114 additions and 132 deletions
@@ -233,6 +233,11 @@ namespace {
"Toggles the rendering of moving particles along the lines. Can, for example, "
"illustrate magnetic flow."
};
constexpr openspace::properties::Property::PropertyInfo InterestingStreamsInfo = {
"interestingStreamsEnabled",
"Interesting Streams Enabled",
"Toggles the rendering of selected streams."
};
constexpr openspace::properties::Property::PropertyInfo FlowParticleSizeInfo = {
"particleSize",
"Particle Size",
@@ -304,6 +309,11 @@ namespace {
"Distance factor",
"This value decides how far away the camera must be to start impacting the nodesize"
};
/*constexpr openspace::properties::Property::PropertyInfo TestChangeInfo = {
"testChange",
"Test factor",
"Test"
};*/
enum class SourceFileType : int {
Json = 0,
Invalid
@@ -394,6 +404,7 @@ RenderableStreamNodes::RenderableStreamNodes(const ghoul::Dictionary& dictionary
glm::vec4(1.f)
)
, _pFlowEnabled(FlowEnabledInfo, false)
, _pInterestingStreamsEnabled(InterestingStreamsInfo, false)
, _pFlowGroup({ "Flow" })
, _pFlowParticleSize(FlowParticleSizeInfo, 5, 0, 500)
, _pFlowParticleSpacing(FlowParticleSpacingInfo, 60, 0, 500)
@@ -410,6 +421,7 @@ RenderableStreamNodes::RenderableStreamNodes(const ghoul::Dictionary& dictionary
, _pGaussianAlphaFilter(GaussiandAlphaFilterInfo, false)
, _pRadiusPerspective(RadiusPerspectiveInfo, true)
, _pPerspectiveDistanceFactor(perspectiveDistanceFactorInfo, 6.f, 1.f, 20.f)
//, _pTestChange(TestChangeInfo, 0.5f, 0.0f, 1.f)
{
_dictionary = std::make_unique<ghoul::Dictionary>(dictionary);
@@ -1121,6 +1133,7 @@ void RenderableStreamNodes::setupProperties() {
_pEarthdistGroup.addProperty(_pDistancemethod);
_pEarthdistGroup.addProperty(_pDistanceThreshold);
_pEarthdistGroup.addProperty(_pEnhancemethod);
_pEarthdistGroup.addProperty(_pInterestingStreamsEnabled);
_pFlowGroup.addProperty(_pFlowEnabled);
_pFlowGroup.addProperty(_pFlowColor);
@@ -1129,6 +1142,8 @@ void RenderableStreamNodes::setupProperties() {
_pFlowGroup.addProperty(_pFlowSpeed);
_pFlowGroup.addProperty(_pUseFlowColor);
// _pStreamGroup.addProperty(_pTestChange);
// --------------------- Add Options to OptionProperties --------------------- //
_pGoesEnergyBins.addOption(static_cast<int>(GoesEnergyBins::Emin01), "Emin01");
_pGoesEnergyBins.addOption(static_cast<int>(GoesEnergyBins::Emin03), "Emin03");
@@ -1154,7 +1169,7 @@ void RenderableStreamNodes::setupProperties() {
_pEnhancemethod.addOption(static_cast<int>(EnhanceMethod::Sizescaling), "SizeScaling");
_pEnhancemethod.addOption(static_cast<int>(EnhanceMethod::Colortables), "ColorTables");
_pEnhancemethod.addOption(static_cast<int>(EnhanceMethod::Outline), "Outline");
_pEnhancemethod.addOption(static_cast<int>(EnhanceMethod::Lines), "Lines");
_pEnhancemethod.addOption(static_cast<int>(EnhanceMethod::Blinking), "Blinking");
_pEnhancemethod.addOption(static_cast<int>(EnhanceMethod::Sizeandcolor), "Sizescaling and colortables");
_pEnhancemethod.addOption(static_cast<int>(EnhanceMethod::test), "test");
@@ -1304,6 +1319,7 @@ void RenderableStreamNodes::render(const RenderData& data, RendererTasks&) {
_shaderProgram->setUniform("enhanceMethod", _pEnhancemethod);
_shaderProgram->setUniform("flowColor", _pFlowColor);
_shaderProgram->setUniform("usingParticles", _pFlowEnabled);
_shaderProgram->setUniform("usingInterestingStreams", _pInterestingStreamsEnabled);
_shaderProgram->setUniform("particleSize", _pFlowParticleSize);
_shaderProgram->setUniform("particleSpacing", _pFlowParticleSpacing);
_shaderProgram->setUniform("particleSpeed", _pFlowSpeed);
@@ -1320,7 +1336,8 @@ void RenderableStreamNodes::render(const RenderData& data, RendererTasks&) {
_shaderProgram->setUniform("drawHollow", _pDrawingHollow);
_shaderProgram->setUniform("useGaussian", _pGaussianAlphaFilter);
_shaderProgram->setUniform("usingRadiusPerspective", _pRadiusPerspective);
_shaderProgram->setUniform("PerspectiveDistanceFactor", _pPerspectiveDistanceFactor);
_shaderProgram->setUniform("perspectiveDistanceFactor", _pPerspectiveDistanceFactor);
//_shaderProgram->setUniform("testChange", _pTestChange);
//////// test for camera perspective:
/*
@@ -89,7 +89,7 @@ private:
Sizescaling = 0,
Colortables = 1,
Outline = 2,
Lines = 3,
Blinking = 3,
Sizeandcolor = 4,
test = 5
};
@@ -228,6 +228,8 @@ private:
properties::FloatProperty _pMaxNodeDistanceSize;
// Threshold for where to interpolate between the max and min node distance
properties::FloatProperty _pNodeDistanceThreshold;
// Toggle selected streams [ON/OFF]
properties::BoolProperty _pInterestingStreamsEnabled;
/// Line width for the line rendering part
properties::FloatProperty _pLineWidth;
@@ -283,6 +285,8 @@ private:
properties::BoolProperty _pRadiusPerspective;
properties::FloatProperty _pPerspectiveDistanceFactor;
//properties::FloatProperty _pTestChange;
// initialization
std::vector<std::string> _sourceFiles;
// binary files sourcefolder
@@ -28,6 +28,7 @@ uniform sampler2D texture1;
uniform bool drawCircles;
uniform bool drawHollow;
uniform bool useGaussian;
//uniform float testChange;
in vec2 vs_st;
in vec4 vs_color;
in float vs_depth;
@@ -44,6 +45,12 @@ Fragment getFragment() {
frag.color = fragColor;
vec2 coord = gl_PointCoord - vec2(0.5);
/*if(length(coord.x) > 0.15){
if((coord.y) > 0){
discard;
}
}*/
if(drawCircles){
if(length(coord) > 0.5){
discard;
@@ -73,6 +80,7 @@ Fragment getFragment() {
discard;
}
frag.color.a = alphaV;
//else{
//frag.color.a = alphaV;
}
@@ -76,6 +76,7 @@ uniform int activeStreamNumber;
uniform bool firstRender;
uniform int enhanceMethod;
uniform double time;
uniform bool usingInterestingStreams;
//uniform float interestingStreams[4];
@@ -98,7 +99,7 @@ uniform vec3 cameraPos;
//uniform vec2 screenSize;
uniform bool usingCameraPerspective;
uniform bool usingRadiusPerspective;
uniform float PerspectiveDistanceFactor;
uniform float perspectiveDistanceFactor;
// Inputs
// Should be provided in meters
@@ -212,107 +213,49 @@ bool CheckvertexIndex(){
//todo fix gl_VertexID
bool isParticle(){
int modulusResult = int(double(particleSpeed) * time + gl_VertexID) % particleSpacing;
float speedIrregular = 1;
if(rValue > 1){
//if(Streamnumber % 2 == 1)
//{
speedIrregular = 4;
modulusResult = int(double(particleSpeed)* speedIrregular * time + gl_VertexID) % particleSpacing;
//}
//else{
// modulusResult = int(double(particleSpeed) * time + gl_VertexID) % particleSpacing;
//}
}
else{
modulusResult = int(double(particleSpeed) * time + gl_VertexID*2) % particleSpacing;
}
return modulusResult > 0 && modulusResult <= particleSize;
return false;
}
//function for showing nodes different depending on distance to earth
void DecidehowtoshowClosetoEarth(){
//Sizescaling
if(enhanceMethod == 0){
float tempR = rValue + 0.4;
if(tempR > 1.5){
tempR = 1.5;
}
// SizeScaling
if(enhanceMethod == 0){
float tempR = rValue + 0.4;
if(tempR > 1.5){
tempR = 1.5;
}
gl_PointSize = tempR * tempR * tempR * gl_PointSize * 5;
return;
}
//Colortables
if(enhanceMethod == 1){
vec4 fluxColor = getTransferFunctionColor(colorTable);
vs_color = vec4(fluxColor.xyz, fluxColor.a);
return;
}
//Outline
if(enhanceMethod == 2){
if(!firstRender && vs_color.x != 0 && vs_color.y != 0){
gl_PointSize = gl_PointSize + 1;
vs_color = vec4(streamColor.xyz, fluxColorAlpha);
}
return;
}
//lines
if(enhanceMethod == 3){
// Draw every other line grey
vs_color = vec4(0.18, 0.18, 0.18, 1*fluxColorAlpha);
float interestingStreams[6] = float[](154, 156, 153, 157, 158, 163);
// vs_color = vec4(0);
//float interestingStreams[26] = float[](135, 138, 145, 146, 147, 149, 153, 154, 155, 156, 157, 158, 159, 160, 167, 163,
//168, 169, 170, 172, 174, 180, 181, 183, 356, 364);
//float interestingStreams[3] = float[](37, 154, 210);
int modulusResult = int(double(particleSpeed) * time + gl_VertexID) % particleSpacing;
for(int i = 0; i < interestingStreams.length(); i++){
if(Streamnumber == interestingStreams[i]){
// if(!firstRender){
// vs_color = vec4(streamColor.xyz, fluxColorAlpha);
if(usingParticles && isParticle() && rValue > 0.f){
if(modulusResult >= particleSize - 30){
if(flowColoring){
vec4 fluxColor3 = getTransferFunctionColor(colorTable);
vs_color = vec4(fluxColor3.xyz, flowColor.a * 0.8);
//vs_color = vec4(1,1,1,1);
}
else{
vs_color = vec4(0.9,0.9,0.9,0.5);
//vs_color = flowColor;
}
}
else{
vec4 fluxColorFlow = getTransferFunctionColor(colorTableFlow);
vs_color = vec4(fluxColorFlow.xyz, 1);
}
//vs_color = vec4(0.37, 0.37, 0.37, flowColor.a);
// }
// else{
// vec4 fluxColor3 = getTransferFunctionColor(colorTable);
// vs_color = vec4(fluxColor3.xyz, fluxColor3.a);
// vs_color = vec4(0.37, 0.37, 0.37, flowColor.a);
}
}
}
// }
}
//SizeandColor
// ColorTables
if(enhanceMethod == 1){
vec4 fluxColor = getTransferFunctionColor(colorTable);
vs_color = vec4(fluxColor.xyz, fluxColor.a);
return;
}
// Outline
if(enhanceMethod == 2){
if(!firstRender && vs_color.x != 0 && vs_color.y != 0){
gl_PointSize = gl_PointSize + 1;
vs_color = vec4(streamColor.xyz, fluxColorAlpha);
}
return;
}
// Blinking
if(enhanceMethod == 3){
}
//SizeColor
if(enhanceMethod == 4){
vec4 fluxColor3 = getTransferFunctionColor(colorTable);
vs_color = vec4(fluxColor3.xyz, fluxColor3.a);
vec4 fluxColor3 = getTransferFunctionColor(colorTable);
vs_color = vec4(fluxColor3.xyz, fluxColor3.a);
float tempR2 = rValue + 0.4;
if(tempR2 > 1.5){
tempR2 = 1.5;
}
gl_PointSize = tempR2 * tempR2 * tempR2 * gl_PointSize * 5;
float tempR2 = rValue + 0.4;
if(tempR2 > 1.5){
tempR2 = 1.5;
}
gl_PointSize = tempR2 * tempR2 * tempR2 * gl_PointSize * 5;
}
}
@@ -386,6 +329,45 @@ void main() {
vs_color = vec4(0);
}
if(usingInterestingStreams){
// Draw every other line grey
//vs_color = vec4(0.18, 0.18, 0.18, 1*fluxColorAlpha);
vs_color = vec4(0);
float interestingStreams[6] = float[](154, 156, 153, 157, 158, 163);
//float interestingStreams[26] = float[](135, 138, 145, 146, 147, 149, 153, 154, 155, 156, 157, 158, 159, 160, 167, 163,
//168, 169, 170, 172, 174, 180, 181, 183, 356, 364);
//float interestingStreams[3] = float[](37, 154, 210);
for(int i = 0; i < interestingStreams.length(); i++){
if(Streamnumber == interestingStreams[i]){
vec4 fluxColor3 = getTransferFunctionColor(colorTable);
vs_color = vec4(fluxColor3.xyz, 1*fluxColorAlpha);
}
}
}
if(usingParticles && isParticle() && rValue > 0.f){
int modulusResult = int(double(particleSpeed) * time + gl_VertexID)
% particleSpacing;
if(modulusResult >= particleSize - 30){
if(flowColoring){
vec4 fluxColor3 = getTransferFunctionColor(colorTable);
vs_color = vec4(fluxColor3.xyz, flowColor.a * 0.8);
//vs_color = vec4(1,1,1,1);
}
else{
vs_color = vec4(0.9,0.9,0.9,0.5);
//vs_color = flowColor;
}
}
else{
vec4 fluxColorFlow = getTransferFunctionColor(colorTableFlow);
vs_color = vec4(fluxColorFlow.xyz, 1);
}
}
if(usingCameraPerspective){
float rtemp = 1.0;
if(rValue > 1.0){
@@ -395,12 +377,12 @@ void main() {
rtemp = rValue;
}
float maxdist = 100000000000.f * PerspectiveDistanceFactor;
float distancevec = distance(cameraPos, in_position.xyz);
float maxDistance = 100000000000.f * perspectiveDistanceFactor;
float distanceVec = distance(cameraPos, in_position.xyz);
if(distancevec < maxdist){
float distScale = 1 - smoothstep(0, maxdist, distancevec);
//float distMinScale = 1 - smoothstep(0, nodeDistanceThreshold, distancevec);
if(distanceVec < maxDistance){
float distScale = 1 - smoothstep(0, maxDistance, distanceVec);
//float distMinScale = 1 - smoothstep(0, nodeDistanceThreshold, distanceVec);
float factorS = 1.f;
if(usingRadiusPerspective){
factorS = pow(distScale, 9) * 100.f * pow(rtemp, 2);
@@ -409,16 +391,16 @@ void main() {
factorS = pow(distScale, 9) * 100.f;
}
gl_PointSize = factorS * maxNodeDistanceSize * 0.8;
}
}
// else{
// gl_PointSize = nodeSize;
// }
if(gl_PointSize > 40){
gl_PointSize = 40;
gl_PointSize = 40;
}
if(gl_PointSize < 1.f){
gl_PointSize = 1.f;
gl_PointSize = 1.f;
}
}