mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-02 08:49:20 -05:00
Functionality for higher resolution data and node manipulation
This commit is contained in:
@@ -142,7 +142,7 @@ namespace openspace {
|
||||
glm::vec4(1.f))
|
||||
, _pPointSize(PointSizeInfo, 2.f, 0, 20)
|
||||
, _pTimeStep(TimeStepInfo, 1, 1, 30)
|
||||
, _pDistanceFactor(DistanceFactorInfo, 5, 1, 20)
|
||||
, _pDistanceFactor(DistanceFactorInfo, 20, 1, 30)
|
||||
, _pShowLabel(LabelInfo, false)
|
||||
, _pShouldFollowLight(FollowLightInfo, false)
|
||||
, _pFadeDistance(FadeDistanceInfo, 10.f, 9.f, 20.f)
|
||||
|
||||
@@ -304,6 +304,26 @@ namespace {
|
||||
"Distance factor",
|
||||
"This value decides how far away the camera must be to start impacting the nodesize"
|
||||
};
|
||||
constexpr openspace::properties::Property::PropertyInfo MinNodeSizeInfo = {
|
||||
"minNodeSize",
|
||||
"Minimum node size",
|
||||
"the minimum node size."
|
||||
};
|
||||
constexpr openspace::properties::Property::PropertyInfo MaxNodeSizeInfo = {
|
||||
"maxNodeSize",
|
||||
"Maximum node size",
|
||||
"the minimum node size."
|
||||
};
|
||||
constexpr openspace::properties::Property::PropertyInfo AlwaysBlinkInfo = {
|
||||
"alwaysBlinking",
|
||||
"Blinking regardless of camera position",
|
||||
"Always have nodes close to earth blinking regardless of position."
|
||||
};
|
||||
constexpr openspace::properties::Property::PropertyInfo UseBlinkInfo = {
|
||||
"blinking",
|
||||
"Nodes close to Earth blinks",
|
||||
"Boolean for blinking."
|
||||
};
|
||||
enum class SourceFileType : int {
|
||||
Json = 0,
|
||||
Invalid
|
||||
@@ -385,7 +405,7 @@ RenderableStreamNodes::RenderableStreamNodes(const ghoul::Dictionary& dictionary
|
||||
, _pRadiusNodeSkipThreshold(RadiusNodeSkipThresholdInfo, 0.f, 0.f, 5.f)
|
||||
, _pEarthdistGroup({ "Earthfocus" })
|
||||
, _pDistanceThreshold(DistanceThresholdInfo, 0.0f, 0.0f, 700000000000.0f)
|
||||
, _pActiveStreamNumber(ActiveStreamNumberInfo, 0, 0, 383)
|
||||
, _pActiveStreamNumber(ActiveStreamNumberInfo, 0, 0, _numberofStreams)
|
||||
, _pMisalignedIndex(MisalignedIndexInfo, 0, -5, 20)
|
||||
, _pFlowColor(
|
||||
FlowColorInfo,
|
||||
@@ -410,6 +430,10 @@ RenderableStreamNodes::RenderableStreamNodes(const ghoul::Dictionary& dictionary
|
||||
, _pGaussianAlphaFilter(GaussiandAlphaFilterInfo, false)
|
||||
, _pRadiusPerspective(RadiusPerspectiveInfo, true)
|
||||
, _pPerspectiveDistanceFactor(perspectiveDistanceFactorInfo, 6.f, 1.f, 20.f)
|
||||
, _pMaxNodeSize(MaxNodeSizeInfo, 30.f, 1.f, 200.f)
|
||||
, _pMinNodeSize(MinNodeSizeInfo, 1.f, 1.f, 10.f)
|
||||
, _pUseBlinking(UseBlinkInfo, true)
|
||||
, _pBlinkAlways(AlwaysBlinkInfo, false)
|
||||
|
||||
{
|
||||
_dictionary = std::make_unique<ghoul::Dictionary>(dictionary);
|
||||
@@ -522,12 +546,13 @@ void RenderableStreamNodes::initializeGL() {
|
||||
extractTriggerTimesFromFileNames();
|
||||
computeSequenceEndTime();
|
||||
|
||||
createStreamnumberVector();
|
||||
// Either we load in the data dynamically or statically at the start.
|
||||
// If we should load in everything to Ram this if statement is true.
|
||||
if (!_loadingStatesDynamically) {
|
||||
loadNodeData();
|
||||
}
|
||||
|
||||
|
||||
//float distanceThreshold = 65525112832.f;
|
||||
//float distanceThreshold = 33561643008.f;
|
||||
//ExtractandwriteInterestingStreams(distanceThreshold);
|
||||
@@ -561,15 +586,15 @@ void RenderableStreamNodes::initializeGL() {
|
||||
}
|
||||
|
||||
void RenderableStreamNodes::loadNodeData() {
|
||||
createStreamnumberVector();
|
||||
|
||||
|
||||
if (shouldreadBinariesDirectly) {
|
||||
bool success = loadBinaryfilesDirectly("");
|
||||
if(success) return;
|
||||
}
|
||||
std::string _file = "StreamnodesCachePosition";
|
||||
std::string _file2 = "StreamnodesCacheColor";
|
||||
std::string _file3 = "StreamnodesCacheRadius";
|
||||
std::string _file = "StreamnodesCachePositionv3";
|
||||
std::string _file2 = "StreamnodesCacheColorv3";
|
||||
std::string _file3 = "StreamnodesCacheRadiusv3";
|
||||
if (shouldwritecacheforemin03) {
|
||||
_file = "StreamnodesCachePosition_emin03";
|
||||
_file2 = "StreamnodesCacheColor_emin03";
|
||||
@@ -615,14 +640,14 @@ void RenderableStreamNodes::loadNodeData() {
|
||||
// If thats the case we want to load in the files from json format
|
||||
// and then write new cached files.
|
||||
loadFilesIntoRam();
|
||||
writeCachedFile("StreamnodesCachePosition");
|
||||
writeCachedFile("StreamnodesCachePositionv3");
|
||||
}
|
||||
}
|
||||
else {
|
||||
// We could not find the cachedfiles, parse the data statically
|
||||
// instead and write it to binary format.
|
||||
loadFilesIntoRam();
|
||||
writeCachedFile("StreamnodesCachePosition");
|
||||
writeCachedFile("StreamnodesCachePositionv3");
|
||||
}
|
||||
|
||||
|
||||
@@ -630,9 +655,9 @@ void RenderableStreamNodes::loadNodeData() {
|
||||
void RenderableStreamNodes::createStreamnumberVector() {
|
||||
int nPoints = 1999;
|
||||
int lineStartIdx = 0;
|
||||
int numberofStreams = 383;
|
||||
for (int i = 0; i < 383; ++i) {
|
||||
for (int k = 0; k < 1999; ++k) {
|
||||
|
||||
for (int i = 0; i < _numberofStreams; ++i) {
|
||||
for (int k = 0; k < nPoints; ++k) {
|
||||
|
||||
_vertexStreamnumber.push_back(i);
|
||||
//lineStartIdx++;
|
||||
@@ -666,7 +691,8 @@ bool RenderableStreamNodes::loadFilesIntoRam() {
|
||||
std::string testtime = jsonobj["time"];
|
||||
|
||||
size_t lineStartIdx = 0;
|
||||
const int numberofStreams = 383;
|
||||
//const int _numberofStreams = 383;
|
||||
// const int _numberofStreams = 863;
|
||||
constexpr const float AuToMeter = 149597870700.f; // Astronomical Units
|
||||
|
||||
// Clear all the vectors in order to not have old states information in them
|
||||
@@ -681,7 +707,7 @@ bool RenderableStreamNodes::loadFilesIntoRam() {
|
||||
const size_t nPoints = 1;
|
||||
|
||||
// Loop through all the streams
|
||||
for (int i = 0; i < numberofStreams; ++i) {
|
||||
for (int i = 0; i < _numberofStreams; ++i) {
|
||||
|
||||
|
||||
// Make an iterator at stream number i, then loop through that stream
|
||||
@@ -736,9 +762,9 @@ bool RenderableStreamNodes::loadFilesIntoRam() {
|
||||
|
||||
void RenderableStreamNodes::writeCachedFile(const std::string& file) const {
|
||||
// Todo, write all of the vertexobjects into here
|
||||
std::string _file = "StreamnodesCachePosition";
|
||||
std::string _file2 = "StreamnodesCacheColor";
|
||||
std::string _file3 = "StreamnodesCacheRadius";
|
||||
std::string _file = "StreamnodesCachePositionv3";
|
||||
std::string _file2 = "StreamnodesCacheColorv3";
|
||||
std::string _file3 = "StreamnodesCacheRadiusv3";
|
||||
|
||||
|
||||
if(shouldwritecacheforemin03){
|
||||
@@ -884,9 +910,9 @@ bool RenderableStreamNodes::readCachedFile(const std::string& file, const std::s
|
||||
bool RenderableStreamNodes::loadBinaryfilesDirectly(const std::string& energybin) {
|
||||
|
||||
LDEBUG("Loading in binary files directly from sync folder");
|
||||
std::string _file = _binarySourceFilePath + "\\StreamnodesCachePosition" + energybin;
|
||||
std::string _file2 = _binarySourceFilePath + "\\StreamnodesCacheColor" + energybin;
|
||||
std::string _file3 = _binarySourceFilePath + "\\StreamnodesCacheRadius" + energybin;
|
||||
std::string _file = _binarySourceFilePath + "\\StreamnodesCachePositionv3" + energybin;
|
||||
std::string _file2 = _binarySourceFilePath + "\\StreamnodesCacheColorv3" + energybin;
|
||||
std::string _file3 = _binarySourceFilePath + "\\StreamnodesCacheRadiusv3" + energybin;
|
||||
std::string cachedFile = FileSys.cacheManager()->cachedFilename(
|
||||
_file,
|
||||
ghoul::filesystem::CacheManager::Persistent::Yes
|
||||
@@ -1164,7 +1190,10 @@ void RenderableStreamNodes::setupProperties() {
|
||||
_pCameraPerspectiveGroup.addProperty(_pDrawingHollow);
|
||||
_pCameraPerspectiveGroup.addProperty(_pGaussianAlphaFilter);
|
||||
_pCameraPerspectiveGroup.addProperty(_pRadiusPerspective);
|
||||
|
||||
_pCameraPerspectiveGroup.addProperty(_pMaxNodeSize);
|
||||
_pCameraPerspectiveGroup.addProperty(_pMinNodeSize);
|
||||
_pCameraPerspectiveGroup.addProperty(_pUseBlinking);
|
||||
_pCameraPerspectiveGroup.addProperty(_pBlinkAlways);
|
||||
|
||||
definePropertyCallbackFunctions();
|
||||
// Set default
|
||||
@@ -1321,7 +1350,10 @@ void RenderableStreamNodes::render(const RenderData& data, RendererTasks&) {
|
||||
_shaderProgram->setUniform("useGaussian", _pGaussianAlphaFilter);
|
||||
_shaderProgram->setUniform("usingRadiusPerspective", _pRadiusPerspective);
|
||||
_shaderProgram->setUniform("PerspectiveDistanceFactor", _pPerspectiveDistanceFactor);
|
||||
|
||||
_shaderProgram->setUniform("maxNodeSize", _pMaxNodeSize);
|
||||
_shaderProgram->setUniform("minNodeSize", _pMinNodeSize);
|
||||
_shaderProgram->setUniform("UseBlinking", _pUseBlinking);
|
||||
_shaderProgram->setUniform("blinkingAlways", _pBlinkAlways);
|
||||
//////// test for camera perspective:
|
||||
/*
|
||||
glm::dmat4 modelMatrix =
|
||||
@@ -1592,6 +1624,7 @@ void RenderableStreamNodes::update(const UpdateData& data) {
|
||||
updatePositionBuffer();
|
||||
updateVertexColorBuffer();
|
||||
updateVertexFilteringBuffer();
|
||||
updateVertexStreamNumberBuffer();
|
||||
//updateArrow();
|
||||
}
|
||||
}
|
||||
@@ -1627,7 +1660,8 @@ std::vector<std::string> RenderableStreamNodes::LoadJsonfile(std::string filepat
|
||||
size_t lineStartIdx = 0;
|
||||
|
||||
//Loop through all the nodes
|
||||
const int numberofStreams = 383;
|
||||
// const int numberofStreams = 383;
|
||||
//const int numberofStreams = 863;
|
||||
constexpr const float AuToMeter = 149597870700.f;
|
||||
_vertexPositions.clear();
|
||||
_lineCount.clear();
|
||||
@@ -1637,7 +1671,7 @@ std::vector<std::string> RenderableStreamNodes::LoadJsonfile(std::string filepat
|
||||
int counter = 0;
|
||||
|
||||
const size_t nPoints = 1;
|
||||
for (int i = 0; i < numberofStreams; ++i) {
|
||||
for (int i = 0; i < _numberofStreams; ++i) {
|
||||
|
||||
for (json::iterator lineIter = jsonobj["stream" + std::to_string(i)].begin();
|
||||
lineIter != jsonobj["stream" + std::to_string(i)].end(); ++lineIter) {
|
||||
|
||||
@@ -132,6 +132,7 @@ private:
|
||||
int _activeTriggerTimeIndex = -1;
|
||||
// Number of states in the sequence
|
||||
size_t _nStates = 274;
|
||||
const int _numberofStreams = 863;
|
||||
// In setup it is used to scale JSON coordinates. During runtime it is used to scale
|
||||
// domain limits.
|
||||
float _scalingFactor = 1.f;
|
||||
@@ -153,6 +154,7 @@ private:
|
||||
// OpenGL Vertex Buffer Object containing the stream number for every node.
|
||||
//GLuint _arrow = 0;
|
||||
|
||||
|
||||
// ----------------------------------- POINTERS ------------------------------------//
|
||||
// The Lua-Modfile-Dictionary used during initialization
|
||||
std::unique_ptr<ghoul::Dictionary> _dictionary;
|
||||
@@ -229,6 +231,8 @@ private:
|
||||
// Threshold for where to interpolate between the max and min node distance
|
||||
properties::FloatProperty _pNodeDistanceThreshold;
|
||||
|
||||
properties::FloatProperty _pMaxNodeSize;
|
||||
properties::FloatProperty _pMinNodeSize;
|
||||
/// Line width for the line rendering part
|
||||
properties::FloatProperty _pLineWidth;
|
||||
// Valid range along the Z-axis
|
||||
@@ -282,6 +286,8 @@ private:
|
||||
properties::BoolProperty _pGaussianAlphaFilter;
|
||||
properties::BoolProperty _pRadiusPerspective;
|
||||
properties::FloatProperty _pPerspectiveDistanceFactor;
|
||||
properties::BoolProperty _pUseBlinking;
|
||||
properties::BoolProperty _pBlinkAlways;
|
||||
|
||||
// initialization
|
||||
std::vector<std::string> _sourceFiles;
|
||||
|
||||
@@ -28,9 +28,14 @@ uniform sampler2D texture1;
|
||||
uniform bool drawCircles;
|
||||
uniform bool drawHollow;
|
||||
uniform bool useGaussian;
|
||||
uniform bool blinkingAlways;
|
||||
uniform bool UseBlinking;
|
||||
in vec2 vs_st;
|
||||
in vec4 vs_color;
|
||||
in float vs_depth;
|
||||
in float vs_closeToEarth;
|
||||
in flat double vs_time;
|
||||
in float camera_IsCloseEnough;
|
||||
|
||||
Fragment getFragment() {
|
||||
if (vs_color.a == 0) {
|
||||
@@ -43,17 +48,22 @@ Fragment getFragment() {
|
||||
frag.depth = vs_depth;
|
||||
frag.color = fragColor;
|
||||
vec2 coord = gl_PointCoord - vec2(0.5);
|
||||
|
||||
|
||||
if(camera_IsCloseEnough > 0.5){
|
||||
if(drawCircles){
|
||||
|
||||
if(length(coord) > 0.5){
|
||||
discard;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// if(vs_closeToEarth > 0.5){
|
||||
if(drawHollow && length(coord) < 0.4){
|
||||
discard;
|
||||
}
|
||||
|
||||
//}
|
||||
// outline
|
||||
/*
|
||||
if(length(coord) > 0.4){
|
||||
@@ -66,16 +76,47 @@ Fragment getFragment() {
|
||||
}
|
||||
*/
|
||||
//float alphaV = 1 - smoothstep(0, 1, length(coord));
|
||||
if(useGaussian){
|
||||
float e = 2.718055f;
|
||||
|
||||
|
||||
if(useGaussian){
|
||||
float y = 1 * pow(e, - (pow(length(coord), 2)) /( 2 * pow(0.2, 2)));
|
||||
if(y < 0.05){
|
||||
discard;
|
||||
}
|
||||
frag.color.a = y;
|
||||
}
|
||||
|
||||
}
|
||||
if(UseBlinking){
|
||||
if(vs_closeToEarth > 0.5){
|
||||
if(blinkingAlways || camera_IsCloseEnough > 0.5){
|
||||
if(length(coord) > 0.46){
|
||||
float speed = 40.f;
|
||||
int modulusResult = int(double(speed) * vs_time) % 60;
|
||||
if(modulusResult > 0 && modulusResult < 20){
|
||||
|
||||
//frag.color = vec4(1, 1, 1,1);
|
||||
discard;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//homecooked solution to get similar to normal distribution
|
||||
/*
|
||||
float alphaV = sqrt(pow(1 - length(coord), 3));
|
||||
alphaV = pow(alphaV, 3);
|
||||
if(alphaV < 0.1){
|
||||
discard;
|
||||
}
|
||||
frag.color.a = alphaV;
|
||||
*/
|
||||
|
||||
|
||||
//else{
|
||||
//frag.color.a = alphaV;
|
||||
}
|
||||
//}
|
||||
|
||||
//vec2 coord = gl_PointCoord;
|
||||
|
||||
|
||||
@@ -99,7 +99,8 @@ uniform vec3 cameraPos;
|
||||
uniform bool usingCameraPerspective;
|
||||
uniform bool usingRadiusPerspective;
|
||||
uniform float PerspectiveDistanceFactor;
|
||||
|
||||
uniform float maxNodeSize;
|
||||
uniform float minNodeSize;
|
||||
// Inputs
|
||||
// Should be provided in meters
|
||||
layout(location = 0) in vec3 in_position;
|
||||
@@ -146,6 +147,10 @@ const int lnRFlux = 4;
|
||||
out vec4 vs_color;
|
||||
out float vs_depth;
|
||||
out vec2 vs_st;
|
||||
out float camera_IsCloseEnough;
|
||||
out float vs_closeToEarth;
|
||||
out double vs_time;
|
||||
out vec3 vs_camerapos;
|
||||
//out vec4 vs_gPosition;
|
||||
|
||||
vec4 getTransferFunctionColor(sampler1D InColorTable) {
|
||||
@@ -179,6 +184,8 @@ bool CheckvertexIndex(){
|
||||
int nodeIndex = gl_VertexID;
|
||||
// nodeIndex = gl_VertexIndex;
|
||||
//if(enhanceMethod == 3) return false;
|
||||
|
||||
|
||||
if(nodeSkipMethod == uniformskip){
|
||||
if(mod(nodeIndex, nodeSkip) == 0){
|
||||
return true;
|
||||
@@ -263,10 +270,10 @@ void DecidehowtoshowClosetoEarth(){
|
||||
// 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);
|
||||
//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[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;
|
||||
@@ -318,12 +325,24 @@ void DecidehowtoshowClosetoEarth(){
|
||||
|
||||
void CheckdistanceMethod() {
|
||||
//Enhance by distance to Earth
|
||||
float maxdist = 10000000000.f * PerspectiveDistanceFactor;
|
||||
float distancevec = distance(earthPos, in_position.xyz);
|
||||
vs_closeToEarth = 0;
|
||||
if(distancevec < maxdist){
|
||||
|
||||
if(distancevec < maxdist / 2){
|
||||
vs_closeToEarth = 1;
|
||||
//gl_PointSize = 20;
|
||||
}
|
||||
}
|
||||
if(enhanceMethod == 1 || enhanceMethod == 4){
|
||||
vec4 fluxColor2 = getTransferFunctionColor(colorTableEarth);
|
||||
vs_color = vec4(fluxColor2.xyz, fluxColor2.a);
|
||||
//vs_color = vec4(0.3, 0.3, 0.3, 1.0);
|
||||
}
|
||||
if(distanceMethod == 0){
|
||||
if(distance(earthPos, in_position) < distanceThreshold){
|
||||
|
||||
DecidehowtoshowClosetoEarth();
|
||||
}
|
||||
}
|
||||
@@ -394,19 +413,27 @@ void main() {
|
||||
else{
|
||||
rtemp = rValue;
|
||||
}
|
||||
|
||||
|
||||
float maxdist = 100000000000.f * PerspectiveDistanceFactor;
|
||||
//maxdist = 600000000000.f;
|
||||
float distancevec = distance(cameraPos, in_position.xyz);
|
||||
|
||||
if(distancevec > maxdist && vs_closeToEarth < 0.5){
|
||||
camera_IsCloseEnough = 0;
|
||||
}
|
||||
else{
|
||||
camera_IsCloseEnough = 1;
|
||||
}
|
||||
if(distancevec < maxdist){
|
||||
vs_closeToEarth = 0;
|
||||
float distScale = 1 - smoothstep(0, maxdist, distancevec);
|
||||
//float distMinScale = 1 - smoothstep(0, nodeDistanceThreshold, distancevec);
|
||||
float factorS = 1.f;
|
||||
if(usingRadiusPerspective){
|
||||
factorS = pow(distScale, 9) * 100.f * pow(rtemp, 2);
|
||||
factorS = pow(distScale, 9) * 500.f * pow(rtemp, 2);
|
||||
}
|
||||
else{
|
||||
factorS = pow(distScale, 9) * 100.f;
|
||||
factorS = pow(distScale, 9) * 500.f;
|
||||
}
|
||||
gl_PointSize = factorS * maxNodeDistanceSize * 0.8;
|
||||
}
|
||||
@@ -414,20 +441,28 @@ void main() {
|
||||
// gl_PointSize = nodeSize;
|
||||
// }
|
||||
|
||||
if(gl_PointSize > 40){
|
||||
gl_PointSize = 40;
|
||||
|
||||
if(gl_PointSize > maxNodeSize){
|
||||
gl_PointSize = maxNodeSize;
|
||||
}
|
||||
if(gl_PointSize < 1.f){
|
||||
gl_PointSize = 1.f;
|
||||
|
||||
if(gl_PointSize < minNodeSize){
|
||||
gl_PointSize = minNodeSize;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
vs_time = time;
|
||||
vec4 position_in_meters = vec4(in_position, 1);
|
||||
vec4 positionClipSpace = modelViewProjection * position_in_meters;
|
||||
//vs_gPosition = vec4(modelViewTransform * dvec4(in_point_position, 1));
|
||||
|
||||
gl_Position = vec4(positionClipSpace.xy, 0, positionClipSpace.w);
|
||||
vs_depth = gl_Position.w;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user