WebGL NetLogo-Like 3G Demo

Oops, your browser does not support the canvas element.

Notes

This is the first of two experiments looking at the use of openGL/WebGL for NetLogo-like modeling. Our interest is two-fold:

For our experiment, we use a model based on NetLogo’s Diffusion Graphics sample model.

This version of the experiment takes the most standard openGL approach possible: GLSL Attribute buffers for most of the Shader interactions, and JavaScript for all but the standard matrix pipeline computations. The only sophistication is use of a “z” uniform to let all the 2D objects have their own z plane.

The program uses two high level JavaScript objects, patches and turtles, which in turn contain arrays of individual patch and turtle objects. Each turtle and patch contain its shape, x,y position and color. Turtles also have a heading while the patches have a heat value. The higher level patches and turtles object contain a count of their objects along with the WebGL Attribute buffers they use.

The program is not object oriented in the usual sense but typical javascript. It is purposely simple so that most of it has a chance of migrating to the shaders.

Each frame does a LOT of processing in the JavaScript “step” function:

In terms of computation, this involves:

I’m seriously amazed how well it performs, given the large amount of computation done by JavaScript and the relatively large GPU Attribute changes each step.

The second model moves to much more computing done in the GPU.