Time for action — combing two compositors in code

This time we don't need a new compositor. We are just going to modify the application a bit:

  1. First add and enable the invert compositor:
    Ogre::CompositorManager::getSingleton().addCompositor(mCamera->getViewport(), "Compositor3");
    Ogre::CompositorManager::getSingleton().setCompositorEnabled(mCamera->getViewport(), "Compositor3", true);
    
  2. Then add the black and white compositor:
    Ogre::CompositorManager::getSingleton().addCompositor(mCamera->getViewport(), "Compositor2");
    Ogre::CompositorManager::getSingleton().setCompositorEnabled(mCamera->getViewport(), "Compositor2", true);
    
  3. Again compile and run the application. The result should be the same, only this time we combined the compositor in our application code rather than in the script itself.

What just happened?

We combined two compositors using the addCompositor() function. This function can take any number of compositors and chain them together; the output result of one will be the input of the other. If we want to add a compositor at a certain position, we can pass the position as the third parameter of the addCompositor() function. With this function, we can combine all sorts of different compositors without the need to write a single line of script. It also enables us to reuse compositors in other chains because we don't have to hardcode chains in scripts.

Have a go hero — swapping the green and blue color channels

Create a compositor that swaps the green and blue color channels of the scene. The result should look like the following image:

Have a go hero — swapping the green and blue color channels
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.214.141