void Viewer::cb_initGL() { Utils::GLSLShader::setCurrentOGLVersion(2) ; CGoGNout << "GL VERSION = "<< glGetString(GL_VERSION)<< CGoGNendl; Utils::GLSLShader::areShadersSupported(); m_render = new Algo::Render::GL2::MapRender() ; m_topoRender = new Algo::Render::GL2::TopoRenderMap<PFP>() ; m_topoRender->setInitialDartsColor(0.25f, 0.25f, 0.25f) ; m_positionVBO = new Utils::VBO() ; m_normalVBO = new Utils::VBO() ; m_phongShader = new Utils::ShaderPhong() ; m_phongShader->setAttributePosition(m_positionVBO) ; m_phongShader->setAttributeNormal(m_normalVBO) ; m_phongShader->setAmbiant(colClear) ; m_phongShader->setDiffuse(colDif) ; m_phongShader->setSpecular(colSpec) ; m_phongShader->setShininess(shininess) ; m_flatShader = new Utils::ShaderFlat() ; m_flatShader->setAttributePosition(m_positionVBO) ; m_flatShader->setAmbiant(colClear) ; m_flatShader->setDiffuse(colDif) ; m_flatShader->setDiffuseBack(Geom::Vec4f(0,0,0,0)) ; m_flatShader->setExplode(faceShrinkage) ; m_vectorShader = new Utils::ShaderVectorPerVertex() ; m_vectorShader->setAttributePosition(m_positionVBO) ; m_vectorShader->setAttributeVector(m_normalVBO) ; m_vectorShader->setColor(colNormal) ; m_simpleColorShader = new Utils::ShaderSimpleColor() ; m_simpleColorShader->setAttributePosition(m_positionVBO) ; Geom::Vec4f c(0.0f, 0.0f, 0.0f, 1.0f) ; m_simpleColorShader->setColor(c) ; m_pointSprite = new Utils::PointSprite() ; m_pointSprite->setAttributePosition(m_positionVBO) ; m_pointSprite->setColor(Geom::Vec4f(0.0f, 0.0f, 1.0f, 1.0f)) ; registerShader(m_phongShader) ; registerShader(m_flatShader) ; registerShader(m_vectorShader) ; registerShader(m_simpleColorShader) ; registerShader(m_pointSprite) ; }
void MCMesh::cb_initGL() { Geom::Vec4f colClear(0.2f, 0.2f, 0.2f, 0.1f); Geom::Vec4f colDif(0.8f, 0.9f, 0.7f, 1.0f); Geom::Vec4f colSpec(0.9f, 0.9f, 0.9f, 1.0f); m_render = new Algo::Render::GL2::MapRender(); m_positionVBO = new Utils::VBO(); m_flatShader = new Utils::ShaderFlat(); m_flatShader->setAttributePosition(m_positionVBO); m_flatShader->setAmbiant(colClear); m_flatShader->setDiffuse(colDif); m_flatShader->setExplode(1.0f); //m_simpleColorShader = new Utils::ShaderSimpleColor(); //m_simpleColorShader->setAttributePosition(m_positionVBO); m_linesShader = new Utils::ShaderBoldLines(); m_linesShader->setAttributePosition(m_positionVBO); registerShader(m_flatShader); // registerShader(m_simpleColorShader); registerShader(m_linesShader); m_dr = new Utils::Drawer(); m_dr->newList(); m_dr->pointSize(4.0f); m_dr->lineWidth(25.0f); m_dr->begin(GL_LINES); m_dr->color3f(1.0,0.0,0.0); m_dr->vertex3f(15.0,15.0,65.0); m_dr->vertex3f(110.0,110.0,65.0); m_dr->color3f(0.0,1.0,0.0); m_dr->vertex3f(110.0,15.0,75.0); m_dr->vertex3f(15.0,110.0,75.0); m_dr->end(); m_dr->endList(); }
void MCMesh::cb_initGL() { Geom::Vec4f colClear(0.2f, 0.2f, 0.2f, 0.1f); Geom::Vec4f colDif(0.8f, 0.9f, 0.7f, 1.0f); Geom::Vec4f colSpec(0.9f, 0.9f, 0.9f, 1.0f); Utils::GLSLShader::setCurrentOGLVersion(2); m_render = new Algo::Render::GL2::MapRender(); m_positionVBO = new Utils::VBO(); m_flatShader = new Utils::ShaderFlat(); m_flatShader->setAttributePosition(m_positionVBO); m_flatShader->setAmbiant(colClear); m_flatShader->setDiffuse(colDif); m_flatShader->setExplode(1.0f); m_simpleColorShader = new Utils::ShaderSimpleColor(); m_simpleColorShader->setAttributePosition(m_positionVBO); registerShader(m_flatShader); registerShader(m_simpleColorShader); }
MapHandlerGen* Surface_Radiance_Plugin::importFromFile(const QString& fileName) { QFileInfo fi(fileName); if(fi.exists()) { MapHandlerGen* mhg = m_schnapps->addMap(fi.baseName(), 2); if(mhg) { MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(mhg); PFP2::MAP* map = mh->getMap(); MeshTablesSurface_Radiance importer(*map); if (!importer.importPLY<Utils::SphericalHarmonics<PFP2::REAL, PFP2::VEC3> >(fileName.toStdString())) { std::cout << "could not import " << fileName.toStdString() << std::endl; return NULL; } CGoGN::Algo::Surface::Import::importMesh<PFP2>(*map, importer); // get vertex position attribute VertexAttribute<PFP2::VEC3, PFP2::MAP> position = map->getAttribute<PFP2::VEC3, VERTEX, PFP2::MAP>("position") ; VertexAttribute<PFP2::VEC3, PFP2::MAP> normal = map->getAttribute<PFP2::VEC3, VERTEX, PFP2::MAP>("normal"); mh->registerAttribute(position); mh->registerAttribute(normal); MapParameters& mapParams = h_mapParameterSet[mhg]; mapParams.nbVertices = Algo::Topo::getNbOrbits<VERTEX>(*map); mapParams.radiance = map->getAttribute<Utils::SphericalHarmonics<PFP2::REAL, PFP2::VEC3>, VERTEX, PFP2::MAP>("radiance") ; mapParams.radianceTexture = new Utils::Texture<2, Geom::Vec3f>(GL_FLOAT); mapParams.param = map->checkAttribute<Geom::Vec2i, VERTEX, PFP2::MAP>("param"); // create texture unsigned int nbv_nbc = Algo::Topo::getNbOrbits<VERTEX>(*map) * Utils::SphericalHarmonics<PFP2::REAL, PFP2::VEC3>::get_nb_coefs(); unsigned int size = 1; while (size * size < nbv_nbc) size <<= 1; mapParams.radianceTexture->create(Geom::Vec2i(size, size)); // fill texture unsigned int count = 0; foreach_cell<VERTEX>(*map, [&] (Vertex v) { unsigned int i = count / size; unsigned int j = count % size; mapParams.param[v] = Geom::Vec2i(i, j) ; // first index for current vertex for (int l = 0 ; l <= Utils::SphericalHarmonics<PFP2::REAL, PFP2::VEC3>::get_resolution() ; ++l) { for (int m = -l ; m <= l ; ++m) { i = count / size; j = count % size; (*(mapParams.radianceTexture))(i,j) = mapParams.radiance[v].get_coef(l, m); ++count; } } }) ; // resulting texture : SH00_vx0, SH1-1_vx0, ..., SHlm_vx0, SH00_vx1, SH1-1_vx1, ..., SHlm_vx1, etc. // resulting param : param[vxI] points to SH00_vxI // the size of the texture is needed to know where to do the divisions and modulos. mapParams.radianceTexture->update(); // uncomment this line to be able to load multiple objects with different SH basis // (decimation will be unavailable) // map->removeAttribute(mapParams.radiance); mapParams.paramVBO = new Utils::VBO(); mapParams.paramVBO->updateData(mapParams.param); mapParams.radiancePerVertexShader = new Utils::ShaderRadiancePerVertex(Utils::SphericalHarmonics<PFP2::REAL, PFP2::VEC3>::get_resolution()); registerShader(mapParams.radiancePerVertexShader); } this->pythonRecording("importFile", mhg->getName(), fi.baseName()); return mhg; } else return NULL; }
void Viewer::cb_initGL() { Utils::GLSLShader::setCurrentOGLVersion(2) ; setFocal(5.0f) ; m_render = new Algo::Render::GL2::MapRender() ; m_topoRender = new Algo::Render::GL2::TopoRender() ; m_topoRender->setInitialDartsColor(0.25f, 0.25f, 0.25f) ; m_positionVBO = new Utils::VBO() ; m_normalVBO = new Utils::VBO() ; m_phongShader = new Utils::ShaderPhong() ; m_phongShader->setAttributePosition(m_positionVBO) ; m_phongShader->setAttributeNormal(m_normalVBO) ; m_phongShader->setAmbiant(colClear) ; m_phongShader->setDiffuse(colDif) ; m_phongShader->setSpecular(colSpec) ; m_phongShader->setShininess(shininess) ; m_flatShader = new Utils::ShaderFlat() ; m_flatShader->setAttributePosition(m_positionVBO) ; m_flatShader->setAmbiant(colClear) ; m_flatShader->setDiffuse(colDif) ; m_flatShader->setExplode(faceShrinkage) ; m_vectorShader = new Utils::ShaderVectorPerVertex() ; m_vectorShader->setAttributePosition(m_positionVBO) ; m_vectorShader->setAttributeVector(m_normalVBO) ; m_vectorShader->setColor(colNormal) ; m_simpleColorShader = new Utils::ShaderSimpleColor() ; m_simpleColorShader->setAttributePosition(m_positionVBO) ; Geom::Vec4f c(0.1f, 0.1f, 0.1f, 1.0f) ; m_simpleColorShader->setColor(c) ; m_normalShader = new Utils::ShaderOutputNormal(); m_normalShader->setAttributePosition(m_positionVBO); m_normalShader->setAttributeNormal(m_normalVBO); m_positionAndNormalShader = new Utils::ShaderOutputPositionAndNormal(); m_positionAndNormalShader->setAttributePosition(m_positionVBO); m_positionAndNormalShader->setAttributeNormal(m_normalVBO); m_computeSSAOShader = new Utils::ShaderComputeSSAO(); m_computeSSAOShader->setAttributePosition(Utils::TextureSticker::GetQuadPositionsVbo()); m_computeSSAOShader->setAttributeTexCoord(Utils::TextureSticker::GetQuadTexCoordsVbo()); m_multTexturesShader = new Utils::ShaderMultTextures(); m_multTexturesShader->setAttributePosition(Utils::TextureSticker::GetQuadPositionsVbo()); m_multTexturesShader->setAttributeTexCoord(Utils::TextureSticker::GetQuadTexCoordsVbo()); m_textureBlurHShader = new Utils::ShaderTextureBlurH(); m_textureBlurHShader->setAttributePosition(Utils::TextureSticker::GetQuadPositionsVbo()); m_textureBlurHShader->setAttributeTexCoord(Utils::TextureSticker::GetQuadTexCoordsVbo()); m_textureBlurVShader = new Utils::ShaderTextureBlurV(); m_textureBlurVShader->setAttributePosition(Utils::TextureSticker::GetQuadPositionsVbo()); m_textureBlurVShader->setAttributeTexCoord(Utils::TextureSticker::GetQuadTexCoordsVbo()); m_pointSprite = new Utils::PointSprite() ; m_pointSprite->setAttributePosition(m_positionVBO) ; registerShader(m_phongShader) ; registerShader(m_flatShader) ; registerShader(m_vectorShader) ; registerShader(m_simpleColorShader) ; registerShader(m_normalShader) ; registerShader(m_positionAndNormalShader) ; registerShader(m_pointSprite) ; m_positionsAndNormalsFbo = new Utils::FBO(1024, 1024); m_positionsAndNormalsFbo->AttachRenderbuffer(GL_DEPTH_COMPONENT); m_positionsAndNormalsFbo->AttachColorTexture(GL_RGBA32F); m_positionsAndNormalsFbo->AttachColorTexture(GL_RGBA); m_positionsAndNormalsFbo->AttachDepthTexture(); m_SSAOFbo = new Utils::FBO(1024, 1024); m_SSAOFbo->AttachColorTexture(GL_RGBA); m_SSAOFirstBlurPassFbo = new Utils::FBO(1024, 1024); m_SSAOFirstBlurPassFbo->AttachColorTexture(GL_RGBA); m_SSAOSecondBlurPassFbo = new Utils::FBO(1024, 1024); m_SSAOSecondBlurPassFbo->AttachColorTexture(GL_RGBA); m_finalRenderFbo = new Utils::FBO(1024, 1024); m_finalRenderFbo->AttachRenderbuffer(GL_DEPTH_COMPONENT); m_finalRenderFbo->AttachColorTexture(GL_RGBA); m_finalRenderFbo->AttachDepthTexture(); m_colorAndSSAOMergeFbo = new Utils::FBO(1024, 1024); m_colorAndSSAOMergeFbo->AttachColorTexture(GL_RGBA); }