Devlog #4 | Lights and Menus


Dynamic Menus

The menu system has been overhauled to be fully dynamic. It adapts to the available options and primarily server as a navigation tool for development rooms, where I test new mechanics and features. image.png

New Development Room: Lighting

One of these new rooms focuses on lighting and is essentially a copy of the dungeon generator. However, it now includes a fully functional lighting system to test and refine interactions.

Lighting System Overview

The new lighting system allows for:

  1. A light on the player character, providing constant illumination.
  2. Magical lights (up to 4) that the player can place by clicking anywhere on the map.

Magical Light Mechanics:

  • Duration: Light remains active for 15 seconds (currently adjustable).
  • Enemy Repulsion: Enemies are repelled while the light is active.
  • Limits: Players can place up to 4 lights simultaneously. When max reached, user has to wait to a light disappearance until another can be placed. This mechanic adds a strategic layer to game-play, as players must decide where and when to place lights to maintain control over the environment.

Technical Implementation

The lighting system is inspired by GrizzliusMaximus’s 2020 post and shares similarities with Mike Daily’s Real-Time 2D Lighting but includes several optimizations for efficiency.

Shader-Based Lighting

The system heavily relies on shaders to shift shadow calculations from the CPU to the GPU, improving performance and reducing lag. Here’s a breakdown of how it works:

  1. Vertex Shader:
  • Calculates light positioning and size.
  • Positions vertices dynamically for shadows.
  1. Fragment Shader:
  • Renders the light with intensity decreasing as distance increases.
  • Optimized for scalable light sizes.
  1. Z-Buffer Optimizations
  • Shadows are rendered on a different Z-plane than lights, ensuring accurate depth handling without texture swapping.

This approach allows all lights and shadows to be drawn on a single surface, significantly reducing texture swap overhead. image.png image.png

Get Shadows and Sorcery

Leave a comment

Log in with itch.io to leave a comment.