Enables shadow casting for light (1=success, 0=failure, creates shadow map texture).
Takes light (light entity handle), shadowMapWidth (shadow map width in pixels), shadowMapHeight (shadow map height in pixels, ignored for point lights).
Returns 1 (TRUE) if success, 0 (FALSE) if failure.
3D Graphics
Parameters & Returns
Parameters
lightInt
shadowMapWidthInt
shadowMapHeightInt
Returns
Int
Quick Summary
Enables shadow casting for light (1=success, 0=failure, creates shadow map texture).
Takes light (light entity handle), shadowMapWidth (shadow map width in pixels), shadowMapHeight (shadow map height in pixels, ignored for point lights).
Returns 1 (TRUE) if success, 0 (FALSE) if failure.
Technical Exegesis...
Enables shadow casting for light (1=success, 0=failure, creates shadow map texture). Takes light (light entity handle), shadowMapWidth (shadow map width in pixels), shadowMapHeight (shadow map height in pixels, ignored for point lights). Returns 1 (TRUE) if success, 0 (FALSE) if failure.
Enables shadow casting for light (1=success, 0=failure, creates shadow map texture). Takes light (light entity handle), shadowMapWidth (shadow map width in pixels), shadowMapHeight (shadow map height in pixels, ignored for point lights). Returns 1 (TRUE) if success, 0 (FALSE) if failure. Validates entity is ENTITY_LIGHT type, creates shadow map texture (cube map for point lights using width as size, 2D map for directional/spot lights using width x height), sets light->castsShadows=true and light->shadowMap=allocated map. Shadow mapping for realistic shadows.
This function enables shadows. Shadow maps: depth texture rendered from light's perspective (stores distance from light to nearest surface), during main rendering compares pixel depth to shadow map (if pixel further than shadow map value then in shadow, else lit). Shadow map types: LIGHT_POINT (type=0) uses cube shadow map (6 faces, width x width x 6, captures all directions), LIGHT_DIRECTIONAL (type=1) and LIGHT_SPOT (type=2) use 2D shadow map (width x height, single direction). Resolution: higher resolution = sharper shadows (1024x1024 typical, 2048x2048 high quality, 512x512 low quality for performance), cube maps use width for all 6 faces (512 = 512x512x6). Shadow map creation: allocates GPU texture (depth format), creates render target view for shadow pass, stores in light->shadowMap pointer. Already enabled: if shadows already enabled (castsShadows=true and shadowMap!=nullptr) returns TRUE immediately (no-op, avoids duplicate allocation). Use cases: (1) Directional shadows (sun casting shadows on terrain/buildings), (2) Point light shadows (omnidirectional shadows from lamps), (3) Spot light shadows (flashlight shadows in cone), (4) Dynamic shadows (moving lights/objects cast moving shadows), (5) Indoor lighting (room lights casting furniture shadows). Common patterns: sun b3dEnableShadows(sun, 2048, 2048) for high-quality directional shadows, torch b3dEnableShadows(torch, 512, 512) for point light cube shadows, flashlight b3dEnableShadows(flashlight, 1024, 1024) for spot shadows. Typical usage: enable shadows for key lights (sun, main lights), disable shadows for fill lights (performance optimization), use lower resolution for distant/dim lights. Performance: shadow casting expensive (renders scene once per shadow map face, point lights render 6 times), use sparingly (1-3 shadow-casting lights typical), lower resolution for better performance. Shadow artifacts: low resolution causes blocky shadows (increase resolution), shadow acne (add bias), peter panning (reduce bias), light bleeding (increase filter quality). Validation: returns FALSE if invalid light handle, non-light entity, or shadow map creation fails (prints error to stderr). Related: b3dDisableShadows disables shadows and frees shadow map, b3dLightCastsShadows checks if light casts shadows, b3dLightShadowColor/Alpha configure shadow appearance.