diff --git a/data/colormap_parula.jpg b/data/colormap_parula.jpg new file mode 100644 index 0000000000..696b292668 Binary files /dev/null and b/data/colormap_parula.jpg differ diff --git a/data/colormap_parula.png b/data/colormap_parula.png new file mode 100644 index 0000000000..8e296ed05f Binary files /dev/null and b/data/colormap_parula.png differ diff --git a/include/openspace/rendering/transferfunction.h b/include/openspace/rendering/transferfunction.h index a6a4d85c77..71023b00d5 100644 --- a/include/openspace/rendering/transferfunction.h +++ b/include/openspace/rendering/transferfunction.h @@ -41,6 +41,7 @@ namespace openspace { TransferFunction(const std::string& filepath, TfChangedCallback tfChangedCallback = TfChangedCallback()); void setPath(const std::string& filepath); ghoul::opengl::Texture& getTexture(); + void bind(); void update(); glm::vec4 sample(size_t t); size_t width(); diff --git a/modules/iswa/rendering/cygnetplane.cpp b/modules/iswa/rendering/cygnetplane.cpp index b22ecb85c3..432875c71a 100644 --- a/modules/iswa/rendering/cygnetplane.cpp +++ b/modules/iswa/rendering/cygnetplane.cpp @@ -93,7 +93,7 @@ void CygnetPlane::render(const RenderData& data){ _shader->setUniform("ViewProjection", data.camera.viewProjectionMatrix()); _shader->setUniform("ModelTransform", transform); - _shader->setUniform("background", _backgroundValue); + // _shader->setUniform("background", _backgroundValue); // _shader->setUniform("top", _topColor.value()); // _shader->setUniform("mid", _midColor.value()); @@ -102,11 +102,22 @@ void CygnetPlane::render(const RenderData& data){ 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); + + + + glBindVertexArray(_quad); glDrawArrays(GL_TRIANGLES, 0, 6); glEnable(GL_CULL_FACE); @@ -145,13 +156,12 @@ void CygnetPlane::update(const UpdateData& data){ if(loadTexture()) _futureObject = nullptr; } + + if(_transferFunction) + _transferFunction->update(); } void CygnetPlane::createPlane(){ - GLUquadricObj *Cylinder; // Create pointer for our cylinder - - Cylinder = gluNewQuadric(); - glGenVertexArrays(1, &_quad); // generate array glGenBuffers(1, &_vertexPositionBuffer); // generate buffer diff --git a/modules/iswa/rendering/dataplane.cpp b/modules/iswa/rendering/dataplane.cpp index 361641b752..4c20206675 100644 --- a/modules/iswa/rendering/dataplane.cpp +++ b/modules/iswa/rendering/dataplane.cpp @@ -107,6 +107,8 @@ bool DataPlane::initialize(){ updateTexture(); + std::string tfPath = "${OPENSPACE_DATA}/colormap_parula.jpg"; + _transferFunction = std::make_shared(tfPath); // std::cout << "Creating Colorbar" << std::endl; // _colorbar = std::make_shared(); // if(_colorbar){ diff --git a/modules/iswa/rendering/iswacygnet.cpp b/modules/iswa/rendering/iswacygnet.cpp index fe8e487f08..a58999e4e7 100644 --- a/modules/iswa/rendering/iswacygnet.cpp +++ b/modules/iswa/rendering/iswacygnet.cpp @@ -36,6 +36,8 @@ ISWACygnet::ISWACygnet(const ghoul::Dictionary& dictionary) , _shader(nullptr) , _texture(nullptr) , _memorybuffer("") + ,_transferFunction(nullptr) + ,_tfTexture(nullptr) { _data = std::make_shared(); diff --git a/modules/iswa/rendering/iswacygnet.h b/modules/iswa/rendering/iswacygnet.h index 3d0f79509b..9f26de4626 100644 --- a/modules/iswa/rendering/iswacygnet.h +++ b/modules/iswa/rendering/iswacygnet.h @@ -44,6 +44,7 @@ #include #include #include +#include namespace openspace{ @@ -106,6 +107,8 @@ protected: std::chrono::milliseconds _lastUpdateRealTime; int _minRealTimeUpdateInterval; + std::shared_ptr _transferFunction; + int _id; }; diff --git a/modules/iswa/shaders/dataplane_fs.glsl b/modules/iswa/shaders/dataplane_fs.glsl index 36973065ca..70fa633060 100644 --- a/modules/iswa/shaders/dataplane_fs.glsl +++ b/modules/iswa/shaders/dataplane_fs.glsl @@ -23,8 +23,9 @@ ****************************************************************************************/ uniform float time; uniform sampler2D texture1; +uniform sampler2D tf; -uniform float background; +// uniform float background; in vec2 vs_st; in vec4 vs_position; @@ -37,8 +38,10 @@ Fragment getFragment() { float depth = pscDepth(position); vec4 diffuse; - diffuse = texture(texture1, vec2(vs_st.s, 1-vs_st.t)); - //float v = texture(texture1, vec2(vs_st.s, 1-vs_st.t)).r; + // 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; diff --git a/src/rendering/transferfunction.cpp b/src/rendering/transferfunction.cpp index 1bfcb87b0b..5a596fe8c5 100644 --- a/src/rendering/transferfunction.cpp +++ b/src/rendering/transferfunction.cpp @@ -224,4 +224,9 @@ size_t TransferFunction::width() { update(); return _texture->width(); } + +void TransferFunction::bind() { + update(); + _texture->bind(); +} }