Examples

Atmo example


This example is based on the paper "Precomputed Atmospheric Scattering", Eric Bruneton and Fabrice Neyret, EGSR 2008, and on the associated source code. To use it, launch the application twice: the first launch will precompute the atmospheric textures (using the code and shaders in the "precompute" sub directory), and the second one will use them to render the atmosphere.

The "HelloWorld.cpp" is taken from the "Edit1" example from the edit plugin. The scene graph organization is also quite simple and should now be quite self explanatory. It makes use, in particular, of a globalsShader to hold the shared global variables, here the world camera position, the world Sun direction, and a camera exposure for tone mapping (see the "Terrain5" example).

This exposure can be changed with the tweak bar, thanks to the following resources:

    <tweakBar name="settings" label="Options">
        <float label="Exposure" keyincr="+" keydecr="-"
            group="Rendering" help="Choose exposure factor for tone mapping"
            min="0.01" max="10.0" step="0.01" path="sky/material/hdrExposure"/>
    </tweakBar>

    <tweakBarManager name="tweakBar" next="viewHandler">
        <editor id="resources" bar="settings" permanent="true" exclusive="false"/>
        <editor id="scene" bar="editScene" exclusive="false"/>
    </tweakBarManager>

Here the "settings" tweak bar is configured to edit the float uniform named "hdrExposure" in the "material" module of the "sky" scene node, i.e., in the "skyShader" shader. It also defines min and max values for this uniform, shortcut keys to increment and decrement it by "step" values, and also associate to it a tweak bar group and a help message. You can of course add many more controls like this in your applications.

Note:
the sky shader can work both with flat and spherical terrains. For flat terrains, as in this example, you must set the "origin" uniform of this shader to (0,0,radius), where radius is the planet radius used when precomputing the atmospheric textures (here 6360000):
    <module name="skyShader" version="330" source="skyShader.glsl">
        <uniformSampler name="glareSampler" texture="sunglare"/>
        <uniform3f name="origin" x="0.0" y="0.0" z="6360000.0"/>
    </module>

For spherical terrains you must set the origin to (0,0,0).


Generated on Sat May 12 09:42:18 2012 for proland by  doxygen 1.6.1