Notice to GitKraken users: A vulnerability has been found in the SSH key generation of GitKraken versions 7.6.0 to 8.0.0 (https://www.gitkraken.com/blog/weak-ssh-key-fix). If you use GitKraken and have generated a SSH key using one of these versions, please remove it both from your local workstation and from your LRZ GitLab profile.

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

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

further work on Columbia module / introducing GeometryStrainRenderer stub

parent c862eaac
......@@ -109,9 +109,7 @@ namespace campvis {
vao.addVertexAttribute(tgt::VertexArrayObject::ColorsAttribute, _colorsBuffer);
if (_normalsBuffer)
vao.addVertexAttribute(tgt::VertexArrayObject::NormalsAttribute, _normalsBuffer);
vao.setIndexBuffer(_indicesBuffer);
LGL_ERROR;
vao.bindIndexBuffer(_indicesBuffer);
glDrawElements(mode, static_cast<GLsizei>(_indices.size()), GL_UNSIGNED_SHORT, 0);
LGL_ERROR;
......
......@@ -43,6 +43,7 @@ struct TextureParameters3D {
// Transformation matrices
mat4 _textureToWorldMatrix;
mat4 _worldToTextureMatrix;
vec2 _realWorldMapping;
};
......@@ -83,6 +84,17 @@ vec4 textureToWorld(in TextureParameters3D texParams, in vec3 texCoords) {
return texParams._textureToWorldMatrix * vec4(texCoords, 1.0);
}
/**
* Transforms world coordinates for texture \a tex to texture coordinates using the texture's
* world-to-texture matrix.
* \param texParams TextureParameters3D struct with texture for lookup
* \param worldCoords world coordinates
* \return \a texCoords transformes to texture coordinates.
*/
vec4 worldToTexture(in TextureParameters3D texParams, in vec3 worldCoords) {
return texParams._worldToTextureMatrix * vec4(worldCoords, 1.0);
}
float applyRealWorldMapping(in TextureParameters3D tex, in float value) {
return (value + tex._realWorldMapping.x) * tex._realWorldMapping.y;
}
......
......@@ -70,7 +70,7 @@ namespace tgt {
// }
}
void VertexArrayObject::setIndexBuffer(BufferObject* bufferObject) {
void VertexArrayObject::bindIndexBuffer(BufferObject* bufferObject) {
tgtAssert(bufferObject->getTargetType() == BufferObject::ELEMENT_ARRAY_BUFFER, "Buffer needs to have target type ELEMENT_ARRAY_BUFFER!");
bind();
......
......@@ -90,7 +90,11 @@ namespace tgt {
*/
void unbind();
void setIndexBuffer(BufferObject* bufferObject);
/**
* Binds the provided buffer \a bufferObject as index buffer to this VAO.
* \param bufferObject Buffer to use as element index buffer.
*/
void bindIndexBuffer(BufferObject* bufferObject);
/**
* Add a VertexAttribute to this VertexArrayObject.
......
// ================================================================================================
//
// 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 "tools/shading.frag"
#include "tools/texture3d.frag"
in vec3 ex_TexCoord; ///< incoming texture coordinate
in vec4 ex_Position; ///< incoming texture coordinate
out vec4 out_Color; ///< outgoing fragment color
uniform vec4 _color;
uniform LightSource _lightSource;
uniform vec3 _cameraPosition;
uniform sampler3D _strainTexture;
uniform TextureParameters3D _textureParameters;
void main() {
out_Color = _color;
vec3 worldCoords = ex_Position.xyz / ex_Position.z;
vec3 texCoords = worldToTexture(_textureParameters, worldCoords);
out_Color = getElement3DNormalized(_strainTexture, _textureParameters, texCoords);
while (length(out_Color) == 0.0) {
worldCoords -= normalize(ex_TexCoord) * 0.1;
texCoords = worldToTexture(_textureParameters, worldCoords);
out_Color = getElement3DNormalized(_strainTexture, _textureParameters, texCoords);
}
#ifdef ENABLE_SHADING
// compute gradient (needed for shading and normals)
vec3 gradient = ex_TexCoord;
out_Color.rgb = calculatePhongShading(ex_Position.xyz / ex_Position.z, _lightSource, _cameraPosition, gradient, _color.rgb, _color.rgb, vec3(1.0, 1.0, 1.0));
#endif
}
......@@ -95,7 +95,8 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords)
// lookup intensity and TF
vec4 strain = getElement3DNormalized(_volume, _volumeTextureParams, samplePosition);
vec4 color = (_volumeTextureParams._numChannels == 4) ? strain : vec4(strain.xyz, 0.2);
vec4 color = (_volumeTextureParams._numChannels == 4) ? strain : vec4(strain.xyz, 0.0);
color.a = clamp(length(strain.xyz)/1.0, 0.0, 1.0);
#ifdef ENABLE_ADAPTIVE_STEPSIZE
if (color.a <= 0.0) {
......@@ -114,7 +115,8 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords)
// lookup refined intensity + TF
vec4 newStrain = getElement3DNormalized(_volume, _volumeTextureParams, newSamplePosition);
vec4 newColor = (_volumeTextureParams._numChannels == 4) ? newStrain : vec4(newStrain.xyz, 0.2);
vec4 newColor = (_volumeTextureParams._numChannels == 4) ? newStrain : vec4(newStrain.xyz, 0.0);
newColor.a = clamp(length(newColor.xyz)/1.0, 0.0, 1.0);
if (newColor.a <= 0.0) {
// we're back in the void - look on the right-hand side
......
......@@ -37,11 +37,12 @@
#include "modules/io/processors/ltfimagereader.h"
#include "modules/io/processors/vtkimagereader.h"
#include "modules/columbia/processors/geometrystrainrenderer.h"
#include "modules/columbia/processors/imageseriessplitter.h"
#include "modules/columbia/processors/strainraycaster.h"
#include "modules/vis/processors/geometryrenderer.h"
#include "modules/vis/processors/sliceextractor.h"
#include "modules/vis/processors/volumerenderer.h"
#include "modules/vis/processors/geometryrenderer.h"
namespace campvis {
class Columbia1 : public VisualizationPipeline {
......
// ================================================================================================
//
// 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 Universitt Mnchen
// Boltzmannstr. 3, 85748 Garching b. Mnchen, 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 "geometrystrainrenderer.h"
#include "tgt/glmath.h"
#include "tgt/logmanager.h"
#include "tgt/shadermanager.h"
#include "tgt/textureunit.h"
#include "core/datastructures/imagedata.h"
#include "core/datastructures/imagerepresentationgl.h"
#include "core/datastructures/imagerepresentationrendertarget.h"
#include "core/datastructures/meshgeometry.h"
#include "core/pipeline/processordecoratorshading.h"
namespace campvis {
const std::string GeometryStrainRenderer::loggerCat_ = "CAMPVis.modules.vis.GeometryStrainRenderer";
GeometryStrainRenderer::GeometryStrainRenderer(IVec2Property& canvasSize)
: VisualizationProcessor(canvasSize)
, p_geometryID("geometryID", "Input Geometry ID", "gr.geometry", DataNameProperty::READ)
, p_strainId("StrainDataId", "Input Strain Data ID", "gr.strain", DataNameProperty::READ)
, p_renderTargetID("p_renderTargetID", "Output Image", "gr.output", DataNameProperty::WRITE)
, p_camera("camera", "Camera")
, p_color("color", "Rendering Color", tgt::vec4(1.f), tgt::vec4(0.f), tgt::vec4(1.f))
, _shader(0)
{
addDecorator(new ProcessorDecoratorShading());
addProperty(&p_geometryID);
addProperty(&p_renderTargetID);
addProperty(&p_camera);
addProperty(&p_color);
decoratePropertyCollection(this);
}
GeometryStrainRenderer::~GeometryStrainRenderer() {
}
void GeometryStrainRenderer::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "modules/vis/glsl/geometrystrainrenderer.frag", "", false);
if (_shader != 0) {
_shader->setAttributeLocation(0, "in_Position");
}
}
void GeometryStrainRenderer::deinit() {
ShdrMgr.dispose(_shader);
_shader = 0;
VisualizationProcessor::deinit();
}
void GeometryStrainRenderer::process(DataContainer& data) {
DataContainer::ScopedTypedData<GeometryData> proxyGeometry(data, p_geometryID.getValue());
ImageRepresentationGL::ScopedRepresentation strainData(data, p_strainId.getValue());
if (proxyGeometry != 0 && strainData != 0 && _shader != 0) {
if (hasInvalidShader()) {
_shader->setHeaders(generateGlslHeader());
_shader->rebuild();
validate(INVALID_SHADER);
}
// set modelview and projection matrices
_shader->activate();
decorateRenderProlog(data, _shader);
_shader->setUniform("_projectionMatrix", p_camera.getValue().getProjectionMatrix());
_shader->setUniform("_viewMatrix", p_camera.getValue().getViewMatrix());
_shader->setUniform("_color", p_color.getValue());
tgt::TextureUnit strainUnit;
strainData->bind(_shader, strainUnit, "_strainTexture");
// create entry points texture
std::pair<ImageData*, ImageRepresentationRenderTarget*> rt = ImageRepresentationRenderTarget::createWithImageData(_renderTargetSize.getValue(), GL_RGBA16);
rt.second->activate();
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glClearDepth(1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
proxyGeometry->render();
rt.second->deactivate();
decorateRenderEpilog(_shader);
_shader->deactivate();
glDisable(GL_DEPTH_TEST);
LGL_ERROR;
data.addData(p_renderTargetID.getValue(), rt.first);
p_renderTargetID.issueWrite();
}
else {
LERROR("No suitable input geometry found.");
}
validate(INVALID_RESULT);
}
std::string GeometryStrainRenderer::generateGlslHeader() const {
std::string toReturn = getDecoratedHeader();
return toReturn;
}
}
// ================================================================================================
//
// 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 GEOMETRYSTRAINRENDERER_H__
#define GEOMETRYSTRAINRENDERER_H__
#include <string>
#include "core/pipeline/visualizationprocessor.h"
#include "core/pipeline/abstractprocessordecorator.h"
#include "core/properties/cameraproperty.h"
#include "core/properties/datanameproperty.h"
#include "core/properties/genericproperty.h"
#include "core/properties/numericproperty.h"
namespace tgt {
class Shader;
}
namespace campvis {
/**
* Genereates entry-/exit point textures for the given image and camera.
*/
class GeometryStrainRenderer : public VisualizationProcessor, public HasProcessorDecorators {
public:
/**
* Constructs a new GeometryStrainRenderer Processor
**/
GeometryStrainRenderer(IVec2Property& canvasSize);
/**
* Destructor
**/
virtual ~GeometryStrainRenderer();
/// \see AbstractProcessor::init
virtual void init();
/// \see AbstractProcessor::deinit
virtual void deinit();
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "GeometryStrainRenderer"; };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Renders Geometry."; };
virtual void process(DataContainer& data);
DataNameProperty p_geometryID; ///< ID for input geometry
DataNameProperty p_strainId; ///< ID for input strain data
DataNameProperty p_renderTargetID; ///< image ID for output image
CameraProperty p_camera;
Vec4Property p_color; ///< rendering color
protected:
/**
* Generates the GLSL header.
*/
std::string generateGlslHeader() const;
tgt::Shader* _shader; ///< Shader for EEP generation
static const std::string loggerCat_;
};
}
#endif // GEOMETRYSTRAINRENDERER_H__
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