version 3.3

VRS::ShadowTechniqueTemplateGL Class Reference

#include <vrs/opengl/shadowtechniquegl.h>

Inheritance diagram for VRS::ShadowTechniqueTemplateGL:

VRS::TechniqueGL VRS::Technique VRS::RenderObj VRS::SharedObj VRS::Visitable VRS::BaseShadowVolumeTechniqueGL VRS::DepthmapShadowTechniqueGL VRS::ShadowVolumeTechniqueGL VRS::TwoSidedShadowVolumeTechniqueGL VRS::AlphaTextureShadowTechniqueGL VRS::DepthTextureShadowTechniqueGL

List of all members.

Public Member Functions

 ShadowTechniqueTemplateGL ()
virtual bool isSupported (Engine *, bool verbose) const =0
virtual int rate (Engine *) const =0
virtual bool canBeUsed (Engine *) const
virtual void start (Engine *)
virtual void stop (Engine *)
virtual bool preparePass (Engine *)
virtual void finishPass (Engine *)
virtual void nextPass (Engine *)
virtual bool prepareEval (Engine *, const Shape *)
virtual void finishEval (Engine *, const Shape *)
 VRS_TYPEINFO (ShadowTechniqueTemplateGL, TechniqueGL)
 VRS_SERIALIZABLE_ABSTRACT_CLASS (ShadowTechniqueTemplateGL)

Protected Types

enum  LightAdjustment { OnlyAmbient, OnlyDiffuseAndSpecular }

Protected Member Functions

virtual void startHook (Engine *)=0
 called by start()
virtual void stopHook (Engine *)=0
 called by stop()
virtual bool preparePassHook (Engine *)=0
virtual void finishPassHook (Engine *)=0
 called by finishPass()
virtual void nextPassHook (Engine *)=0
 called by nextPass()
virtual bool prepareEvalHook (Engine *, const Shape *)=0
virtual void finishEvalHook (Engine *, const Shape *, bool render)=0
void singleLightAddSettings (Engine *engine, bool on)
 Sets up lighting for the single currently handled light.
virtual void setupShadowTest (bool onOff, Engine *)=0
virtual void toggleShadowTest (bool receiving, Engine *)=0
virtual Iterator< SO< Light > > * newLightIterator () const
void setLight (Light *mylight, bool am, bool df, bool sp, Engine *engine)
virtual void resetLight (Engine *)
 VRS_SERIALIZABLE_CLASS_ENUM (LightAdjustment)
virtual void adjustLights (Engine *, LightAdjustment, Light *=0)
 only used internally by prepareEval to change lights.
LightcurrentLight () const
 short for (*lightWithShadows_)[lightIndex_]
virtual Iterator< SO
< ShadowCaster > > * 
getShadowCasterAttributesInScene () const
 return a valid result after GATHERLIGHTS
virtual Iterator< SO< Shadowed > > * getShadowedAttributesInScene () const
 return a valid result after GATHERLIGHTS

Protected Attributes

unsigned int lightIndex_


Member Enumeration Documentation

Enumerator:
OnlyAmbient 
OnlyDiffuseAndSpecular 


Constructor & Destructor Documentation

VRS::ShadowTechniqueTemplateGL::ShadowTechniqueTemplateGL (  ) 

Abstract base class for various concrete shadow-techniques. This class implements the base structure for all shadow techniques in VRS. It is based upon the template pattern; base classes must overwrite the abstract, protected hook-methods. The hook methods are always called at the end of each method.

The generic implementation of a shadow technique is as follows: pass GATHERLIGHTS (same pass as BOUNDINGBOX): This pass is an analyzation pass that determines those light sources in the scene graph for whose also a shadow casting attribute and a shadow receive attribute is in the scene graph. Nothing is rendered. Subclasses might want to determine the bounding box of shadow casting shapes during this pass.

TODO: GATHERLIGHTS currently is not really implemented (see newLightIterator() )

pass MAIN: All shapes are rendered, for shapes with receiving attribute, the diffuse and specular lighting is set to zero. For each light source, this light later is added separately. MIRRORFACETREDRAW does the same; this pass is only evaluated for mirroring facets in the mirror technique. pass SIMPLESHADOWADDLIGHT: This pass is repeated for every shadowing light. Before this pass, a derived concrete shadow technique must have calculated those regions in light, and have marked them somehow - for example in the stencil of the alpha buffer. For those regions in light, the diffuse and specular lighting of the one light is blended on.


Member Function Documentation

virtual bool VRS::ShadowTechniqueTemplateGL::isSupported ( Engine ,
bool  verbose 
) const [pure virtual]

