It's always nice when you fix a bug, but when you fix a big, ugly, hidden, stealthy bug, now that's a day to be happy in. For those readers from yesterday, you will have guessed by now that I have indeed found the source of the heap corruption, and for the tech heads out there I am going to explain some more.
It all came about when a rather LARGE vertex declaration was requested from DirectX, and that request failed (i.e. position, normal, two sets of UVs, tangents, bi-normals and bone data). Turns out my static shader for the lightmapper had a left-over matrix palette constant set-up which forced the shader effect handler to add bone data to my meshes, which in turn created a non viable custom FVF, and when it exited the mesh change state early it did not recreate the mesh buffer to match the already re-sized vertex data and the memory copy did all the rest. Boom! I am now able to lightmap and load the models, and apply the shaders without the heap corruption and no more crashing. I still have them problem of understanding why some of the entities succeed the mesh change and some fail, which will no doubt lead to some conversion code, and I also need to expand my prototype to light map 'all' The Escape level rather than a subset but I am on the home stretch when it comes to getting this level lit properly so I can move onto finesse, video memory usage and finally performance.
Believe it or not but this was not the hog of the day! For the first time in recorded TGC history, we had a 2 hour conference call covering the subject of lighting in the engine. After much debate and many points of view (far more than the people in the call I might add), we arrived at settings which will be the new defaults for the next build. In short, ambiance to 30, brightness to 0, contrast to 50 and we are also replacing Veg Specular with a Global Specular slider which will allow all specular effect to be regulated across entity, terrain, characters and any other official shader effects. Also, to ensure end users who want to override a specific specular effect, I will be adding a new FPE field called specular which will allow the engine to select between the provided specular file, or to choose a pre-set none, low, medium and high specular on a per entity basis. It would also make a nice trick if you wanted to reduce the memory footprint of entities that have a consistent specular value (as the textures used will only be 1x1 in size and re-used).
As you can see above, this was our final agreed lighting between direct sunlight on the nearest building to low lighting on the building behind which is not directly facing the sun. Simon also discovered that all our lighting is based on a near sun-set style sun position, as demonstrated with his before and after shots.
To this end, we are adjusting the sky spec files to lift the sun higher in the sky to create a nicer overall blend of lighting between terrain and scenery objects. Seems in a single day I have the potential to add lightmapping and an improved overall colour balance to the engine.
In other news, we also had a chance to play the new multiplayer prototype, and Ravey has pulled it off once again with actual characters animating, running, shooting and generally behaving like the skeleton of a real death-match game. It was great to see, and the icing on the cake was that thanks to the Steam API, connection was a breeze. No router configuring, no firewall advice required, just go to Steam, click play, join lobby, game starts, run for your life, magic! Next on his list is things like jumping, fragging, re-spawning and host migration. Nothing pretty so how yet, just raw functionality, but progress is going well on this front and we think you will approve.
Alas it is only 2:28 PM in the afternoon and I have a few good hours ahead of me, and thanks to the protracted call this morning the 4 PM call has been cancelled so it's plane sailing to tea time. Just leaving my massive level to pre-bake while I add the global specular constant to all the shaders in anticipation of connecting the slider bar. Happy days...