mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-25 22:39:04 -06:00
Add transferFunction to dataplane
This commit is contained in:
BIN
data/colormap_parula.jpg
Normal file
BIN
data/colormap_parula.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 953 B |
BIN
data/colormap_parula.png
Normal file
BIN
data/colormap_parula.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 846 B |
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -107,6 +107,8 @@ bool DataPlane::initialize(){
|
||||
updateTexture();
|
||||
|
||||
|
||||
std::string tfPath = "${OPENSPACE_DATA}/colormap_parula.jpg";
|
||||
_transferFunction = std::make_shared<TransferFunction>(tfPath);
|
||||
// std::cout << "Creating Colorbar" << std::endl;
|
||||
// _colorbar = std::make_shared<ColorBar>();
|
||||
// if(_colorbar){
|
||||
|
||||
@@ -36,6 +36,8 @@ ISWACygnet::ISWACygnet(const ghoul::Dictionary& dictionary)
|
||||
, _shader(nullptr)
|
||||
, _texture(nullptr)
|
||||
, _memorybuffer("")
|
||||
,_transferFunction(nullptr)
|
||||
,_tfTexture(nullptr)
|
||||
{
|
||||
_data = std::make_shared<Metadata>();
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include <modules/iswa/util/iswamanager.h>
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/rendering/transferfunction.h>
|
||||
|
||||
|
||||
namespace openspace{
|
||||
@@ -106,6 +107,8 @@ protected:
|
||||
std::chrono::milliseconds _lastUpdateRealTime;
|
||||
int _minRealTimeUpdateInterval;
|
||||
|
||||
std::shared_ptr<TransferFunction> _transferFunction;
|
||||
|
||||
int _id;
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -224,4 +224,9 @@ size_t TransferFunction::width() {
|
||||
update();
|
||||
return _texture->width();
|
||||
}
|
||||
|
||||
void TransferFunction::bind() {
|
||||
update();
|
||||
_texture->bind();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user