mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-13 17:09:05 -05:00
Filter out background values
This commit is contained in:
Submodule ext/ghoul updated: 11bac4f34a...f6fcc8c142
@@ -29,7 +29,6 @@ CygnetPlane::CygnetPlane(const ghoul::Dictionary& dictionary)
|
||||
,_quad(0)
|
||||
,_vertexPositionBuffer(0)
|
||||
,_futureObject(nullptr)
|
||||
// ,_backgroundValue(0.0f)
|
||||
{}
|
||||
|
||||
CygnetPlane::~CygnetPlane(){}
|
||||
|
||||
@@ -42,6 +42,7 @@ 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)
|
||||
@@ -56,6 +57,7 @@ DataPlane::DataPlane(const ghoul::Dictionary& dictionary)
|
||||
addProperty(_useHistogram);
|
||||
addProperty(_useRGB);
|
||||
addProperty(_normValues);
|
||||
addProperty(_backgroundValues);
|
||||
addProperty(_averageValues);
|
||||
addProperty(_dataOptions);
|
||||
|
||||
@@ -65,6 +67,7 @@ DataPlane::DataPlane(const ghoul::Dictionary& dictionary)
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_useHistogram);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_useRGB);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_normValues);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_backgroundValues);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_averageValues);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_dataOptions);
|
||||
|
||||
@@ -107,13 +110,13 @@ bool DataPlane::initialize(){
|
||||
|
||||
updateTexture();
|
||||
|
||||
// std::string tfPath = "${OPENSPACE_DATA}/colormap_parula.jpg";
|
||||
std::string tfPath = "${OPENSPACE_DATA}/red.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";
|
||||
std::string tfPath = "${OPENSPACE_DATA}/colormap_parula.jpg";
|
||||
// std::string tfPath = "${OPENSPACE_DATA}/red.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>();
|
||||
@@ -244,6 +247,7 @@ void DataPlane::setUniforms(){
|
||||
_shader->setUniform("numTextures", activeTextures);
|
||||
_shader->setUniform("numTransferFunctions", activeTransferfunctions);
|
||||
_shader->setUniform("averageValues", _averageValues.value());
|
||||
_shader->setUniform("backgroundValues", _backgroundValues.value());
|
||||
};
|
||||
|
||||
bool DataPlane::textureReady(){
|
||||
|
||||
@@ -66,6 +66,7 @@ class DataPlane : public CygnetPlane {
|
||||
|
||||
properties::SelectionProperty _dataOptions;
|
||||
properties::Vec2Property _normValues;
|
||||
properties::Vec2Property _backgroundValues;
|
||||
properties::BoolProperty _useLog;
|
||||
properties::BoolProperty _useHistogram;
|
||||
properties::BoolProperty _useRGB;
|
||||
|
||||
@@ -32,6 +32,7 @@ uniform sampler2D transferFunctions[6];
|
||||
uniform int numTextures;
|
||||
uniform int numTransferFunctions;
|
||||
uniform bool averageValues;
|
||||
uniform vec2 backgroundValues;
|
||||
|
||||
// uniform float background;
|
||||
|
||||
@@ -44,7 +45,8 @@ in vec4 vs_position;
|
||||
Fragment getFragment() {
|
||||
vec4 position = vs_position;
|
||||
float depth = pscDepth(position);
|
||||
vec4 diffuse = vec4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
vec4 transparent = vec4(0.0f);
|
||||
vec4 diffuse = transparent;
|
||||
float v;
|
||||
|
||||
for(int i=0; i<numTextures; i++){
|
||||
@@ -55,7 +57,14 @@ Fragment getFragment() {
|
||||
// if(numTextures > 1){
|
||||
// for(uint i=0; i<numTextures; i++){
|
||||
v = texture(textures[i], vec2(vs_st.s, 1-vs_st.t)).r;
|
||||
diffuse += texture(transferFunctions[j], 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 += texture(textures[1], vec2(vs_st.s, 1-vs_st.t));
|
||||
// diffuse += texture(textures[2], vec2(vs_st.s, 1-vs_st.t));
|
||||
@@ -73,8 +82,8 @@ Fragment getFragment() {
|
||||
// diffuse = texture(tf, vec2(1-vs_st.s, 0));
|
||||
// diffuse = texture(tf, texture(texture1, vec2(vs_st.s,1-vs_st.t)).r);
|
||||
|
||||
// if (diffuse.a <= 0.05)
|
||||
// discard;
|
||||
if (diffuse.a <= backgroundValues.y)
|
||||
discard;
|
||||
|
||||
Fragment frag;
|
||||
frag.color = diffuse;
|
||||
|
||||
Reference in New Issue
Block a user