Contents User Forum Source Index APIs by Task APIs by Level Data


G3D::ToneMap Class Reference

Applies gamma correction and bloom. More...

#include <ToneMap.h>

Inherits G3D::ReferenceCountedObject.

List of all members.

Public Member Functions

void beginFrame (RenderDevice *rd)
bool enabled () const
void endFrame (RenderDevice *rd)
LightingRef prepareLighting (const LightingRef &L) const
SkyParameters prepareSkyParameters (const SkyParameters &L) const
void ReferenceCountedObject_zeroWeakPointers ()
void setEnabled (bool e)

Static Public Member Functions

static ToneMapRef create ()

Public Attributes

AtomicInt32 ReferenceCountedObject_refCount
_WeakPtrLinkedListReferenceCountedObject_weakPointer

Classes

class  Settings


Detailed Description

Applies gamma correction and bloom.

GApp subclasses have a built-in ToneMap named GApp::toneMap.

In the real world, the shadow under a car is about 1,000,000 times darker than the specular highlight off its hood. Most computer displays can only represent a dynamic range of 255 values (eight bits) per color channel, so bright areas are blown out and all detail is lost in dark areas. This is the dynamic range problem of displays.

Furthermore, displays were designed for 2D rendering where rgb=128 should appear half as bright as rgb=255. In contrast, 3D rendering simulates light, so rgb=128 should have half as much energy as rgb=255, which does not correspond to the perception of half as bright. This is the gamma ramp problem.

There are many sophisticated algorithms for altering a rendered image to correct both of these. This ToneMap class uses an algorithm that is not the most sophisticated, but is extremely fast and produces attractive results. It alters the lights in a scene to conserve dynamic range and then post-processes an image to make overexposed areas "glow" and correct the gamma ramp for all other areas. The resulting images have more detail in dark areas and appear more realistic than unprocessed ones.

Use Example:

  void onGraphics(RenderDevice* rd) {
    LightingRef        lighting      = toneMap.prepareLighting(app->lighting);
    SkyParameters      skyParameters = toneMap.prepareSkyParameters(app->skyParameters);

    toneMap.beginFrame(rd);
        rendering code ...
    toneMap.endFrame(rd);
  }
  


Member Function Documentation

void G3D::ToneMap::beginFrame ( RenderDevice rd  ) 

Call before rendering anything (including clearing the screen.

static ToneMapRef G3D::ToneMap::create (  )  [inline, static]

bool G3D::ToneMap::enabled (  )  const [inline]

void G3D::ToneMap::endFrame ( RenderDevice rd  ) 

Call after rendering the rest of the scene to apply tone mapping.

LightingRef G3D::ToneMap::prepareLighting ( const LightingRef L  )  const

Call before rendering the scene to create a tone-mapping compatible lighting environment.

Guaranteed to return a new lighting environment that is safe to further mutate.

If you created the lighting from SkyParameters that was itself prepared, do not call this method or the lights will be too dark.

SkyParameters G3D::ToneMap::prepareSkyParameters ( const SkyParameters L  )  const

Call before rendering the scene to create a tone-mapping compatible lighting environment.

void G3D::ReferenceCountedObject::ReferenceCountedObject_zeroWeakPointers (  )  [inline, inherited]

Automatically called immediately before the object is deleted.

This is not called from the destructor because it needs to be invoked before the subclass destructor.

void G3D::ToneMap::setEnabled ( bool  e  ) 


Member Data Documentation

The long name is to keep this from accidentally conflicting with a subclass's variable name.

Do not use or explicitly manipulate this value--its type may change in the future and is not part of the supported API.

Linked list of all weak pointers that reference this (some may be on the stack!).

Do not use or explicitly manipulate this value.


The documentation for this class was generated from the following file:
Generated on Thu Aug 2 11:40:48 2007 for G3D by doxygen 1.5.2
Hosted by SourceForge.net Logo