Homeworld: Unbound 0.2: fixing ships that looked lit from every side
Someone who played 0.1 told me it “seems to have a sort of lighting from all sides, where the original only had parallel lighting from one distant source”.
That’s a really useful bug report, because it describes what they saw without guessing at the cause. And they were right.
The shading code was fine
The shading code was doing the right thing the whole time. It works out the same lit and shadowed sides on the headset as it does on desktop, and the values it produced were correct.
The problem was what happened to those values afterwards. The swapchain was getting linear color and treating it as sRGB, so all the mid-tones got lifted. Shadowed faces came up closer to the lit ones and the falloff across a hull flattened out. The result looks exactly like what the player described, with light coming from everywhere instead of from one direction.
The fix was declaring the right color space. I didn’t touch how the ships are lit at all.
Color bugs can look like lighting bugs
When a rendering bug looks like a lighting bug, it’s usually a color bug. You can tell because it affects everything evenly. If one model looked wrong you’d suspect its normals, but when the whole scene looks flat, the problem is in the pipeline.