void GeometryRendererDemo::init() {
        AutoEvaluationPipeline::init();

        // load textureData from file
        cgt::TextureReaderTga trt;
        cgt::Texture* campTexture = trt.loadTexture(ShdrMgr.completePath("/modules/vis/sampledata/camplogo.tga"), cgt::Texture::LINEAR);
        ImageData* textureData = new ImageData(2, campTexture->getDimensions(), campTexture->getNumChannels());
        ImageRepresentationGL::create(textureData, campTexture);
        getDataContainer().addData("CampTexture", textureData);

        // connect slots
        _geometryReader.s_validated.connect(this, &GeometryRendererDemo::onProcessorValidated);

        // create Teapot
        auto teapot = GeometryDataFactory::createTeapot();
        teapot->applyTransformationToVertices(cgt::mat4::createTranslation(cgt::vec3(5.f, 10.f, 5.f)) * cgt::mat4::createScale(cgt::vec3(16.f)));
        getDataContainer().addData("teapot", teapot.release());

        // create cube
        auto cube = GeometryDataFactory::createCube(cgt::Bounds(cgt::vec3(7.f), cgt::vec3(9.f)), cgt::Bounds(cgt::vec3(0.f), cgt::vec3(1.f)));
        getDataContainer().addData("cube", cube.release());

        // setup pipeline
        _geometryReader.p_url.setValue(ShdrMgr.completePath("/modules/vis/sampledata/left_ventricle_mesh.vtk"));
        _geometryReader.p_targetImageID.setValue("reader.output");

        _lvRenderer.p_geometryID.setValue("reader.output");
        _lvRenderer.p_renderTargetID.setValue("lv.render");
        _lvRenderer.p_renderMode.selectById("triangles");
        _lvRenderer.p_solidColor.setValue(cgt::vec4(0.8f, 0.f, 0.f, .9f));

        _teapotRenderer.p_geometryID.setValue("teapot");
        _teapotRenderer.p_renderTargetID.setValue("teapot.render");
        _teapotRenderer.p_renderMode.selectById("trianglestrip");
        _teapotRenderer.p_showWireframe.setValue(false);
        _teapotRenderer.p_solidColor.setValue(cgt::vec4(1.f, 0.5f, 0.f, 1.f));
    
        _cubeRenderer.p_geometryID.setValue("cube");
        _cubeRenderer.p_renderTargetID.setValue("cube.render");
        _cubeRenderer.p_renderMode.selectById("trianglefan");
        _cubeRenderer.p_showWireframe.setValue(false);
        _cubeRenderer.p_textureID.setValue("CampTexture");
        _cubeRenderer.p_coloringMode.selectByOption(GeometryRenderer::TEXTURE_COLOR);

        _compositor1.p_firstImageId.setValue("lv.render");
        _compositor1.p_secondImageId.setValue("teapot.render");
        _compositor1.p_compositingMethod.selectById("depth");
        _compositor1.p_targetImageId.setValue("combine1");
        _compositor1.p_enableBackground.setValue(false);

        _compositor2.p_firstImageId.setValue("combine1");
        _compositor2.p_secondImageId.setValue("cube.render");
        _compositor2.p_compositingMethod.selectById("depth");
        _compositor2.p_targetImageId.setValue("combine2");

        _renderTargetID.setValue("combine2");
    }
void MeshRenderProcessorGLSR::setNearFarPlane() {
    if (!inport_.hasData()) return;

    auto geom = inport_.getData();

    auto posBuffer =
        dynamic_cast<const Vec3BufferRAM*>(geom->getBuffer(0)->getRepresentation<BufferRAM>());

    if (posBuffer == nullptr) return;

    auto pos = posBuffer->getDataContainer();

    if (pos->empty()) return;

    float nearDist, farDist;
    nearDist = std::numeric_limits<float>::infinity();
    farDist = 0;
    vec3 nearPos, farPos;
    vec3 camPos = (geom->getCoordinateTransformer().getWorldToModelMatrix() *
                   vec4(camera_.getLookFrom(), 1.0))
                      .xyz();
    for (auto& po : *pos) {
        auto d = glm::distance2(po, camPos);
        if (d < nearDist) {
            nearDist = d;
            nearPos = po;
        }
        if (d > farDist) {
            farDist = d;
            farPos = po;
        }
    }

    mat4 m = camera_.viewMatrix() * geom->getCoordinateTransformer().getModelToWorldMatrix();

    camera_.setNearPlaneDist(std::max(0.0f, 0.99f * std::abs((m * vec4(nearPos, 1.0f)).z)));
    camera_.setFarPlaneDist(std::max(0.0f, 1.01f * std::abs((m * vec4(farPos, 1.0f)).z)));
}
 void ViscontestDemo::executePipeline() {
     AutoEvaluationPipeline::executePipeline();
     _horizontalSplitter.render(getDataContainer());
 }