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. |
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.
light | Light source handle |
epsilon1 | First epsilon value (compensates inaccuracy of floating-point values) |
epsilon2 | Second 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()
light | Light source handle |
state | Light casting priority |
BBDECL int BBCALL xLightShadowsEnabled | ( | Light * | light ) |
Checks if light source has shadows.
light | Light source to be checked |
BBDECL void BBCALL xSetShadowsBlur | ( | int | blurLevel ) |
Sets the level of Gaussian blur for the shadows.
blurLevel | The 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.
path | Shader 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.
dirSize | Shadow map size for direction light type |
spotSize | Shadow map size for spot light type |
pointSize | Shadow 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).
splitPlanes | Number of split planes for PSSM rendering |
splitLambda | Value for active camera pliting frustum. |
useOrtho | True to use orthographical projection for shadow map rendering, false - for perspective projection |
lightDist | Distance 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.
priority | Global shadow casting priority |
BBDECL void BBCALL xCameraDisableShadows | ( | Camera * | camera ) |
Disables shadows rendering for specified camera.
camera | Camera handle |
BBDECL void BBCALL xCameraEnableShadows | ( | Camera * | camera ) |
Enables shadows rendering for specified camera.
camera | Camera handle |
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
entity | Entity which must be excluded from list of casters |
light | Light source from which entity will not cast shadows. If 1 spefified command will affects to all lights |
state | If true - entity will cast shadows. |
BBDECL int BBCALL xEntityIsCaster | ( | Entity * | entity, |
Light * | light | ||
) |
Checks if entity casts shadows from light source.
entity | Entity to be checked |
light | Light to be checked |
BBDECL int BBCALL xEntityIsReceiver | ( | Entity * | entity, |
Light * | light | ||
) |
Checks if entity receive shadows from light source.
entity | Entity to be checked |
light | Light to be checked |