Laboration 3

Procedural geometry, fractals, FBM/terrain generation

3a. Generate a fractal tree

The lab shell gives you a simple scene with a tree trunk, a somewhat narrowing cylinder. The cylinder is procedurally generated so you can customize it as you please (but you don’t have to).

We will be using the package “GLUGG” (OpenGL Utilities for Geometry Generation), which allows you to generate geometry with some helper functions, including translation, scaling, rotation, and a matrix stack. This allows you to use the stack for different recursion depths.

Preliminary lab material. No project or makefiles are included at this time. Noise functions are not included, but you can use the ones from lab 1.

lab3.zip (tested, work, Codeblocks projects included) Updated 2021-11-27!

Old versions, kept just in case:

lab3-preliminary.zip (mostly OK, just one obsolete function name)

lab3-old.zip (tested, work, Codeblocks projects included - strange #include in lab 3 fixed in new version above)

3a1. Create a tree by adding the shape multiple times, recursively.

(Details on GLUGG)

What transformations did you use to create the tree?

Do you get performance degradation? At what depth?

3a2. Add randomness to add variation to the tree

It is up to you to decide how to create the randomness and how to apply it.

How did you use randomness for the tree? What difference did it make?

3b. Generate terrain using noise

A similarly simple lab shell gives you a mostly flat surface. Your task is to add detail to it. This can be done either on the CPU or on the GPU. At this time, the first time the lab runs, we leave this an open choice, you do not have to make both.

3b1 Generate the terrain

You should decide on some method for generating a terrain with wide frequency spectrum like FBM. There are several possible method, all with different features, performance, suitability for parallel implementation etc.

What kind of noise function did you use?

3b2 Compute normal vectors

Implement a method for computing normals. Watch the edges!

What method did you use?

How did you handle the edges?

3b3. Add one more feature to the terrain

Free choice from below. If you are running out of time, take an easy one.

1. Put a procedural texture on the terrain (easy)

2. Vary color/texture depending on height (easy to medium)

3. Vary color/texture depending on slope (medium)

4. Make the camera follow the surface so we can “walk on the surface” (somewhat harder but there can be simple variants)

5. Make objects follow the surface (similar to 5 but a but more sensitive to errors)

Since this is the free choice step, we will be tolerant to minor errors in the result.

© Ingemar Ragnemalm 2021