Added functions for illuminance filtering (enhance method) + color tables for illuminance

This commit is contained in:
Emilie
2020-09-10 19:58:32 +02:00
parent 4de2034750
commit b0928405eb
8 changed files with 111 additions and 5 deletions

View File

@@ -18,8 +18,11 @@ openspace.setPropertyValueSingle("Modules.Space.ShowExceptions", false)
local transferFunctions = asset.localResource("transferfunctions")
local streamnodeColorTable = transferFunctions .. "/stream_nodes.txt"
local streamnodeColorTableCMR = transferFunctions .. "/CMR.txt"
local streamnodeColorTableEarth = transferFunctions .. "/stream_nodes_grey_scale.txt"
local streamnodeColorTableFlow = transferFunctions .. "/stream_nodes_flow.txt"
local streamnodeColorTableIlluminance = transferFunctions .. "/CMR_illuminance.txt"
local streamnodeColorTableIlluminance2 = transferFunctions .. "/CMR_illuminance2.txt"
local streamnodesDirectory = asset.syncedResource({
Name = "Bastille Day Stream nodes",
@@ -55,8 +58,11 @@ local Streamnodes = {
InputFileType = "json",
ColorTablePaths = {
streamnodeColorTable,
streamnodeColorTableCMR,
streamnodeColorTableEarth,
streamnodeColorTableFlow,
streamnodeColorTableIlluminance,
streamnodeColorTableIlluminance2,
},
--ColorTableMinMax = {
-- { 0, 1000000 },

View File

@@ -0,0 +1,15 @@
width 10
lower 0.0
upper 1.0
mappingkey 0.0 1 1 4 255
mappingkey 0.083 30 30 100 255
mappingkey 0.166 60 38 164 255
mappingkey 0.332 106 43 167 255
mappingkey 0.415 173 54 110 255
mappingkey 0.498 253 64 40 255
mappingkey 0.664 234 117 6 255
mappingkey 0.830 230 169 16 255
mappingkey 0.915 236 236 159 255
mappingkey 1.0 251 251 235 255

View File

@@ -0,0 +1,15 @@
width 10
lower 0.0
upper 1.0
mappingkey 0.0 17 17 56 255
mappingkey 0.083 47 38 142 255
mappingkey 0.166 80 39 189 255
mappingkey 0.332 139 49 139 255
mappingkey 0.415 221 60 68 255
mappingkey 0.498 243 95 20 255
mappingkey 0.664 230 147 8 255
mappingkey 0.830 230 195 34 255
mappingkey 0.915 230 226 118 255
mappingkey 1.0 255 255 255 255

View File

@@ -0,0 +1,15 @@
width 10
lower 0.0
upper 1.0
mappingkey 0.0 60 38 164 255
mappingkey 0.083 106 43 167 255
mappingkey 0.166 173 54 110 255
mappingkey 0.332 253 64 40 255
mappingkey 0.415 234 117 6 255
mappingkey 0.498 230 169 16 255
mappingkey 0.664 236 236 159 255
mappingkey 0.830 251 251 235 255
mappingkey 0.915 255 255 255 255
mappingkey 1.0 255 255 255 255

View File

@@ -9,7 +9,7 @@ mappingkey 0.166 55 90 246 255
mappingkey 0.332 23 152 242 255
mappingkey 0.415 13 194 224 255
mappingkey 0.498 138 254 174 255
mappingkey 0.664 227 197 105 255
mappingkey 0.664 227 197 105 255
mappingkey 0.830 255 128 66 255
mappingkey 0.915 251 79 37 255
mappingkey 1.0 255 0 0 255

View File

@@ -182,6 +182,11 @@ namespace {
"Flux Color Alpha",
"The value of alpha for the flux color mode."
};
/*constexpr openspace::properties::Property::PropertyInfo FluxColorAlphaIlluminanceInfo = {
"fluxColorAlphaIlluminance",
"Flux Color Alpha for illuminance",
"The value of alpha for the flux color mode."
};*/
constexpr openspace::properties::Property::PropertyInfo FluxNodeskipThresholdInfo = {
"skippingNodesByFlux",
"Skipping Nodes By Flux",
@@ -405,6 +410,7 @@ RenderableStreamNodes::RenderableStreamNodes(const ghoul::Dictionary& dictionary
, _pColorTableRange(colorTableRangeInfo)
, _pDomainZ(DomainZInfo)
, _pFluxColorAlpha(FluxColorAlphaInfo, 1.f, 0.f, 1.f)
//, _pFluxColorAlphaIlluminance(FluxColorAlphaIlluminanceInfo, 1.f, 0.f, 1.f)
, _pThresholdFlux(ThresholdFluxInfo, 0.f, -50.f, 10.f)
, _pFilteringLower(FilteringInfo, 0.f, 0.f, 5.f)
, _pFilteringUpper(FilteringUpperInfo, 5.f, 0.f, 5.f)
@@ -537,8 +543,11 @@ void RenderableStreamNodes::initializeGL() {
// corrupt or not provided!
_colorTablePaths.push_back(FieldlinesSequenceModule::DefaultTransferFunctionFile);
_transferFunction = std::make_unique<TransferFunction>(absPath(_colorTablePaths[0]));
_transferFunctionEarth = std::make_unique<TransferFunction>(absPath(_colorTablePaths[1]));
_transferFunctionFlow = std::make_unique<TransferFunction>(absPath(_colorTablePaths[2]));
_transferFunctionCMR = std::make_unique<TransferFunction>(absPath(_colorTablePaths[1]));
_transferFunctionEarth = std::make_unique<TransferFunction>(absPath(_colorTablePaths[2]));
_transferFunctionFlow = std::make_unique<TransferFunction>(absPath(_colorTablePaths[3]));
_transferFunctionIlluminance = std::make_unique<TransferFunction>(absPath(_colorTablePaths[4]));
_transferFunctionIlluminance2 = std::make_unique<TransferFunction>(absPath(_colorTablePaths[5]));
// EXTRACT OPTIONAL INFORMATION FROM DICTIONARY
std::string outputFolderPath;
@@ -1138,6 +1147,7 @@ void RenderableStreamNodes::setupProperties() {
_pColorGroup.addProperty(_pColorTablePath);
_pColorGroup.addProperty(_pStreamColor);
_pColorGroup.addProperty(_pFluxColorAlpha);
//_pColorGroup.addProperty(_pFluxColorAlphaIlluminance);
_pStreamGroup.addProperty(_pThresholdFlux);
_pStreamGroup.addProperty(_pFilteringLower);
@@ -1189,6 +1199,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::Sizeandcolor), "Sizescaling and colortables");
_pEnhancemethod.addOption(static_cast<int>(EnhanceMethod::Illuminance), "Illuminance");
_pCameraPerspectiveGroup.addProperty(_pCameraPerspectiveEnabled);
_pCameraPerspectiveGroup.addProperty(_pPerspectiveDistanceFactor);
@@ -1333,6 +1344,7 @@ void RenderableStreamNodes::render(const RenderData& data, RendererTasks&) {
_shaderProgram->setUniform("nodeSkipFluxThreshold", _pFluxNodeskipThreshold);
_shaderProgram->setUniform("nodeSkipRadiusThreshold", _pRadiusNodeSkipThreshold);
_shaderProgram->setUniform("fluxColorAlpha", _pFluxColorAlpha);
//_shaderProgram->setUniform("fluxColorAlphaIlluminance", _pFluxColorAlphaIlluminance);
_shaderProgram->setUniform("earthPos", earthPos);
_shaderProgram->setUniform("distanceThreshold", _pDistanceThreshold);
_shaderProgram->setUniform("activeStreamNumber", _pActiveStreamNumber);
@@ -1447,6 +1459,11 @@ void RenderableStreamNodes::render(const RenderData& data, RendererTasks&) {
_transferFunction->bind(); // Calls update internally
_shaderProgram->setUniform("colorTable", textureUnit);
ghoul::opengl::TextureUnit textureUnitCMR;
textureUnitCMR.activate();
_transferFunctionCMR->bind(); // Calls update internally
_shaderProgram->setUniform("colorTableCMR", textureUnitCMR);
ghoul::opengl::TextureUnit textureUnitEarth;
textureUnitEarth.activate();
_transferFunctionEarth->bind(); // Calls update internally
@@ -1456,6 +1473,16 @@ void RenderableStreamNodes::render(const RenderData& data, RendererTasks&) {
textureUnitFlow.activate();
_transferFunctionFlow->bind(); // Calls update internally
_shaderProgram->setUniform("colorTableFlow", textureUnitFlow);
ghoul::opengl::TextureUnit textureUnitIlluminance;
textureUnitIlluminance.activate();
_transferFunctionIlluminance->bind(); // Calls update internally
_shaderProgram->setUniform("colorTableIlluminance", textureUnitIlluminance);
ghoul::opengl::TextureUnit textureUnitIlluminance2;
textureUnitIlluminance2.activate();
_transferFunctionIlluminance2->bind(); // Calls update internally
_shaderProgram->setUniform("colorTableIlluminance2", textureUnitIlluminance2);
}
const std::vector<glm::vec3>& vertPos = _vertexPositions;

View File

@@ -83,6 +83,7 @@ private:
Sizescaling = 0,
Colortables = 1,
Sizeandcolor = 2,
Illuminance = 3,
};
UniformCache(streamColor, nodeSize, nodeSizeLargerFlux, thresholdFlux)
@@ -154,10 +155,16 @@ private:
std::unique_ptr<ghoul::opengl::ProgramObject> _shaderProgram;
// Transfer function used to color lines when _pColorMethod is set to BY_FLUX_VALUE
std::unique_ptr<TransferFunction> _transferFunction;
// Transfer function used to color with the CMR map
std::unique_ptr<TransferFunction> _transferFunctionCMR;
// 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;
// Transfer function used to color illuminance for nodes close to the Earth
std::unique_ptr<TransferFunction> _transferFunctionIlluminance;
// Transfer function used to color illuminance for nodes close to the Earth2
std::unique_ptr<TransferFunction> _transferFunctionIlluminance2;
// ------------------------------------ VECTORS ----------------------------------- //
// Paths to color tables. One for each 'ColorFlux'
@@ -203,6 +210,8 @@ private:
properties::Vec2Property _pColorTableRange;
// The value of alpha for the flux color mode
properties::FloatProperty _pFluxColorAlpha;
// The value of alpha for the flux illuminance color mode
//properties::FloatProperty _pFluxColorAlphaIlluminance;
// Group to hold the particle properties
properties::PropertyOwner _pStreamGroup;
// Scaling options

View File

@@ -32,8 +32,11 @@ uniform mat4 modelViewProjection;
// Uniforms needed to color by quantity
uniform int colorMode;
uniform sampler1D colorTable;
uniform sampler1D colorTableCMR;
uniform sampler1D colorTableEarth;
uniform sampler1D colorTableFlow;
uniform sampler1D colorTableIlluminance;
uniform sampler1D colorTableIlluminance2;
uniform vec2 colorTableRange;
// Uniforms needed for Particle Flow
@@ -69,6 +72,7 @@ uniform int nodeSkipDefault;
uniform float nodeSkipFluxThreshold;
uniform float nodeSkipRadiusThreshold;
uniform float fluxColorAlpha;
//uniform float fluxColorAlphaIlluminance;
uniform vec3 earthPos;
uniform float distanceThreshold;
uniform int activeStreamNumber;
@@ -77,7 +81,6 @@ uniform int enhanceMethod;
uniform double time;
uniform bool usingInterestingStreams;
//uniform float interestingStreams[4];
// Speicific uniforms for cameraperspective
@@ -149,6 +152,7 @@ const int lnRFlux = 4;
const int sizeScaling = 0;
const int colorTables = 1;
const int sizeAndColor = 2;
const int illuminance = 3;
out vec4 vs_color;
out float vs_depth;
@@ -246,7 +250,7 @@ void DecidehowtoshowClosetoEarth(){
vec4 fluxColor = getTransferFunctionColor(colorTable);
vs_color = vec4(fluxColor.xyz, fluxColor.a);
}
//SizeColor
// SizeColor
if(enhanceMethod == sizeAndColor){
vec4 fluxColor3 = getTransferFunctionColor(colorTable);
vs_color = vec4(fluxColor3.xyz, fluxColor3.a);
@@ -257,6 +261,12 @@ void DecidehowtoshowClosetoEarth(){
}
gl_PointSize = tempR2 * tempR2 * tempR2 * gl_PointSize * 5;
}
// Illuminance
if(enhanceMethod == illuminance){
//vec4 fluxColor1 = getTransferFunctionColor(colorTableIlluminance);
vec4 fluxColor1 = getTransferFunctionColor(colorTableCMR);
vs_color = vec4(fluxColor1.xyz, fluxColor1.a);
}
}
void CheckdistanceMethod() {
@@ -279,10 +289,19 @@ void CheckdistanceMethod() {
vec4 fluxColor2 = getTransferFunctionColor(colorTableEarth);
vs_color = vec4(fluxColor2.xyz, fluxColorAlpha);
//vs_color = vec4(0.3, 0.3, 0.3, fluxColorAlpha);
}
if(enhanceMethod == illuminance){
vec4 fluxColor = getTransferFunctionColor(colorTableCMR);
vs_color = vec4(fluxColor.xyz, fluxColorAlpha);
}
if(distance(earthPos, in_position) < distanceThreshold){
DecidehowtoshowClosetoEarth();
}
/*else{
if(enhanceMethod == illuminance){
vs_color.a = fluxColorAlphaIlluminance;
}
}*/
}
void main() {