2.12.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

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