void ColorDisplayFilter::onCreate(const ColorDisplayFilter *source) { Inherited::onCreate(source); // Don't add the prototype instances to the list if(GlobalSystemState != Running) return; SimpleSHLChunkUnrecPtr pShader = SimpleSHLChunk::createLocal(FCLocal::Cluster); pShader->setVertexProgram (vp_program ); pShader->setFragmentProgram(fp_program ); pShader->addUniformVariable("grabTexture", 0); pShader->addUniformVariable("shadingTexture", 1); this->setFilterShader(pShader); }
void HDRStage::resizeStageData(HDRStageData *pData, Int32 iPixelWidth, Int32 iPixelHeight) { FrameBufferObject *pSceneFBO = this->getRenderTarget(); pSceneFBO->resizeAll(iPixelWidth, iPixelHeight); FrameBufferObject *pShrinkFBO = pData->getShrinkRenderTarget(); pShrinkFBO->resizeAll(iPixelWidth / 2, iPixelHeight / 2); FrameBufferObject *pBlurFBO = pData->getBlurRenderTarget(); pBlurFBO->resizeAll(iPixelWidth / 4, iPixelHeight / 4); SimpleSHLChunk *pHBlurShader = pData->getHBlurShader(); std::string szNewFragProg = generate1DConvolutionFilterFPString(getBlurWidth(), false, true, iPixelWidth / 2, iPixelHeight / 2); pHBlurShader->setFragmentProgram(szNewFragProg); szNewFragProg = generate1DConvolutionFilterFPString(getBlurWidth(), true, true, iPixelWidth / 2, iPixelHeight / 2); SimpleSHLChunkUnrecPtr pVBlurShader = pData->getVBlurShader(); pVBlurShader->setFragmentProgram(szNewFragProg); commitChanges(); }
int main(int argc, char **argv) { // OSG init osgInit(argc,argv); // Set up Window TutorialWindow = createNativeWindow(); TutorialWindow->initWindow(); TutorialWindow->setDisplayCallback(display); TutorialWindow->setReshapeCallback(reshape); //Add Window Listener TutorialKeyListener TheKeyListener; TutorialWindow->addKeyListener(&TheKeyListener); TutorialMouseListener TheTutorialMouseListener; TutorialMouseMotionListener TheTutorialMouseMotionListener; TutorialWindow->addMouseListener(&TheTutorialMouseListener); TutorialWindow->addMouseMotionListener(&TheTutorialMouseMotionListener); // Create the SimpleSceneManager helper mgr = new SimpleSceneManager; // Tell the Manager what to manage mgr->setWindow(TutorialWindow); //Shader Material BlendChunkUnrecPtr ExampleBlendChunk = BlendChunk::create(); ExampleBlendChunk->setSrcFactor(GL_SRC_ALPHA); ExampleBlendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA); //Material Chunk MaterialChunkUnrecPtr ShaderMaterialChunk = MaterialChunk::create(); ShaderMaterialChunk->setAmbient(Color4f(0.4f,0.4f,0.4f,1.0f)); ShaderMaterialChunk->setDiffuse(Color4f(0.7f,0.7f,0.7f,1.0f)); ShaderMaterialChunk->setSpecular(Color4f(1.0f,1.0f,1.0f,1.0f)); //Shader Chunk SimpleSHLChunkUnrecPtr TheSHLChunk = SimpleSHLChunk::create(); TheSHLChunk->setVertexProgram(createSHLVertexProg()); TheSHLChunk->setFragmentProgram(createSHLFragProg()); //Color Parameter ShaderVariableVec4fUnrecPtr Color1Parameter = ShaderVariableVec4f::create(); Color1Parameter->setName("Color1"); Color1Parameter->setValue(Vec4f(0.0f,1.0f,0.0f,1.0f)); ShaderVariableVec4fUnrecPtr Color2Parameter = ShaderVariableVec4f::create(); Color2Parameter->setName("Color2"); Color2Parameter->setValue(Vec4f(1.0f,1.0f,1.0f,1.0f)); //Shader Parameter Chunk SHLParameterChunkUnrecPtr SHLParameters = SHLParameterChunk::create(); SHLParameters->getParameters().push_back(Color1Parameter); SHLParameters->getParameters().push_back(Color2Parameter); SHLParameters->setSHLChunk(TheSHLChunk); ChunkMaterialUnrecPtr ShaderMaterial = ChunkMaterial::create(); ShaderMaterial->addChunk(ShaderMaterialChunk); ShaderMaterial->addChunk(TheSHLChunk); ShaderMaterial->addChunk(SHLParameters); //Torus Node GeometryUnrecPtr TorusGeometry = makeTorusGeo(5.0f,20.0f, 32,32); TorusGeometry->setMaterial(ShaderMaterial); NodeUnrecPtr TorusNode = Node::create(); TorusNode->setCore(TorusGeometry); // Make Main Scene Node NodeUnrecPtr scene = Node::create(); scene->setCore(Group::create()); scene->addChild(TorusNode); mgr->setRoot(scene); // Show the whole Scene mgr->showAll(); //Create the Animations initAnimations(Color1Parameter, "value"); //Open Window Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f); Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5); TutorialWindow->openWindow(WinPos, WinSize, "04ShaderAnimation"); //Main Loop TutorialWindow->mainLoop(); osgExit(); return 0; }
DepthPeelingStageDataTransitPtr DepthPeelingStage::setupStageData(Int32 iPixelWidth, Int32 iPixelHeight) { DepthPeelingStageDataTransitPtr returnValue = DepthPeelingStageData::createLocal(); if(returnValue == NULL) return returnValue; OSG::Thread::setCurrentLocalFlags(); //Depth, Blend chunks and Background in Data? DepthChunkUnrecPtr pDepthOffChunk = DepthChunk::createLocal(); pDepthOffChunk->setEnable(false); DepthChunkUnrecPtr pDepthOnChunk = DepthChunk::createLocal(); pDepthOnChunk->setEnable(true); returnValue->setDepthChunk(pDepthOnChunk); ShaderProgramVariableChunkUnrecPtr pSPVChunk1 = ShaderProgramVariableChunk::createLocal(); pSPVChunk1->addUniformVariable("uIsPeelPass", true); returnValue->setSpvIsPeelChunk(pSPVChunk1); ShaderProgramVariableChunkUnrecPtr pSPVChunk2 = ShaderProgramVariableChunk::createLocal(); pSPVChunk2->addUniformVariable("uIsPeelPass", false); returnValue->setSpvIsInitialChunk(pSPVChunk2); BlendChunkUnrecPtr pBlendChunk = BlendChunk::createLocal(); pBlendChunk->setSrcFactor(GL_DST_ALPHA); pBlendChunk->setDestFactor(GL_ONE); pBlendChunk->setAlphaSrcFactor(GL_ZERO); pBlendChunk->setAlphaDestFactor(GL_ONE_MINUS_SRC_ALPHA); pBlendChunk->setEquation(GL_FUNC_ADD); SolidBackgroundUnrecPtr pSolidBackground = SolidBackground::createLocal(); pSolidBackground->setColor(Color3f(0.f, 0.f, 0.f)); pSolidBackground->setAlpha(0.f); returnValue->setBackground(pSolidBackground); SimpleSHLChunkUnrecPtr pQuadShader = SimpleSHLChunk::createLocal(); pQuadShader->setFragmentProgram(std::string(blendFS)); pQuadShader->addUniformVariable("uSampler", 0); //2 FBOs (Ping-Pong) FrameBufferObjectUnrecPtr pPeelFBOs[2]; TextureBufferUnrecPtr pPeelColorTexBuffers[2]; TextureBufferUnrecPtr pPeelDepthTexBuffers[2]; TextureObjChunkUnrecPtr pColorTexs[2]; ImageUnrecPtr pColorImgs[2]; TextureObjChunkUnrecPtr pDepthTexs[2]; ImageUnrecPtr pDepthImgs[2]; for (int i=0; i<2; ++i) { //Color textures pColorTexs[i] = TextureObjChunk::createLocal(); pColorImgs[i] = Image ::createLocal(); pColorImgs[i]->set(Image::OSG_RGBA_PF, iPixelWidth, iPixelHeight, 1, 1, 1, 0.0, 0, Image::OSG_FLOAT32_IMAGEDATA, false); pColorTexs[i] ->setImage (pColorImgs[i] ); pColorTexs[i] ->setMinFilter (GL_NEAREST ); pColorTexs[i] ->setMagFilter (GL_NEAREST ); pColorTexs[i] ->setWrapS (GL_CLAMP_TO_EDGE ); pColorTexs[i] ->setWrapT (GL_CLAMP_TO_EDGE ); pColorTexs[i] ->setInternalFormat(GL_RGBA8); pPeelColorTexBuffers[i] = TextureBuffer::createLocal(); pPeelColorTexBuffers[i]->setTexture(pColorTexs[i]); //Depth textures pDepthTexs[i] = TextureObjChunk::createLocal(); pDepthImgs[i] = Image ::createLocal(); pDepthImgs[i]->set(Image::OSG_DEPTH_PF, iPixelWidth, iPixelHeight, 1, 1, 1, 0.0, 0, Image::OSG_FLOAT32_IMAGEDATA, false); pDepthTexs[i] ->setImage (pDepthImgs[i] ); pDepthTexs[i] ->setMinFilter (GL_NEAREST ); pDepthTexs[i] ->setMagFilter (GL_NEAREST ); pDepthTexs[i] ->setWrapS (GL_CLAMP_TO_EDGE ); pDepthTexs[i] ->setWrapT (GL_CLAMP_TO_EDGE ); pDepthTexs[i] ->setInternalFormat(GL_DEPTH_COMPONENT32F); pDepthTexs[i] ->setExternalFormat(GL_DEPTH_COMPONENT); pPeelDepthTexBuffers[i] = TextureBuffer::createLocal(); pPeelDepthTexBuffers[i]->setTexture(pDepthTexs[i]); pPeelFBOs[i] = FrameBufferObject::createLocal(); pPeelFBOs[i]->setSize(iPixelWidth, iPixelHeight); pPeelFBOs[i]->setColorAttachment(pPeelColorTexBuffers[i], 0); pPeelFBOs[i]->setDepthAttachment(pPeelDepthTexBuffers[i]); pPeelFBOs[i]->editMFDrawBuffers()->push_back(GL_COLOR_ATTACHMENT0_EXT); //Peel material for Quad (!) ChunkMaterialUnrecPtr pPeelMat = ChunkMaterial ::createLocal(); pPeelMat->addChunk(pQuadShader, 0); pPeelMat->addChunk(pColorTexs[i], 0); pPeelMat->addChunk(pDepthOffChunk); pPeelMat->addChunk(pBlendChunk); if (i == 0) { returnValue->setPeelPingFBO(pPeelFBOs[i]); returnValue->setPeelPingMaterial(pPeelMat); } else { returnValue->setPeelPongFBO(pPeelFBOs[i]); returnValue->setPeelPongMaterial(pPeelMat); } } // The final color blend target FrameBufferObjectUnrecPtr pBlendFBO = FrameBufferObject::createLocal(); //Color texture TextureObjChunkUnrecPtr pBlendColorTex = TextureObjChunk::createLocal(); ImageUnrecPtr pBlendColorImg = Image ::createLocal(); pBlendColorImg->set(Image::OSG_RGBA_PF, iPixelWidth, iPixelHeight, 1, 1, 1, 0.0, 0, Image::OSG_FLOAT32_IMAGEDATA, false); pBlendColorTex->setImage (pBlendColorImg ); pBlendColorTex->setMinFilter (GL_NEAREST ); pBlendColorTex->setMagFilter (GL_NEAREST ); pBlendColorTex->setWrapS (GL_CLAMP_TO_EDGE ); pBlendColorTex->setWrapT (GL_CLAMP_TO_EDGE ); pBlendColorTex->setInternalFormat(GL_RGBA8); TextureBufferUnrecPtr pBlendColorTexBuffer = TextureBuffer::createLocal(); pBlendColorTexBuffer->setTexture(pBlendColorTex); TextureBufferUnrecPtr pBlendDepthTexBuffer = TextureBuffer::createLocal(); pBlendDepthTexBuffer->setTexture(pDepthTexs[0]); pBlendFBO->setSize(iPixelWidth, iPixelHeight); pBlendFBO->setColorAttachment(pBlendColorTexBuffer, 0); pBlendFBO->setDepthAttachment(pBlendDepthTexBuffer); pBlendFBO->editMFDrawBuffers()->push_back(GL_COLOR_ATTACHMENT0_EXT); returnValue->setBlendFBO(pBlendFBO); // Blend Final Material ChunkMaterialUnrecPtr pBlendFinalMat = ChunkMaterial::createLocal(); pBlendFinalMat->addChunk(pDepthOffChunk); pBlendFinalMat->addChunk(pBlendColorTex, 0); SimpleSHLChunkUnrecPtr pBlendFinalShader = SimpleSHLChunk::createLocal(); pBlendFinalShader->setFragmentProgram(std::string(blendFinalFS)); pBlendFinalShader->addUniformVariable("uSampler", 0); pBlendFinalMat->addChunk(pBlendFinalShader, 0); returnValue->setBlendFinalMaterial(pBlendFinalMat); OSG::Thread::resetCurrentLocalFlags(); Thread::getCurrentChangeList()->commitChanges(); return returnValue; }
HDRStageDataTransitPtr HDRStage::setupStageData(Int32 iPixelWidth, Int32 iPixelHeight) { HDRStageDataTransitPtr returnValue = HDRStageData::createLocal(); if(returnValue == NULL) return returnValue; OSG::Thread::setCurrentLocalFlags(); // Scene Target FrameBufferObjectUnrecPtr pSceneFBO = FrameBufferObject::createLocal(); RenderBufferUnrecPtr pDepthBuffer = RenderBuffer ::createLocal(); pDepthBuffer->setInternalFormat(GL_DEPTH_COMPONENT24 ); TextureObjChunkUnrecPtr pSceneTex = TextureObjChunk::createLocal(); TextureEnvChunkUnrecPtr pSceneTexEnv = TextureEnvChunk::createLocal(); ImageUnrecPtr pImg = Image ::createLocal(); pImg->set(Image::OSG_RGB_PF, iPixelWidth, iPixelHeight, 1, 1, 1, 0.0, 0, Image::OSG_FLOAT32_IMAGEDATA, false); pSceneTex ->setImage (pImg ); pSceneTex ->setMinFilter (GL_LINEAR ); pSceneTex ->setMagFilter (GL_LINEAR ); pSceneTex ->setWrapS (GL_CLAMP_TO_EDGE ); pSceneTex ->setWrapT (GL_CLAMP_TO_EDGE ); pSceneTex ->setInternalFormat(getBufferFormat()); pSceneTexEnv->setEnvMode (GL_REPLACE ); TextureBufferUnrecPtr pSceneTexBuffer = TextureBuffer::createLocal(); pSceneTexBuffer->setTexture(pSceneTex); pSceneFBO->setSize(iPixelWidth, iPixelHeight); pSceneFBO->setColorAttachment(pSceneTexBuffer, 0); pSceneFBO->setDepthAttachment(pDepthBuffer ); pSceneFBO->editMFDrawBuffers()->push_back(GL_COLOR_ATTACHMENT0_EXT); setRenderTarget(pSceneFBO); // Shrink Target (w/2, h/2) FrameBufferObjectUnrecPtr pShrinkFBO = FrameBufferObject::createLocal(); TextureObjChunkUnrecPtr pShrinkTex = TextureObjChunk::createLocal(); TextureEnvChunkUnrecPtr pShrinkTexEnv = TextureEnvChunk::createLocal(); pImg = Image ::createLocal(); pImg->set(Image::OSG_RGB_PF, iPixelWidth / 2, iPixelHeight / 2, 1, 1, 1, 0.0, 0, Image::OSG_FLOAT32_IMAGEDATA, false); pShrinkTex ->setImage (pImg ); pShrinkTex ->setMinFilter (GL_LINEAR ); pShrinkTex ->setMagFilter (GL_LINEAR ); pShrinkTex ->setWrapS (GL_CLAMP_TO_EDGE ); pShrinkTex ->setWrapT (GL_CLAMP_TO_EDGE ); pShrinkTex ->setInternalFormat(getBufferFormat()); pShrinkTexEnv->setEnvMode (GL_REPLACE ); TextureBufferUnrecPtr pShrinkTexBuffer = TextureBuffer::createLocal(); pShrinkTexBuffer->setTexture(pShrinkTex); pShrinkFBO->setSize(iPixelWidth / 2, iPixelHeight / 2); pShrinkFBO->setColorAttachment(pShrinkTexBuffer, 0); pShrinkFBO->editMFDrawBuffers()->push_back(GL_COLOR_ATTACHMENT0_EXT); returnValue->setShrinkRenderTarget(pShrinkFBO); // blur (w/4, h/4) FrameBufferObjectUnrecPtr pBlurFBO = FrameBufferObject::createLocal(); TextureObjChunkUnrecPtr pBlurTex1 = TextureObjChunk ::createLocal(); TextureEnvChunkUnrecPtr pBlurTex1Env = TextureEnvChunk ::createLocal(); pImg = Image::createLocal(); pImg->set(Image::OSG_RGB_PF, iPixelWidth / 4, iPixelHeight / 4, 1, 1, 1, 0.0, 0, Image::OSG_FLOAT32_IMAGEDATA, false); pBlurTex1 ->setImage (pImg ); pBlurTex1 ->setMinFilter (GL_LINEAR ); pBlurTex1 ->setMagFilter (GL_LINEAR ); pBlurTex1 ->setWrapS (GL_CLAMP_TO_EDGE ); pBlurTex1 ->setWrapT (GL_CLAMP_TO_EDGE ); pBlurTex1 ->setInternalFormat(getBufferFormat()); pBlurTex1Env->setEnvMode (GL_REPLACE ); TextureBufferUnrecPtr pBlurTexBuffer1 = TextureBuffer::createLocal(); pBlurTexBuffer1->setTexture(pBlurTex1); TextureObjChunkUnrecPtr pBlurTex2 = TextureObjChunk::createLocal(); TextureEnvChunkUnrecPtr pBlurTex2Env = TextureEnvChunk::createLocal(); pImg = Image::createLocal(); pImg->set(Image::OSG_RGB_PF, iPixelWidth / 4, iPixelHeight / 4, 1, 1, 1, 0.0, 0, Image::OSG_FLOAT32_IMAGEDATA, false); pBlurTex2 ->setImage (pImg ); pBlurTex2 ->setMinFilter (GL_LINEAR ); pBlurTex2 ->setMagFilter (GL_LINEAR ); pBlurTex2 ->setWrapS (GL_CLAMP_TO_EDGE ); pBlurTex2 ->setWrapT (GL_CLAMP_TO_EDGE ); pBlurTex2 ->setInternalFormat(getBufferFormat()); pBlurTex2Env->setEnvMode (GL_REPLACE ); TextureBufferUnrecPtr pBlurTexBuffer2 = TextureBuffer::createLocal(); pBlurTexBuffer2->setTexture(pBlurTex2); pBlurFBO->setSize(iPixelWidth / 4, iPixelHeight / 4); pBlurFBO->setColorAttachment(pBlurTexBuffer1, 0); pBlurFBO->setColorAttachment(pBlurTexBuffer2, 1); returnValue->setBlurRenderTarget(pBlurFBO); // general mat chunk MaterialChunkUnrecPtr pMatChunk = MaterialChunk::createLocal(); pMatChunk->setLit(false); // tone map material ChunkMaterialUnrecPtr pTonemapMat = ChunkMaterial ::createLocal(); pTonemapMat->addChunk(pMatChunk ); pTonemapMat->addChunk(pSceneTex, 0); pTonemapMat->addChunk(pSceneTexEnv, 0); pTonemapMat->addChunk(pBlurTex1, 1); pTonemapMat->addChunk(pBlurTex1Env, 1); SimpleSHLChunkUnrecPtr pTonemapShader = generateHDRFragmentProgram(); pTonemapShader->addUniformVariable("sceneTex", 0); pTonemapShader->addUniformVariable("blurTex", 1); pTonemapShader->addUniformVariable("blurAmount", getBlurAmount ()); pTonemapShader->addUniformVariable("exposure", getExposure ()); pTonemapShader->addUniformVariable("effectAmount", getEffectAmount()); pTonemapShader->addUniformVariable("gamma", getGamma ()); pTonemapMat->addChunk(pTonemapShader, 0); returnValue->setToneMappingMaterial(pTonemapMat); // Shrink material ChunkMaterialUnrecPtr pShrinkMat = ChunkMaterial::createLocal(); pShrinkMat->addChunk(pMatChunk ); pShrinkMat->addChunk(pSceneTex, 0); pShrinkMat->addChunk(pSceneTexEnv, 0); SimpleSHLChunkUnrecPtr pShrinkShader = generate2DShrinkHalfFilterFP(); pShrinkShader->addUniformVariable("inputTex", 0); pShrinkMat->addChunk(pShrinkShader, 0); returnValue->setShrinkMaterial(pShrinkMat); // Blur material ChunkMaterialUnrecPtr pBlurMat = ChunkMaterial::createLocal(); pBlurMat->addChunk(pMatChunk ); pBlurMat->addChunk(pShrinkTex, 0); pBlurMat->addChunk(pShrinkTexEnv, 0); pBlurMat->addChunk(pBlurTex1, 1); pBlurMat->addChunk(pBlurTex1Env, 1); pBlurMat->addChunk(pBlurTex2, 2); pBlurMat->addChunk(pBlurTex2Env, 2); pBlurMat->addChunk(pShrinkShader, 0); returnValue->setBlurMaterial(pBlurMat); // generate blur fragment programs SimpleSHLChunkUnrecPtr pHBlurShader = generate1DConvolutionFilterFP(getBlurWidth(), false, true, iPixelWidth / 2, iPixelHeight / 2); pHBlurShader->addUniformVariable("inputTex", 0); returnValue->setHBlurShader(pHBlurShader); // VBlur Override SimpleSHLChunkUnrecPtr pVBlurShader = generate1DConvolutionFilterFP(getBlurWidth(), true, true, iPixelWidth / 2, iPixelHeight / 2); pVBlurShader->addUniformVariable("inputTex", 1); returnValue->setVBlurShader(pVBlurShader); OSG::Thread::resetCurrentLocalFlags(); Thread::getCurrentChangeList()->commitChanges(); return returnValue; }
int main(int argc, char **argv) { // OSG init osgInit(argc,argv); { // Set up Window WindowEventProducerRecPtr TutorialWindow = createNativeWindow(); //Initialize Window TutorialWindow->initWindow(); SimpleSceneManager sceneManager; TutorialWindow->setDisplayCallback(boost::bind(display, &sceneManager)); TutorialWindow->setReshapeCallback(boost::bind(reshape, _1, &sceneManager)); // Tell the Manager what to manage sceneManager.setWindow(TutorialWindow); //Attach to events TutorialWindow->connectMousePressed(boost::bind(mousePressed, _1, &sceneManager)); TutorialWindow->connectMouseReleased(boost::bind(mouseReleased, _1, &sceneManager)); TutorialWindow->connectMouseDragged(boost::bind(mouseDragged, _1, &sceneManager)); TutorialWindow->connectMouseWheelMoved(boost::bind(mouseWheelMoved, _1, &sceneManager)); TutorialWindow->connectKeyPressed(boost::bind(keyPressed, _1, TutorialWindow.get())); //Shader Chunk SimpleSHLChunkUnrecPtr TheSHLChunk = SimpleSHLChunk::create(); TheSHLChunk->setVertexProgram(createSHLVertexProg()); TheSHLChunk->setFragmentProgram(createSHLFragProg()); //TheSHLChunk->addUniformVariable("Color1",Vec4f(0.0f,1.0f,0.0f,1.0f)); //TheSHLChunk->addUniformVariable("Color2",Vec4f(1.0f,1.0f,1.0f,1.0f)); //Shader Parameter Chunk SimpleSHLVariableChunkUnrecPtr SHLParameters = SimpleSHLVariableChunk::create(); //Color Parameter SHLParameters->addUniformVariable("Color1",Vec4f(0.0f,1.0f,0.0f,1.0f)); SHLParameters->addUniformVariable("Color2",Vec4f(1.0f,1.0f,1.0f,1.0f)); ChunkMaterialUnrecPtr ShaderMaterial = ChunkMaterial::create(); ShaderMaterial->addChunk(TheSHLChunk); ShaderMaterial->addChunk(SHLParameters); //Torus Node GeometryUnrecPtr TorusGeometry = makeTorusGeo(5.0f,20.0f, 32,32); TorusGeometry->setMaterial(ShaderMaterial); NodeUnrecPtr TorusNode = Node::create(); TorusNode->setCore(TorusGeometry); // Make Main Scene Node NodeUnrecPtr scene = Node::create(); scene->setCore(Group::create()); scene->addChild(TorusNode); sceneManager.setRoot(scene); // Show the whole Scene sceneManager.showAll(); //Create the Animations ShaderVariableVec4fUnrecPtr Color1Parameter; ShaderVariableVec4fUnrecPtr Color2Parameter; Color1Parameter = dynamic_cast<ShaderVariableVec4f*>(const_cast<ShaderVariable*>(SHLParameters->getVariables()->getVariable("Color1"))); Color2Parameter = dynamic_cast<ShaderVariableVec4f*>(const_cast<ShaderVariable*>(SHLParameters->getVariables()->getVariable("Color2"))); commitChanges(); AnimationUnrecPtr TheAnimation = setupAnimation(Color1Parameter, "value"); TheAnimation->attachUpdateProducer(TutorialWindow); TheAnimation->start(); //Open Window Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f); Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5); TutorialWindow->openWindow(WinPos, WinSize, "04ShaderAnimation"); //Main Loop TutorialWindow->mainLoop(); } osgExit(); return 0; }