SEARCH
TOOLBOX
LANGUAGES
Using Ogre Viewer

Using Ogre Viewer

From SOFAWiki

Jump to: navigation, search

Using Ogre Viewer

Ogre is "one of the most popular open-source graphics rendering engines". It is possible to use it within Sofa very easily.

  1. Download and Install Ogre
  2. Open the correct configuration file and specify the path where is located Ogre library
    • Windows release configuration file located at SOFA/share/config/plugins_win.cfg
    • Windows debug configuration file located at SOFA/share/config/plugins_win_d.cfg
    • Linux and MacOS configuration file located at SOFA/share/config/pluging.cfg
  3. Launch sofaConfiguration
    • Find the option SOFA_GUI_QTOGREVIEWER inside the Viewers options, and activate it.
    • ONLY if you don't use Windows specify OGRE_INCLUDE_PATH, the Path where the headers of Ogre are located.
    • Save and Update your configuration
  4. Compile Sofa
  5. To test it, launch Sofa with the option g: runSofa -g ogre. If you launch Sofa directly with an other viewer, you can change the viewer by using the menu View->OGRE


Using Shaders

image:OgreShader.png

To add a shader to your OgreVisualModel you have to:

  • specify the shader with the Data: materialOgre. Ogre engine handles shaders written in HLSL, GLSL, CG.
  • if your shader needs some parameters, use the component OgreShaderParameter. You have to specify the entry point of your custom parameter. To ease the parametrization, we set by default the first 4 entries to be the ambient(1), diffuse(2), specular(3) color, and shininess(4) of the material. See the Fur shader for example: it takes 2 parameters:
    • the Fur length
    • The light coefficient for the fur.

Using Compositors

Ogre provides a very easy way to do compositing effects: we add to the Ogre Viewer a quick interface to manipulate them. BR See next for some of the effects available:

It is also easy to create new effects, as it relies on scripts. Just create a new Compositor (see in $SOFA/share/materials/scripts/Examples.compositor), and bind the different render target to your custom shader. You can enable these effects for a given scene using the component OgreViewerSetting. Specifiy the data compositors, which is a vector of string, and these effects will we active with your scene.

See the example scene $SOFA/examples/Sandbox/OgreShaderDemo.scn for a full use of OgreViewer (shaders + custom parameters + texture specifications + compositing effects)