Zsar's picture

Procedural Figures?

I would like to pass a function like "f(x):=(y=x+1; z=x-1)" or "f(x, y):=(z=x+y)" or "f(x0):=(x++; y=x+x0; z=x+z)", a precision identifier, say 1000 or 0x3 for three decimal places, an optional limit to recursion depth and be done with it, as the manual advises to keep the number of GL calls to a minimum - and to pass any of (potentially very large) n values "manually" when I could just pass the function which generates these values seems to be supremely wasteful.

The relevant manual entry is empty.
The quick start file shows how to add figures per vertex. Methods to construct figures by vector are easily found within the API.
How would one add a figure by function? Is the obvious solution: compute-vertex-or-vector-and-insert-loop; the only one?


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Inertia's picture

This was supposed to fill the manual page you were linking to, but it was only used for stuff in the example launcher and makes not much sense to develop further. We just required some simple objects to keep the examples clean of tons of vertex definitions and independent of a model library.
What you're looking to do is straightforward to draw with points or lines, but you could also search the web for function plotting applications that accept your expressions.

Zsar's picture

So I cannot build a cellbased worldspace by declaring a cell fillable by Langermann’s function, the next by Rosenbrock's valley etc.?
Or a cube with sides from Schwefel's function?
... Without calculating it beforehand on the CPU, that is.

Mayhap a way to pass pointers from OpenCL to OpenGL? I have not yet looked into OpenCL but its description would suggest that it provide the interface necessary for such a task.

Inertia's picture

It can be done with both GLSL and OpenCL through for example sphere tracing, but that is not what the GPU is really good at and pretty slow... rather try a polygon representation and see whether there is a performance problem at all.
That Schwefel' Cube will most likely not look correct - there should be large gaps at the edges of the cube, maybe try an UV sphere or a capped cylinder instead.

Edit: Building Worlds With Distance Functions in GLSL @Geeks3D