Commit 8fa3a1ab authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Moved IXPV into its own module, removing devil module dependency from vis module

parent aeb8f778
/**********************************************************************
* *
* Voreen - The Volume Rendering Engine *
* *
* Copyright (C) 2005-2012 Visualization and Computer Graphics Group, *
* Department of Computer Science, University of Muenster, Germany. *
* <http://viscg.uni-muenster.de> *
* *
* This file is part of the Voreen software package. Voreen is free *
* software: you can redistribute it and/or modify it under the terms *
* of the GNU General Public License version 2 as published by the *
* Free Software Foundation. *
* *
* Voreen is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* in the file "LICENSE.txt" along with this program. *
* If not, see <http://www.gnu.org/licenses/>. *
* *
* The authors reserve all rights not expressly granted herein. For *
* non-commercial academic use see the license exception specified in *
* the file "LICENSE-academic.txt". To get information about *
* commercial licensing please contact the authors. *
* *
**********************************************************************/
in vec3 ex_TexCoord;
out vec4 out_Color;
#include "tools/texture2d.frag"
#include "tools/background.frag"
uniform sampler2D _xRayColor;
uniform sampler2D _xRayDepth;
uniform TextureParameters2D _xRayTexParams;
uniform sampler2D _sliceColor;
uniform sampler2D _sliceDepth;
uniform TextureParameters2D _sliceTexParams;
uniform sampler2D _drrFullColor;
uniform TextureParameters2D _drrFullTexParams;
uniform sampler2D _drrClippedColor;
uniform TextureParameters2D _drrClippedTexParams;
/***
* The main method.
***/
void main() {
// fetch input textures
vec4 xRayColor = getElement2DNormalized(_xRayColor, _xRayTexParams, ex_TexCoord.xy);
float xRayDepth = getElement2DNormalized(_xRayDepth, _xRayTexParams, ex_TexCoord.xy).z;
vec4 sliceColor = getElement2DNormalized(_sliceColor, _sliceTexParams, ex_TexCoord.xy);
float sliceDepth = getElement2DNormalized(_sliceDepth, _sliceTexParams, ex_TexCoord.xy).z;
float drrFull = getElement2DNormalized(_drrFullColor, _drrFullTexParams, ex_TexCoord.xy).r;
float drrClipped = getElement2DNormalized(_drrClippedColor, _drrClippedTexParams, ex_TexCoord.xy).r;
float weightingFactor = 0.0;
if (drrClipped > 0)
weightingFactor = clamp(drrClipped / drrFull, 0.0, 1.0);
float fragDepth = weightingFactor;
if (weightingFactor == 0.0)
fragDepth = sliceDepth;
else if (weightingFactor == 1.0)
fragDepth = xRayDepth;
else
fragDepth = min(xRayDepth, sliceDepth);
out_Color = weightingFactor*xRayColor + (1.0-weightingFactor)*sliceColor;
gl_FragDepth = fragDepth;
if (out_Color.a == 0) {
renderBackground(ex_TexCoord.xy, out_Color);
}
}
/**********************************************************************
* *
* Voreen - The Volume Rendering Engine *
* *
* Copyright (C) 2005-2012 Visualization and Computer Graphics Group, *
* Department of Computer Science, University of Muenster, Germany. *
* <http://viscg.uni-muenster.de> *
* *
* This file is part of the Voreen software package. Voreen is free *
* software: you can redistribute it and/or modify it under the terms *
* of the GNU General Public License version 2 as published by the *
* Free Software Foundation. *
* *
* Voreen is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* in the file "LICENSE.txt" along with this program. *
* If not, see <http://www.gnu.org/licenses/>. *
* *
* The authors reserve all rights not expressly granted herein. For *
* non-commercial academic use see the license exception specified in *
* the file "LICENSE-academic.txt". To get information about *
* commercial licensing please contact the authors. *
* *
**********************************************************************/
in vec3 ex_TexCoord;
out vec4 out_Color;
#include "tools/texture2d.frag"
#include "tools/background.frag"
uniform sampler2D _xRayColor;
uniform sampler2D _xRayDepth;
uniform TextureParameters2D _xRayTexParams;
uniform sampler2D _sliceColor;
uniform sampler2D _sliceDepth;
uniform TextureParameters2D _sliceTexParams;
uniform sampler2D _drrFullColor;
uniform TextureParameters2D _drrFullTexParams;
uniform sampler2D _drrClippedColor;
uniform TextureParameters2D _drrClippedTexParams;
/***
* The main method.
***/
void main() {
// fetch input textures
vec4 xRayColor = getElement2DNormalized(_xRayColor, _xRayTexParams, ex_TexCoord.xy);
float xRayDepth = getElement2DNormalized(_xRayDepth, _xRayTexParams, ex_TexCoord.xy).r;
vec4 sliceColor = getElement2DNormalized(_sliceColor, _sliceTexParams, ex_TexCoord.xy);
float sliceDepth = getElement2DNormalized(_sliceDepth, _sliceTexParams, ex_TexCoord.xy).r;
float drrFull = getElement2DNormalized(_drrFullColor, _drrFullTexParams, ex_TexCoord.xy).r;
float drrClipped = getElement2DNormalized(_drrClippedColor, _drrClippedTexParams, ex_TexCoord.xy).r;
float weightingFactor = 0.0;
if (drrClipped > 0)
weightingFactor = clamp(drrClipped / drrFull, 0.0, 1.0);
float fragDepth = weightingFactor;
if (weightingFactor == 0.0)
fragDepth = sliceDepth;
else if (weightingFactor == 1.0)
fragDepth = xRayDepth;
else
fragDepth = min(xRayDepth, sliceDepth);
out_Color = weightingFactor*xRayColor + (1.0-weightingFactor)*sliceColor;
gl_FragDepth = fragDepth;
if (out_Color.a == 0) {
renderBackground(ex_TexCoord.xy, out_Color);
}
}
# CMake file for IXPV module
# Source files:
FILE(GLOB ThisModSources RELATIVE ${ModulesDir}
modules/ixpv/pipelines/*.cpp
modules/ixpv/processors/*.cpp
)
# Header files (including GLSL files so that they'll appear in VS projects)
FILE(GLOB ThisModHeaders RELATIVE ${ModulesDir}
modules/ixpv/glsl/*.frag
modules/ixpv/glsl/*.vert
modules/ixpv/pipelines/*.h
modules/ixpv/processors/*.h
)
SET(ThisModShaderDirectories "modules/ixpv/glsl")
SET(ThisModDependencies vis devil io)
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universität München
// Boltzmannstr. 3, 85748 Garching b. München, Germany
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
#ifndef IXPVDEMO_H__
#define IXPVDEMO_H__
#include "core/datastructures/imagerepresentationlocal.h"
#include "core/eventhandlers/trackballnavigationeventlistener.h"
#include "core/eventhandlers/mwheeltonumericpropertyeventlistener.h"
#include "core/properties/cameraproperty.h"
#include "core/pipeline/autoevaluationpipeline.h"
#include "modules/io/processors/mhdimagereader.h"
#include "modules/devil/processors/devilimagereader.h"
#include "modules/vis/processors/sliceextractor.h"
#include "modules/vis/processors/proxygeometrygenerator.h"
#include "modules/vis/processors/geometryrenderer.h"
#include "modules/vis/processors/eepgenerator.h"
#include "modules/vis/processors/drrraycaster.h"
#include "modules/vis/processors/simpleraycaster.h"
#include "modules/vis/processors/rendertargetcompositor.h"
#include "modules/vis/processors/slicerenderer3d.h"
#include "modules/vis/processors/ixpvcompositor.h"
namespace campvis {
class IxpvDemo : public AutoEvaluationPipeline {
public:
/**
* Creates a AutoEvaluationPipeline.
*/
IxpvDemo(DataContainer* dc);
/**
* Virtual Destructor
**/
virtual ~IxpvDemo();
/// \see AutoEvaluationPipeline::init()
virtual void init();
/// \see AbstractPipeline::getName()
virtual const std::string getName() const { return getId(); };
static const std::string getId() { return "IxpvDemo"; };
//virtual void keyEvent(tgt::KeyEvent* e);
protected:
/**
* Slot getting called when one of the observed processors got validated.
* Updates the camera properties, when the input image has changed.
* \param processor The processor that emitted the signal
*/
virtual void onProcessorValidated(AbstractProcessor* processor);
DevilImageReader _xrayReader;
MhdImageReader _ctReader;
ProxyGeometryGenerator _ctProxy;
EEPGenerator _ctFullEEP;
EEPGenerator _ctClippedEEP;
SimpleRaycaster _ctDVR;
DRRRaycaster _ctFullDRR;
DRRRaycaster _ctClippedDRR;
MhdImageReader _usReader;
SliceRenderer3D _usSliceRenderer;
RenderTargetCompositor _compositor;
RenderTargetCompositor _compositor2;
IxpvCompositor _ixpvCompositor;
CameraProperty _camera;
TrackballNavigationEventListener* _trackballHandler;
MWheelToNumericPropertyEventListener _wheelHandler;
};
}
#endif // IXPVDEMO_H__
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universität München
// Boltzmannstr. 3, 85748 Garching b. München, Germany
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
#ifndef IXPVDEMO_H__
#define IXPVDEMO_H__
#include "core/datastructures/imagerepresentationlocal.h"
#include "core/eventhandlers/trackballnavigationeventlistener.h"
#include "core/eventhandlers/mwheeltonumericpropertyeventlistener.h"
#include "core/properties/cameraproperty.h"
#include "core/pipeline/autoevaluationpipeline.h"
#include "modules/io/processors/mhdimagereader.h"
#include "modules/devil/processors/devilimagereader.h"
#include "modules/vis/processors/sliceextractor.h"
#include "modules/vis/processors/proxygeometrygenerator.h"
#include "modules/vis/processors/geometryrenderer.h"
#include "modules/vis/processors/eepgenerator.h"
#include "modules/vis/processors/drrraycaster.h"
#include "modules/vis/processors/simpleraycaster.h"
#include "modules/vis/processors/rendertargetcompositor.h"
#include "modules/vis/processors/slicerenderer3d.h"
#include "modules/ixpv/processors/ixpvcompositor.h"
namespace campvis {
class IxpvDemo : public AutoEvaluationPipeline {
public:
/**
* Creates a AutoEvaluationPipeline.
*/
IxpvDemo(DataContainer* dc);
/**
* Virtual Destructor
**/
virtual ~IxpvDemo();
/// \see AutoEvaluationPipeline::init()
virtual void init();
/// \see AbstractPipeline::getName()
virtual const std::string getName() const { return getId(); };
static const std::string getId() { return "IxpvDemo"; };
//virtual void keyEvent(tgt::KeyEvent* e);
protected:
/**
* Slot getting called when one of the observed processors got validated.
* Updates the camera properties, when the input image has changed.
* \param processor The processor that emitted the signal
*/
virtual void onProcessorValidated(AbstractProcessor* processor);
DevilImageReader _xrayReader;
MhdImageReader _ctReader;
ProxyGeometryGenerator _ctProxy;
EEPGenerator _ctFullEEP;
EEPGenerator _ctClippedEEP;
SimpleRaycaster _ctDVR;
DRRRaycaster _ctFullDRR;
DRRRaycaster _ctClippedDRR;
MhdImageReader _usReader;
SliceRenderer3D _usSliceRenderer;
RenderTargetCompositor _compositor;
RenderTargetCompositor _compositor2;
IxpvCompositor _ixpvCompositor;
CameraProperty _camera;
TrackballNavigationEventListener* _trackballHandler;
MWheelToNumericPropertyEventListener _wheelHandler;
};
}
#endif // IXPVDEMO_H__
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universität München
// Boltzmannstr. 3, 85748 Garching b. München, Germany
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
#include "ixpvcompositor.h"
#include "tgt/logmanager.h"
#include "tgt/shadermanager.h"
#include "tgt/textureunit.h"
#include "core/datastructures/imagedata.h"
#include "core/datastructures/renderdata.h"
#include "core/classification/simpletransferfunction.h"
#include "core/tools/quadrenderer.h"
namespace campvis {
const std::string IxpvCompositor::loggerCat_ = "CAMPVis.modules.vis.IxpvCompositor";
IxpvCompositor::IxpvCompositor(IVec2Property* viewportSizeProp)
: VisualizationProcessor(viewportSizeProp)
, p_xRayImageId("XRayImageId", "X-Ray input image", "", DataNameProperty::READ)
, p_3dSliceImageId("3DSliceImageId", "Slice input image rendered in 3D world space", "", DataNameProperty::READ)
, p_drrFullImageId("DrrFullImageId", "Full DRR input image", "", DataNameProperty::READ)
, p_drrClippedImageId("DrrClippedImageId", "Clipped DRR input image", "", DataNameProperty::READ)
, p_targetImageId("TargetImageId", "Output Image", "", DataNameProperty::WRITE)
, _shader(0)
{
addProperty(&p_xRayImageId);
addProperty(&p_3dSliceImageId);
addProperty(&p_drrFullImageId);
addProperty(&p_drrFullImageId);
addProperty(&p_targetImageId);
addDecorator(new ProcessorDecoratorBackground());
decoratePropertyCollection(this);
}
IxpvCompositor::~IxpvCompositor() {
}
void IxpvCompositor::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "modules/vis/glsl/ixpvcompositor.frag", "", false);
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
}
void IxpvCompositor::deinit() {
VisualizationProcessor::deinit();
ShdrMgr.dispose(_shader);
}
void IxpvCompositor::process(DataContainer& data) {
ScopedTypedData<RenderData> xRayImage(data, p_xRayImageId.getValue());
ScopedTypedData<RenderData> sliceImage(data, p_3dSliceImageId.getValue());
ScopedTypedData<RenderData> drrFullImage(data, p_drrFullImageId.getValue());
ScopedTypedData<RenderData> drrClippedImage(data, p_drrClippedImageId.getValue());
if (xRayImage != 0 && sliceImage != 0 && drrFullImage != 0 && drrClippedImage != 0) {
FramebufferActivationGuard fag(this);
createAndAttachColorTexture();
createAndAttachDepthTexture();
_shader->activate();
tgt::TextureUnit xRayColorUnit, xRayDepthUnit, sliceColorUnit, sliceDepthUnit, drrFullUnit, drrClippedUnit;
xRayImage->bind(_shader, xRayColorUnit, xRayDepthUnit, "_xRayColor", "_xRayDepth", "_xRayTexParams");
sliceImage->bind(_shader, sliceColorUnit, sliceDepthUnit, "_sliceColor", "_sliceDepth", "_sliceTexParams");
drrFullImage->bindColorTexture(_shader, drrFullUnit, "_drrFullColor", "_drrFullTexParams");
drrClippedImage->bindColorTexture(_shader, drrClippedUnit, "_drrClippedColor", "_drrClippedTexParams");
decorateRenderProlog(data, _shader);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
QuadRdr.renderQuad();
_shader->deactivate();
tgt::TextureUnit::setZeroUnit();
LGL_ERROR;
data.addData(p_targetImageId.getValue(), new RenderData(_fbo));
}
else {
LERROR("No suitable input images found.");
}
validate(INVALID_RESULT);
}
}
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universität München
// Boltzmannstr. 3, 85748 Garching b. München, Germany
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
#include "ixpvcompositor.h"
#include "tgt/logmanager.h"
#include "tgt/shadermanager.h"
#include "tgt/textureunit.h"
#include "core/datastructures/imagedata.h"
#include "core/datastructures/renderdata.h"
#include "core/classification/simpletransferfunction.h"
#include "core/tools/quadrenderer.h"
namespace campvis {
const std::string IxpvCompositor::loggerCat_ = "CAMPVis.modules.vis.IxpvCompositor";
IxpvCompositor::IxpvCompositor(IVec2Property* viewportSizeProp)
: VisualizationProcessor(viewportSizeProp)
, p_xRayImageId("XRayImageId", "X-Ray input image", "", DataNameProperty::READ)
, p_3dSliceImageId("3DSliceImageId", "Slice input image rendered in 3D world space", "", DataNameProperty::READ)
, p_drrFullImageId("DrrFullImageId", "Full DRR input image", "", DataNameProperty::READ)
, p_drrClippedImageId("DrrClippedImageId", "Clipped DRR input image", "", DataNameProperty::READ)
, p_targetImageId("TargetImageId", "Output Image", "", DataNameProperty::WRITE)
, _shader(0)
{
addProperty(&p_xRayImageId);
addProperty(&p_3dSliceImageId);
addProperty(&p_drrFullImageId);
addProperty(&p_drrClippedImageId);
addProperty(&p_targetImageId);
addDecorator(new ProcessorDecoratorBackground());
decoratePropertyCollection(this);
}
IxpvCompositor::~IxpvCompositor() {
}
void IxpvCompositor::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "modules/ixpv/glsl/ixpvcompositor.frag", "", false);
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
}
void IxpvCompositor::deinit() {
VisualizationProcessor::deinit();
ShdrMgr.dispose(_shader);
}
void IxpvCompositor::process(DataContainer& data) {
ScopedTypedData<RenderData> xRayImage(data, p_xRayImageId.getValue());
ScopedTypedData<RenderData> sliceImage(data, p_3dSliceImageId.getValue());
ScopedTypedData<RenderData> drrFullImage(data, p_drrFullImageId.getValue());
ScopedTypedData<RenderData> drrClippedImage(data, p_drrClippedImageId.getValue());
if (xRayImage != 0 && sliceImage != 0 && drrFullImage != 0 && drrClippedImage != 0) {
_shader->activate();
tgt::TextureUnit xRayColorUnit, xRayDepthUnit, sliceColorUnit, sliceDepthUnit, drrFullUnit, drrClippedUnit;
xRayImage->bind(_shader, xRayColorUnit, xRayDepthUnit, "_xRayColor", "_xRayDepth", "_xRayTexParams");
sliceImage->bind