| Description | Hierarchy | Fields | Methods | Properties |
type TShadowVolumesHelper = class(TObject)
This class performs various initialization and calculations related to shadow volume rendering. It does everything, except the actual shadow volume rendering (this is handled elsewhere, for example in TVRMLFlatSceneGL.RenderShadowVolume).
To use this class: call InitGLContext, InitFrustumAndLight, InitScene at appropriate moments. Setup your stencil buffer by setting StencilSetupKind before InitScene. Pass the instance of this to TVRMLFlatSceneGL.RenderShadowVolume.
![]() |
procedure InitGLContext; |
![]() |
procedure InitFrustumAndLight( const Frustum: TFrustum; const ALightPosition: TVector4Single); |
![]() |
procedure InitScene(const SceneBox: TBox3d); |
![]() |
procedure InitSceneDontSetupStencil(const SceneBox: TBox3d); |
![]() |
procedure InitSceneOnlySetupStencil; |
![]() |
procedure InitSceneAlwaysVisible; |
![]() |
property WrapAvailable: boolean read FWrapAvailable; |
![]() |
property LightPosition: TVector4Single read FLightPosition; |
![]() |
property LightPositionDouble: TVector4Double read FLightPositionDouble; |
![]() |
property SceneShadowPossiblyVisible: boolean
read FSceneShadowPossiblyVisible; |
![]() |
property ZFail: boolean read FZFail; |
![]() |
property ZFailAndLightCap: boolean read FZFailAndLightCap; |
![]() |
property StencilTwoSided: boolean read FStencilTwoSided; |
![]() |
property StencilSetupKind: TStencilSetupKind
read FStencilSetupKind write FStencilSetupKind
default ssFrontAndBack; |
![]() |
property Count: boolean read FCount write FCount default false; |
![]() |
property CountScenes: Cardinal read FCountScenes; |
![]() |
property CountShadowsNotVisible: Cardinal read FCountShadowsNotVisible; |
![]() |
property CountZPass: Cardinal read FCountZPass; |
![]() |
property CountZFailNoLightCap: Cardinal read FCountZFailNoLightCap; |
![]() |
property CountZFailAndLightCap: Cardinal read FCountZFailAndLightCap; |
![]() |
procedure InitGLContext; |
|
Call this when OpenGL context is initialized, this will set some things. For now, this sets StencilOpIncrWrap, StencilOpDecrWrap. | |
![]() |
procedure InitFrustumAndLight( const Frustum: TFrustum; const ALightPosition: TVector4Single); |
|
Call this when camera frustum is known and light position (of the shadow casting light) is known, typically at the beginning of your drawing routine. You have to call this before InitScene. This prepares some things (so that each InitScene call doesn't have to) and all subsequent InitScene calls assume that Frustum and LightPosition are the same. It also resets CountScenes etc. counters for debug purposes. | |
![]() |
procedure InitScene(const SceneBox: TBox3d); |
|
Call this when the bounding box of shadow caster is known. This calculates various things related to shadow volumes rendering of this scene. 1. checks whether you need to render shadow of the object inside SceneBox, settting SceneShadowPossiblyVisible. 2. checks whether ZFail method is needed, setting ZFail. This assumes that Frustum and LightPosition values given in InitFrustumAndLight are OK. Also note that after InitFrustumAndLight, all The above optimization works OK if you do not change StencilOp configuration yourself during SV rendering. | |
![]() |
procedure InitSceneDontSetupStencil(const SceneBox: TBox3d); |
|
You can split InitScene call into these two calls, first This is useful only in very special cases, in particular: if you only have one shadow caster object in your scene. Then you can call | |
![]() |
procedure InitSceneOnlySetupStencil; |
![]() |
procedure InitSceneAlwaysVisible; |
|
This is an alternative version of InitScene that initializes the same variables as InitScene, but assumes that the scene, along with it's shadow, will always be visible. This means that for example SceneShadowPossiblyVisible, ZFail, ZFailAndLightCap will always be Use this only if you have a scene that will really be always visible and z-fail will be needed. For example, level scene in FPS games will usually be always visible, so making optimizations in InitScene may be useless. Also, this is useful if for any reason you don't know bounding box of the scene. | |
![]() |
property WrapAvailable: boolean read FWrapAvailable; |
![]() |
property LightPosition: TVector4Single read FLightPosition; |
|
Light casting shadows position, initialized by InitFrustumAndLight. | |
![]() |
property LightPositionDouble: TVector4Double read FLightPositionDouble; |
![]() |
property SceneShadowPossiblyVisible: boolean
read FSceneShadowPossiblyVisible; |
|
Does the shadow need to be rendered, set by InitScene. | |
![]() |
property ZFail: boolean read FZFail; |
|
Is the | |
![]() |
property ZFailAndLightCap: boolean read FZFailAndLightCap; |
|
Is the ZFail with light caps method needed, set by InitScene. | |
![]() |
property StencilTwoSided: boolean read FStencilTwoSided; |
|
Is two-sided stencil test (that allows you to make SV in a single pass) available ? This is initialized by InitGLContext, and is true if OpenGL provides one of:
| |
![]() |
property StencilSetupKind: TStencilSetupKind
read FStencilSetupKind write FStencilSetupKind
default ssFrontAndBack; |
|
What kind of stencil settings should be set by InitScene ? Set ssFrontAndBack only if StencilTwoSided is | |
![]() |
property Count: boolean read FCount write FCount default false; |
![]() |
property CountScenes: Cardinal read FCountScenes; |
![]() |
property CountShadowsNotVisible: Cardinal read FCountShadowsNotVisible; |
![]() |
property CountZPass: Cardinal read FCountZPass; |
![]() |
property CountZFailNoLightCap: Cardinal read FCountZFailNoLightCap; |
![]() |
property CountZFailAndLightCap: Cardinal read FCountZFailAndLightCap; |