Laboration 4

The procedural planet

Using geometry and/or tesselation shaders, you should go from a trivial shape to a somewhat interesting planet. You will mostly work in the geometry shader, and use my tesselation shader as a tool on the way there.

Here is the lab shell, with Codeblocks project file:

lab4.zip

And shortly before this, I uploaded the lab shell without Codeblocks project file, kept because I believe in backup plans:

lab4-preliminary.zip

Makefiles exist for Mac and Linux.

The lab shell gives you a cube, initially as wireframe. You can rotate it with the mouse. Using a noise function and tesselation, you should reshape this to a nice looking planet (actually a bumpy sphere).

The lab shell includes a complete chain of tesselation and geometry shaders, although what you see initially is just a simple pass-through. Use this to define tesselation and apply the noise for offsets.

1. The cube is initially drawn as wireframe. Change the tesselation of the cube. You change the tesselation level by the keys 1 and 2 for outer 1, 3 and 4 for outer 2, 5 and 6 for outer 3, + and - for inner.

Feel free to change the initial tesselation levels.

What tesselation level seems like a good idea?

2. Change the cube to a sphere. Use the geometry shader for this. Try different tesselations.

Did you get gaps? Why?

How did you make a sphere?

3. Set the geometry shader to render a solid. Add noise to the positions. Hint: Consider what noise function I provided.

What noise did you use, and why?

How did you add the noise?

4. Extend the noise to multi-band (FBM) noise.

How many bands did you need for a good look?

5. Calculate normal vectors. Hint: Sample your noise functions more than once

This is the hardest part of the lab so I will guide you:

Follow the following steps:

Calculate three different vectors along the surface, based on the position being the normal vector. You can do this before the noise offsets.

Using small steps along these, find three points around the vertex.

Use these three, the “triangle method”, for finding the new normal.

How did you find the three points?

What distance did you use to the neighbors?

6. Optional! If you have time, make it nicer. Open question. Move the camera over the surface? Texture? Add lakes? Height variations? Your trees from lab 3?

That’s all! I hope you found the lab series interesting and not too hard! All labs are brand new so I am interested in your input.

© Ingemar Ragnemalm 2021