Functions

Shadows
[Command reference]

Functions

BBDECL void BBCALL xCameraDisableShadows (Camera *camera)
 Disables shadows rendering for specified camera.
BBDECL void BBCALL xCameraEnableShadows (Camera *camera)
 Enables shadows rendering for specified camera.
BBDECL void BBCALL xEntityCastShadows (Entity *entity, Light *light, bool state)
 Enables or disables shadow casting for entity.
BBDECL int BBCALL xEntityIsCaster (Entity *entity, Light *light)
 Checks if entity casts shadows from light source.
BBDECL int BBCALL xEntityIsReceiver (Entity *entity, Light *light)
 Checks if entity receive shadows from light source.
BBDECL void BBCALL xInitShadows (int dirSize, int spotSize, int pointSize)
 Initializes engine shadow system.
BBDECL void BBCALL xLightEnableShadows (Light *light, int state)
 Enables or disables shadow casting for light.
BBDECL void BBCALL xLightShadowEpsilons (Light *light, float epsilon1, float epsilon2)
 Sets epsilon values of light source.
BBDECL int BBCALL xLightShadowsEnabled (Light *light)
 Checks if light source has shadows.
BBDECL void BBCALL xSetShadowParams (int splitPlanes=4, float splitLambda=0.95f, bool useOrtho=true, float lightDist=300.0f)
 Sets PSSM system parameters.
BBDECL void BBCALL xSetShadowsBlur (int blurLevel)
 Sets the level of Gaussian blur for the shadows.
BBDECL void BBCALL xSetShadowShader (const char *path)
 Sets path to shadow shader.
BBDECL void BBCALL xShadowPriority (int priority)
 Sets minimum priority for shadow casting.

Function Documentation

BBDECL void BBCALL xLightShadowEpsilons ( Light *  light,
float  epsilon1,
float  epsilon2 
)

Sets epsilon values of light source.

Every light sources has 2 epsilon values for shadows rendering. First value is a depth bias (it's needed to compensate inaccuracy of floating-point values), second value is to prevent shadowing of angularly triangles. Epsilons delete some noise from shadows, but can lead to incorrect rejection of a part of shadow. Default values are optimal, but you may need to adjust them for best results.

Parameters:
lightLight source handle
epsilon1First epsilon value (compensates inaccuracy of floating-point values)
epsilon2Second epsilon value (prevents shadowing of angularly triangles), actually it is a cosine of maximum angle of shadowed triangle.
BBDECL void BBCALL xLightEnableShadows ( Light *  light,
int  state 
)

Enables or disables shadow casting for light.

You should set casting priority for light source greater than zero to enable shadow casting from it. Priority allows you to change shadows quality in your game, for more information see xShadowPriority()

Parameters:
lightLight source handle
stateLight casting priority
See also:
xShadowPriority()
BBDECL int BBCALL xLightShadowsEnabled ( Light *  light )

Checks if light source has shadows.

Parameters:
lightLight source to be checked
BBDECL void BBCALL xSetShadowsBlur ( int  blurLevel )

Sets the level of Gaussian blur for the shadows.

Parameters:
blurLevelThe level of blur. See 'The levels of blur for the shadows.' for more information about the constants.
BBDECL void BBCALL xSetShadowShader ( const char *  path )

Sets path to shadow shader.

Specified shader must contain code for rendring shadow maps (writing depth textures), final scene rendering with shadows, and mixing result from all light sources. If no shader is specified in this function - default built-in shader ill be used.

Parameters:
pathShader file name
BBDECL void BBCALL xInitShadows ( int  dirSize,
int  spotSize,
int  pointSize 
)

Initializes engine shadow system.

You should call this function to use shadows in your game. You can specify size of shadow maps for all light types separatelly. If you set 0 shadow map will not be created for this light type, you can't cast shadows from this type, but you will save some video memory.

Parameters:
dirSizeShadow map size for direction light type
spotSizeShadow map size for spot light type
pointSizeShadow map size for point light type (uses cube map, it needs 6 renders of scene)
BBDECL void BBCALL xSetShadowParams ( int  splitPlanes = 4,
float  splitLambda = 0.95f,
bool  useOrtho = true,
float  lightDist = 300.0f 
)

Sets PSSM system parameters.

You can change number of PSSM split planes (PSSM technique splits visible scene in some parts, each part will be rendered separatelly to its own shadow map and will use all this map. It increases quality of shadows near camera, but may cause loss of quality in large distance from camera), and split lambda. We set optimal values, but you may change them for best quality (or for increase of speed). Also you can change projection type for shadow map rendering, and set distance of light source from camera view point (larger distance causes larger part of scene which casts shadows, but quality of shadows will be poorer).

Parameters:
splitPlanesNumber of split planes for PSSM rendering
splitLambdaValue for active camera pliting frustum.
useOrthoTrue to use orthographical projection for shadow map rendering, false - for perspective projection
lightDistDistance from light source to view point
BBDECL void BBCALL xShadowPriority ( int  priority )

Sets minimum priority for shadow casting.

All light sources have shadow casting priority. If priority is greater than zero - light source will cast shadows. But you can set global priority and shadow casting will be disabled for all light sources, which priority is less than the global one. You can use it for changing shadows quality in your game (enable more light for powerful machines, and disable it for old hardware) using one command.

Parameters:
priorityGlobal shadow casting priority
BBDECL void BBCALL xCameraDisableShadows ( Camera *  camera )

Disables shadows rendering for specified camera.

Parameters:
cameraCamera handle
See also:
xCameraEnableShadows()
BBDECL void BBCALL xCameraEnableShadows ( Camera *  camera )

Enables shadows rendering for specified camera.

Parameters:
cameraCamera handle
See also:
xCameraDisableShadows()
BBDECL void BBCALL xEntityCastShadows ( Entity *  entity,
Light *  light,
bool  state 
)

Enables or disables shadow casting for entity.

In some cases you need some entity which doesn't cast shadows from specified light source (e.g. light bulb). This function excludes entity from list of shadow casters. By default entity casts shadows from all light sources.

Note: Any transparent or ordered entity will automtically exclude from casters

Parameters:
entityEntity which must be excluded from list of casters
lightLight source from which entity will not cast shadows. If 1 spefified command will affects to all lights
stateIf true - entity will cast shadows.
See also:
xEntityIsCaster()
BBDECL int BBCALL xEntityIsCaster ( Entity *  entity,
Light *  light 
)

Checks if entity casts shadows from light source.

Parameters:
entityEntity to be checked
lightLight to be checked
See also:
xEntityCastShadows()
BBDECL int BBCALL xEntityIsReceiver ( Entity *  entity,
Light *  light 
)

Checks if entity receive shadows from light source.

Parameters:
entityEntity to be checked
lightLight to be checked
See also:
xEntityReceiveShadows()

Xors3d Engine, Copyright © 2009-2011, www.xors3d.com Generated by Doxygen