This week end, i started to work on dynamic shadow maps for the station. It's been really exhausting. I found two nice bugs:
- shadow mapping involves a texture projection from light space to world space. When applying the transformation to a vertex in world coordinates, i forgot to divide the projection result by the w component. The x,y and z components were invalid, and i didn't understand why, until.. too late.
- the second bug was a typo in the code. I applied a transpose() operation to a matrix, thinking it would act as selfTranspose(). In the first case, the matrix is untouched and the function results the transposed matrix, while in the second case, the matrix is erased by its transposed part.
Now, shadow mapping is more or less working. The results aren't very good yet, i'm afraid.. lots of artifacts everywhere. I still have to tweak them and to match the light frustum to the object frustum ( at the moment some resolution is lost in the shadow maps ). Each object ( the station is composed of 7 objects ) gets its own 1024^2 shadow map. It's funny to move the light in circles around the station, and see the shadows running around.