/** * @brief Render sphere */ void render (const Tucano::Camera& camera, const Tucano::Camera& light) { Eigen::Vector4f viewport = camera.getViewport(); glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); sphere_shader.bind(); sphere_shader.setUniform("modelMatrix", model_matrix); sphere_shader.setUniform("viewMatrix", camera.getViewMatrix()); sphere_shader.setUniform("projectionMatrix", camera.getProjectionMatrix()); sphere_shader.setUniform("lightViewMatrix", light.getViewMatrix()); sphere_shader.setUniform("in_Color", color); vector <string> attribs; sphere_shader.getActiveAttributes(attribs); this->setAttributeLocation(&sphere_shader); glEnable(GL_DEPTH_TEST); this->bindBuffers(); this->renderElements(); this->unbindBuffers(); glDisable(GL_DEPTH_TEST); sphere_shader.unbind(); #ifdef TUCANODEBUG errorCheckFunc(__FILE__, __LINE__); #endif }
void Volume::calculateGradient(){ cout<<" Calculating gradient "<<endl; gradShader = new Shader("shaders/","gradShader",1); gradShader->initialize(); gradShader->enable(); cout<<" Shader initialized "<<endl; texture = new Texture(); texture->create(GL_TEXTURE_3D, GL_RGBA8, volSize[0], volSize[1], GL_RGBA, GL_UNSIGNED_BYTE, NULL, volSize[2]); GLuint unit = texture->bind(); glBindImageTexture(unit, texture->texID(), 0, GL_TRUE, 0, GL_READ_WRITE, GL_RGBA8); GLint baseUnit = scratchTexture->bind(); Eigen::Vector3f dimensions = getTextureResolution(); gradShader->setUniform("baseTexture", baseUnit); gradShader->setUniform("gradientTexture", (GLint)unit); gradShader->setUniform("resolution", &dimensions[0], 3, 1); glDispatchCompute(volSize[0], volSize[1], volSize[2]); glBindImageTexture(0, 0, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_RGBA32F); scratchTexture->unbind(); texture->unbind(); errorCheckFunc(__FILE__, __LINE__); }
void Volume::loadVolume(){ cout << "Loading volume..."<<endl; cout << volSize[0] << " " << volSize[1] << " " << volSize[2] << endl; mesh -> createParallelepiped(realDimension[0], realDimension[1], realDimension[1]); cout<< "Parallelepiped created, now to the texture..."<<endl; scratchTexture = new Texture(); cout << "Texture instantiated." << endl; scratchTexture->create(GL_TEXTURE_3D, GL_R8, volSize[0], volSize[1], GL_RED, GL_UNSIGNED_BYTE, voxelArray, volSize[2]); // "Id =" because... //...this funcion returns a GLuint value that represents the texture ID. cout << "Texture created." << endl; scratchTexture->setTexParameters(GL_CLAMP, GL_CLAMP, GL_CLAMP, GL_LINEAR, GL_LINEAR); errorCheckFunc(__FILE__, __LINE__); cout << "Texture parameters set." << endl; cout<<"Texture successfully created!"<<endl; delete voxelArray; calculateGradient(); errorCheckFunc(__FILE__, __LINE__); }