Checks whether the necessary extensions to run the technique exist. If verbose is set, in case of missing extensions or such, warnings are emited.

Implemented in VRS::AlphaTextureShadowTechniqueGL, VRS::DepthTextureShadowTechniqueGL, VRS::BaseShadowVolumeTechniqueGL, and VRS::TwoSidedShadowVolumeTechniqueGL.

virtual int VRS::ShadowTechniqueTemplateGL::rate ( Engine  )  const [pure virtual]

Rates the shadow technique. Values smaller/equal than 0 mean that the technique is not supported. For values greater than 0, the higher the value, the better the quality of the technique is. This method is used by the ShadowTechniqueGL factory to decide which concrete shadow technique to choose.

TODO: more sophisticated rating system that allows for quality /performance tradeoff

Implemented in VRS::AlphaTextureShadowTechniqueGL, VRS::DepthTextureShadowTechniqueGL, VRS::ShadowVolumeTechniqueGL, and VRS::TwoSidedShadowVolumeTechniqueGL.

virtual bool VRS::ShadowTechniqueTemplateGL::canBeUsed ( Engine  )  const [virtual]

A shadow technique can be used when isSupported says the necessary extensions and features are available. Else isSupported will give a warning.

Reimplemented from VRS::Technique.

virtual void VRS::ShadowTechniqueTemplateGL::start ( Engine  )  [virtual]

Starts the shadow technique. Calls constructLightIterator(). Implicitely calls startHook() of derived techniques at the end of the method.

Reimplemented from VRS::Technique.

virtual void VRS::ShadowTechniqueTemplateGL::stop ( Engine  )  [virtual]

Stops the shadow technique. Implicitely calls stopHook() of derived techniques at the end of the method.

Reimplemented from VRS::Technique.

virtual bool VRS::ShadowTechniqueTemplateGL::preparePass ( Engine  )  [virtual]

Does only interesting things in pass SIMPLESHADOWADDLIGHT. Here, the shadow testing function are set up and activated (setupShadowTest and toggleShadowTest). Also, additive blending is activated and all lights but the current light for which shadow is calculated are switched off. Always implicitely calls preparePassHook() of derived techniques at the end of the method.

Implements VRS::Technique.

virtual void VRS::ShadowTechniqueTemplateGL::finishPass ( Engine  )  [virtual]

Undoes changes of preparePass. Always implicitely calls finishPassHook() of derived techniques at the end of the method.

Implements VRS::Technique.

virtual void VRS::ShadowTechniqueTemplateGL::nextPass ( Engine  )  [virtual]

When the current pass is SIMPLESHADOWADDLIGHT, and there are light sources that cast shadow left, trigger another SIMPLESHADOWADDLIGHT pass. Always implicitely calls nextPassHook() of derived techniques at the end of the method.

Reimplemented from VRS::Technique.

virtual bool VRS::ShadowTechniqueTemplateGL::prepareEval ( Engine ,
const Shape  
) [virtual]

In pass MAIN (or MIRRORFACETREDRAW), if the shape is shadowed with respect to a light source, diffuse and specular contribution of the light source is disabled. In pass SIMPLESHADOWADDLIGHT, the shape is only rendered when it is shadowed with respect to the light source that is currently treated in this pass. Always implicitely calls prepareEvalHook() of derived techniques at the end of the method.

Implements VRS::Technique.

virtual void VRS::ShadowTechniqueTemplateGL::finishEval ( Engine ,
const Shape  
) [virtual]

Undoes changes of prepareEval. Always implicitely calls finishEvalHook() of derived techniques at the end of the method.

Implements VRS::Technique.

VRS::ShadowTechniqueTemplateGL::VRS_TYPEINFO ( ShadowTechniqueTemplateGL  ,
TechniqueGL   
)

VRS::ShadowTechniqueTemplateGL::VRS_SERIALIZABLE_ABSTRACT_CLASS ( ShadowTechniqueTemplateGL   ) 

virtual void VRS::ShadowTechniqueTemplateGL::startHook ( Engine  )  [protected, pure virtual]

virtual void VRS::ShadowTechniqueTemplateGL::stopHook ( Engine  )  [protected, pure virtual]

virtual bool VRS::ShadowTechniqueTemplateGL::preparePassHook ( Engine  )  [protected, pure virtual]

called by preparePass(). If the result is true, the pass will be evaluated in any case. If the result is false, it is up to the ShadowTechniqueTemplateGL base technique whether the pass is evaluated or not. (see preparePass() )

