Page 1 of 1

One logical expansion of CFDG is to move to 3D

Posted: Tue Feb 15, 2011 2:16 pm
by mycelium
I post my ideas about 3D features in Context Free beacause I think it would be a great opportunity for new beautiful designs.
Unfortunately I don't have time to try to implement it and probably I am not able to.

Context3 (by Nom) has probably already implemented this, but I was never able to use it and now it seems like it is not available anymore.

Structure Synth is a very nice 3D version of Context Free but truly it is very different.
- Structure Synth is oriented in creating 3D models
- Context Free is oriented in painting


1. Rendering Engine.
CF rendering engine should be the same. Output is a "paint" not different from what is now.

2. Fixed Camera and flat projection default
- this allows total compatibility with previous designs.
- a simple directive may specify different camera parameters. (ie: camera {distance 100 angle 30})

3. 3D Geometry 3d rotations
- 3D is maybe already implemented in CF since we can specify z coordinate.
- What we need is the rx and ry parameters (rx: rotate around x axis; ry: rotate around y axis;) r parameter equals to rz

4. 3D basic objects
a) Sprites. Sprites are figures that are always drawn perpendicolar to z axis (painted flat). The existing figures SQUARE, CIRCLE, TRIANGLE, can be the default built-in sprites.
b) Planar figures such as DISK or FACE should be painted with geometry stretched according to 3d rotation and each pixel may have a different z coord.

5. Shades and lights
No shades and no lights.
Shading can be obtained manipulating colors. Maybe cycling brightness and saturation like hue could help.


- CF can evolute to 3D without loosing its unique features such as the ability of drawing millions of shapes and have superb antialias.
- The first step to 3D could be having 3D rotations.
- A basic 3D implementation in CF opens the door to unique, ultra detailed, 3d fractal architectures.

Re: One logical expansion of CFDG is to move to 3D

Posted: Mon Apr 09, 2012 12:25 am
by mycelium

I implemented some of this idea using (a lot of) parameters and some code with the new V3.

built in z coord seems to work really very well even with a huge number of shapes and a lot of transparencies.

A 3d wire

A dephormed sphere

A fractal

A dephormed cube filled with a wire

Math for 3d rotations was taken from here

Re: One logical expansion of CFDG is to move to 3D

Posted: Sun Dec 16, 2012 9:35 am
by mycelium
Update 2
After the first 3D designs I discovered that I always did similar things, using similar tecniques and doing a lot of copy/paste of formulas...

Since this didn't seem a complex job, I implemented a preprocessor (or maybe a translator, I don't know in what category it should be) that takes a modified 3D-CFDG code and creates a standard CFDG v3 code. It does some simple and mechanical things adding 3d formulas and manipulating strings in every shape / rule declaration, this is why I consider it a preprocessor.
I used PHP because I am familiar with it and it has many string manipulation functions.

Once translated, the 3D reference system and transformations are managed with the numeric parameters of the shape directive. Calculations and anything else is done normally by CFA.

In 1st implementation, some days ago, I used directly x,y,z, s of CFA to manage position and scaling. But I had sometimes problems with Z coord and this also was limitative for some aspects. The nice thing was that the smallest size internal directive for terminating the rendering still worked.

In 2nd and actual implementation absolute x,y,z are part of the new reference system. In this way it is also possible to create perspective view, shodows on a plane and maybe other things. (like in spaghetti chair)

The 3d shape adjustments are

X, Y, Z : move relatively x,y,z
RX RY RZ : rotate around X, Y or Z relative axis, R is same of RZ
SX SY SZ : scale relative axis X Y Z
S : SX,SY,SZ in identical manner

There is no skew and flip.
It is possible to mirror the reference system setting SX or SY or SZ to -1

3D primitives are implemented directly in CFA using paths too, directly using the variables rapresenting the reference system, for exemple a 4 side TUBO (a pipe) primitive in the semprevivo.

Rendering termination is obtained by specifing an absolute minimum shape size. Since I couldn't use "If" command (scope of variables is limited inside control structure) termination is obtained using boolean operation in the s adjustment of the shape... s (size > minimum).