Saturday, May 4, 2019

Procedural City: Secondary Buildings Update

I'm still working on secondary buildings for 3DWorld's procedural city. I've made various minor improvements since the last post:
  • Added porch roofs to some houses.
  • Added garages and sheds to some houses.
  • Made the antennas on building roofs pointed and darker.
  • Reduced building draw time by more than 2x.
  • Various minor fixes to house placement and drawing.
  • Added logic to keep buildings from overlapping user-placed 3D models.
  • Added logic to keep buildings from being placed over the player start location.
House roofs and porches are simple geometry added to the building models. Porch roofs consist of a small, low roof placed about halfway down on the inside corner of L-shaped houses, plus a thin vertical support cube. Garages and sheds are really the same thing. These are additional smaller cube structures placed separate from the main house for L-shaped houses that may or may not have windows. The random number generator is used to choose sizes and placements of these objects. Here are some images showing examples of these new features.

House with covered porch (front) and house with shed (back).

House with garage (left) and house with covered porch (right).

I made a few changes so that user-placed 3D models interact correctly with buildings. The most important change was to prevent the building placement algorithm from placing a building that overlaps the XY bounding box footprint of any 3D model. Collision detection (for the player) somewhat works with models placed in tiled terrain mode. 3D models already project correct shadows onto buildings and themselves. However, buildings don't project shadows onto models yet. This is difficult due to the transformed coordinate space of the models, and the fact that models can be larger than terrain tiles. This limitation forced me to choose a model that was larger and higher than the buildings.

A Ferris wheel seemed like a good fit. It took a while to find one online that was free, in a file format that 3DWorld supports (obj and 3DS), and didn't have any issues. The model I used has no textures, so it's completely white. Well, I suppose that's pretty common for a Ferris wheel. They tend to be mostly made of white painted metal. It looks a bit odd though, because the cabins, base, and and smaller details aren't textured. Maybe I can add colored lights to it later. That would actually look pretty good at night. Anyway, here is what the Ferris wheel looks like when placed near a city.

Ferris wheel model placed in the city scene with interesting shadows. Buildings avoid overlapping it.

Note that the model flattens the terrain underneath it just like buildings, producing a depression around it's bounding box. There are no buildings overlapping the Ferris wheel.

There's quite a lot of geometry in this city scene now. We have the terrain, buildings, grass, trees, clouds, benches, roads, bridges, tunnels, cars, pedestrians, and placed models (the Ferris wheel). Here's a wireframe screenshot showing the high geometric density of the scene.

Wireframe models of Ferris wheel, buildings, city grid, terrain, and grass showing geometric complexity.

The grass blades seem to produce the most geometry, with a few million grass blade triangles in this view. There are about 250K triangles in the Ferris wheel, about 2M triangles in the terrain, about 500K triangles in the buildings, and maybe a few hundred thousand triangles in everything else. Many of the objects have occlusion culling enabled, which improves draw times. Both the terrain and buildings can act as occluders. I get almost 100 FPS (frames per second) on my GTX1070 for this view.

No comments:

Post a Comment