Implemented in VRS::AlphaTextureShadowTechniqueGL, VRS::DepthTextureShadowTechniqueGL, VRS::BaseShadowVolumeTechniqueGL, and VRS::TwoSidedShadowVolumeTechniqueGL.

virtual void VRS::ShadowTechniqueTemplateGL::finishPassHook ( Engine  )  [protected, pure virtual]

virtual void VRS::ShadowTechniqueTemplateGL::nextPassHook ( Engine  )  [protected, pure virtual]

virtual bool VRS::ShadowTechniqueTemplateGL::prepareEvalHook ( Engine ,
const Shape  
) [protected, pure virtual]

called by prepareEval(). If the result is false, the shape will not be rendered in any case. If the result is true, it is up to the ShadowTechniqueTemplateGL base technique whether the shape is rendered or not (see prepareEval() )

Implemented in VRS::AlphaTextureShadowTechniqueGL, VRS::DepthTextureShadowTechniqueGL, and VRS::BaseShadowVolumeTechniqueGL.

virtual void VRS::ShadowTechniqueTemplateGL::finishEvalHook ( Engine ,
const Shape ,
bool  render 
) [protected, pure virtual]

called by finishEval(). render contains the information whether the shape has been rendered or not.

Implemented in VRS::AlphaTextureShadowTechniqueGL, VRS::DepthTextureShadowTechniqueGL, and VRS::BaseShadowVolumeTechniqueGL.

void VRS::ShadowTechniqueTemplateGL::singleLightAddSettings ( Engine engine,
bool  on 
) [protected]

Sets up lighting for the single currently handled light.

virtual void VRS::ShadowTechniqueTemplateGL::setupShadowTest ( bool  onOff,
Engine  
) [protected, pure virtual]

For SIMPLESHADOWADDLIGHT pass, if onOff is true, sets up opengl stenciling and/or blending function in a way that only fragments in light are rendered. If onOff is false, the settings are undone.

Implemented in VRS::AlphaTextureShadowTechniqueGL, VRS::DepthTextureShadowTechniqueGL, and VRS::BaseShadowVolumeTechniqueGL.

virtual void VRS::ShadowTechniqueTemplateGL::toggleShadowTest ( bool  receiving,
Engine  
) [protected, pure virtual]

For SIMPLESHADOWADDLIGHT pass, enables resp. disables the fragment check for shadowed regions.

Implemented in VRS::AlphaTextureShadowTechniqueGL, VRS::DepthTextureShadowTechniqueGL, and VRS::BaseShadowVolumeTechniqueGL.

virtual Iterator<SO<Light> >* VRS::ShadowTechniqueTemplateGL::newLightIterator (  )  const [protected, virtual]

returns a list of lights which may cause shadows. Other lightsources can be ignored for shadow techniques. The list is generated in the pass GATHERLIGHTS (=BOUNDINGBOX)

void VRS::ShadowTechniqueTemplateGL::setLight ( Light mylight,
bool  am,
bool  df,
bool  sp,
Engine engine 
) [protected]

Sets ambient/diffuse/specular light of mylight to zero if false, else to its normal value.

virtual void VRS::ShadowTechniqueTemplateGL::resetLight ( Engine  )  [protected, virtual]

Undoes all changes by setLight-calls and set the ambient/diffuse/specular values to their normal value.

VRS::ShadowTechniqueTemplateGL::VRS_SERIALIZABLE_CLASS_ENUM ( LightAdjustment   )  [protected]

virtual void VRS::ShadowTechniqueTemplateGL::adjustLights ( Engine ,
LightAdjustment  ,
Light = 0 
) [protected, virtual]

only used internally by prepareEval to change lights.

Light* VRS::ShadowTechniqueTemplateGL::currentLight (  )  const [protected]

short for (*lightWithShadows_)[lightIndex_]

virtual Iterator<SO<ShadowCaster> >* VRS::ShadowTechniqueTemplateGL::getShadowCasterAttributesInScene (  )  const [protected, virtual]

return a valid result after GATHERLIGHTS

virtual Iterator<SO<Shadowed> >* VRS::ShadowTechniqueTemplateGL::getShadowedAttributesInScene (  )  const [protected, virtual]

return a valid result after GATHERLIGHTS


Member Data Documentation

The index of the light that is treated in rendering passes that handle each light separately. Derived should NOT change lightIndex_ in the SIMPLESHADOWADDLIGHT pass. They are responsable to change lightIndex_ in other passes that are done for each shadowed light.


The documentation for this class was generated from the following file:

Generated on Tue May 22 06:00:24 2012 by Doxygen 1.5.6
© 2001-2010 Hasso-Plattner-Institut | Impressum | Contact