Shadows #586

Open
opened 2025-12-14 20:48:39 +00:00 by SakulFlee · 0 comments
SakulFlee commented 2025-12-14 20:48:39 +00:00 (Migrated from github.com)

Currently, we have no shadows implemented at all.
The initial idea was to implement Voxel Lighting, which would have coincidentally also implemented proper shadows.
However, this idea was scrapped for now.

Any shadow technique could work for now ... it just has to be performant enough and work well with our engine.
Without much more thought and without any weight, some ideas from Copilot:

There are multiple techniques to implement shadows in a 3D engine. The choice of technique may vary depending on performance requirements, visual fidelity, and the hardware used. Below are some of the most common methods:

1. Shadow Mapping
A widely used technique where the scene is rendered from the perspective of the light source to create a depth map (shadow map). During the second rendering pass, pixels are checked against this map to determine if they are in shadow.

Variants:

Basic Shadow Mapping: Simple and fast but may have aliasing issues.
Percentage-Closer Filtering (PCF): Adds softening to the shadow edges.
Variance Shadow Maps (VSM): Uses a depth range to allow smoother, anti-aliased edges.
Cascaded Shadow Maps (CSM): Specially designed for wide, open areas like terrains, splitting the shadow map into multiple levels of detail.
2. Stencil Shadows (Shadow Volumes)
Generates a mesh of the shadow volume based on the occluder’s geometry. The stencil buffer is used to determine which parts of the screen are in shadow.

Pros:

Exact shadow silhouettes.
Works well for hard-edged shadows.
Good on older hardware.
Cons:

Computationally expensive and less efficient for dynamic scenes or soft shadows.
Complexity increases with the number of light sources.
3. Screen Space Shadows
A screen-space technique that generates shadows directly in screen space at runtime. Examples include Screen-Space Directional Occlusion (SSDO) or Screen Space Ambient Occlusion (SSAO) with shadow emphasis.

Pros:

Efficient on modern GPUs.
Easy to integrate into modern PBR pipelines.
Cons:

Shadows won't appear for objects that are offscreen.
Less accurate for long-distance shadows.
4. Ray-Traced Shadows
Uses ray tracing to calculate shadows directly. This has become practical with hardware acceleration in modern GPUs like NVIDIA RTX and AMD's RDNA-based architecture.

Pros:

Physically accurate soft and sharp shadows.
Handles any light type (point lights, area lights, etc.).
Cons:

Requires high-performance GPUs; unsuitable for low-end hardware.
Potentially high development complexity.
5. Light Propagation Volumes (LPVs)
A voxel-based technique that involves subdividing the 3D scene into a grid, storing light propagation information in each cell. LPVs can also model global illumination.

Pros:

Supports dynamic lighting and shadows.
Provides global illumination alongside shadows.
Cons:

Less accurate than shadow maps.
Higher performance cost.
6. Projected Textures
A simplified approach where the shadow is represented as a texture projected onto surfaces. Often used for precomputed or offline processing.

Pros:

Simple for static shadows.
Low performance requirements.
Cons:

Doesn't handle dynamic objects well.
7. Hybrid Techniques
Combining several techniques (e.g., ray tracing with shadow mapping or cascaded shadow maps). Hybrid methods try to balance performance and quality depending on the scene context.
Currently, we have no shadows implemented at all. The initial idea was to implement _Voxel Lighting_, which would have coincidentally also implemented proper shadows. However, this idea was scrapped for now. Any shadow technique could work for now ... it just has to be performant enough and work well with our engine. Without much more thought and without any weight, some ideas from Copilot: ``` There are multiple techniques to implement shadows in a 3D engine. The choice of technique may vary depending on performance requirements, visual fidelity, and the hardware used. Below are some of the most common methods: 1. Shadow Mapping A widely used technique where the scene is rendered from the perspective of the light source to create a depth map (shadow map). During the second rendering pass, pixels are checked against this map to determine if they are in shadow. Variants: Basic Shadow Mapping: Simple and fast but may have aliasing issues. Percentage-Closer Filtering (PCF): Adds softening to the shadow edges. Variance Shadow Maps (VSM): Uses a depth range to allow smoother, anti-aliased edges. Cascaded Shadow Maps (CSM): Specially designed for wide, open areas like terrains, splitting the shadow map into multiple levels of detail. 2. Stencil Shadows (Shadow Volumes) Generates a mesh of the shadow volume based on the occluder’s geometry. The stencil buffer is used to determine which parts of the screen are in shadow. Pros: Exact shadow silhouettes. Works well for hard-edged shadows. Good on older hardware. Cons: Computationally expensive and less efficient for dynamic scenes or soft shadows. Complexity increases with the number of light sources. 3. Screen Space Shadows A screen-space technique that generates shadows directly in screen space at runtime. Examples include Screen-Space Directional Occlusion (SSDO) or Screen Space Ambient Occlusion (SSAO) with shadow emphasis. Pros: Efficient on modern GPUs. Easy to integrate into modern PBR pipelines. Cons: Shadows won't appear for objects that are offscreen. Less accurate for long-distance shadows. 4. Ray-Traced Shadows Uses ray tracing to calculate shadows directly. This has become practical with hardware acceleration in modern GPUs like NVIDIA RTX and AMD's RDNA-based architecture. Pros: Physically accurate soft and sharp shadows. Handles any light type (point lights, area lights, etc.). Cons: Requires high-performance GPUs; unsuitable for low-end hardware. Potentially high development complexity. 5. Light Propagation Volumes (LPVs) A voxel-based technique that involves subdividing the 3D scene into a grid, storing light propagation information in each cell. LPVs can also model global illumination. Pros: Supports dynamic lighting and shadows. Provides global illumination alongside shadows. Cons: Less accurate than shadow maps. Higher performance cost. 6. Projected Textures A simplified approach where the shadow is represented as a texture projected onto surfaces. Often used for precomputed or offline processing. Pros: Simple for static shadows. Low performance requirements. Cons: Doesn't handle dynamic objects well. 7. Hybrid Techniques Combining several techniques (e.g., ray tracing with shadow mapping or cascaded shadow maps). Hybrid methods try to balance performance and quality depending on the scene context. ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
SakulFlee/Orbital#586
No description provided.