Starting from 2021-07-01, all LRZ GitLab users will be required to explicitly accept the GitLab Terms of Service. Please see the detailed information at https://doku.lrz.de/display/PUBLIC/GitLab and make sure that your projects conform to the requirements.

Commit c2e5178b authored by schultezub's avatar schultezub
Browse files

* further work on DRRRaycaster

 * fixed ImageDataRenderTarget::bind()
 * fixed InvalidationLevel

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@224 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent 0c21a2ad
......@@ -127,20 +127,21 @@ namespace TUMVis {
_depthTexture->bind();
}
void ImageDataRenderTarget::bind(tgt::Shader* shader, const tgt::TextureUnit* colorTexUnit, const tgt::TextureUnit* depthTexUnit, const std::string& colorTexUniform /*= "_colorTexture"*/, const std::string& depthTexUniform /*= "_depthTexture"*/, const std::string& textureParametersUniform /*= "_textureParameters"*/) const {
if (colorTexUnit != 0)
bindColorTexture(*colorTexUnit);
if (depthTexUnit != 0)
bindDepthTexture(*depthTexUnit);
void ImageDataRenderTarget::bind(tgt::Shader* shader, const tgt::TextureUnit* colorTexUnit, const tgt::TextureUnit* depthTexUnit, const std::string& colorTexUniform /*= "_colorTexture"*/, const std::string& depthTexUniform /*= "_depthTexture"*/) const {
bool tmp = shader->getIgnoreUniformLocationError();
shader->setIgnoreUniformLocationError(true);
if (colorTexUnit != 0)
shader->setUniform(colorTexUniform, colorTexUnit->getUnitNumber());
if (depthTexUnit != 0)
shader->setUniform(depthTexUniform, depthTexUnit->getUnitNumber());
shader->setUniform(textureParametersUniform + "._size", tgt::vec2(_size.xy()));
shader->setUniform(textureParametersUniform + "._sizeRCP", tgt::vec2(1.f) / tgt::vec2(_size.xy()));
if (colorTexUnit != 0) {
bindColorTexture(*colorTexUnit);
shader->setUniform(colorTexUniform + "._texture", colorTexUnit->getUnitNumber());
shader->setUniform(colorTexUniform + "._size", tgt::vec2(_size.xy()));
shader->setUniform(colorTexUniform + "._sizeRCP", tgt::vec2(1.f) / tgt::vec2(_size.xy()));
}
if (depthTexUnit != 0) {
bindDepthTexture(*depthTexUnit);
shader->setUniform(depthTexUniform + "._texture", colorTexUnit->getUnitNumber());
shader->setUniform(depthTexUniform + "._size", tgt::vec2(_size.xy()));
shader->setUniform(depthTexUniform + "._sizeRCP", tgt::vec2(1.f) / tgt::vec2(_size.xy()));
}
shader->setIgnoreUniformLocationError(tmp);
}
......
......@@ -90,17 +90,15 @@ namespace TUMVis {
* \param shader Shader to set the uniforms to.
* \param colorTexUnit Pointer to color texture unit, may be 0.
* \param depthTexUnit Pointer to depth texture unit, may be 0.
* \param colorTexUniform Name for color texture unit uniform.
* \param depthTexUniform Name for depth texture unit uniform.
* \param textureParametersUniform Name for texture parameters uniform.
* \param colorTexUniform Name for color texture struct uniform.
* \param depthTexUniform Name for depth texture struct uniform.
*/
void bind(
tgt::Shader* shader,
const tgt::TextureUnit* colorTexUnit,
const tgt::TextureUnit* depthTexUnit,
const std::string& colorTexUniform = "_colorTexture",
const std::string& depthTexUniform = "_depthTexture",
const std::string& textureParametersUniform = "_textureParameters") const;
const std::string& depthTexUniform = "_depthTexture") const;
protected:
......
#include "visualizationpipeline.h"
#include "tgt/tgt_gl.h"
#include "tgt/glcanvas.h"
#include "tgt/glcontext.h"
#include "core/datastructures/imagedatarendertarget.h"
......@@ -73,7 +74,8 @@ namespace TUMVis {
tgtAssert(_canvas != 0, "Set a valid canvas before calling this method!");
tgt::GLContextScopedLock lock(_canvas->getContext());
executeProcessor(processor);
glFlush(); // TODO: is glFlush enough or do we need a glFinish here?
glFinish(); // TODO: is glFlush enough or do we need a glFinish here?
LGL_ERROR;
}
void VisualizationPipeline::setCanvas(tgt::GLCanvas* canvas) {
......
......@@ -44,11 +44,11 @@ namespace TUMVis {
}
bool isInvalidResult() const {
return _level == static_cast<int>(INVALID_RESULT);
return (_level & static_cast<int>(INVALID_RESULT)) != 0;
}
bool isInvalidShader() const {
return _level == static_cast<int>(INVALID_SHADER);
return (_level & static_cast<int>(INVALID_SHADER)) != 0;
}
......
......@@ -41,7 +41,6 @@ namespace TUMVis {
_eepGenerator._exitImageID.setValue("eep.exit");
_renderTargetID.setValue("drr.output");
//_renderTargetID.addSharedProperty(&(_eepGenerator._entryImageID));
_imageReader.s_invalidated.connect<DVRVis>(this, &DVRVis::onProcessorInvalidated);
_eepGenerator.s_invalidated.connect<DVRVis>(this, &DVRVis::onProcessorInvalidated);
......@@ -70,15 +69,13 @@ namespace TUMVis {
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());
/* tgt::Camera cam(pos, volumeExtent.center());
cam.setFarDist(500.f);
_eepGenerator._camera.setValue(cam);*/
}
}
if (! _eepGenerator.getInvalidationLevel().isValid()) {
lockGLContextAndExecuteProcessor(_eepGenerator);
lockGLContextAndExecuteProcessor(_drrraycater);
}
if (! _drrraycater.getInvalidationLevel().isValid()) {
if (! _eepGenerator.getInvalidationLevel().isValid() || !_drrraycater.getInvalidationLevel().isValid()) {
lockGLContextAndExecuteProcessor(_drrraycater);
}
}
......
......@@ -45,7 +45,10 @@ namespace TUMVis {
void DRRRaycaster::init() {
VisualizationProcessor::init();
// _shader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "core/glsl/copyimage.frag", "", false);
_shader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "modules/vis/drrraycaster.frag", "", false);
_shader->setHeaders(generateHeader());
_shader->rebuild();
}
void DRRRaycaster::deinit() {
......@@ -66,28 +69,31 @@ namespace TUMVis {
_shader->rebuild();
}
ImageDataRenderTarget* output = new ImageDataRenderTarget(tgt::svec3(_renderTargetSize.getValue(), 1));
ImageDataRenderTarget* rt = new ImageDataRenderTarget(tgt::svec3(_renderTargetSize.getValue(), 1));
_shader->activate();
_shader->setUniform("_viewportSizeRCP", 1.f / tgt::vec2(_renderTargetSize.getValue()));
_shader->setUniform("_samplingStepSize", _samplingStepSize.getValue());
_shader->setUniform("_shift", _shift.getValue());
_shader->setUniform("_scale", _scale.getValue());
tgt::TextureUnit volumeUnit, entryUnit, exitUnit, tfUnit;
img->bind(_shader, volumeUnit, "_volume");
entryPoints->bind(_shader, &entryUnit, 0, "_entryPoints", "", "_entryParameters");
exitPoints->bind(_shader, &exitUnit, 0, "_exitPoints", "", "_exitParameters");
entryPoints->bind(_shader, &entryUnit, 0, "_entryPoints");
exitPoints->bind(_shader, &exitUnit, 0, "_exitPoints");
_transferFunction.getTF()->bind(_shader, tfUnit);
output->activate();
rt->activate();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
LGL_ERROR;
tgt::QuadRenderer::renderQuad();
output->deactivate();
LGL_ERROR;
rt->deactivate();
_shader->deactivate();
tgt::TextureUnit::setZeroUnit();
data.addData(_targetImageID.getValue(), output);
data.addData(_targetImageID.getValue(), rt);
}
else {
LERROR("Input image must have dimensionality of 3.");
......
......@@ -2,7 +2,6 @@
#include "tools/texture3d.frag"
#include "tools/transferfunction.frag"
uniform vec2 _viewportSize;
uniform vec2 _viewportSizeRCP;
uniform Texture2D _entryPoints; // ray entry points
......@@ -99,8 +98,8 @@ vec4 raycastDRR(in vec3 first, in vec3 last, vec2 p) {
***/
void main() {
vec2 p = gl_FragCoord.xy * _viewportSizeRCP;
vec3 frontPos = getElement2D(_entryPoints, p).rgb;
vec3 backPos = getElement2D(_exitPoints, p).rgb;
vec3 frontPos = getElement2DNormalized(_entryPoints, p).rgb;
vec3 backPos = getElement2DNormalized(_exitPoints, p).rgb;
//determine whether the ray has to be casted
if (frontPos == backPos) {
......
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