Overview

Geopipe’s facade textures always contain an integer number of rows and columns of windows. The information stored in the integer and fractional components of the UV coordinate can be used to uniquely identify the window in a given patch.

Facade Details

The number of columns and rows in a given facade are stored in the integer portion of the x and y coordinates of the secondary UV map.

number_of_rows_and_columns = floor(secondary_uv)

The unique ID for a given facade is stored in the fractional bits of the x and y coordinates of the secondary UV map.

facade_id = frac(secondary_uv.x) * 32768 + frac(secondary_uv.y) * 256

Window Location

By multiplying the primary UV coordinates by the total number of rows and columns and rounding down to the nearest integer, you get a coordinate to the current window. Coordinate (0,0) is equivalent to the bottom left of the building facade.

window_coordinate = floor(primary_uv * number_of_rows_and_columns)

Per-Window ID

The facade ID and window coordinates can then be combined to produce a window ID that is unique across the entire model. The specifics will vary depending on your shader language.

final glowing windows

Implementation

We have a tutorial for Unity that turns this guide into a shader. If you are using a different game engine or 3D modelling software, you can use that tutorial and this overview as a starting point to develop your own shader.