diff --git a/data/assets/scene/solarsystem/sun/heliosphere/mas/bastille_day/transferfunctions/stream_nodes1.txt b/data/assets/scene/solarsystem/sun/heliosphere/mas/bastille_day/transferfunctions/stream_nodes1.txt new file mode 100644 index 0000000000..8b6c693964 --- /dev/null +++ b/data/assets/scene/solarsystem/sun/heliosphere/mas/bastille_day/transferfunctions/stream_nodes1.txt @@ -0,0 +1,13 @@ + +width 6 +lower 0.0 +upper 1.0 + +mappingkey 0.0 123 104 238 255 +mappingkey 0.166 100 149 235 255 +mappingkey 0.332 175 238 238 255 +mappingkey 0.498 152 251 152 170 +mappingkey 0.664 255 250 205 255 +mappingkey 0.830 255 141 141 255 +mappingkey 1.0 255 80 80 255 + diff --git a/modules/fieldlinessequence/rendering/renderablestreamnodes.cpp b/modules/fieldlinessequence/rendering/renderablestreamnodes.cpp index 918c5e7b8c..5d3cfd8a01 100644 --- a/modules/fieldlinessequence/rendering/renderablestreamnodes.cpp +++ b/modules/fieldlinessequence/rendering/renderablestreamnodes.cpp @@ -150,10 +150,10 @@ namespace { "This value specifies the line width of the field lines if the " "selected rendering method includes lines." }; - constexpr openspace::properties::Property::PropertyInfo ThresholdRadiusInfo = { - "thresholdRadius", - "Threshold flux scaling", - "This value specifies the threshold that will be changed with the radius." + constexpr openspace::properties::Property::PropertyInfo ThresholdFluxInfo = { + "thresholdFlux", + "Threshold flux value", + "This value specifies the threshold that will be changed with the flux value." }; constexpr openspace::properties::Property::PropertyInfo FilteringInfo = { "filtering", @@ -180,6 +180,11 @@ namespace { "Z-limits Lower", "Valid range along the Z-axis. [Min, Max]" }; + constexpr openspace::properties::Property::PropertyInfo FluxColorAlphaInfo = { + "fluxColorAlpha", + "Flux Color Alpha", + "The value of alpha for the flux color mode" + }; enum class SourceFileType : int { Json = 0, Cdf, @@ -240,7 +245,7 @@ namespace openspace { , _pColorGroup({ "Color" }) , _pColorMode(ColorModeInfo, OptionProperty::DisplayType::Radio) , _pScalingmethod(ScalingmethodInfo, OptionProperty::DisplayType::Radio) - //, _pColorFlux(ColorFluxInfo, OptionProperty::DisplayType::Dropdown) + , _pColorFlux(ColorFluxInfo, OptionProperty::DisplayType::Dropdown) //, _pColorFluxMin(ColorFluxMinInfo) //, _pColorFluxMax(ColorFluxMaxInfo) , _pColorTablePath(ColorTablePathInfo) @@ -254,10 +259,8 @@ namespace openspace { , _pLineWidth(LineWidthInfo, 1.f, 1.f, 20.f) , _pColorTableRange(colorTableRangeInfo) , _pDomainZ(DomainZInfo) - //, _pThresholdRadius(ThresholdRadiusInfo, -2.f, -5.f, 5.f) - //, _pThresholdRadius(ThresholdRadiusInfo, 100000000000.f, -500000000000.f, 400000000000.f) - , _pThresholdRadius(ThresholdRadiusInfo, -10.f, -10.f, 10.f) - + , _pFluxColorAlpha(FluxColorAlphaInfo, 1.f, 0.f, 1.f) + , _pThresholdFlux(ThresholdFluxInfo, -10.f, -10.f, 10.f) // , _pFiltering(FilteringInfo, 100000.f, 10000000.f, 1000000000000.f) // , _pFilteringUpper(FilteringUpperInfo, 600000000000.f, 1000000.f, 1000000000000.f) , _pFiltering(FilteringInfo, 0.f, 0.f, 5.f) @@ -269,9 +272,18 @@ namespace openspace { } void RenderableStreamNodes::definePropertyCallbackFunctions() { - _pColorTablePath = _colorTablePaths[0]; + /*_pColorTablePath = _colorTablePaths[0]; _transferFunction->setPath(_pColorTablePath); - _colorTablePaths[0] = _pColorTablePath; + _colorTablePaths[0] = _pColorTablePath;*/ + + _pColorFlux.onChange([this] { + _pColorTablePath = _colorTablePaths[_pColorFlux]; + }); + + _pColorTablePath.onChange([this] { + _transferFunction->setPath(_pColorTablePath); + _colorTablePaths[_pColorFlux] = _pColorTablePath; + }); } void RenderableStreamNodes::setModelDependentConstants() { @@ -342,6 +354,7 @@ namespace openspace { extractTriggerTimesFromFileNames(); computeSequenceEndTime(); + LDEBUG("filepath i init: " + std::to_string(_sourceFiles.size())); if (!_loadingStatesDynamically) { LoadfilesintoRam(); @@ -361,7 +374,7 @@ namespace openspace { _uniformCache.streamColor = _shaderProgram->uniformLocation("streamColor"); _uniformCache.usingParticles = _shaderProgram->uniformLocation("usingParticles"); _uniformCache.nodeSize = _shaderProgram->uniformLocation("nodeSize"); - _uniformCache.thresholdRadius = _shaderProgram->uniformLocation("thresholdRadius"); + _uniformCache.thresholdFlux = _shaderProgram->uniformLocation("thresholdFlux"); glGenVertexArrays(1, &_vertexArrayObject); glGenBuffers(1, &_vertexPositionBuffer); @@ -373,7 +386,7 @@ namespace openspace { } bool RenderableStreamNodes::LoadfilesintoRam() { - size_t filesnumbers = 270; + //size_t filesnumbers = 270; for (size_t j = 0; j < _nStates; ++j) { std::ifstream streamdata(_sourceFiles[j]); @@ -591,7 +604,7 @@ namespace openspace { } float thresholdRadiusValue; if (_dictionary->getValue(KeyThresholdRadius, thresholdRadiusValue)) { - _pThresholdRadius = thresholdRadiusValue; + _pThresholdFlux = thresholdRadiusValue; } float scaleFactor; if (_dictionary->getValue(KeyJsonScalingFactor, scaleFactor)) { @@ -626,8 +639,9 @@ namespace openspace { _pColorGroup.addProperty(_pColorTableRange); _pColorGroup.addProperty(_pColorTablePath); _pColorGroup.addProperty(_pStreamColor); + _pColorGroup.addProperty(_pFluxColorAlpha); _pStreamGroup.addProperty(_pNodeSize); - _pStreamGroup.addProperty(_pThresholdRadius); + _pStreamGroup.addProperty(_pThresholdFlux); // --------------------- Add Options to OptionProperties --------------------- // _pColorMode.addOption(static_cast(ColorMethod::Uniform), "Uniform"); @@ -638,9 +652,11 @@ namespace openspace { _pScalingmethod.addOption(static_cast(ScalingMethod::R2Flux), "Radius^2 * Flux"); _pScalingmethod.addOption(static_cast(ScalingMethod::log10RFlux), "log10(r) * Flux"); _pScalingmethod.addOption(static_cast(ScalingMethod::lnRFlux), "ln(r) * Flux"); + definePropertyCallbackFunctions(); // Set defaults + //_pColorFlux = 0; _pColorTablePath = _colorTablePaths[0]; } @@ -741,13 +757,14 @@ namespace openspace { _shaderProgram->setUniform(_uniformCache.streamColor, _pStreamColor); _shaderProgram->setUniform(_uniformCache.usingParticles, _pStreamsEnabled); _shaderProgram->setUniform(_uniformCache.nodeSize, 1); - _shaderProgram->setUniform(_uniformCache.thresholdRadius, _pThresholdRadius); + _shaderProgram->setUniform(_uniformCache.thresholdFlux, _pThresholdFlux); _shaderProgram->setUniform("colorMode", _pColorMode); _shaderProgram->setUniform("filterRadius", _pFiltering); _shaderProgram->setUniform("filterUpper", _pFilteringUpper); _shaderProgram->setUniform("ScalingMode", _pScalingmethod); _shaderProgram->setUniform("colorTableRange", _pColorTableRange.value()); _shaderProgram->setUniform("domainLimZ", _pDomainZ.value()); + _shaderProgram->setUniform("fluxColorAlpha", _pFluxColorAlpha); if (_pColorMode == static_cast(ColorMethod::ByFluxValue)) { ghoul::opengl::TextureUnit textureUnit; @@ -829,7 +846,6 @@ namespace openspace { // _mustLoadNewStateFromDisk = true; - _needsUpdate = true; _activeStateIndex = _activeTriggerTimeIndex; diff --git a/modules/fieldlinessequence/rendering/renderablestreamnodes.h b/modules/fieldlinessequence/rendering/renderablestreamnodes.h index 8dfdd974f0..5cd8958025 100644 --- a/modules/fieldlinessequence/rendering/renderablestreamnodes.h +++ b/modules/fieldlinessequence/rendering/renderablestreamnodes.h @@ -77,7 +77,7 @@ namespace openspace { lnRFlux = 4 }; - UniformCache(streamColor, usingParticles, nodeSize, thresholdRadius) + UniformCache(streamColor, usingParticles, nodeSize, thresholdFlux) _uniformCache; // ------------------------------------ STRINGS ------------------------------------// @@ -130,7 +130,7 @@ namespace openspace { // Uniform stream Color properties::Vec4Property _pStreamColor; // Index of the flux value to color lines by - //properties::OptionProperty _pColorFlux; + properties::OptionProperty _pColorFlux; // Color table/transfer function min //properties::StringProperty _pColorFluxMin; // Color table/transfer function max @@ -150,11 +150,13 @@ namespace openspace { //////////////// properties::Vec2Property _pDomainZ; /// /////////// - properties::FloatProperty _pThresholdRadius; + properties::FloatProperty _pThresholdFlux; // Filtering nodes within a range properties::FloatProperty _pFiltering; // Filtering nodes with a upper range properties::FloatProperty _pFilteringUpper; + //////////////// + properties::FloatProperty _pFluxColorAlpha; // initialization std::vector _sourceFiles; diff --git a/modules/fieldlinessequence/shaders/streamnodes_vs.glsl b/modules/fieldlinessequence/shaders/streamnodes_vs.glsl index c8bfd25af0..081ffd9e0b 100644 --- a/modules/fieldlinessequence/shaders/streamnodes_vs.glsl +++ b/modules/fieldlinessequence/shaders/streamnodes_vs.glsl @@ -55,10 +55,11 @@ uniform vec2 domainLimR; // Streamnodes specific uniforms uniform float nodeSize; uniform vec4 streamColor; -uniform float thresholdRadius; +uniform float thresholdFlux; uniform float filterRadius; uniform float filterUpper; uniform int ScalingMode; +uniform float fluxColorAlpha; // Inputs // Should be provided in meters @@ -107,11 +108,12 @@ vec4 getTransferFunctionColor() { else if(ScalingMode == R2Flux){ scalevalue = rValue * rValue * fluxValue; } - if(scalevalue > thresholdRadius){ + + //if(scalevalue > thresholdFlux){ float lookUpVal = (scalevalue - colorTableRange.x)/(colorTableRange.y - colorTableRange.x); return texture(colorTable, lookUpVal); - } - return vec4(0); + //} + // return vec4(0); } bool isPartOfParticle(const double time, const int vertexId, const int particleSize, @@ -129,9 +131,15 @@ void main() { if(colorMode == 0){ vs_color = streamColor; } - else if (colorMode == 1){ - vec4 quantityColor = getTransferFunctionColor(); - vs_color = vec4(quantityColor.xyz, quantityColor.w); + else{ //else if (colorMode == 1){ + vec4 fluxColor = getTransferFunctionColor(); + + if(fluxValue > thresholdFlux){ + vs_color = vec4(fluxColor.xyz, fluxColor.w); + } + else{ + vs_color = vec4(fluxColor.xyz, fluxColorAlpha); + } } } else{ @@ -142,7 +150,7 @@ void main() { vs_color = vec4(0); } - //if(rValue > thresholdRadius){ + //if(rValue > thresholdFlux){ // vs_color = vec4(0); //}