From 200a3d4dd6f79263c53c45f1ba74bb6964f4364d Mon Sep 17 00:00:00 2001 From: Sebastian Piwell Date: Thu, 28 Apr 2016 17:40:04 -0400 Subject: [PATCH] Filter out background values --- ext/ghoul | 2 +- modules/iswa/rendering/cygnetplane.cpp | 1 - modules/iswa/rendering/dataplane.cpp | 16 ++++++++++------ modules/iswa/rendering/dataplane.h | 1 + modules/iswa/shaders/dataplane_fs.glsl | 17 +++++++++++++---- 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 11bac4f34a..f6fcc8c142 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 11bac4f34ab385ede423754d62368e3c210eaabd +Subproject commit f6fcc8c142f24c63b4eb5987e88ef37c6ef2ff51 diff --git a/modules/iswa/rendering/cygnetplane.cpp b/modules/iswa/rendering/cygnetplane.cpp index 20fe76ef5a..6671ea72a5 100644 --- a/modules/iswa/rendering/cygnetplane.cpp +++ b/modules/iswa/rendering/cygnetplane.cpp @@ -29,7 +29,6 @@ CygnetPlane::CygnetPlane(const ghoul::Dictionary& dictionary) ,_quad(0) ,_vertexPositionBuffer(0) ,_futureObject(nullptr) - // ,_backgroundValue(0.0f) {} CygnetPlane::~CygnetPlane(){} diff --git a/modules/iswa/rendering/dataplane.cpp b/modules/iswa/rendering/dataplane.cpp index ee345c77f5..80f54667db 100644 --- a/modules/iswa/rendering/dataplane.cpp +++ b/modules/iswa/rendering/dataplane.cpp @@ -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(tfPath)); - tfPath = "${OPENSPACE_DATA}/blue.jpg"; - _transferFunctions.push_back(std::make_shared(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(tfPath)); + // tfPath = "${OPENSPACE_DATA}/blue.jpg"; + // _transferFunctions.push_back(std::make_shared(tfPath)); + // tfPath = "${OPENSPACE_DATA}/green.jpg"; + // _transferFunctions.push_back(std::make_shared(tfPath)); // std::cout << "Creating Colorbar" << std::endl; // _colorbar = std::make_shared(); @@ -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(){ diff --git a/modules/iswa/rendering/dataplane.h b/modules/iswa/rendering/dataplane.h index 4b3ec85c4d..a1ff104975 100644 --- a/modules/iswa/rendering/dataplane.h +++ b/modules/iswa/rendering/dataplane.h @@ -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; diff --git a/modules/iswa/shaders/dataplane_fs.glsl b/modules/iswa/shaders/dataplane_fs.glsl index efa761fe45..518da11d71 100644 --- a/modules/iswa/shaders/dataplane_fs.glsl +++ b/modules/iswa/shaders/dataplane_fs.glsl @@ -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 1){ // for(uint i=0; i(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;