Changed the appearance of the flow

Added another color table for the flow (brighter than the usual color table)
This commit is contained in:
Emilie
2020-07-08 16:50:59 +02:00
parent c54ed88901
commit 4344b9435a
5 changed files with 62 additions and 9 deletions

View File

@@ -19,6 +19,7 @@ openspace.setPropertyValueSingle("Modules.Space.ShowExceptions", false)
local transferFunctions = asset.localResource("transferfunctions")
local streamnodeColorTable = transferFunctions .. "/stream_nodes.txt"
local streamnodeColorTableEarth = transferFunctions .. "/stream_nodes10.txt"
local streamnodeColorTableFlow = transferFunctions .. "/stream_nodesFlow.txt"
local streamnodesDirectory = asset.syncedResource({
Name = "Bastille Day Stream nodes",
@@ -47,6 +48,7 @@ local Streamnodes = {
ColorTablePaths = {
streamnodeColorTable,
streamnodeColorTableEarth,
streamnodeColorTableFlow,
},
--ColorTableMinMax = {
-- { 0, 1000000 },

View File

@@ -0,0 +1,12 @@
width 7
lower 0.0
upper 1.0
mappingkey 0.0 178 102 255 255
mappingkey 0.166 102 102 255 255
mappingkey 0.332 102 255 255 255
mappingkey 0.498 102 255 102 255
mappingkey 0.664 255 255 102 255
mappingkey 0.830 255 178 102 255
mappingkey 1.0 255 102 102 255

View File

@@ -114,6 +114,11 @@ namespace {
"Path to Color Table for nodes close to Earth",
"Color Table/Transfer Function for nodes around Earth."
};
constexpr openspace::properties::Property::PropertyInfo ColorTablePathFlowInfo = {
"colorTablePathFlow",
"Path to Color Table for nodes to show the flow",
"Color Table/Transfer Function for flow."
};
constexpr openspace::properties::Property::PropertyInfo StreamColorInfo = {
"color",
"Color",
@@ -313,6 +318,7 @@ RenderableStreamNodes::RenderableStreamNodes(const ghoul::Dictionary& dictionary
, _pEnhancemethod(EnhanceMethodInfo, OptionProperty::DisplayType::Dropdown)
, _pColorTablePath(ColorTablePathInfo)
, _pColorTablePathEarth(ColorTablePathEarthInfo)
, _pColorTablePathFlow(ColorTablePathFlowInfo)
, _pStreamColor(StreamColorInfo,
glm::vec4(0.96f, 0.88f, 0.8f, 0.5f),
glm::vec4(0.f),
@@ -366,6 +372,12 @@ void RenderableStreamNodes::definePropertyCallbackFunctions() {
_colorTablePathsEarth[0] = _pColorTablePathEarth;
});
_pColorTablePathFlow.onChange([this] {
_transferFunctionFlow->setPath(_pColorTablePathFlow);
_colorTablePathsFlow[0] = _pColorTablePathFlow;
});
_pGoesEnergyBins.onChange([this] {
if (_pGoesEnergyBins == 1) {
_isLoadingNewEnergyBin = true;
@@ -424,8 +436,10 @@ void RenderableStreamNodes::initializeGL() {
// corrupt or not provided!
_colorTablePaths.push_back(FieldlinesSequenceModule::DefaultTransferFunctionFile);
_colorTablePathsEarth.push_back(FieldlinesSequenceModule::DefaultTransferFunctionFile);
_colorTablePathsFlow.push_back(FieldlinesSequenceModule::DefaultTransferFunctionFile);
_transferFunction = std::make_unique<TransferFunction>(absPath(_colorTablePaths[0]));
_transferFunctionEarth = std::make_unique<TransferFunction>(absPath(_colorTablePathsEarth[0]));
_transferFunctionFlow = std::make_unique<TransferFunction>(absPath(_colorTablePathsFlow[0]));
// EXTRACT OPTIONAL INFORMATION FROM DICTIONARY
std::string outputFolderPath;
@@ -439,12 +453,16 @@ void RenderableStreamNodes::initializeGL() {
// Clear the default! It is already specified in the transferFunction
_colorTablePaths.clear();
_colorTablePathsEarth.clear();
_colorTablePathsFlow.clear();
_colorTablePaths.push_back(
colorTablesPathsDictionary.value<std::string>(std::to_string(1)));
_colorTablePathsEarth.push_back(
colorTablesPathsDictionary.value<std::string>(std::to_string(2)));
_colorTablePathsFlow.push_back(
colorTablesPathsDictionary.value<std::string>(std::to_string(3)));
}
}
@@ -979,6 +997,7 @@ void RenderableStreamNodes::setupProperties() {
_pColorGroup.addProperty(_pColorTableRange);
_pColorGroup.addProperty(_pColorTablePath);
_pColorGroup.addProperty(_pColorTablePathEarth);
_pColorGroup.addProperty(_pColorTablePathFlow);
_pColorGroup.addProperty(_pStreamColor);
_pColorGroup.addProperty(_pFluxColorAlpha);
@@ -1039,6 +1058,7 @@ void RenderableStreamNodes::setupProperties() {
// Set default
_pColorTablePath = _colorTablePaths[0];
_pColorTablePathEarth = _colorTablePathsEarth[0];
_pColorTablePathFlow = _colorTablePathsFlow[0];
}
void RenderableStreamNodes::deinitializeGL() {
@@ -1181,6 +1201,11 @@ void RenderableStreamNodes::render(const RenderData& data, RendererTasks&) {
textureUnitEarth.activate();
_transferFunctionEarth->bind(); // Calls update internally
_shaderProgram->setUniform("colorTableEarth", textureUnitEarth);
ghoul::opengl::TextureUnit textureUnitFlow;
textureUnitFlow.activate();
_transferFunctionFlow->bind(); // Calls update internally
_shaderProgram->setUniform("colorTableFlow", textureUnitFlow);
}
const std::vector<glm::vec3>& vertPos = _vertexPositions;

View File

@@ -156,12 +156,16 @@ private:
std::unique_ptr<TransferFunction> _transferFunction;
// Transfer function used to color line near Earth
std::unique_ptr<TransferFunction> _transferFunctionEarth;
// Transfer function used to color line flow
std::unique_ptr<TransferFunction> _transferFunctionFlow;
// ------------------------------------ VECTORS ----------------------------------- //
// Paths to color tables. One for each 'ColorFlux'
std::vector<std::string> _colorTablePaths;
// Paths to Earth color tables
std::vector<std::string> _colorTablePathsEarth;
// Paths to Flow color tables
std::vector<std::string> _colorTablePathsFlow;
// Values represents min & max values represented in the color table
std::vector<glm::vec2> _colorTableRanges;
// Contains the _triggerTimes for all FieldlineStates in the sequence
@@ -205,6 +209,8 @@ private:
properties::StringProperty _pColorTablePath;
// Color table/transfer function for Earth
properties::StringProperty _pColorTablePathEarth;
// Color table/transfer function for Flow
properties::StringProperty _pColorTablePathFlow;
// Valid range for the color table
properties::Vec2Property _pColorTableRange;
// The value of alpha for the flux color mode

View File

@@ -31,6 +31,7 @@ uniform mat4 modelViewProjection;
uniform int colorMode;
uniform sampler1D colorTable;
uniform sampler1D colorTableEarth;
uniform sampler1D colorTableFlow;
uniform vec2 colorTableRange;
// Uniforms needed for Particle Flow
@@ -183,13 +184,11 @@ bool CheckvertexIndex(){
//is Particle?:
bool isParticle(){
int modulusResult = int(double(particleSpeed) * time + gl_VertexID) % particleSpacing;
return modulusResult > 0 && modulusResult <= particleSize;
return false;
}
//function for showing nodes different depending on distance to earth
void DecidehowtoshowClosetoEarth(){
if(EnhanceMethod == 0){
@@ -211,6 +210,9 @@ void DecidehowtoshowClosetoEarth(){
}
//lines
if(EnhanceMethod == 3){
// Draw every other line grey
vs_color = vec4(0.18, 0.18, 0.18, 1*fluxColorAlpha);
// float interestingStreams[4] = float[](154, 156, 153, 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);
@@ -220,17 +222,23 @@ void DecidehowtoshowClosetoEarth(){
// if(!firstrender){
// vs_color = vec4(streamColor.xyz, fluxColorAlpha);
if(usingParticles && isParticle()){
vs_color = flowColor;
gl_PointSize = 1;
int modulusResult = int(double(particleSpeed) * time + gl_VertexID) % particleSpacing;
if(modulusResult >= particleSize - 10){
vs_color = vec4(1,1,1,1);
}
else{
vec4 fluxColorFlow = getTransferFunctionColor(colorTableFlow);
vs_color = vec4(fluxColorFlow.xyz, fluxColorFlow.a);
}
}
else{
vec4 fluxColor3 = getTransferFunctionColor(colorTable);
vs_color = vec4(fluxColor3.xyz, fluxColor3.a);
vec4 fluxColor3 = getTransferFunctionColor(colorTable);
vs_color = vec4(fluxColor3.xyz, fluxColor3.a);
}
}
}
// }
}
// }
}
//SizeandColor
if(EnhanceMethod == 4){
vec4 fluxColor3 = getTransferFunctionColor(colorTable);