Particle Life Simulation in the Browser: A WebGPU Power Play

2025-05-26
Particle Life Simulation in the Browser: A WebGPU Power Play

This article details a browser-based particle life simulation powered by WebGPU. The simulation uses a non-physical model with asymmetric inter-particle forces, creating life-like behavior. The author explains the model, WebGPU implementation, spatial hashing optimization for performance, and rendering techniques, including a parallel prefix sum algorithm for efficient binning. The result is a visually stunning simulation capable of generating diverse and interesting life forms, with options for custom rules and sharing.

Read more
Development Particle Simulation

Virtual Pipes: A Simple and Efficient Method for Simulating Water Over Terrain

2025-02-06
Virtual Pipes: A Simple and Efficient Method for Simulating Water Over Terrain

This article introduces a simple and efficient method for simulating water flow over terrain in games – the virtual pipes method. Based on shallow water equations and using a staggered grid, this method treats water flow as columns connected by imaginary pipes. Water flow is accelerated based on water level differences, and outflow scaling prevents negative water amounts. The author details the three steps: flow acceleration, outflow scaling, and water column updating, providing code examples. This method is easy to understand, computationally efficient, and suitable for games requiring terrain modification and water simulation, such as city builders. While it has limitations such as lacking inertia and velocity diffusion, it's practical for most game scenarios.

Read more
Development water simulation

Mipmapping Alpha-Tested Textures: A Clever SDF-Based Solution

2025-01-17
Mipmapping Alpha-Tested Textures: A Clever SDF-Based Solution

A game developer encountered issues with mipmapping alpha-tested textures used for foliage rendering. Mipmaps caused textures to disappear or distort at a distance. The article explores various solutions, including adjusting alpha values and using Signed Distance Fields (SDFs). Ultimately, a combined approach using premultiplied alpha, max downsampling of SDFs, and averaging premultiplied colors proved effective, preserving texture shape while avoiding artifacts and improving visual quality.

Read more