My previous post on building interior cube map reflections ended with a comment that I planned to make this work for city exteriors, and that's exactly what I did. Exterior reflections work almost the same as interior reflections. This wasn't too difficult to add because they already shared the same shader code. However, there was still some work to be done.
The first step was to go through all of my building exterior textures and determine which ones should be reflective. I had to decide what building materials were shiny metal or glass vs. other surfaces such as concrete. Three of the skyscraper textures were good candidates for reflections, but they had a mixture of colors for the parts that were windows vs. something else. I didn't want to make the entire surface the same reflectivity because that didn't look very realistic for mixed surface material buildings. I spent a while experimenting with different math that used the luminance (average of red, green and blue colors) of a texel to weight the reflection constants until I found a result that looked reasonable.
Another related problem was that I had a different reflection function for metals and glass. Metals support colored reflections and variable roughness/shininess, while glass uses Fresnel reflection and refraction based on the index of refraction with white (uncolored) reflections. It's not possible to use both at the same time for mixed metal and glass surfaces. I went with an equation closer to metal because I felt the variable roughness parameter gave me more control over the final look.
Here is an example of a flat-sided reflective building exterior viewed from the roof of an adjacent building. The lighter pixels are more reflective than the darker ones.
![]() |
Reflective glass and steel exterior of a city office building, viewed from the roof of a nearby building. |
The reflected image includes other buildings in the same city, sidewalks, roads, streetlights, telephone poles, and a few other objects. It doesn't include cars, pedestrians, trees, and buildings outside this city because these objects have high geometric complexity and are slow to draw. In addition, moving cars and people would require regenerating the cube map faces every frame, even when the player was standing still.
Cars themselves aren't reflective either. I added those 3D models years ago before 3DWorld supported metal materials and custom index of refraction values. These started as OBJ files, so I could always go back and modify the material parameters as they're stored as text. That would be a lot of effort though, especially considering that many cars have a large number of materials with names that are either generic (such as "material1") or not in English. It would be hours of trial-and-error trying to guess the correct settings for dozens of materials in each of the 13 car and truck models. I may do this eventually though.
I haven't yet solved the reflection sliding problem from the previous post. Cube maps are still being rendered at the camera (player's eye position) and only updated when the player moves. I have some amount of parallax correction includes, which helps somewhat.
Curved cylindrical buildings are supported as well. I particularly like the reflections they create. The sliding effect isn't as obvious on these curved surfaces.
![]() |
Some curved buildings also have reflective surfaces. (That red stack of spheres on the right is one of my new outdoor abstract art decorations.) |
It's not only buildings that are reflective. I've enabled reflections for all of the shiny surfaces. This includes metals such as walkway support pillars, stop signs, and news racks. There are also reflective glass surfaces such as walkway elevators and mall skylights, as well as water surfaces of ponds. Here is a screenshot showing a walkway elevator and cylindrical support. The reflections are difficult to see on the elevator glass since it's close to transparent, but they are there. Nearby buildings are mostly concrete and non-reflective.
![]() |
Reflections are visible in the shiny painted metal cylindrical walkway support pillars. The elevator glass is also reflective, though it's difficult to tell in this screenshot. |
Even the top glass surface of skyways is reflective. I didn't really need to add this since the player can't get up here without flying in "noclip" mode. This was picked up for free because it uses the same material as elevator walls and skylights. Skyways are up so high in the air that the reflection is mostly of the sky and clouds, which are rendered as a light blue color in the image below. This will change with time of day to match the average sky color and will fade to near black at night.
![]() |
Reflective upper glass surface of the city skyway. The player normally can't get up here. |
Solar panels on the roofs of parking lots also have a reflective glass layer. This gives a nice planar reflection of the surrounding city. The player can't easily get onto these, but reflections are still somewhat visible from ground level. (Note that the player can in theory fall onto these parking shades when jumping off building roofs. I haven't been able to do it, but it may be possible.)
![]() |
The glass surfaces of solar panels placed on the parking lot roofs are also reflective. |
I only added reflections to commercial cities with office buildings because residential cities with houses are lacking large shiny surfaces. There are a few surfaces such as park ponds and swimming pool water, but I didn't feel like those small areas were worth the cost of drawing the scene multiple times. Residential cities are actually more expensive to draw because there are many more houses than there are office buildings, which means more visible triangles.
![]() |
Reflections in the surface of a city pond. Swimming pools have similar reflections. |
Here is a YouTube video I recorded of city building reflections. They're far from perfect, but I still feel like the improve the look of the city.
I'm done with reflections for now. I may get back to this later if I come up with a better solution to the sliding problem. Various people have made suggestions that sound reasonable but don't work with my rendering system. For example, someone suggested mixing cube maps with screen space reflections and representing the closest few exterior walls as planar reflections. I'm not sure I want to do a big rewrite to fix it.
No comments:
Post a Comment