Making windows you can look into, with a dark room behind
Steampunk windows are now open, barred or shut, and an open one shows a real room that reads darker than its wall and shifts as you move.
The houses in Blobber’s streets now have windows you can look into. Each window on a steampunk house is open with its iron shutters folded back, barred, or shut behind riveted shutters, and about half are open. Behind an open one is a real room that the game builds inside the house. By day the opening is darker than the wall around it, and when you sidestep past it the inside slides across the frame.
Why did I want real rooms?
I wanted most windows to be looked through, and I wanted each look to treat them its own way. Cyberpunk is glass, steampunk is open or barred, fantasy is open with no glass and eldritch is some kind of membrane. I also didn’t want a room painted on a flat pane by a shader, so every house gets real rooms behind its windows. Only steampunk’s row is built so far. For the other looks a fill the kit hasn’t made yet leaves the window an open hole.
How is the mix drawn?
Each window is one of three kinds, open, second and shut, drawn with weights of 55, 30 and 15. In steampunk, second is iron bars. The kind is drawn once per face and storey, so one storey of a face has one fill and doesn’t look like a patchwork. Then with a 35 percent chance one window on a face is redrawn as a different kind, so there is at most one odd window per face. One house in eight is shut whole.
The draw uses its own random stream named “windows”, so adding it didn’t move any earlier draw. I planned 400 requests twice and got the same bytes. The wall pieces for an open window come from the building kit without a pane. A window with a fill gets a socket, and the assembler reads the socket to put in the shutters, bars or nothing.
Counted over 400 houses (4,950 windows), 44 houses were shut whole. In the other 356 the split was 52 percent open, 31.6 barred and 16.3 shut. Over every window it is 46, 28 and 26 percent.
Why did the first room look like a lit board?
My first version of the room read as a brown board that was brighter than the wall, which looked like a poster in the hole. The review sent it back. I measured it from 6 m at 15:00 and the window’s mean luma was 0.231 against 0.165 for the facade next to it.
The sun wasn’t the cause, because hiding it changed nothing. Three other things were. The short interior pieces were drawn on their model’s own material, with a pale plaster several times brighter than the sooty facade, at the full sky light. The shell’s linings behind them were also at full sky light. And the world’s fog, at density 0.02 there, was laid over the whole view into the room, so even a black room would have read 0.180. The barred windows had looked fine only because the bars broke the board up.
How does the room get dark?
All of it is in the one building shader, which has a define for each form. Every inside face takes 0.22 of the sky’s light, and keeps its ambient occlusion, its specular and the sun. The short interior pieces get the house’s numbers instead of their raw material.
The fog needed a different trick. Each open window gets a thin sheet of “air” laid in the opening, the same size as a glass pane. Its shader reads the screen and depth pictures to redraw what is behind the opening. It takes the world’s fog off, darkens the result by the depth behind the opening and puts fog back over only the distance from the eye to the opening. The darkening is 0.85 times (1 - e^(-depth / 3 m)). A face just inside the window is nearly as lit as the street, the far wall is dim, and it gets darker deeper in. At night the air thins by 0.6 and the room’s inside faces take the lamp’s warm light, so a lit window is one glow and not two.
I did it this way because a flat dark panel has no parallax. Reading the real room through the depth picture means the stairs and rails slide across the opening as you move. The limit is that the fog in that sheet is the plain exponential fog, so in long hazy views it can differ a little from the wall’s. It also can’t show a transparent thing behind the opening.
Rooms are built out to 64 m from the cell’s middle. Past that an open wall is drawn with its glazed twin, so a far window is a dark pane and never a hole through an empty house.
Does it work?
By day the opening is now 0.153 against 0.175 for the wall, and with the fog off it is 0.030 against 0.079. A test checks both. Another sends a ray through every open window in 24 plans and requires the first face to be at least 1.2 m behind the wall. Across 128 windows the nearest was 1.47 m, which is a stair run along a window wall, and the middle was 5.83 m, the far wall.
Held still, the room reads as a dark recess and not much more. The reviewer saw the depth only while moving, and that is how a player sees it, so I kept it. Walking back from 44 m to 84 m in fog showed no pop as the rooms end at 64 m, but I’ve only proven that in this fog.
What is still wrong
By day the near room is all one dark, so I want to lighten its first meter. At night it is one flat orange, which looks more like a lit blind than a lamp in a room, so it needs a falloff from the lamp. Barred windows lost the pale wall they had, and might need a faint lit far wall. The share of barred windows stays at about one in three for now, because I’m fine with it.