Introduction

Interactive and dynamic painting simulation in WebGL.

Live version here.

This is a WebGL port of the visualization part of my OpenGL project flow-gpu.

Donate

Description

The painting is actually the superposition of several layers. Each layer is made of a set of particles, a flow map, and a background image.

Background

The background image is fixed and has 2 purposes:

Flow map

The flowmap is a 2D vector field. It can be altered with the mouse, and has 2 purposes:

Particles

The particles are "paint strokes" and are drawn as oriented, colored rectangles. A particle has:

A particles' state is stored in data textures, each pixel corresponding to a particle. The states are stored in 4 RGBA textures:

The WebGL extension ANGLE_instance_arrays is used to draw the particles. The position, birthdate and looks textures are updated in 3 separate passes, since by default WebGL doesn't support multiple render targets (MRT). There is an extension that allows MRT (WEBGL_draw_buffers), however this extension isn't widely supported yet (especially in mobile devices) so I chose not to use it.