an ok working state

This commit is contained in:
elon
2021-02-09 09:24:02 -05:00
parent 046bb644da
commit 0c005c05d1
6 changed files with 671 additions and 636 deletions

View File

@@ -28,7 +28,7 @@ local streamnodesDirectory = asset.syncedResource({
Name = "Bastille Day Stream nodes",
Type = "HttpSynchronization",
Identifier = "bastille_day_streamnodes",
Version = 4
Version = 10
})
local streamnodesBinaries = asset.syncedResource({
Name = "Bastille day Stream nodes binaries",
@@ -37,8 +37,6 @@ local streamnodesBinaries = asset.syncedResource({
Version = 1
})
local sunRadius = 6.957E8
-- Streamnodes from binaries
@@ -51,18 +49,18 @@ local Streamnodes = {
Renderable = {
Type = "RenderableStreamNodes",
SourceFolder = streamnodesDirectory,
BinarySourceFolder = streamnodesBinaries,
BinarySourceFolder = streamnodesBinaries,
-- StreamsEnabled = false,
-- LineWidth = 1.0;
-- AlphaBlendlingEnabled = false,
InputFileType = "json",
ColorTablePaths = {
streamnodeColorTable,
streamnodeColorTableCMR,
streamnodeColorTableEarth,
streamnodeColorTableFlow,
--streamnodeColorTableIlluminance,
--streamnodeColorTableIlluminance2,
streamnodeColorTable,
streamnodeColorTableCMR,
streamnodeColorTableEarth,
streamnodeColorTableFlow,
--streamnodeColorTableIlluminance,
--streamnodeColorTableIlluminance2,
},
--ColorTableMinMax = {
-- { 0, 1000000 },

File diff suppressed because it is too large Load Diff

View File

@@ -36,7 +36,6 @@
#include <modules/base/rendering/renderabletrail.h>
namespace { enum class SourceFileType; }
namespace openspace {
@@ -86,8 +85,18 @@ private:
Illuminance = 3,
};
UniformCache(streamColor, nodeSize, nodeSizeLargerFlux, thresholdFlux)
UniformCache(streamColor, nodeSize, nodeSizeLargerFlux, thresholdFlux, colorMode,
filterLower, filterUpper, scalingMode, colorTableRange, domainLimZ, nodeSkip,
nodeSkipDefault, nodeSkipEarth, nodeSkipMethod, nodeSkipFluxThreshold,
nodeSkipRadiusThreshold, fluxColorAlpha, fluxColorAlphaIlluminance, earthPos,
distanceThreshold, activeStreamNumber, enhanceMethod, flowColor, usingParticles,
usingInterestingStreams, particleSize, particleSpacing, particleSpeed)
_uniformCache;
UniformCache(time, flowColoring, maxNodeDistanceSize, usingCameraPerspective,
drawCircles, drawHollow, useGaussian, usingRadiusPerspective,
perspectiveDistanceFactor, maxNodeSize, minNodeSize, usingPulse,
usingGaussianPulse, pulsatingAlways)
_uniformCache2;
// ------------------------------------ STRINGS ------------------------------------//
// Name of the Node
@@ -111,9 +120,9 @@ private:
bool _isLoadingNewEnergyBin = false;
//can be used when loading in emin03 files for the first time.
bool shouldwritecacheforemin03 = false;
bool _shouldwritecacheforemin03 = false;
//Used for reading directly from sync-folder
bool shouldreadBinariesDirectly = true;
bool _shouldreadBinariesDirectly = true;
bool _shouldloademin03directly = true;
// --------------------------------- NUMERICALS ----------------------------------- //
@@ -124,10 +133,13 @@ private:
// Active index of _startTimes
int _activeTriggerTimeIndex = -1;
// Number of states in the sequence
size_t _nStates = 274;
uint32_t _nStates = 0;
// 383 for lower resolution, 863 for higher resolution.
//const int _numberofStreams = 383;
const int _numberofStreams = 863;
//const int _numberofStreams = 863;
const int _numberofStreams = 3;
// In setup it is used to scale JSON coordinates. During runtime it is used to scale
// domain limits.
float _scalingFactor = 1.f;
@@ -154,6 +166,7 @@ private:
// The Lua-Modfile-Dictionary used during initialization
std::unique_ptr<ghoul::Dictionary> _dictionary;
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
@@ -172,7 +185,7 @@ private:
std::vector<std::string> _colorTablePaths;
// Values represents min & max values represented in the color table
std::vector<glm::vec2> _colorTableRanges;
// Contains the _triggerTimes for all FieldlineStates in the sequence
// Contains the _triggerTimes for all streams in the sequence
std::vector<double> _startTimes;
// Contains vertexPositions
std::vector<glm::vec3> _vertexPositions;
@@ -299,21 +312,25 @@ private:
// initialization
std::vector<std::string> _sourceFiles;
std::vector<std::string> _binarySourceFiles;
// binary files sourcefolder
std::string _binarySourceFilePath;
// meta data file
std::string _metaTimeSteps;
// --------------------- FUNCTIONS USED DURING INITIALIZATION --------------------- //
bool extractMandatoryInfoFromDictionary(SourceFileType& sourceFileType);
bool extractMandatoryInfoFromDictionary();
void definePropertyCallbackFunctions();
bool extractJsonInfoFromDictionary(fls::Model& model);
std::vector<std::string> LoadJsonfile(std::string filepath);
void extractTriggerTimesFromFileNames();
void populateStartTimes();
void computeSequenceEndTime();
void setModelDependentConstants();
void setupProperties();
void writeCachedFile(const std::string& file) const;
bool readCachedFile(const std::string& file, const std::string& energybin);
void writeCachedFile() const;
//bool readCachedFile(const std::string& file, const std::string& energybin);
bool loadFilesIntoRam();
void loadNodeData();
void createStreamnumberVector();

View File

@@ -44,11 +44,13 @@ in flat double vs_time;
in float camera_IsCloseEnough;
Fragment getFragment() {
if (vs_color.a == 0) {
discard;
}
vec4 fragColor = vs_color;
if (vs_color.a == 0) {
discard;
// //fragColor = vec4(1.0,1.0,1.0,1.0);
}
vec2 pos = vec2(0.5)-vs_st;
float r = length(pos)*2.0;
@@ -59,7 +61,7 @@ Fragment getFragment() {
color = vec3( 1.-smoothstep(f,f, r) );
//fragColor = vec4(color, 1.0);
//hÄr
Fragment frag;
frag.depth = vs_depth;
frag.color = fragColor;
@@ -79,45 +81,33 @@ Fragment getFragment() {
}
// if(vs_closeToEarth > 0.5){
if(drawHollow && length(coord) < 0.4){
if(drawHollow &&
length(coord) < 0.4 &&
(vs_closeToEarth > 0.5 ||
distance(cameraPos, vec3(0)) < 500000000000.0f)){
//frag.color.xyz = streamColor.xyz;
if(vs_closeToEarth > 0.5 || distance(cameraPos, vec3(0)) < 500000000000.f){
if(usingGaussianPulse && usingCameraPerspective){
if(vs_closeToEarth > 0.5){
if(length(coord) < 0.3){
if(pulsatingAlways || camera_IsCloseEnough > 0.5){
float e = 2.718055f;
float y = 1 * pow(e, - (pow(length(coord), 2)) /( 2 * pow(0.2, 2)));
if(y < 0.05){
discard;
}
frag.color.a = y;
}
}
}
else{
if(usingGaussianPulse &&
usingCameraPerspective &&
vs_closeToEarth > 0.5){
if(length(coord) < 0.3 &&
(pulsatingAlways ||
camera_IsCloseEnough > 0.5)){
float e = 2.718055f;
float y = 1 * pow(e, -(pow(length(coord), 2)) /( 2 * pow(0.2, 2)));
if(y < 0.05){
discard;
}
frag.color.a = y;
}
else{
discard;
}
}
else{
discard;
}
}
//}
// outline
/*
if(length(coord) > 0.4){
frag.color = vec4(1, 1, 1, 1);
}
*/
/*
if(length(coord) < 0.1){
frag.color.a = 1.0;
}
*/
//float alphaV = 1 - smoothstep(0, 1, length(coord));
float e = 2.718055f;
if(useGaussian){
@@ -125,22 +115,22 @@ Fragment getFragment() {
if(y < 0.05){
discard;
}
frag.color.a = y;
frag.color.a = y;
}
//}
if(usingPulse && usingCameraPerspective){
if(vs_closeToEarth > 0.5){
if(pulsatingAlways || camera_IsCloseEnough > 0.5){
if(length(coord) > 0.46){ //0.46 (utan vec4(1, 1, 1, 1)), 0.4, 0.32
//frag.color = vec4(1,1,1,1); //HÄR
float speed = 60.f;
int modulusResult = int(double(speed) * vs_time) % 60;
if(modulusResult > 0 && modulusResult < 30){
//discard;
}
}
}
if(usingPulse &&
usingCameraPerspective &&
vs_closeToEarth > 0.5 &&
(pulsatingAlways || camera_IsCloseEnough > 0.5) &&
length(coord) > 0.46){
//0.46 (without vec4(1, 1, 1, 1)), 0.4, 0.32
//frag.color = vec4(1,1,1,1); //Here!
float speed = 60.0f;
int modulusResult = int(double(speed) * vs_time) % 60;
if(modulusResult > 0 && modulusResult < 30){
discard;
}
}

View File

@@ -156,13 +156,13 @@ const int sizeAndColor = 2;
const int illuminance = 3;
const float AUtoMeter = 149597871000.0;
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;
varying out vec4 vs_color;
varying out float vs_depth;
varying out vec2 vs_st;
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) {
@@ -299,7 +299,7 @@ void CheckdistanceMethod() {
}
if(distance(earthPos, in_position) < AUtoMeter * distanceThreshold){
if(mod(gl_VertexID, nodeSkipEarth) == 0){
DecidehowtoshowClosetoEarth();
DecidehowtoshowClosetoEarth();
}
else{
vs_color = vec4(0);
@@ -307,12 +307,12 @@ void CheckdistanceMethod() {
}
else{
if(enhanceMethod == illuminance){
vs_color.a = fluxColorAlphaIlluminance;
vs_color.a = fluxColorAlphaIlluminance;
}
if(fluxValue < thresholdFlux){
vs_color.a = fluxColorAlpha;
}
if(fluxValue < thresholdFlux){
vs_color.a = fluxColorAlpha;
}
}
}
@@ -324,64 +324,57 @@ void main() {
// Checking if we should render the vertex dependent on the vertexindex,
// by using modulus.
if(CheckvertexIndex() || distance(earthPos, in_position) < distanceThreshold * AUtoMeter){
//Filtering by radius and z-axis
if(rValue > filterLower && rValue < filterUpper){ //if(rValue > filterLower){
if(in_position.z > (domainLimZ.x * AUtoMeter) && in_position.z < (domainLimZ.y * AUtoMeter)){
// We should color it by flux
if(colorMode == 0){
//vec4 fluxColor = getTransferFunctionColor(colorTable);
vec4 fluxColor = getTransferFunctionColor(colorTableCMR);
if(fluxValue > thresholdFlux){
vs_color = vec4(fluxColor.xyz, fluxColor.a);
gl_PointSize = nodeSizeLargerFlux;
}
else{
vs_color = vec4(fluxColor.xyz, fluxColorAlpha);
gl_PointSize = nodeSize;
}
if(CheckvertexIndex() ||
distance(earthPos, in_position) < (distanceThreshold * AUtoMeter) &&
rValue/AUtoMeter > filterLower &&
rValue/AUtoMeter < filterUpper &&
in_position.z > (domainLimZ.x * AUtoMeter) &&
in_position.z < (domainLimZ.y * AUtoMeter)){
// We should color it by flux
if(colorMode == 0){
//vec4 fluxColor = getTransferFunctionColor(colorTable);
vec4 fluxColor = getTransferFunctionColor(colorTableCMR);
if(fluxValue > thresholdFlux){
vs_color = vec4(fluxColor.xyz, fluxColor.a);
gl_PointSize = nodeSizeLargerFlux;
}
//Uniform coloring
else{
vs_color = streamColor;
vs_color = vec4(fluxColor.xyz, fluxColorAlpha);
gl_PointSize = nodeSize;
}
CheckdistanceMethod();
}
else{
vs_color = vec4(0);
}
}
else{
vs_color = vec4(0);
//Uniform coloring
vs_color = streamColor;
}
CheckdistanceMethod();
}
else{
vs_color = vec4(0);
}
if(usingInterestingStreams){
// Draw every other line grey
//vs_color = vec4(0.18, 0.18, 0.18, 1*fluxColorAlpha);
// Draw every other line grey
//vs_color = vec4(0.18, 0.18, 0.18, 1*fluxColorAlpha);
vs_color = vec4(0);
vs_color = vec4(0);
// Close to Earth (384 nodes)
//float interestingStreams[8] = float[](339, 340, 351, 352, 353, 354, 366, 367);
//float interestingStreams[6] = float[](154, 156, 153, 157, 158, 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);
//float interestingStreams[3] = float[](37, 154, 210);
// Close to Earth (384 nodes)
//float interestingStreams[8] = float[](339, 340, 351, 352, 353, 354, 366, 367);
//float interestingStreams[6] = float[](154, 156, 153, 157, 158, 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);
//float interestingStreams[3] = float[](37, 154, 210);
// Close to Earth (863 nodes)
float interestingStreams[7] = float[](340, 350, 351, 352, 353, 363, 364);
//float interestingStreams[10] = float[](339, 340, 350, 351, 352, 353, 362, 363, 364, 365);
//float interestingStreams[20] = float[](326, 327, 328, 329, 338, 339, 340, 341, 350, 351, 352, 353, 362, 363, 364, 365, 374, 375, 376, 377);
// Close to Earth (863 nodes)
float interestingStreams[7] = float[](340, 350, 351, 352, 353, 363, 364);
//float interestingStreams[10] = float[](339, 340, 350, 351, 352, 353, 362, 363, 364, 365);
//float interestingStreams[20] = float[](326, 327, 328, 329, 338, 339, 340, 341, 350, 351, 352, 353, 362, 363, 364, 365, 374, 375, 376, 377);
for(int i = 0; i < interestingStreams.length(); i++){
if(Streamnumber == interestingStreams[i]){
if(CheckvertexIndex()){
if(Streamnumber == interestingStreams[i] && CheckvertexIndex()){
vec4 fluxColor3 = getTransferFunctionColor(colorTable);
vs_color = vec4(fluxColor3.xyz, 1*fluxColorAlpha);
}
}
}
}
@@ -430,12 +423,12 @@ void main() {
//vs_closeToEarth = 0;
float distScale = 1 - smoothstep(0, maxDistance, distanceVec);
//float distMinScale = 1 - smoothstep(0, nodeDistanceThreshold, distanceVec);
float factorS = 1.f;
float factorS = 1.0;
if(usingRadiusPerspective){
factorS = pow(distScale, 9) * 500.f * pow(rtemp, 2);
factorS = pow(distScale, 9) * 500.0 * pow(rtemp, 2);
}
else{
factorS = pow(distScale, 9) * 500.f;
factorS = pow(distScale, 9) * 500.0;
}
gl_PointSize = factorS * maxNodeDistanceSize * 0.8;
}