//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void MeshEffectGenerator::updateForShaderBasedRendering(cvf::Effect* effect) const { cvf::ShaderProgramGenerator spGen("Mesh", cvf::ShaderSourceProvider::instance()); spGen.addVertexCode(cvf::ShaderSourceRepository::vs_Standard); spGen.addFragmentCode(cvf::ShaderSourceRepository::src_Color); spGen.addFragmentCode(cvf::ShaderSourceRepository::fs_Unlit); cvf::ref<cvf::ShaderProgram> shaderProg = spGen.generate(); cvf::ref<cvf::Effect> eff = effect; eff->setShaderProgram(shaderProg.p()); eff->setUniform(new cvf::UniformFloat("u_color", cvf::Color4f(m_color, 1.0))); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool OverlayItems::onInitialize() { PartCompoundGenerator gen; gen.setPartDistribution(Vec3i(5, 5, 5)); gen.setNumEffects(8); gen.useRandomEffectAssignment(false); gen.setExtent(Vec3f(3,3,3)); gen.setOrigin(Vec3f(-1.5f, -1.5f, -1.5f)); Collection<Part> parts; gen.generateSpheres(20, 20, &parts); m_model = new ModelBasicList; cvf::ShaderSourceProvider::instance(); ShaderProgramGenerator spGen("SimpleHeadlight", cvf::ShaderSourceProvider::instance()); spGen.configureStandardHeadlightColor(); m_shaderProg = spGen.generate(); m_useShaders = false; size_t i; for (i = 0; i < parts.size(); i++) { Part* part = parts[i].p(); ref<Effect> eff = part->effect(); eff->setShaderProgram(m_useShaders ? m_shaderProg.p() : NULL); m_model->addPart(parts[i].p()); } m_model->updateBoundingBoxesRecursive(); m_renderSequence->firstRendering()->scene()->addModel(m_model.p()); //addOverlayItemsVariousTypes(); addOverlayItemsTestLayout(); BoundingBox bb = m_model->boundingBox(); if (bb.isValid()) { m_camera->fitView(bb, Vec3d::Y_AXIS, Vec3d::Z_AXIS); } return true; }