コード例 #1
0
ファイル: depthMap.hpp プロジェクト: brunoferraz/project
    /** * @brief Render the mesh given a camera and light, using a Phong shader 
     * @param mesh Given mesh
     * @param camera Given camera 
     * @param lightTrackball Given light camera 
     */
    void render (Tucano::Mesh& mesh, const Tucano::Camera& camera, const Tucano::Camera& lightTrackball)
    {

        Eigen::Vector4f viewport = camera.getViewport();
        glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);

        depthmap_shader.bind();

        // sets all uniform variables for the phong shader
        depthmap_shader.setUniform("projectionMatrix", camera.getProjectionMatrix());
        depthmap_shader.setUniform("modelMatrix", mesh.getModelMatrix());
        depthmap_shader.setUniform("viewMatrix", camera.getViewMatrix());
        depthmap_shader.setUniform("near", 0.1);
        depthmap_shader.setUniform("far", 10000.0);

//        std::cout << "Model" << std::endl;
//        std::cout << mesh.getModelMatrix().matrix() << std::endl;

//        std::cout << "View" << std::endl;
//        std::cout << camera.getViewMatrix().matrix() << std::endl;

        mesh.setAttributeLocation(depthmap_shader);

        glEnable(GL_DEPTH_TEST);
        mesh.render();

        depthmap_shader.unbind();
    }
コード例 #2
0
ファイル: toon.hpp プロジェクト: LCG-UFRJ/tucano
    /**
     * @brief Render the mesh given a camera and light trackball, using a Toon shader
     * @param mesh Given mesh
     * @param cameraTrackball Given camera trackball
     * @param lightTrackball Given light trackball
     */
    virtual void render (Tucano::Mesh& mesh, const Tucano::Trackball& cameraTrackball, const Tucano::Trackball& lightTrackball)
	{       

        Eigen::Vector4f viewport = cameraTrackball.getViewport();
        glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);

        toon_shader.bind();

        toon_shader.setUniform("projectionMatrix", cameraTrackball.getProjectionMatrix());
        toon_shader.setUniform("modelMatrix", mesh.getModelMatrix());
        toon_shader.setUniform("viewMatrix", cameraTrackball.getViewMatrix());
        toon_shader.setUniform("lightViewMatrix", lightTrackball.getViewMatrix());
        toon_shader.setUniform("has_color", mesh.hasAttribute("in_Color"));
        toon_shader.setUniform("quantizationLevel", quantization_level);

        mesh.setAttributeLocation(toon_shader);
		mesh.render();

        toon_shader.unbind();
	}
コード例 #3
0
ファイル: normalvector.hpp プロジェクト: mseefelder/tucano
    /**
     * @brief Render the mesh given a camera trackball
     * @param mesh Given mesh
     * @param cameraTrackball Given camera trackball     
     */
	virtual void render(Tucano::Mesh& mesh, const Tucano::Camera& camera)
    {
        Eigen::Vector4f viewport = camera.getViewport();
        glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);

        normalvec_shader.bind();

        // sets all uniform variables for the phong shader
        normalvec_shader.setUniform("projectionMatrix", camera.getProjectionMatrix());
        normalvec_shader.setUniform("modelMatrix", mesh.getModelMatrix());
        normalvec_shader.setUniform("viewMatrix", camera.getViewMatrix());

        mesh.setAttributeLocation(normalvec_shader);

        glEnable(GL_DEPTH_TEST);
        mesh.render();
        glDisable(GL_DEPTH_TEST);

        normalvec_shader.unbind();
    }
コード例 #4
0
ファイル: blurrednormalmap.hpp プロジェクト: LCG-UFRJ/tucano
    /**
     * @brief Render the mesh given a camera trackball
     * @param mesh Given mesh
     * @param cameraTrackball Given camera trackball     
     */
    virtual void render (Tucano::Mesh& mesh, const Tucano::Trackball& cameraTrackball)
    {
        Eigen::Vector4f viewport = cameraTrackball.getViewport();
        glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);


        if (fbo.getWidth() != (viewport[2]-viewport[1]) || fbo.getHeight() != (viewport[3]-viewport[1]))
        {
            fbo.create(viewport[2]-viewport[1], viewport[3]-viewport[1], 1);
        }

        // sets the FBO first (and only) attachment as output
        fbo.clearAttachments();
        fbo.bindRenderBuffer(0);

        normalmap_shader.bind();

        // sets all uniform variables for the phong shader
        normalmap_shader.setUniform("projectionMatrix", cameraTrackball.getProjectionMatrix());
        normalmap_shader.setUniform("modelMatrix", mesh.getModelMatrix());
        normalmap_shader.setUniform("viewMatrix", cameraTrackball.getViewMatrix());

        mesh.setAttributeLocation(normalmap_shader);

        glEnable(GL_DEPTH_TEST);
        mesh.render();
        glDisable(GL_DEPTH_TEST);

        normalmap_shader.unbind();


        // *** unbind the buffer as output buffer, and applies the blur filter ****
        fbo.unbind(); // automatically returns the draw buffer to GL_BACK

        blur_shader.bind();
        blur_shader.setUniform("imageTexture", fbo.bindAttachment(0));
        blur_shader.setUniform("kernelsize", 5);
        quad.render();
        blur_shader.unbind();
        fbo.unbindAttachments();
    }
コード例 #5
0
ファイル: directcolor.hpp プロジェクト: LCG-UFRJ/tucano
    /** * @brief Render the mesh given a camera 
     * @param mesh Given mesh
     * @param camera Given camera
     */
    void render (Tucano::Mesh& mesh, const Tucano::Camera& camera)
    {

        Eigen::Vector4f viewport = camera.getViewport();
        glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);

        directcolor_shader.bind();

        // sets all uniform variables for the phong shader
        directcolor_shader.setUniform("projectionMatrix", camera.getProjectionMatrix());
        directcolor_shader.setUniform("modelMatrix", mesh.getModelMatrix());
        directcolor_shader.setUniform("viewMatrix", camera.getViewMatrix());
        directcolor_shader.setUniform("has_color", mesh.hasAttribute("in_Color"));
		directcolor_shader.setUniform("default_color", default_color);

        mesh.setAttributeLocation(directcolor_shader);

        glEnable(GL_DEPTH_TEST);
        mesh.render();

        directcolor_shader.unbind();
    }