Small bug fixes

This commit is contained in:
Sebastian Piwell
2016-05-26 09:49:24 -04:00
parent c374fa2ce4
commit 0e3749fcf9
6 changed files with 55 additions and 32 deletions
+15 -5
View File
@@ -37,6 +37,7 @@
namespace {
const std::string _loggerCat = "DataPlane";
const int MAX_TEXTURES = 6;
}
namespace openspace {
@@ -161,7 +162,11 @@ bool DataPlane::initialize(){
loadTexture();
});
_dataOptions.onChange([this](){ loadTexture();} );
_dataOptions.onChange([this](){
if(_dataOptions.value().size() > MAX_TEXTURES)
LWARNING("Too many options chosen, max is " + std::to_string(MAX_TEXTURES));
loadTexture();
});
_transferFunctionsFile.onChange([this](){
setTransferFunctions(_transferFunctionsFile.value());
@@ -255,10 +260,10 @@ bool DataPlane::readyToRender(){
void DataPlane::setUniformAndTextures(){
std::vector<int> selectedOptions = _dataOptions.value();
int activeTextures = selectedOptions.size();
int activeTransferfunctions = _transferFunctions.size();
int activeTextures = std::min((int)selectedOptions.size(), MAX_TEXTURES);
int activeTransferfunctions = std::min((int)_transferFunctions.size(), MAX_TEXTURES);
ghoul::opengl::TextureUnit txUnits[10];
ghoul::opengl::TextureUnit txUnits[6];
int j = 0;
for(int option : selectedOptions){
if(_textures[option]){
@@ -270,6 +275,7 @@ void DataPlane::setUniformAndTextures(){
);
j++;
if(j >= MAX_TEXTURES) break;
}
}
@@ -278,7 +284,7 @@ void DataPlane::setUniformAndTextures(){
activeTransferfunctions = 1;
}
ghoul::opengl::TextureUnit tfUnits[10];
ghoul::opengl::TextureUnit tfUnits[6];
j = 0;
if((activeTransferfunctions == 1)){
@@ -305,6 +311,7 @@ void DataPlane::setUniformAndTextures(){
);
j++;
if(j >= MAX_TEXTURES) break;
}
}
}
@@ -340,8 +347,11 @@ void DataPlane::setTransferFunctions(std::string tfPath){
tfs.push_back(tf);
}
}
tfFile.close();
}
if(!tfs.empty()){
_transferFunctions.clear();
_transferFunctions = tfs;
+13 -3
View File
@@ -32,6 +32,7 @@
namespace {
const std::string _loggerCat = "DataSphere";
const int MAX_TEXTURES = 6;
}
namespace openspace {
@@ -155,7 +156,11 @@ bool DataSphere::initialize(){
loadTexture();
});
_dataOptions.onChange([this](){ loadTexture();} );
_dataOptions.onChange([this](){
if(_dataOptions.value().size() > MAX_TEXTURES)
LWARNING("Too many options chosen, max is " + std::to_string(MAX_TEXTURES));
loadTexture();
});
_transferFunctionsFile.onChange([this](){
setTransferFunctions(_transferFunctionsFile.value());
@@ -257,8 +262,8 @@ bool DataSphere::readyToRender(){
void DataSphere::setUniformAndTextures(){
std::vector<int> selectedOptions = _dataOptions.value();
int activeTextures = selectedOptions.size();
int activeTransferfunctions = _transferFunctions.size();
int activeTextures = std::min((int)selectedOptions.size(), MAX_TEXTURES);
int activeTransferfunctions = std::min((int)_transferFunctions.size(), MAX_TEXTURES);
ghoul::opengl::TextureUnit txUnits[10];
int j = 0;
@@ -272,6 +277,8 @@ void DataSphere::setUniformAndTextures(){
);
j++;
if(j >= MAX_TEXTURES) break;
}
}
@@ -307,6 +314,7 @@ void DataSphere::setUniformAndTextures(){
);
j++;
if(j >= MAX_TEXTURES) break;
}
}
}
@@ -345,8 +353,10 @@ void DataSphere::setTransferFunctions(std::string tfPath){
tfs.push_back(tf);
}
}
tfFile.close();
}
if(!tfs.empty()){
_transferFunctions.clear();
_transferFunctions = tfs;
+15 -5
View File
@@ -43,6 +43,8 @@
namespace {
using json = nlohmann::json;
const std::string _loggerCat = "KameleonPlane";
const int MAX_TEXTURES = 6;
}
namespace openspace {
@@ -351,10 +353,11 @@ bool KameleonPlane::readyToRender(){
void KameleonPlane::setUniformAndTextures(){
std::vector<int> selectedOptions = _dataOptions.value();
int activeTextures = selectedOptions.size();
int activeTransferfunctions = _transferFunctions.size();
int activeTextures = std::min((int)selectedOptions.size(), MAX_TEXTURES);
int activeTransferfunctions = std::min((int)_transferFunctions.size(), MAX_TEXTURES);
ghoul::opengl::TextureUnit txUnits[10];
ghoul::opengl::TextureUnit txUnits[6];
int j = 0;
for(int option : selectedOptions){
if(_textures[option]){
@@ -366,6 +369,7 @@ void KameleonPlane::setUniformAndTextures(){
);
j++;
if(j >= MAX_TEXTURES) break;
}
}
@@ -374,7 +378,7 @@ void KameleonPlane::setUniformAndTextures(){
activeTransferfunctions = 1;
}
ghoul::opengl::TextureUnit tfUnits[10];
ghoul::opengl::TextureUnit tfUnits[6];
j = 0;
if((activeTransferfunctions == 1)){
@@ -395,6 +399,7 @@ void KameleonPlane::setUniformAndTextures(){
);
j++;
if(j >= MAX_TEXTURES) break;
}
}
}
@@ -430,6 +435,7 @@ void KameleonPlane::setTransferFunctions(std::string tfPath){
tfs.push_back(tf);
}
}
tfFile.close();
}
if(!tfs.empty()){
@@ -457,7 +463,11 @@ void KameleonPlane::fillOptions(){
_dataOptions.setValue(std::vector<int>(1,0));
// IswaManager::ref().registerOptionsToGroup(_data->groupName, _dataOptions.options());
}
_dataOptions.onChange([this](){loadTexture();});
_dataOptions.onChange([this](){
if(_dataOptions.value().size() > MAX_TEXTURES)
LWARNING("Too many options chosen, max is " + std::to_string(MAX_TEXTURES));
loadTexture();
});
}
void KameleonPlane::updateFieldlineSeeds(){
+5 -17
View File
@@ -51,6 +51,9 @@ Fragment getFragment() {
vec4 diffuse = transparent;
float v = 0;
float x = backgroundValues.x;
float y = backgroundValues.y;
if((numTransferFunctions == 1) || (numTextures > numTransferFunctions)){
for(int i=0; i<numTextures; i++){
v += texture(textures[i], vec2(vs_st.s, 1-vs_st.t)).r;
@@ -58,34 +61,19 @@ Fragment getFragment() {
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, clamp(1,0,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));
if((v<(x+y)) && v>(x-y))
color = mix(transparent, color, clamp(1,0,abs(v-x)));
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);
if(numTextures == 0) diffuse = transparent;
if (diffuse.a <= backgroundValues.y)
discard;
+5 -2
View File
@@ -50,6 +50,9 @@ Fragment getFragment() {
vec4 diffuse = transparent;
float v = 0;
float x = backgroundValues.x;
float y = backgroundValues.y;
if((numTransferFunctions == 1) || (numTextures > numTransferFunctions)){
for(int i=0; i<numTextures; i++){
v += texture(textures[i], vec2(vs_st.t, vs_st.s)).r;
@@ -57,8 +60,6 @@ Fragment getFragment() {
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, clamp(1,0,abs(v-x)));
@@ -67,6 +68,8 @@ Fragment getFragment() {
for(int i=0; i<numTextures; i++){
v = texture(textures[i], vec2(vs_st.t, vs_st.s)).r;
vec4 color = texture(transferFunctions[i], vec2(v,0));
if((v<(x+y)) && v>(x-y))
color = mix(transparent, color, clamp(1,0,abs(v-x)));
diffuse += color;
}
}
+2
View File
@@ -608,6 +608,8 @@ void IswaManager::addCdfFiles(std::string path){
}
}
jsonFile.close();
}
}else{
LWARNING( path + " is not a cdf file or can't be found.");