clean up, more codegen for volume renderable, moved heliosphere folder and reference frames

This commit is contained in:
ElonOlsson
2021-06-16 16:35:50 -04:00
parent f0c14910c8
commit bbd69ecf98
39 changed files with 160 additions and 560 deletions

View File

@@ -59,14 +59,14 @@ namespace {
constexpr int8_t CurrentCacheVersion = 2;
//streamColor, nodeSize, nodeSizeLargerFlux, thresholdFlux,
constexpr const std::array<const char*, 27> UniformNames = {
constexpr const std::array<const char*, 26> UniformNames = {
"streamColor", "nodeSize", "nodeSizeLargerFlux", "thresholdFlux", "colorMode",
"filterLower", "filterUpper", "scalingMode", "colorTableRange", "domainLimZ",
"nodeSkip", "nodeSkipDefault", "nodeSkipEarth", "nodeSkipMethod",
"nodeSkipFluxThreshold", "nodeSkipRadiusThreshold", "fluxColorAlpha",
"fluxColorAlphaIlluminance", "earthPos", "distanceThreshold",
"enhanceMethod", "flowColor", "usingParticles",
"usingInterestingStreams","particleSize", "particleSpacing", "particleSpeed"
"particleSize", "particleSpacing", "particleSpeed"
};
constexpr const std::array<const char*, 14> UniformNames2 = {
"time", "flowColoring", "maxNodeDistanceSize", "usingCameraPerspective",
@@ -336,9 +336,16 @@ namespace {
struct [[codegen::Dictionary(RenderableFluxNodes)]] Parameters {
// path to source folder with the 3 binary files in it
std::string binarySourceFolder;
std::string sourceFolder;
//
struct TransferFunctions {
std::string standard;
std::string flow;
std::string earth;
std::string cmr [[codegen::key("CMR")]];
};
// [[codegen::verbatim(ColorTablePathInfo.description)]]
std::optional<std::vector<std::string>> colorTablePaths;
TransferFunctions colorTablePaths;
// [[codegen::verbatim(LineWidthInfo.description)]]
//float lineWidth;
// [[codegen::verbatim(GoesEnergyBinsInfo.description)]]
@@ -435,20 +442,18 @@ RenderableFluxNodes::RenderableFluxNodes(const ghoul::Dictionary& dictionary)
const Parameters p = codegen::bake<Parameters>(dictionary);
_transferFunction =
std::make_unique<TransferFunction>(p.colorTablePaths.standard);
_transferFunctionCMR =
std::make_unique<TransferFunction>(p.colorTablePaths.cmr);
_transferFunctionEarth =
std::make_unique<TransferFunction>(p.colorTablePaths.earth);
_transferFunctionFlow =
std::make_unique<TransferFunction>(p.colorTablePaths.flow);
_pColorTablePath = p.colorTablePaths.standard;
if (p.colorTablePaths.has_value()) {
_colorTablePaths = p.colorTablePaths.value_or(_colorTablePaths);
_transferFunction = std::make_unique<TransferFunction>(_colorTablePaths[0]);
_transferFunctionCMR =
std::make_unique<TransferFunction>(absPath(_colorTablePaths[1]).string());
_transferFunctionEarth =
std::make_unique<TransferFunction>(absPath(_colorTablePaths[2]).string());
_transferFunctionFlow =
std::make_unique<TransferFunction>(absPath(_colorTablePaths[3]).string());
}
_pColorTablePath = _colorTablePaths[0];
_binarySourceFolderPath = p.binarySourceFolder;
_binarySourceFolderPath = p.sourceFolder;
if (std::filesystem::is_directory(_binarySourceFolderPath)) {
// Extract all file paths from the provided folder
_binarySourceFiles.clear();
@@ -507,7 +512,7 @@ RenderableFluxNodes::RenderableFluxNodes(const ghoul::Dictionary& dictionary)
_pGoesEnergyBins.setValue(p.energyBin.value());
}
else { // default int 1 == Emin03 == MeV>100
LWARNING("Assuming default value 1, meaning Emin03");
LINFO("Assuming default value 1, meaning Emin03");
_pGoesEnergyBins.setValue(1);
}
}
@@ -555,7 +560,6 @@ void RenderableFluxNodes::definePropertyCallbackFunctions() {
_pColorTablePath.onChange([this] {
_transferFunction->setPath(_pColorTablePath);
_colorTablePaths[0] = _pColorTablePath;
});
_pGoesEnergyBins.onChange([this] {
@@ -889,8 +893,6 @@ void RenderableFluxNodes::render(const RenderData& data, RendererTasks&) {
_shaderProgram->setUniform(_uniformCache.enhanceMethod, _pEnhancemethod);
_shaderProgram->setUniform(_uniformCache.flowColor, _pFlowColor);
_shaderProgram->setUniform(_uniformCache.usingParticles, _pFlowEnabled);
_shaderProgram->setUniform(_uniformCache.usingInterestingStreams,
_pInterestingStreamsEnabled);
_shaderProgram->setUniform(_uniformCache.particleSize, _pFlowParticleSize);
_shaderProgram->setUniform(_uniformCache.particleSpacing, _pFlowParticleSpacing);
_shaderProgram->setUniform(_uniformCache.particleSpeed, _pFlowSpeed);

View File

@@ -92,7 +92,7 @@ private:
nodeSkipDefault, nodeSkipEarth, nodeSkipMethod, nodeSkipFluxThreshold,
nodeSkipRadiusThreshold, fluxColorAlpha, fluxColorAlphaIlluminance, earthPos,
distanceThreshold, enhanceMethod, flowColor, usingParticles,
usingInterestingStreams, particleSize, particleSpacing, particleSpeed)
particleSize, particleSpacing, particleSpeed)
_uniformCache;
UniformCache(time, flowColoring, maxNodeDistanceSize, usingCameraPerspective,
drawCircles, drawHollow, useGaussian, usingRadiusPerspective,
@@ -138,8 +138,6 @@ private:
std::unique_ptr<TransferFunction> _transferFunctionFlow;
// ------------------------------------ VECTORS ----------------------------------- //
// Paths to color tables. One for each 'ColorFlux'
std::vector<std::string> _colorTablePaths;
// Contains the _triggerTimes for all streams in the sequence
std::vector<double> _startTimes;
// Contains vertexPositions

View File

@@ -75,17 +75,10 @@ uniform float distanceThreshold;
uniform int enhanceMethod;
uniform double time;
//uniform float interestingStreams[4];
// Speicific uniforms for cameraperspective
//uniform float scaleFactor;
//uniform float minNodeDistanceSize;
uniform float maxNodeDistanceSize;
uniform float nodeDistanceThreshold;
//uniform mat4 cameraViewProjectionMatrix;
//uniform dmat4 modelMatrix;
uniform vec3 cameraPos;
//uniform vec2 screenSize;
uniform bool usingCameraPerspective;
@@ -95,21 +88,18 @@ uniform float perspectiveDistanceFactor;
uniform float maxNodeSize;
uniform float minNodeSize;
uniform bool usingPulse;
// Inputs
// Should be provided in meters
// Should be provided in meters VaPosition
layout(location = 0) in vec3 in_position;
// The extra value used to color lines. Location must correspond to _VA_COLOR in
// renderablefieldlinessequence.h
// The extra value used to color lines. Location must correspond to VaColor in
// renderablefluxnodes.h
layout(location = 1) in float fluxValue;
// The extra value used to mask out parts of lines. Location must correspond to
// _VA_MASKING in renderablefieldlinessequence.h
layout(location = 2)
in float rValue;
//layout(location = 5)
//in vec2 arrow;
// VaFiltering in renderablefluxnodes.h
layout(location = 2) in float rValue;
// These should correspond to the enum 'ColorMode' in renderablefluxnodes.cpp
const int colorByFluxValue = 0;
@@ -138,7 +128,6 @@ varying out float camera_IsCloseEnough;
varying out float vs_closeToEarth;
varying out double vs_time;
varying out vec3 vs_camerapos;
//out vec4 vs_gPosition;
vec4 getTransferFunctionColor(sampler1D InColorTable) {
// Remap the color scalar to a [0,1] range
@@ -203,8 +192,7 @@ return false;
//function for showing nodes different depending on distance to earth
void DecidehowtoshowClosetoEarth(){
// SizeScaling
if(enhanceMethod == sizeScaling){
// vec4 fluxColor = getTransferFunctionColor(colorTable);
if(enhanceMethod == sizeScaling || enhanceMethod == illuminance){
vec4 fluxColor = getTransferFunctionColor(colorTableCMR);
vs_color = vec4(fluxColor.xyz, fluxColor.a);
}
@@ -224,11 +212,6 @@ void DecidehowtoshowClosetoEarth(){
}
gl_PointSize = tempR2 * tempR2 * tempR2 * gl_PointSize * 5;
}
// Illuminance
if(enhanceMethod == illuminance){
vec4 fluxColor1 = getTransferFunctionColor(colorTableCMR);
vs_color = vec4(fluxColor1.xyz, fluxColor1.a);
}
}
void CheckdistanceMethod() {
@@ -238,15 +221,13 @@ void CheckdistanceMethod() {
vs_closeToEarth = 0;
//if(distancevec < maxdist){
if(distancevec < AUtoMeter * distanceThreshold && usingPulse){
vs_closeToEarth = 1;
gl_PointSize = gl_PointSize * 5;
vec4 fluxColor = getTransferFunctionColor(colorTable);
vs_color = vec4(fluxColor.xyz, fluxColorAlpha);
//vs_color = vec4(streamColor.xyz, fluxColorAlpha); // HÄR
}
//}
if(distancevec < AUtoMeter * distanceThreshold && usingPulse){
vs_closeToEarth = 1;
gl_PointSize = gl_PointSize * 5;
vec4 fluxColor = getTransferFunctionColor(colorTable);
vs_color = vec4(fluxColor.xyz, fluxColorAlpha);
}
if(enhanceMethod == colorTables || enhanceMethod == sizeAndColor){
vec4 fluxColor2 = getTransferFunctionColor(colorTableEarth);
vs_color = vec4(fluxColor2.xyz, fluxColorAlpha);
@@ -381,5 +362,5 @@ void main() {
gl_Position = vec4(positionClipSpace.xy, 0, positionClipSpace.w);
vs_depth = gl_Position.w;
}

View File

@@ -50,11 +50,6 @@
namespace {
constexpr const char* _loggerCat = "RenderableTimeVaryingVolume";
const char* KeyStepSize = "StepSize";
const char* KeyGridType = "GridType";
const char* KeyOpacity = "Opacity";
const char* KeyTransferFunction = "TransferFunction";
const float SecondsInOneDay = 60 * 60 * 24;
constexpr const float VolumeMaxOpacity = 500;
@@ -151,6 +146,9 @@ namespace {
std::optional<float> opacity;
std::optional<double> stepSize;
std::optional<std::string> gridType;
std::optional<ghoul::Dictionary> clipPlanes;
};
@@ -197,13 +195,10 @@ RenderableTimeVaryingVolume::RenderableTimeVaryingVolume(
});
_gridType = static_cast<int>(volume::VolumeGridType::Cartesian);
if (dictionary.hasValue<double>(KeyStepSize)) {
_stepSize = static_cast<float>(dictionary.value<double>(KeyStepSize));
}
_stepSize = p.stepSize.value_or(_stepSize);
if (dictionary.hasValue<double>(KeyOpacity)) {
_opacity = static_cast<float>(dictionary.value<double>(KeyOpacity)
* VolumeMaxOpacity);
if (p.opacity.has_value()) {
_opacity = *p.opacity * VolumeMaxOpacity;
}
_secondsBefore = p.secondsBefore.value_or(_secondsBefore);
@@ -214,10 +209,8 @@ RenderableTimeVaryingVolume::RenderableTimeVaryingVolume(
_clipPlanes->setIdentifier("clipPlanes");
_clipPlanes->setGuiName("Clip Planes");
if (dictionary.hasValue<std::string>(KeyGridType)) {
VolumeGridType gridType = volume::parseGridType(
dictionary.value<std::string>(KeyGridType)
);
if (p.gridType.has_value()) {
VolumeGridType gridType = volume::parseGridType(*p.gridType);
_gridType = static_cast<std::underlying_type_t<VolumeGridType>>(gridType);
}