Procedural City Generator
Overview
|
Features
Data-Driven Generation
This project uses an XML file to define the attributes that affect how buildings are generated. The attributes used are “Richness (how rich people in an area are)” and “Density (population density).” Richness affects how big of the area in a 2D slice the building takes. Density affects the height of the buildings. Each attribute has its own affective area, which is defined by 3 different value: the value in center, radius of affect area, and fade ratio. Both density and richness are more intense at their centers and the effected buildings have a richer/more dense result depending on how close the building is to the center of influencing richness/density.
|
Procedural Generated Buildings
There are 3 different building type in this project: Box, Cylinder, and Classic. Each of them has 3 different subtypes, each subtype changes how buildings are connected and how many sides the building has. All building types are influenced by the attributes loaded from XML during generation.
|
Procedural Generated Textures
This project has 5 different procedurally generated textures: diffuse maps for the lawns, windows and skybox, and normal and specular maps for windows. In order to make the window texture more realistic, each window adjusts its light based on the previous window. Each window dims the light from top to bottom and adds a random noise color inside itself.
|
Bloom Effect
To make the project more visually appealing, a bloom effect was applied in the rendering cycle. The code first fetches the bright side from the current scene and then performs a ping-pong process with Gaussian Blur to soften and spread out the bright area. It then combines the blur texture with current scene to create a bloom effect.
|
Dynamic Skybox
The code generates the texture for the skybox. The skybox randomly generates 1000 white-ish colored dots to represent stars on a 1024 x 1024 texture. The texture coordinates of each vertex of the skybox change overtime to move the position of the stars. The moon is billboarded and moves overtime to create an organic feel for the skybox.
|
Shader Lighting
To make the city feel realistic, the project makes use of a lighting shader. The moon acts as light source, sending its position to the shader every frame. Each rendered pixel of each building changes color based on their normal, specular, and emissive values. The reflection and shadow of windows on each building will changes dynamically.
|
Code Snaps [Github Link]
-
TheGame.hpp
-
TheGame.cpp
-
TextureGenerator.hpp
-
TextureGenerator.cpp
<
>
Demo Video
|