Clean up and multiple transferfunction
@@ -1,20 +0,0 @@
|
||||
{"Run":"Yihua_Zheng_011116_1",
|
||||
"Model":"SWMF",
|
||||
"Discipline":"magnetosphere",
|
||||
"Central Body":"Earth",
|
||||
"Spatial Scale (Custom)":"R_E",
|
||||
"Spatial Scale (SI)":"6371000 m",
|
||||
"Coordinates":"GSM",
|
||||
"Coordinate Type":"Cartesian",
|
||||
"Plot Variable":"N",
|
||||
"Plot Variable Unit (Custom)":"amu/cm^3",
|
||||
"Plot Variable Unit (SI)":"1.0e+06 amu/m^3",
|
||||
"Plot XMIN":0.0,
|
||||
"Plot XMAX":0.0,
|
||||
"Plot YMIN":-48.0,
|
||||
"Plot YMAX":48.0,
|
||||
"Plot ZMIN":-48.0,
|
||||
"Plot ZMAX":48.0,
|
||||
"Plot Scaling":"logarithmic (base: 10)",
|
||||
"ISWA_UPDATE_SECONDS":240
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{"Run":"Yihua_Zheng_011116_1",
|
||||
"Model":"SWMF",
|
||||
"Discipline":"magnetosphere",
|
||||
"Central Body":"Earth",
|
||||
"Spatial Scale (Custom)":"R_E",
|
||||
"Spatial Scale (SI)":"6371000 m",
|
||||
"Coordinates":"GSM",
|
||||
"Coordinate Type":"Cartesian",
|
||||
"Plot Variable":"N",
|
||||
"Plot Variable Unit (Custom)":"amu/cm^3",
|
||||
"Plot Variable Unit (SI)":"1.0e+06 amu/m^3",
|
||||
"Plot XMIN":-224.0,
|
||||
"Plot XMAX":32.0,
|
||||
"Plot YMIN":0.0,
|
||||
"Plot YMAX":0.0,
|
||||
"Plot ZMIN":-48.0,
|
||||
"Plot ZMAX":48.0,
|
||||
"Plot Scaling":"logarithmic (base: 10)",
|
||||
"ISWA_UPDATE_SECONDS":240
|
||||
}
|
||||
|
Before Width: | Height: | Size: 12 KiB |
@@ -1,20 +0,0 @@
|
||||
{"Run":"Yihua_Zheng_011116_1",
|
||||
"Model":"SWMF",
|
||||
"Discipline":"magnetosphere",
|
||||
"Central Body":"Earth",
|
||||
"Spatial Scale (Custom)":"R_E",
|
||||
"Spatial Scale (SI)":"6371000 m",
|
||||
"Coordinates":"GSM",
|
||||
"Coordinate Type":"Cartesian",
|
||||
"Plot Variable":"N",
|
||||
"Plot Variable Unit (Custom)":"amu/cm^3",
|
||||
"Plot Variable Unit (SI)":"1.0e+06 amu/m^3",
|
||||
"Plot XMIN":-224.0,
|
||||
"Plot XMAX":32.0,
|
||||
"Plot YMIN":-48.0,
|
||||
"Plot YMAX":48.0,
|
||||
"Plot ZMIN":0.0,
|
||||
"Plot ZMAX":0.0,
|
||||
"Plot Scaling":"logarithmic (base: 10)",
|
||||
"ISWA_UPDATE_SECONDS":240
|
||||
}
|
||||
|
Before Width: | Height: | Size: 846 B |
@@ -13,9 +13,9 @@ return {
|
||||
Body = "Sun",
|
||||
Observer = "Earth",
|
||||
Kernels = {
|
||||
"${SPICE}/heliospheric.tf",
|
||||
"${SPICE}/GSE.ti",
|
||||
"${SPICE}/GSM.ti",
|
||||
"${SPICE}/iSWAKernels/heliospheric.tf",
|
||||
"${SPICE}/iSWAKernels/GSE.ti",
|
||||
"${SPICE}/iSWAKernels/GSM.ti",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 726 B After Width: | Height: | Size: 726 B |
|
Before Width: | Height: | Size: 953 B After Width: | Height: | Size: 953 B |
|
Before Width: | Height: | Size: 799 B After Width: | Height: | Size: 799 B |
|
Before Width: | Height: | Size: 772 B After Width: | Height: | Size: 772 B |
BIN
data/test.png
|
Before Width: | Height: | Size: 566 KiB |
@@ -82,10 +82,7 @@ DataPlane::DataPlane(const ghoul::Dictionary& dictionary)
|
||||
});
|
||||
|
||||
_useRGB.onChange([this](){
|
||||
if( _useRGB.value() && (_dataOptions.value().size() > 3)){
|
||||
LWARNING("More than 3 values, using only the red channel.");
|
||||
}
|
||||
loadTexture();
|
||||
changeTransferFunctions(_useRGB.value());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -110,13 +107,8 @@ bool DataPlane::initialize(){
|
||||
|
||||
updateTexture();
|
||||
|
||||
std::string tfPath = "${OPENSPACE_DATA}/colormap_parula.jpg";
|
||||
// std::string tfPath = "${OPENSPACE_DATA}/red.jpg";
|
||||
std::string tfPath = "${OPENSPACE_DATA}/scene/iswa/transferfunctions/colormap_parula.jpg";
|
||||
_transferFunctions.push_back(std::make_shared<TransferFunction>(tfPath));
|
||||
// tfPath = "${OPENSPACE_DATA}/blue.jpg";
|
||||
// _transferFunctions.push_back(std::make_shared<TransferFunction>(tfPath));
|
||||
// tfPath = "${OPENSPACE_DATA}/green.jpg";
|
||||
// _transferFunctions.push_back(std::make_shared<TransferFunction>(tfPath));
|
||||
|
||||
// std::cout << "Creating Colorbar" << std::endl;
|
||||
// _colorbar = std::make_shared<ColorBar>();
|
||||
@@ -149,18 +141,13 @@ bool DataPlane::loadTexture() {
|
||||
return false;
|
||||
|
||||
bool texturesReady = false;
|
||||
// std::cout << _textures.size() << std::endl;
|
||||
for(int i=0; i<_textures.size(); i++){
|
||||
float* values = data[i];
|
||||
std::vector<int> selectedOptions = _dataOptions.value();
|
||||
|
||||
if(!values){
|
||||
_textures[i] = nullptr;
|
||||
continue;
|
||||
}
|
||||
for(int option: selectedOptions){
|
||||
float* values = data[option];
|
||||
if(!values) continue;
|
||||
|
||||
// return false;
|
||||
|
||||
if (!_textures[i]) {
|
||||
if(!_textures[option]){
|
||||
std::unique_ptr<ghoul::opengl::Texture> texture = std::make_unique<ghoul::opengl::Texture>(
|
||||
values,
|
||||
_dimensions,
|
||||
@@ -174,14 +161,15 @@ bool DataPlane::loadTexture() {
|
||||
if(texture){
|
||||
texture->uploadTexture();
|
||||
texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
|
||||
_textures[i] = std::move(texture);
|
||||
_textures[option] = std::move(texture);
|
||||
}
|
||||
}else{
|
||||
_textures[i]->setPixelData(values);
|
||||
_textures[i]->uploadTexture();
|
||||
_textures[option]->setPixelData(values);
|
||||
_textures[option]->uploadTexture();
|
||||
}
|
||||
texturesReady = true;
|
||||
}
|
||||
|
||||
return texturesReady;
|
||||
}
|
||||
|
||||
@@ -205,48 +193,55 @@ void DataPlane::setUniforms(){
|
||||
// _shader->setUniform("textures", 1, units[1]);
|
||||
// _shader->setUniform("textures", 2, units[2]);
|
||||
// }
|
||||
int activeTextures = 0;
|
||||
for(int i=0; i<_textures.size(); i++){
|
||||
if(_textures[i]) activeTextures++;
|
||||
}
|
||||
std::vector<int> selectedOptions = _dataOptions.value();
|
||||
int activeTextures = selectedOptions.size();
|
||||
|
||||
int activeTransferfunctions = 0;
|
||||
for(auto tf: _transferFunctions){
|
||||
if(tf) activeTransferfunctions++;
|
||||
int activeTransferfunctions = _transferFunctions.size();
|
||||
|
||||
ghoul::opengl::TextureUnit txUnits[activeTextures];
|
||||
int j = 0;
|
||||
for(int option : selectedOptions){
|
||||
if(_textures[option]){
|
||||
txUnits[j].activate();
|
||||
_textures[option]->bind();
|
||||
_shader->setUniform(
|
||||
"textures[" + std::to_string(j) + "]",
|
||||
txUnits[j]
|
||||
);
|
||||
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
ghoul::opengl::TextureUnit tfUnits[activeTransferfunctions];
|
||||
int j = 0;
|
||||
for(int i=0; i<_transferFunctions.size(); i++){
|
||||
if(_transferFunctions[i]){
|
||||
tfUnits[j].activate();
|
||||
_transferFunctions[i]->bind();
|
||||
_shader->setUniform(
|
||||
j = 0;
|
||||
|
||||
if((activeTransferfunctions == 1) && (_textures.size() != _transferFunctions.size())) {
|
||||
tfUnits[0].activate();
|
||||
_transferFunctions[0]->bind();
|
||||
_shader->setUniform(
|
||||
"transferFunctions[0]",
|
||||
tfUnits[0]
|
||||
);
|
||||
}else{
|
||||
for(int option : selectedOptions){
|
||||
std::cout << option << std::endl;
|
||||
if(_transferFunctions[option]){
|
||||
tfUnits[j].activate();
|
||||
_transferFunctions[option]->bind();
|
||||
_shader->setUniform(
|
||||
"transferFunctions[" + std::to_string(j) + "]",
|
||||
tfUnits[j]
|
||||
);
|
||||
);
|
||||
|
||||
j++;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ghoul::opengl::TextureUnit texUnits[activeTextures];
|
||||
j = 0;
|
||||
for(int i=0; i<_textures.size(); i++){
|
||||
if(_textures[i]){
|
||||
texUnits[j].activate();
|
||||
_textures[i]->bind();
|
||||
_shader->setUniform(
|
||||
"textures[" + std::to_string(j) + "]",
|
||||
texUnits[j]
|
||||
);
|
||||
|
||||
j++;
|
||||
}
|
||||
}
|
||||
_shader->setUniform("numTextures", activeTextures);
|
||||
_shader->setUniform("numTransferFunctions", activeTransferfunctions);
|
||||
_shader->setUniform("averageValues", _averageValues.value());
|
||||
_shader->setUniform("backgroundValues", _backgroundValues.value());
|
||||
};
|
||||
|
||||
@@ -473,4 +468,20 @@ float DataPlane::normalizeWithLogarithm(float value, int logMean){
|
||||
float logNormalized = ((value/pow(10,logMean)+logMin))/(logMin+logMax);
|
||||
return glm::clamp(logNormalized,0.0f, 1.0f);
|
||||
}
|
||||
|
||||
void DataPlane::changeTransferFunctions(bool multiple){
|
||||
_transferFunctions.clear();
|
||||
std::string tfPath;
|
||||
if(multiple){
|
||||
tfPath = "${OPENSPACE_DATA}/scene/iswa/transferfunctions/red.jpg";
|
||||
_transferFunctions.push_back(std::make_shared<TransferFunction>(tfPath));
|
||||
tfPath = "${OPENSPACE_DATA}/scene/iswa/transferfunctions/blue.jpg";
|
||||
_transferFunctions.push_back(std::make_shared<TransferFunction>(tfPath));
|
||||
tfPath = "${OPENSPACE_DATA}/scene/iswa/transferfunctions/green.jpg";
|
||||
_transferFunctions.push_back(std::make_shared<TransferFunction>(tfPath));
|
||||
}else{
|
||||
tfPath = "${OPENSPACE_DATA}/scene/iswa/transferfunctions/colormap_parula.jpg";
|
||||
_transferFunctions.push_back(std::make_shared<TransferFunction>(tfPath));
|
||||
}
|
||||
}
|
||||
}// namespace openspace
|
||||
@@ -64,6 +64,8 @@ class DataPlane : public CygnetPlane {
|
||||
float normalizeWithStandardScore(float value, float mean, float sd);
|
||||
float normalizeWithLogarithm(float value, int logMean);
|
||||
|
||||
void changeTransferFunctions(bool multiple);
|
||||
|
||||
properties::SelectionProperty _dataOptions;
|
||||
properties::Vec2Property _normValues;
|
||||
properties::Vec2Property _backgroundValues;
|
||||
|
||||
@@ -47,24 +47,27 @@ Fragment getFragment() {
|
||||
float depth = pscDepth(position);
|
||||
vec4 transparent = vec4(0.0f);
|
||||
vec4 diffuse = transparent;
|
||||
float v;
|
||||
float v = 0;
|
||||
|
||||
for(int i=0; i<numTextures; i++){
|
||||
int j = i;
|
||||
if(numTextures > numTransferFunctions){
|
||||
j = 0;
|
||||
if(numTextures > numTransferFunctions){
|
||||
for(int i=0; i<numTextures; i++){
|
||||
v += texture(textures[i], vec2(vs_st.s, 1-vs_st.t)).r;
|
||||
}
|
||||
// if(numTextures > 1){
|
||||
// for(uint i=0; i<numTextures; i++){
|
||||
v = texture(textures[i], vec2(vs_st.s, 1-vs_st.t)).r;
|
||||
|
||||
v /= numTextures;
|
||||
|
||||
vec4 color = texture(transferFunctions[0], vec2(v,0));
|
||||
float x = backgroundValues.x;
|
||||
float y = backgroundValues.y;
|
||||
|
||||
vec4 color = texture(transferFunctions[j], vec2(v,0));
|
||||
if((v<(x+y)) && v>(x-y))
|
||||
color = mix(transparent, color, abs(v-x));
|
||||
diffuse += color;
|
||||
|
||||
diffuse = color;
|
||||
}else{
|
||||
for(int i=0; i<numTextures; i++){
|
||||
v = texture(textures[i], vec2(vs_st.s, 1-vs_st.t)).r;
|
||||
vec4 color = texture(transferFunctions[i], vec2(v,0));
|
||||
diffuse += color;
|
||||
}
|
||||
}
|
||||
// diffuse += texture(textures[1], vec2(vs_st.s, 1-vs_st.t));
|
||||
// diffuse += texture(textures[2], vec2(vs_st.s, 1-vs_st.t));
|
||||
@@ -75,9 +78,9 @@ Fragment getFragment() {
|
||||
// diffuse = texture(tf, vec2(v,0));
|
||||
// }
|
||||
|
||||
if(averageValues){
|
||||
diffuse /= numTextures;
|
||||
}
|
||||
// if(averageValues){
|
||||
// diffuse /= numTextures;
|
||||
// }
|
||||
|
||||
// diffuse = texture(tf, vec2(1-vs_st.s, 0));
|
||||
// diffuse = texture(tf, texture(texture1, vec2(vs_st.s,1-vs_st.t)).r);
|
||||
|
||||