Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit 7fa2684d authored by schultezub's avatar schultezub
Browse files

* added CameraProperty to RaycastingProcessor

 * fixed depth calculation in SimpleRaycaster

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@235 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent 2c074ac7
......@@ -41,7 +41,7 @@ using namespace TUMVis;
**/
int main(int argc, char** argv) {
TumVisApplication app(argc, argv);
app.addVisualizationPipeline("SliceVis", new SliceVis());
//app.addVisualizationPipeline("SliceVis", new SliceVis());
app.addVisualizationPipeline("DVRVis", new DVRVis());
app.init();
......
......@@ -69,7 +69,59 @@ float depthViewportToEye(in float depth) {
* \return The interpolated depth value.
*/
float interpolateDepthViewport(in float ratio, in float startDepth, in float endDepth) {
float startEye = depthViewportToEye(startDepth);
float endEye = depthViewportToEye(endDepth);
return depthEyeToViewport(startEye + ratio*(endEye - startEye));
float startEye = depthViewportToEye(startDepth);
float endEye = depthViewportToEye(endDepth);
return depthEyeToViewport(startEye + ratio*(endEye - startEye));
}
// FIXME: Because for some reason the above code does not work, I simply copy and pasted Voreens depth calculation.
// This is not nice.
uniform float const_to_z_w_1;
uniform float const_to_z_w_2;
uniform float const_to_z_e_1;
uniform float const_to_z_e_2;
/**
* Calculates the depth value for the current sample specified by the parameter t.
**/
float calculateDepthValue(float t, float entryPointsDepth, float exitPointsDepth) {
/*
Converting eye coordinate depth values to windows coordinate depth values:
(see http://www.opengl.org/resources/faq/technical/depthbuffer.htm 12.050, assuming w_e = 1)
z_w = (1.0/z_e)*((f*n)/(f-n)) + 0.5*((f+n)/(f-n))+0.5; (f=far plane, n=near plane)
We calculate constant terms outside:
const_to_z_w_1 = ((f*n)/(f-n))
const_to_z_w_2 = 0.5*((f+n)/(f-n))+0.5
Converting windows coordinates to eye coordinates:
z_e = 1.0/([z_w - 0.5 - 0.5*((f+n)/(f-n))]*((f-n)/(f*n)));
with constant terms
const_to_z_e_1 = 0.5 + 0.5*((f+n)/(f-n))
const_to_z_e_2 = ((f-n)/(f*n))
*/
// assign front value given in windows coordinates
float zw_front = entryPointsDepth;
// and convert it into eye coordinates
float ze_front = 1.0/((zw_front - const_to_z_e_1)*const_to_z_e_2);
// assign back value given in windows coordinates
float zw_back = exitPointsDepth;
// and convert it into eye coordinates
float ze_back = 1.0/((zw_back - const_to_z_e_1)*const_to_z_e_2);
// interpolate in eye coordinates
float ze_current = ze_front + t*(ze_back-ze_front);
// convert back to window coordinates
float zw_current = (1.0/ze_current)*const_to_z_w_1 + const_to_z_w_2;
return zw_current;
}
\ No newline at end of file
......@@ -48,6 +48,7 @@ namespace TUMVis {
, _sourceImageID("sourceImageID", "Input Image", "")
, _entryImageID("entryImageID", "Output Entry Points Image", "")
, _exitImageID("exitImageID", "Output Exit Points Image", "")
, _camera("camera", "Camera")
, _transferFunction("transferFunction", "Transfer Function", new SimpleTransferFunction(256))
, _samplingStepSize("samplingStepSize", "Sampling Step Size", .1f, 0.001f, 1.f)
, _jitterEntryPoints("jitterEntryPoints", "Jitter Entry Points", true)
......@@ -58,6 +59,7 @@ namespace TUMVis {
addProperty(&_sourceImageID);
addProperty(&_entryImageID);
addProperty(&_exitImageID);
addProperty(&_camera);
addProperty(&_transferFunction);
addProperty(&_samplingStepSize);
addProperty(&_jitterEntryPoints);
......@@ -94,10 +96,22 @@ namespace TUMVis {
glPushAttrib(GL_ALL_ATTRIB_BITS);
_shader->activate();
_shader->setIgnoreUniformLocationError(true);
_shader->setUniform("_viewportSizeRCP", 1.f / tgt::vec2(_renderTargetSize.getValue()));
_shader->setUniform("_jitterEntryPoints", _jitterEntryPoints.getValue());
_shader->setUniform("_samplingStepSize", _samplingStepSize.getValue());
const tgt::Camera& cam = _camera.getValue();
float n = cam.getNearDist();
float f = cam.getFarDist();
_shader->setUniform("const_to_z_e_1", 0.5f + 0.5f*((f+n)/(f-n)));
_shader->setUniform("const_to_z_e_2", ((f-n)/(f*n)));
_shader->setUniform("const_to_z_w_1", ((f*n)/(f-n)));
_shader->setUniform("const_to_z_w_2", 0.5f*((f+n)/(f-n))+0.5f);
_shader->setIgnoreUniformLocationError(false);
tgt::TextureUnit volumeUnit, entryUnit, exitUnit, tfUnit;
img->bind(_shader, volumeUnit, "_volume");
_transferFunction.getTF()->bind(_shader, tfUnit);
......
......@@ -32,6 +32,7 @@
#include <string>
#include "core/pipeline/visualizationprocessor.h"
#include "core/properties/cameraproperty.h"
#include "core/properties/genericproperty.h"
#include "core/properties/numericproperty.h"
#include "core/properties/transferfunctionproperty.h"
......@@ -98,6 +99,7 @@ namespace TUMVis {
GenericProperty<std::string> _entryImageID; ///< image ID for output entry points image
GenericProperty<std::string> _exitImageID; ///< image ID for output exit points image
CameraProperty _camera; ///< Camera used for ray casting
TransferFunctionProperty _transferFunction; ///< Transfer function
FloatProperty _samplingStepSize; ///< Ray casting step size
BoolProperty _jitterEntryPoints; ///< Flag whether to jitter the entry points
......
......@@ -36,13 +36,21 @@ namespace TUMVis {
DVRVis::DVRVis()
: VisualizationPipeline()
, _camera("camera", "Camera")
, _imageReader()
, _eepGenerator(_renderTargetSize)
, _drrraycater(_renderTargetSize)
, _simpleRaycaster(_renderTargetSize)
, _trackballEH(0)
{
_trackballEH = new TrackballNavigationEventHandler(&_eepGenerator._camera, _renderTargetSize.getValue());
addProperty(&_camera);
// TODO: remove this ugly hack: automatically adapt near/far plane to volume extent.
tgt::Camera c;
c.setFarDist(512.f);
_camera.setValue(c);
_trackballEH = new TrackballNavigationEventHandler(&_camera, _renderTargetSize.getValue());
_eventHandlers.push_back(_trackballEH);
_processors.push_back(&_imageReader);
......@@ -58,6 +66,10 @@ namespace TUMVis {
void DVRVis::init() {
VisualizationPipeline::init();
_camera.addSharedProperty(&_eepGenerator._camera);
_camera.addSharedProperty(&_drrraycater._camera);
_camera.addSharedProperty(&_simpleRaycaster._camera);
_imageReader._url.setValue("D:\\Medical Data\\smallHeart.mhd");
_imageReader._targetImageID.setValue("reader.output");
......@@ -76,12 +88,13 @@ namespace TUMVis {
_eepGenerator._entryImageID.setValue("eep.entry");
_eepGenerator._exitImageID.setValue("eep.exit");
_renderTargetID.setValue("drr.output");
_renderTargetID.setValue("dvr.output");
_imageReader.s_invalidated.connect<DVRVis>(this, &DVRVis::onProcessorInvalidated);
_eepGenerator.s_invalidated.connect<DVRVis>(this, &DVRVis::onProcessorInvalidated);
_drrraycater.s_invalidated.connect<DVRVis>(this, &DVRVis::onProcessorInvalidated);
_simpleRaycaster.s_invalidated.connect<DVRVis>(this, &DVRVis::onProcessorInvalidated);
}
void DVRVis::execute() {
......@@ -105,13 +118,11 @@ namespace TUMVis {
tgt::Bounds volumeExtent = img->getWorldBounds();
tgt::vec3 pos = volumeExtent.center() - tgt::vec3(0, 0, tgt::length(volumeExtent.diagonal()));
_trackballEH->setCenter(volumeExtent.center());
_trackballEH->reinitializeCamera(pos, volumeExtent.center(), _eepGenerator._camera.getValue().getUpVector());
_trackballEH->reinitializeCamera(pos, volumeExtent.center(), _camera.getValue().getUpVector());
}
}
if (! _eepGenerator.getInvalidationLevel().isValid()) {
lockGLContextAndExecuteProcessor(_eepGenerator);
lockGLContextAndExecuteProcessor(_drrraycater);
lockGLContextAndExecuteProcessor(_simpleRaycaster);
}
if (! _eepGenerator.getInvalidationLevel().isValid() || !_drrraycater.getInvalidationLevel().isValid()) {
lockGLContextAndExecuteProcessor(_drrraycater);
......
......@@ -32,6 +32,7 @@
#include "core/datastructures/imagedatalocal.h"
#include "core/eventhandlers/trackballnavigationeventhandler.h"
#include "core/pipeline/visualizationpipeline.h"
#include "core/properties/cameraproperty.h"
#include "modules/io/mhdimagereader.h"
#include "modules/vis/eepgenerator.h"
#include "modules/vis/drrraycaster.h"
......@@ -62,6 +63,7 @@ namespace TUMVis {
virtual void execute();
protected:
CameraProperty _camera;
MhdImageReader _imageReader;
EEPGenerator _eepGenerator;
DRRRaycaster _drrraycater;
......
......@@ -52,11 +52,6 @@ namespace TUMVis {
addProperty(&_entryImageID);
addProperty(&_exitImageID);
addProperty(&_camera);
// TODO: remove this ugly hack: automatically adapt near/far plane to volume extent.
tgt::Camera c;
c.setFarDist(512.f);
_camera.setValue(c);
}
EEPGenerator::~EEPGenerator() {
......
......@@ -92,11 +92,11 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords)
// calculate depth value from ray parameter
gl_FragDepth = 1.0;
//if (firstHitT >= 0.0) {
//float depthEntry = getElement2DNormalized(_entryPointsDepth, texCoords).z;
//float depthExit = getElement2DNormalized(_exitPointsDepth, texCoords).z;
//gl_FragDepth = interpolateDepthViewport(firstHitT/tend, depthEntry, depthExit);
//}
if (firstHitT >= 0.0) {
float depthEntry = getElement2DNormalized(_entryPointsDepth, texCoords).z;
float depthExit = getElement2DNormalized(_exitPointsDepth, texCoords).z;
gl_FragDepth = calculateDepthValue(firstHitT/tend, depthEntry, depthExit);
}
return result;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment