CAL

Gordan Milovac, C++OpenGL
Back

This project is a final project for CS1230: Computer Graphics in Fall of 2023 at Brown University. I was mostly working on the Camera movement, Toon Shader and User Interface.


Toon Image


Project details

This project is an OpenGL application that allows users to customise and generate terrain. The user can select the type of biomes they want to generate, which can be either water, mountain, grasslands, forest or desert. Upon running the code a blank canvas shows up, prompting the user to either load an existing drawing or draw the terrain the want to generate. After running Generate Terrain a 3D model of the terrain appears. User can then move the terrain around, rotate it and zoom in and out. Two modes of shading are offered, one tries to make a realistic representation of the terrain and the other uses Toon shader, making the terrain look like a cartoon (or a comic book).

Github repo:

https://github.com/gmilovac/CAL

Demo video:

https://youtu.be/RRnJ7wooko4


Main Window


Project Description

This project is a final project for CS1230: Introduction to Computer Graphics at Brown University. It uses OpenGL and many concepts and ideas covered in the course. Most od the code is written in C++. The project is split into two parts, the first part is a canvas where user gets to draw an image of their terrain (similar to the Raster Project) and the second part is the terrain generation (similar to the Terrain Lab) which implements some new concepts such as Noise maps, Height maps and Toon Shading.


Fully Drawn


Design Choices

Biome Transitions:

As each biome has a different height and noise function, the transitions between biomes were not smooth enough. Adding the blur radius helps with making those transitions look more natural. On top of that, some additional parameters were added (all for aesthetic purposes). Anything above the water level but not quite grassland is considered to be sand(desert). Transition from a grassland to a mountain occasionally made grasslands very tall, so now it turns them into a mountain biome at a lover point. Mountain peaks and some really tall locations have snow on them. No biome can be generated below the water level.

Position(Height) Mapping:

Upon loading/drawing an image, the program generates a height and noise map for the terrain generation. Both are biome dependant. To get the actual position (height in this case) on the 3D model, both noise and height maps are used. Since the Perlin function calculation is very expensive, in order for code to render faster, generateTerrain() stores a height map for each location on the canvas. This allows the program to only calculate the Perlin function once and render in less than a second.

Toon Shading:

Toon shading is a type of non-photorealistic rendering designed to make 3D computer graphics appear to be flat. Toon shading is also known as cel shading. The name comes from a traditional animation process used to add shading to cartoons. The code used in our shader is based on the code from the following website: https://www.reddit.com/r/opengl/comments/1cwynl/toon_shader/

User Interface:

As stated above, user interface is pretty similar to the one in the Raster Project. Every time a new image is loaded, a new pop-up window generates. User can have multiple terrains generated at the same time (all of which support resizing). Buttons have the most necessary functions, such as loading an image, saving an image, generating a terrain and activating/deactivating Toon Shading. The rest of the functions are done using keyboard and mouse. User can move the terrain around, rotate it and zoom in and out. User can also change the blur radius which changes the sharpness of the transitions between biomes.


Output


Team members and contributions

Marcus Winter (mwinter20): Terrain generation, Noise and Height map generation

Gordan Milovac (gmilovac): Terrain movement, Toon shading, User Interface

Time allocated: 30+ hours

Errors / bugs

None found


3D Shader


How to

Build and run your program:

You can now use our OpenGL app!

© Gordan Milovac.Resume PDF