Directional Lights

    Because the distance between the light and the illuminated target is undefined (infinite distance), the lighting effect is not affected by the position and orientation of the light (as shown below, directional light produces the same lighting brightness in all planes). However, rotation affects the direction of directional light, which in turn affects the extent to which the model receives light and where the model produces shadows. This can be done with the Rotate Gizmo in the upper left corner of the editor to adjust the direction of directional light.

    image

    Adding directional lights to the scene can be done as described in .

    A directional light node will be created automatically by default when creating a new scene.

    Note: Starting with v3.5, Parallel Light Shadows are separated from the Scene Settings panel and do not set shadow properties globally.

    image

    Enable CSM Mode

    The Cascaded Shadow Maps (CSM) method solves this problem by providing depth textures in chunks based on the distance from the object to the observer. It splits the camera’s view cone into several parts, and then generates separate depth maps for each part of the split.

    A higher quality shadow map is used for near scenes, and a lower quality shadow map is used for far scenes, with one of the two shadow maps chosen for use where they transition. This ensures that the observer sees higher quality shadows in the near area and lower quality shadows in the far area, because the distant objects occupy only a small fraction of the screen, while the near objects occupy a large fraction of the screen.

    • CSM ON:

    FixedArea Mode

    FixedArea mode is used to set whether to manually control the range of shadow effects displayed within the visible range of the Camera:

    • If this option is unchecked (default), the engine uses the same crop process and camera calculations as CSM (Cascaded Shadow Maps), calculating the range of shadows generated based on the orientation and position of the Camera.

    image

    PCF Soft Shadow

    Percentage Closer Filtering (PCF) is a simple, common technique used to achieve shadow edge desampling, by smoothing shadow edges to eliminate jaggedness in shadow mapping. The principle is to sample around the current pixel (also called a fragment), then calculate the ratio of the sample closer to the lights compared to the fragment, use this ratio to scale the scattered light and specular light, and then color the fragment to blur the shadow edges.

    Cocos Creator currently supports hard sampler (HARD mode), 4x sampler (SOFT mode), 9x sampler (SOFT_2X mode). The larger the magnification, the larger the sampling area and the more softer the shadow edges.