Tuesday, September 15, 2020

Procedural Buildings: Improvements to Interiors

I've continued to improve 3DWorld's procedural building interiors over the past few weeks. I added some new room objects and models, some of them based on suggestions from other people. I'll describe the additions to houses and office buildings, and show some pictures in the approximate order in which I added them.

Houses

Bedrooms were often too large and sparse. One way to use the available space in larger bedrooms is by adding closets against one wall. There are large closets with 4 panels of folding doors, and smaller closets with a single door that opens. Closets can span the entire length/width of a room or only part of it. Closets must be placed to avoid blocking windows, doorways, or access to furniture such as beds.

Here are two screenshots showing a large closet and a small closet. I haven't yet added door handles to large closets.

Bedroom with a large closet in the back.

Bedroom with a small closet in the far corner.

Next I added trim along the edges where walls meet the ceiling and floors. Then I added trim around doors and windows. This makes it easier to tell where the wall and ceiling meet for buildings like the one below that have the same wall and ceiling textures. The screenshot above also shows trim along the walls and door.

House interior with wall trim around floors, ceilings, windows, and doorways.

Note that this trim accounts for a large number of polygons when you add up all the small quads needed, especially around all of the windows. Sure, they're only individual untextured white cubes, but there are more of these in a building than any other object (except for maybe books). This does finally add real 3D geometry for windows, which are cut into the zero width exterior walls using textures. As an optimization, trim is only generated and drawn when the player is very close to a building. Office buildings don't have quite as much trim.

Kitchens needed a bit more work. The kitchen sink was previously only a basin with no faucet. I added a simple two-cube faucet as a placeholder until I find a better model. I also added a dishwasher under the counter next to the sink if there was enough space. The most difficult part was disabling the cabinet doors around the dishwasher and adjusting their positions so that they start and end on either side of the dishwasher with no clipped or small doors.

Kitchen cabinets, counters, sink, dishwasher, and stove. The dishwasher has a shiny metal handle.

I decided that I liked railings better than straight vertical walls for the smaller sets of stairs that appear in houses and some other building types. It took a bit of work to add support for arbitrarily oriented cylinders, but I now have that working. I also added specular color support to the building materials system so that railings reflect light like proper shiny metal objects. You can see this used on the dishwasher handle above as well. This looks much better (and safer) than stairs with no railing at all. Here is an example screenshot, with the railings in beautiful gold.

Simple cylindrical railings have been added to open stairs.

Offices

When I was happy with houses, I moved on to improve office buildings. All those cubicles looked pretty bare. I decided to find a 3D model of a rolling office chair and place one in most cubicles with a random rotation. Right now the chairs are untextured black materials because I couldn't find a free model in a supported format that had proper materials with textures. This doesn't look too bad though, especially considering my chair at work is completely black with little texture.

A large office building room containing cubicles and rotating office chairs.

Adding chairs makes offices look better. But they're not lit very well with a single light in the center of the room. I increased the number of lights for some rooms using an X by Y grid of lights based on room size. Smaller rooms still have a single light, but larger rooms can have a 2x1 or 2x2 array of lights. There may be rooms with more than 2x2, but I haven't come across any yet.

Large offices can now have multiple light sources, usually an array of 2x1 or 2x2.

Desks were too empty, even though some had books on them. I decided to reuse the TV model as a computer monitor to put on some desks. I downloaded several screenshots and used one of my own desktop to create illuminated texture images on some of the monitors. These desktops are a mix of Windows, Linux, and MacOS. Monitors are more common in offices but can also be placed in houses. For now I haven't attempted to make the operating system consistent within a building.

Office desk with a monitor on it, turned on and showing a desktop.

The next step was improving bathrooms. Those individual tall sinks looked fine in residential bathrooms, but larger office bathrooms usually have a single long slab containing multiple sinks. I reused the kitchen sink code with some modifications for these bathrooms. Now the sinks are part of one counter with multiple basins and faucets, as seen below. Also, office bathrooms can have multiple lights as well.

Individual sinks have been replaced with a single long counter with built-in sinks for office bathrooms. They can now also have multiple lights.

I finally found a usable free urinal 3D model to place in the men's restrooms. I even added short walls between the urinals for privacy. Now they look like a proper men's restroom.

The Men's restroom now contains urinals.

I made various other fixes and improvements as well. Some houses have brown wooden front doors instead of white front doors. Straight stairs have walls on the sides or railings to keep people from falling off. The room object placement algorithm has been adjusted again to take into account clearance around objects to prevent the player and AI from getting stuck/blocked. Refrigerators are no longer placed in locations that block windows. Oh, and houses now have a number of bathrooms that scales with the size and number of total rooms in the house.

5 comments:

  1. The trim looks great, really makes it feel finished. If anything I'd make it more pronounced both in color and geometry.
    Now that you have a trim system, counters need a backsplash (tall bit of trim, with a tile texture if you have one)
    Railings are an improvement, though you need balusters (the vertical poles on each step). Could cheat it with a repeating texture on a single quad for distant stairs.
    More lights is better. I work in a small office and about 1/4 of the ceiling tiles are lights, so you can put a lot more in without it feeling too bright. You really need an "ambient" system as well, perhaps on a per-room basis. The ceilings are way too dark, as they would be lit by the indirect light from the room.

    ReplyDelete
    Replies
    1. I added trim on the exterior doors and building outside as well, and it's looking pretty good. The trim in my house is all white with very little contrast to the walls. My parents have black trim, but it's really old and not the style I see in modern houses.

      I was going to add a counter blacksplash but I guess I forgot and never added it to my list. I already have over 100 textures I got online, so I'm sure I can find or download a good one.

      I'm worried that balusters would add too much geometry, especially for curved surfaces. Maybe they can be added in the "detail" pass for nearby buildings. I think they only go in houses, because most office buildings have the railings connected to walls at the ends.

      The problem with building lights is that they really hurt fragment shader performance. The light radius needs to be very large to get the proper effect, even though they're confined to the rooms containing the lights and the connecting hallways. I end up with a single wall that has 20 different lights that overlap it in screen space, most of them with individual shadow maps. I tried merging shadow maps across lights but it didn't look right.

      Each room has pre-computed ambient lighting based on the number/size of lights and windows, etc. that affects room geometry. It doesn't apply to walls/ceilings/floors though because they're shared across multiple rooms. The entire city had 618K total rooms the last time I checked.

      The problem I have with upward pointing lights is that they would need separate shadow maps to keep them from bleeding into the room above. I didn't want to use two of my 60 available shadow maps for a single room light. Making them point lights with 6 cube map shadows would be even worse. I think I need to implement clipping in z (vertical) for lights, then I could use that, as long as there aren't stairs in that room.

      Delete
    2. Yeah, dark trim isn't super common these days. That said, the office I'm in has dark brown trim along the floor, and around the doors.

      Oh, I see. Seems like the solution to ambient lighting is to give each room its own ceiling and floor. Not a lot of additional geometry compared to the trim. Like with trim itself, you only really need it for nearby buildings or buildings that you're actually inside.

      Delete
    3. That's true, my office (which I haven't been to for nearly 8 months) has dark trim. Maybe I can use dark trim for office buildings, or have trim color randomly selected from a set of reasonable colors. I should probably use a variety of room wall colors in houses as well. My house has this light peach color on most of the walls.

      So many things to do, I wish I could work on this full time.

      Delete
    4. I added a dark gray trim around office building interiors and that has a good contrast and looks much nicer. Thanks for the suggestion!

      Delete