Table of Contents

Introduction

This document outlines the implementation of lighting and shadows in our voxel world project. We've focused on creating a visually appealing environment with soft, realistic shadows and a color scheme inspired by a provided example.

Lighting Setup

We've implemented a lighting system that combines ambient light with directional lights to create depth and atmosphere in the scene.

Main Components:

  1. Scene Background
  2. Ambient Light
  3. Main Directional Light (Sun)
  4. Additional Directional Light

Implementation:

function setupLighting() {
    scene.background = new THREE.Color('#454e61');

    const ambientLight = new THREE.AmbientLight(0xffffff, 1.5);
    scene.add(ambientLight);

    const directionalLight = new THREE.DirectionalLight(0xffffff, 1.5);
    directionalLight.position.set(-1, -1, -1).normalize().multiplyScalar(200);
    directionalLight.castShadow = true;
    // Shadow configuration (see Shadow Configuration section)
    scene.add(directionalLight);

    const additionalDirectionalLight = new THREE.DirectionalLight(0x000020, 1.5);
    additionalDirectionalLight.position.set(-1, -1, -1).normalize().multiplyScalar(-200);
    scene.add(additionalDirectionalLight);
}

Shadow Configuration

We've optimized shadow settings for the main directional light to achieve soft, realistic shadows.