More Walls, Rendering Bug, and Sick Family
Hey Folks! Slower day today, as I discovered a rendering bug while working on auto-tiled walls. Also, with the family feeling sick today, I had to duck out frequently to help.
After a bit of email and admin stuff, I was back on my wall sprite rework, updating the complete wall sprite sheet's normal map. I fired-up the engine to see how it looked, and it wasn't too bad! But there was a problem: some of the highlights were in the wrong place.
I've been noticing this off and on over the past months, and every time I adjust my normal maps thinking their RGB channels are backwards (Unity flips one of them compared to other engines). However, O noticed a new detail today that eluded me before: the bug only happens on some lights.
Turns out, it's the orientation of the light! Not the normal maps I'm drawing.
More specifically, the way the shader calculates the direction from the light to an object assumes the light has a zero rotation. But lights can have any rotation on a ship, and even whole ships can have a rotation.
The good news is that this is probably a trivial fix. I've already found the place in the shader where I calc this direction, and all I have to do is rotate that direction by the opposite amount of the light's rotation.
The bad news? This is shader matrix math, and not my forte. I'm not sure how to access the rotation info I need from the available shader params. There are a whack of built-in variables and helper functions which all seem to be close to what I need. But not exactly.
I'll have to dig into this more tomorrow. Once I get that, it should make all things look better everywhere, which is nice! And I can resume making the walls look more detailed/directional. (Which, ultimately, should be a good step towards generating better videos and promotional screenshots.)