sove merge conflict
@@ -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",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BIN
data/scene/iswa/transferfunctions/blue.jpg
Normal file
|
After Width: | Height: | Size: 726 B |
|
Before Width: | Height: | Size: 953 B After Width: | Height: | Size: 953 B |
BIN
data/scene/iswa/transferfunctions/green.jpg
Normal file
|
After Width: | Height: | Size: 799 B |
BIN
data/scene/iswa/transferfunctions/red.jpg
Normal file
|
After Width: | Height: | Size: 772 B |
BIN
data/test.png
|
Before Width: | Height: | Size: 566 KiB |
@@ -29,7 +29,6 @@ CygnetPlane::CygnetPlane(const ghoul::Dictionary& dictionary)
|
||||
,_quad(0)
|
||||
,_vertexPositionBuffer(0)
|
||||
,_futureObject(nullptr)
|
||||
// ,_backgroundValue(0.0f)
|
||||
{}
|
||||
|
||||
CygnetPlane::~CygnetPlane(){}
|
||||
@@ -42,8 +41,7 @@ bool CygnetPlane::isReady() const{
|
||||
}
|
||||
|
||||
void CygnetPlane::render(const RenderData& data){
|
||||
|
||||
if(!_texture) return;
|
||||
if(!textureReady()) return;
|
||||
|
||||
psc position = data.position;
|
||||
glm::mat4 transform = glm::mat4(1.0);
|
||||
@@ -89,22 +87,13 @@ void CygnetPlane::render(const RenderData& data){
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
|
||||
_shader->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
_shader->setUniform("ModelTransform", transform);
|
||||
|
||||
setPscUniforms(*_shader.get(), data.camera, position);
|
||||
|
||||
ghoul::opengl::TextureUnit tfUnit;
|
||||
if(_transferFunction){
|
||||
tfUnit.activate();
|
||||
_transferFunction->bind();
|
||||
_shader->setUniform("tf", tfUnit);
|
||||
}
|
||||
|
||||
ghoul::opengl::TextureUnit unit;
|
||||
unit.activate();
|
||||
_texture->bind();
|
||||
_shader->setUniform("texture1", unit);
|
||||
setUniforms();
|
||||
|
||||
glBindVertexArray(_quad);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
@@ -133,8 +122,12 @@ void CygnetPlane::update(const UpdateData& data){
|
||||
_futureObject = nullptr;
|
||||
}
|
||||
|
||||
if(_transferFunction)
|
||||
_transferFunction->update();
|
||||
if(!_transferFunctions.empty() && _transferFunctions[0])
|
||||
_transferFunctions[0]->update();
|
||||
}
|
||||
|
||||
bool CygnetPlane::textureReady(){
|
||||
return ((!_textures.empty()) && (_textures[0] != nullptr));
|
||||
}
|
||||
|
||||
void CygnetPlane::createPlane(){
|
||||
|
||||
@@ -42,6 +42,8 @@ public:
|
||||
protected:
|
||||
virtual bool loadTexture() = 0;
|
||||
virtual bool updateTexture() = 0;
|
||||
virtual void setUniforms() = 0;
|
||||
virtual bool textureReady();
|
||||
|
||||
void createPlane();
|
||||
void destroyPlane();
|
||||
|
||||
@@ -42,9 +42,11 @@ DataPlane::DataPlane(const ghoul::Dictionary& dictionary)
|
||||
:CygnetPlane(dictionary)
|
||||
,_dataOptions("dataOptions", "Data Options")
|
||||
,_normValues("normValues", "Normalize Values", glm::vec2(1.0,1.0), glm::vec2(0), glm::vec2(5.0))
|
||||
,_backgroundValues("backgroundValues", "Background Values", glm::vec2(0.0), glm::vec2(0), glm::vec2(1.0))
|
||||
,_useLog("useLog","Use Logarithm", false)
|
||||
,_useHistogram("_useHistogram", "Use Histogram", true)
|
||||
,_useRGB("useRGB","Use RGB Channels", false)
|
||||
,_useMultipleTf("_useMultipleTf","Use Multiple transferfunctions", false)
|
||||
// ,_averageValues("averageValues", "Average values", false)
|
||||
// ,_colorbar(nullptr)
|
||||
{
|
||||
std::string name;
|
||||
@@ -53,16 +55,20 @@ DataPlane::DataPlane(const ghoul::Dictionary& dictionary)
|
||||
|
||||
addProperty(_useLog);
|
||||
addProperty(_useHistogram);
|
||||
addProperty(_useRGB);
|
||||
addProperty(_useMultipleTf);
|
||||
addProperty(_normValues);
|
||||
addProperty(_backgroundValues);
|
||||
// addProperty(_averageValues);
|
||||
addProperty(_dataOptions);
|
||||
|
||||
registerProperties();
|
||||
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_useLog);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_useHistogram);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_useRGB);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_useMultipleTf);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_normValues);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_backgroundValues);
|
||||
// OsEng.gui()._iSWAproperty.registerProperty(&_averageValues);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_dataOptions);
|
||||
|
||||
_normValues.onChange([this](){
|
||||
@@ -72,18 +78,10 @@ DataPlane::DataPlane(const ghoul::Dictionary& dictionary)
|
||||
loadTexture();});
|
||||
_useLog.onChange([this](){loadTexture();});
|
||||
_useHistogram.onChange([this](){loadTexture();});
|
||||
_dataOptions.onChange([this](){
|
||||
if( _useRGB.value() && (_dataOptions.value().size() > 3)){
|
||||
LWARNING("More than 3 values, using only the red channel.");
|
||||
}
|
||||
loadTexture();
|
||||
});
|
||||
_dataOptions.onChange([this](){loadTexture();});
|
||||
|
||||
_useRGB.onChange([this](){
|
||||
if( _useRGB.value() && (_dataOptions.value().size() > 3)){
|
||||
LWARNING("More than 3 values, using only the red channel.");
|
||||
}
|
||||
loadTexture();
|
||||
_useMultipleTf.onChange([this](){
|
||||
changeTransferFunctions(_useMultipleTf.value());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -98,7 +96,7 @@ bool DataPlane::initialize(){
|
||||
if (_shader == nullptr) {
|
||||
// DatePlane Program
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
_shader = renderEngine.buildRenderProgram("PlaneProgram",
|
||||
_shader = renderEngine.buildRenderProgram("DataPlaneProgram",
|
||||
"${MODULE_ISWA}/shaders/dataplane_vs.glsl",
|
||||
"${MODULE_ISWA}/shaders/dataplane_fs.glsl"
|
||||
);
|
||||
@@ -108,8 +106,8 @@ bool DataPlane::initialize(){
|
||||
|
||||
updateTexture();
|
||||
|
||||
std::string tfPath = "${OPENSPACE_DATA}/colormap_parula.jpg";
|
||||
_transferFunction = std::make_shared<TransferFunction>(tfPath);
|
||||
std::string tfPath = "${OPENSPACE_DATA}/scene/iswa/transferfunctions/colormap_parula.jpg";
|
||||
_transferFunctions.push_back(std::make_shared<TransferFunction>(tfPath));
|
||||
|
||||
// std::cout << "Creating Colorbar" << std::endl;
|
||||
// _colorbar = std::make_shared<ColorBar>();
|
||||
@@ -117,6 +115,8 @@ bool DataPlane::initialize(){
|
||||
// _colorbar->initialize();
|
||||
// }
|
||||
|
||||
// _textures.push_back(nullptr);
|
||||
|
||||
return isReady();
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ bool DataPlane::deinitialize(){
|
||||
destroyPlane();
|
||||
destroyShader();
|
||||
|
||||
_texture = nullptr;
|
||||
_textures[0] = nullptr;
|
||||
_memorybuffer = "";
|
||||
|
||||
// _colorbar->deinitialize();
|
||||
@@ -135,32 +135,42 @@ bool DataPlane::deinitialize(){
|
||||
}
|
||||
|
||||
bool DataPlane::loadTexture() {
|
||||
|
||||
float* values = readData();
|
||||
if(!values)
|
||||
return false;
|
||||
|
||||
if (!_texture) {
|
||||
std::unique_ptr<ghoul::opengl::Texture> texture = std::make_unique<ghoul::opengl::Texture>(
|
||||
values,
|
||||
_dimensions,
|
||||
ghoul::opengl::Texture::Format::RGB,
|
||||
GL_RGB,
|
||||
GL_FLOAT,
|
||||
ghoul::opengl::Texture::FilterMode::Linear,
|
||||
ghoul::opengl::Texture::WrappingMode::ClampToEdge
|
||||
);
|
||||
|
||||
if(texture){
|
||||
texture->uploadTexture();
|
||||
texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
|
||||
_texture = std::move(texture);
|
||||
std::vector<float*> data = readData();
|
||||
if(data.empty())
|
||||
return false;
|
||||
|
||||
bool texturesReady = false;
|
||||
std::vector<int> selectedOptions = _dataOptions.value();
|
||||
|
||||
for(int option: selectedOptions){
|
||||
float* values = data[option];
|
||||
if(!values) continue;
|
||||
|
||||
if(!_textures[option]){
|
||||
std::unique_ptr<ghoul::opengl::Texture> texture = std::make_unique<ghoul::opengl::Texture>(
|
||||
values,
|
||||
_dimensions,
|
||||
ghoul::opengl::Texture::Format::Red,
|
||||
GL_RED,
|
||||
GL_FLOAT,
|
||||
ghoul::opengl::Texture::FilterMode::Linear,
|
||||
ghoul::opengl::Texture::WrappingMode::ClampToEdge
|
||||
);
|
||||
|
||||
if(texture){
|
||||
texture->uploadTexture();
|
||||
texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
|
||||
_textures[option] = std::move(texture);
|
||||
}
|
||||
}else{
|
||||
_textures[option]->setPixelData(values);
|
||||
_textures[option]->uploadTexture();
|
||||
}
|
||||
}else{
|
||||
_texture->setPixelData(values);
|
||||
_texture->uploadTexture();
|
||||
texturesReady = true;
|
||||
}
|
||||
return true;
|
||||
|
||||
return texturesReady;
|
||||
}
|
||||
|
||||
bool DataPlane::updateTexture(){
|
||||
@@ -178,6 +188,66 @@ bool DataPlane::updateTexture(){
|
||||
return false;
|
||||
}
|
||||
|
||||
void DataPlane::setUniforms(){
|
||||
|
||||
// _shader->setUniform("textures", 1, units[1]);
|
||||
// _shader->setUniform("textures", 2, units[2]);
|
||||
// }
|
||||
std::vector<int> selectedOptions = _dataOptions.value();
|
||||
int activeTextures = selectedOptions.size();
|
||||
|
||||
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];
|
||||
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){
|
||||
if(_transferFunctions[option]){
|
||||
tfUnits[j].activate();
|
||||
_transferFunctions[option]->bind();
|
||||
_shader->setUniform(
|
||||
"transferFunctions[" + std::to_string(j) + "]",
|
||||
tfUnits[j]
|
||||
);
|
||||
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_shader->setUniform("numTextures", activeTextures);
|
||||
_shader->setUniform("numTransferFunctions", activeTransferfunctions);
|
||||
_shader->setUniform("backgroundValues", _backgroundValues.value());
|
||||
};
|
||||
|
||||
bool DataPlane::textureReady(){
|
||||
return (!_textures.empty());
|
||||
}
|
||||
|
||||
void DataPlane::readHeader(){
|
||||
if(!_memorybuffer.empty()){
|
||||
std::stringstream memorystream(_memorybuffer);
|
||||
@@ -209,6 +279,7 @@ void DataPlane::readHeader(){
|
||||
if(option != "x" && option != "y" && option != "z"){
|
||||
_dataOptions.addOption({numOptions, name()+"_"+option});
|
||||
numOptions++;
|
||||
_textures.push_back(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,7 +295,7 @@ void DataPlane::readHeader(){
|
||||
}
|
||||
}
|
||||
|
||||
float* DataPlane::readData(){
|
||||
std::vector<float*> DataPlane::readData(){
|
||||
if(!_memorybuffer.empty()){
|
||||
if(!_dataOptions.options().size()) // load options for value selection
|
||||
readHeader();
|
||||
@@ -233,6 +304,7 @@ float* DataPlane::readData(){
|
||||
std::string line;
|
||||
|
||||
std::vector<int> selectedOptions = _dataOptions.value();
|
||||
|
||||
int numSelected = selectedOptions.size();
|
||||
|
||||
std::vector<float> min(numSelected, std::numeric_limits<float>::max());
|
||||
@@ -240,9 +312,12 @@ float* DataPlane::readData(){
|
||||
|
||||
std::vector<float> sum(numSelected, 0.0f);
|
||||
std::vector<std::vector<float>> optionValues(numSelected, std::vector<float>());
|
||||
|
||||
float* data = new float[3*_dimensions.x*_dimensions.y]{0.0f};
|
||||
|
||||
std::vector<float*> data(_dataOptions.options().size(), nullptr);
|
||||
for(int option : selectedOptions){
|
||||
data[option] = new float[_dimensions.x*_dimensions.y]{0.0f};
|
||||
}
|
||||
|
||||
int numValues = 0;
|
||||
while(getline(memorystream, line)){
|
||||
if(line.find("#") == 0){ //part of the header
|
||||
@@ -281,7 +356,7 @@ float* DataPlane::readData(){
|
||||
|
||||
if(numValues != _dimensions.x*_dimensions.y){
|
||||
LWARNING("Number of values read and expected are not the same");
|
||||
return nullptr;
|
||||
return std::vector<float*>();
|
||||
}
|
||||
|
||||
// // FOR TESTING
|
||||
@@ -291,11 +366,7 @@ float* DataPlane::readData(){
|
||||
// // ===========
|
||||
|
||||
for(int i=0; i<numSelected; i++){
|
||||
if(_useRGB.value() && numSelected <= 3){
|
||||
processData(data, i, optionValues[i], min[i], max[i], sum[i], numSelected);
|
||||
} else {
|
||||
processData(data, i, optionValues[i], min[i], max[i], sum[i], 1);
|
||||
}
|
||||
processData(data, selectedOptions[i], optionValues[i], min[i], max[i], sum[i]);
|
||||
}
|
||||
|
||||
// // FOR TESTING
|
||||
@@ -311,16 +382,17 @@ float* DataPlane::readData(){
|
||||
|
||||
return data;
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
LWARNING("Nothing in memory buffer, are you connected to the information super highway?");
|
||||
return nullptr;
|
||||
return std::vector<float*>();
|
||||
}
|
||||
}
|
||||
|
||||
void DataPlane::processData(float* outputData, int inputChannel, std::vector<float> inputData, float min, float max,float sum, int numOutputChannels){
|
||||
|
||||
|
||||
|
||||
void DataPlane::processData(std::vector<float*> outputData, int inputChannel, std::vector<float> inputData, float min, float max,float sum){
|
||||
|
||||
float* output = outputData[inputChannel];
|
||||
// HISTOGRAM
|
||||
// number of levels/bins/values
|
||||
const int levels = 512;
|
||||
@@ -411,19 +483,9 @@ void DataPlane::processData(float* outputData, int inputChannel, std::vector<flo
|
||||
standardDeviation = newLevels[(int) standardDeviation];
|
||||
}
|
||||
|
||||
// Normalize values
|
||||
// if(_useLog.value()){
|
||||
// v = normalizeWithLogarithm(v, logmean);
|
||||
// }else{
|
||||
v = normalizeWithStandardScore(v, mean, standardDeviation);
|
||||
// }
|
||||
|
||||
if(numOutputChannels == 1 && inputChannel > 0){
|
||||
// take the average.
|
||||
outputData[3*i+0] = ( outputData[3*i+0] * inputChannel + v ) / (inputChannel+1);
|
||||
} else {
|
||||
outputData[3*i+inputChannel] += v;
|
||||
}
|
||||
v = normalizeWithStandardScore(v, mean, standardDeviation);
|
||||
output[i] += v;
|
||||
|
||||
}
|
||||
|
||||
// FOR TESTING
|
||||
@@ -453,4 +515,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
|
||||
@@ -46,31 +46,33 @@ class DataPlane : public CygnetPlane {
|
||||
private:
|
||||
virtual bool loadTexture() override;
|
||||
virtual bool updateTexture() override;
|
||||
virtual void setUniforms() override;
|
||||
virtual bool textureReady() override;
|
||||
|
||||
void readHeader();
|
||||
float* readData();
|
||||
std::vector<float*> readData();
|
||||
void processData(
|
||||
float* outputData, // Where you want your processed data to go
|
||||
std::vector<float*> outputData, // Where you want your processed data to go
|
||||
int inputChannel, // index of the data channel
|
||||
std::vector<float> inputData, //data that needs processing
|
||||
float min, // min value of the input data
|
||||
float max, // max valye of the input data
|
||||
float sum, // sum of the input data
|
||||
int numOutputChannels // number of data channels that you want in the output
|
||||
float sum // sum of the input data
|
||||
);
|
||||
|
||||
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;
|
||||
properties::BoolProperty _useLog;
|
||||
properties::BoolProperty _useHistogram;
|
||||
properties::BoolProperty _useRGB;
|
||||
|
||||
//FOR TESTING
|
||||
// double _avgBenchmarkTime=0.0;
|
||||
// int _numOfBenchmarks = 0;
|
||||
//===========
|
||||
properties::BoolProperty _useMultipleTf;
|
||||
// properties::BoolProperty _averageValues;
|
||||
|
||||
|
||||
// properties::Vec4Property _topColor;
|
||||
// properties::Vec4Property _midColor;
|
||||
@@ -79,6 +81,11 @@ class DataPlane : public CygnetPlane {
|
||||
|
||||
glm::size3_t _dimensions;
|
||||
// std::shared_ptr<ColorBar> _colorbar;
|
||||
|
||||
//FOR TESTING
|
||||
// double _avgBenchmarkTime=0.0;
|
||||
// int _numOfBenchmarks = 0;
|
||||
//===========
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -34,9 +34,9 @@ ISWACygnet::ISWACygnet(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _delete("delete", "Delete")
|
||||
, _shader(nullptr)
|
||||
, _texture(nullptr)
|
||||
// , _texture(nullptr)
|
||||
, _memorybuffer("")
|
||||
,_transferFunction(nullptr)
|
||||
// ,_transferFunction(nullptr)
|
||||
{
|
||||
_data = std::make_shared<Metadata>();
|
||||
|
||||
@@ -90,6 +90,9 @@ ISWACygnet::ISWACygnet(const ghoul::Dictionary& dictionary)
|
||||
// std::cout << std::to_string(_data->spatialScale) << std::endl;
|
||||
|
||||
_delete.onChange([this](){ISWAManager::ref().deleteISWACygnet(name());});
|
||||
|
||||
// _textures.push_back(nullptr);
|
||||
// _transferFunctions.push_back(nullptr);
|
||||
}
|
||||
|
||||
ISWACygnet::~ISWACygnet(){}
|
||||
|
||||
@@ -82,7 +82,7 @@ protected:
|
||||
properties::TriggerProperty _delete;
|
||||
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _shader;
|
||||
std::unique_ptr<ghoul::opengl::Texture> _texture;
|
||||
std::vector<std::unique_ptr<ghoul::opengl::Texture>> _textures;
|
||||
|
||||
std::shared_ptr<Metadata> _data;
|
||||
std::string _memorybuffer;
|
||||
@@ -96,7 +96,7 @@ protected:
|
||||
std::chrono::milliseconds _lastUpdateRealTime;
|
||||
int _minRealTimeUpdateInterval;
|
||||
|
||||
std::shared_ptr<TransferFunction> _transferFunction;
|
||||
std::vector<std::shared_ptr<TransferFunction>> _transferFunctions;
|
||||
};
|
||||
|
||||
}//namespace openspace
|
||||
|
||||
@@ -69,6 +69,8 @@ KameleonPlane::~KameleonPlane(){}
|
||||
|
||||
|
||||
bool KameleonPlane::initialize(){
|
||||
_textures.push_back(nullptr);
|
||||
|
||||
std::cout << "initialize kameleonplane" << std::endl;
|
||||
// std::string kwPath;
|
||||
_kw = std::make_shared<KameleonWrapper>(absPath(_kwPath));
|
||||
@@ -131,7 +133,7 @@ bool KameleonPlane::loadTexture() {
|
||||
// Textures of planets looks much smoother with AnisotropicMipMap rather than linear
|
||||
texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
|
||||
|
||||
_texture = std::move(texture);
|
||||
_textures[0] = std::move(texture);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -140,4 +142,12 @@ bool KameleonPlane::updateTexture(){
|
||||
return true;
|
||||
}
|
||||
|
||||
void KameleonPlane::setUniforms(){
|
||||
ghoul::opengl::TextureUnit unit;
|
||||
|
||||
unit.activate();
|
||||
_textures[0]->bind();
|
||||
_shader->setUniform("texture1", unit);
|
||||
}
|
||||
|
||||
}// namespace openspace
|
||||
@@ -41,6 +41,7 @@
|
||||
private:
|
||||
virtual bool loadTexture() override;
|
||||
virtual bool updateTexture() override;
|
||||
virtual void setUniforms() override;
|
||||
|
||||
static int id();
|
||||
|
||||
|
||||
@@ -53,6 +53,9 @@ TexturePlane::TexturePlane(const ghoul::Dictionary& dictionary)
|
||||
TexturePlane::~TexturePlane(){}
|
||||
|
||||
bool TexturePlane::initialize(){
|
||||
|
||||
_textures.push_back(nullptr);
|
||||
|
||||
initializeTime();
|
||||
createPlane();
|
||||
createShader();
|
||||
@@ -87,8 +90,8 @@ bool TexturePlane::loadTexture() {
|
||||
texture->uploadTexture();
|
||||
// Textures of planets looks much smoother with AnisotropicMipMap rather than linear
|
||||
texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
|
||||
|
||||
_texture = std::move(texture);
|
||||
|
||||
_textures[0] = std::move(texture);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -115,4 +118,12 @@ bool TexturePlane::updateTexture(){
|
||||
return false;
|
||||
}
|
||||
|
||||
void TexturePlane::setUniforms(){
|
||||
ghoul::opengl::TextureUnit unit;
|
||||
|
||||
unit.activate();
|
||||
_textures[0]->bind();
|
||||
_shader->setUniform("texture1", unit);
|
||||
}
|
||||
|
||||
}// namespace openspace
|
||||
@@ -42,6 +42,7 @@
|
||||
private:
|
||||
virtual bool loadTexture() override;
|
||||
virtual bool updateTexture() override;
|
||||
virtual void setUniforms() override;
|
||||
|
||||
static int id();
|
||||
};
|
||||
|
||||
@@ -22,8 +22,17 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
uniform float time;
|
||||
uniform sampler2D texture1;
|
||||
uniform sampler2D tf;
|
||||
|
||||
// uniform sampler2D texture1;
|
||||
uniform sampler2D textures[6];
|
||||
uniform sampler2D transferFunctions[6];
|
||||
// uniform sampler2D tf;
|
||||
// uniform sampler2D tfs[6];
|
||||
|
||||
uniform int numTextures;
|
||||
uniform int numTransferFunctions;
|
||||
uniform bool averageValues;
|
||||
uniform vec2 backgroundValues;
|
||||
|
||||
// uniform float background;
|
||||
|
||||
@@ -36,15 +45,48 @@ in vec4 vs_position;
|
||||
Fragment getFragment() {
|
||||
vec4 position = vs_position;
|
||||
float depth = pscDepth(position);
|
||||
vec4 diffuse;
|
||||
vec4 transparent = vec4(0.0f);
|
||||
vec4 diffuse = transparent;
|
||||
float v = 0;
|
||||
|
||||
if(numTextures > numTransferFunctions){
|
||||
for(int 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;
|
||||
if((v<(x+y)) && v>(x-y))
|
||||
color = mix(transparent, color, abs(v-x));
|
||||
|
||||
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));
|
||||
// diffuse += texture(tf, vec2(v,0));
|
||||
// }
|
||||
// }else{
|
||||
// v = texture(texture1, vec2(vs_st.s, 1-vs_st.t)).r;
|
||||
// diffuse = texture(tf, vec2(v,0));
|
||||
// }
|
||||
|
||||
// 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);
|
||||
float v = texture(texture1, vec2(vs_st.s, 1-vs_st.t)).r;
|
||||
diffuse = texture(tf, vec2(v,0));
|
||||
|
||||
// if (diffuse.a <= 0.05)
|
||||
// discard;
|
||||
if (diffuse.a <= backgroundValues.y)
|
||||
discard;
|
||||
|
||||
Fragment frag;
|
||||
frag.color = diffuse;
|
||||
|
||||