Proceduralness galore
Published Sunday, April 01, 2007 by Glow | E-mail this post
Last week I worked a bit on a new type of mesh for nerve. Next to the way too basic primitive mesh (which could only generate spheres, cubes, planes and cylinders), I implemented a procedural mesh. This mesh has a parameter named "formula" in which is simply a piece of text holding formulas (
or formulae?) for the x,y,z,u and v components of the mesh. Generating this mesh is just a matter of evaluating this formula for different values for s and t, my loop values.
Anyway, I wrote a special formula language for this purpose:
Funk. Here's a piece of Funk code for the image to the right:
// my crappy sphere for testing, uses s, t and pi
var radius = (1 + 0.2 * cos(<s>*20*<pi>) * sin(<t>*20*<pi>));
var x = radius * sin(<s>*<pi>*2) * sin(<t>*<pi>);
var y = radius * cos(<s>*<pi>*2) * sin(<t>*<pi>);
var z = radius * cos(<t>*<pi>);
var u = <s> * 8;
var v = <t> * 8;This piece of code is compiled into Funk VM bytecode. This pile of bytecode gets executed by my Funk VM which is running in my demo system and in Maya.
You can already edit and change this formula and see the results in realtime in Maya, but I'm currently working on a separate Code Editor dialog to make everything a bit more easy.
Although everything works quite okay already, I still have to clean everything up a bit more. And I still have to implement support for this into my viewport renderer and stand alone demo viewer. But I'm already quite pleased with the results.
PS, I used the
GOLD Parsing System to create my own language. Kudos to
Walter for the tip :)
0 Comments for “Proceduralness galore”
Add a comment