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 aeacb03d authored by schultezub's avatar schultezub
Browse files

fixed VizalizationPipeline shaders and shader setup

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@187 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent d54511ca
#include "tgt/camera.h"
#include "tgt/exception.h"
#include "tgt/shadermanager.h"
#include "tgt/qt/qtapplication.h"
#include "tgt/qt/qtcanvas.h"
......@@ -18,22 +20,40 @@ using namespace TUMVis;
int main(int argc, char** argv) {
tgt::QtApplication* app = new tgt::QtApplication(argc, argv);
tgt::QtCanvas* canvas = new tgt::QtCanvas("TUMVis");
SliceVis* sliceVis = 0;
app->addCanvas(canvas);
app->init();
if (argc > 0) {
// ugly hack
std::string programPath(argv[0]);
programPath = tgt::FileSystem::parentDir(tgt::FileSystem::parentDir(tgt::FileSystem::parentDir(programPath)));
ShdrMgr.addPath(programPath);
ShdrMgr.addPath(programPath + "/core/glsl");
}
tgt::Camera camera;
canvas->setCamera(&camera);
//SliceVis sliceVis(canvas);
//canvas->setPainter(&sliceVis);
TumVisPainter painter(canvas);
canvas->setPainter(&painter);
try {
sliceVis = new SliceVis(canvas);
canvas->setPainter(sliceVis);
// TumVisPainter painter(canvas);
// canvas->setPainter(&painter);
}
catch (tgt::Exception& e) {
LERRORC("main.cpp", "Encountered tgt::Exception: " << e.what());
}
catch (std::exception& e) {
LERRORC("main.cpp", "Encountered std::exception: " << e.what());
}
app->run();
app->run();
delete canvas;
delete sliceVis;
delete canvas;
delete app;
return 0;
......
......@@ -127,8 +127,8 @@ namespace TUMVis {
void ImageDataRenderTarget::bind(tgt::Shader* shader, GLint colorTexUnit /*= GL_TEXTURE0*/, GLint depthTexUnit /*= GL_TEXTURE1*/, const std::string& colorTexUniform /*= "_colorTexture"*/, const std::string& depthTexUniform /*= "_depthTexture"*/, const std::string& textureParametersUniform /*= "_textureParameters"*/) const {
bindColorTexture(colorTexUnit);
bindDepthTexture(depthTexUnit);
shader->setUniform(colorTexUniform, 0);
shader->setUniform(depthTexUniform, 1);
shader->setUniform(colorTexUniform, colorTexUnit - GL_TEXTURE0);
shader->setUniform(depthTexUniform, depthTexUnit - GL_TEXTURE0);
shader->setUniform(textureParametersUniform + "._size", tgt::vec2(_size.xy()));
shader->setUniform(textureParametersUniform + "._sizeRCP", tgt::vec2(1.f) / tgt::vec2(_size.xy()));
}
......
......@@ -6,7 +6,7 @@ uniform sampler2D _depthTexture;
uniform TextureParameters _textureParameters;
void main() {
vec2 fragCoord = gl_FragCoord.xy * screenDimRCP_;
vec2 fragCoord = gl_FragCoord.xy * _viewportSizeRCP;
gl_FragData[0] = getElement2DNormalized(_colorTexture, _textureParameters, fragCoord);
gl_FragDepth = getElement2DNormalized(_depthTexture, _textureParameters, fragCoord).z;
}
uniform _viewportSize;
uniform _viewportSizeRCP;
uniform vec2 _viewportSize;
uniform vec2 _viewportSizeRCP;
struct TextureParameters {
vec2 _size;
......@@ -10,14 +10,14 @@ struct TextureParameters {
// Texture lookup function for 2D textures,
// expecting texture coordinates as pixel coordinates, i.e, [(0,0) , textureSize].
vec4 getElement2D(in sampler2D myTexture, in TextureParameters texParams, in vec2 texCoords) {
vec2 texCoordsNormalized = texCoords * texParams.dimensionsRCP_;
vec2 texCoordsTransformed = (texParams.matrix_ * vec4(texCoordsNormalized, 0.0, 1.0)).xy;
return texture2D(myTexture, texCoordsTransformed);
vec2 texCoordsNormalized = texCoords * texParams._sizeRCP;
//vec2 texCoordsTransformed = (texParams.matrix_ * vec4(texCoordsNormalized, 0.0, 1.0)).xy;
return texture2D(myTexture, texCoordsNormalized);
}
// Texture lookup function for 2D textures,
// expecting normalized texture coordinates, i.e., [0,1].
vec4 getElement2DNormalized(in sampler2D myTexture, in TextureParameters texParams, in vec2 texCoords) {
vec2 texCoordsTransformed = (texParams.matrix_ * vec4(texCoords, 0.0, 1.0)).xy;
return texture2D(myTexture, texCoordsTransformed);
//vec2 texCoordsTransformed = (texParams.matrix_ * vec4(texCoords, 0.0, 1.0)).xy;
return texture2D(myTexture, texCoords);
}
......@@ -79,6 +79,7 @@ namespace TUMVis {
// TODO: render some nifty error texture
// so long, we do some dummy rendering
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
getCamera()->setPosition(tgt::vec3(0.f,0.f,2.f));
getCamera()->look();
glColor3f(1.f, 0.f, 0.f);
tgt::Sphere sphere(.5f, 64, 32);
......
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