Ever since I ‘upgraded’ TurtleBrains to use the OpenGL 3.2 Core context, ZoomCarWorld3 has not been rendering. For awhile it would actually throw errors and crash, until all the legacy OpenGL causing those errors was disabled. Last weekend the mission was to bring the rendering state back to where it previously was.
I had already fixed the skybox and wrote the sky shader, and even started the basic object shader. There was no lighting model, lines were not rendered at all nor was the track because it was not using a mesh. First thing to update was the line rendering. I got the lines stored as vertices and pushed through the pipe in a way GL 3.2 required, once that was complete their color was added.
Next up was the track surface which needed to be handled much the same way as the lines. It doesn’t use the same mesh class as the car at this time, so the storage format was updated. I quickly found that the editor gizmo had broke somehow in this process so after getting that working again a track mockup was created. All was going well.
Until I went to add a tree to the world. Notice something messed up? A careful observer can see the tree trunk is blue when it should be brown, also I now need to transpose the matrix before multiplying it on the model matrix. The color issue was simply because I store colors in ARGB format, but OpenGL seems to send colors down the pipe as ABGR. Ended up doing the conversion upon loading and creating the buffer to send to the GPU. So the colors went from ARGB to ABGR and back to ARGB. This went unnoticed on the car because the red and blue just swapped places. (See car in first images.)
The trees and car still look a little odd, especially if you compare from where the visuals were at in the old version with legacy OpenGL. This is because there was a directional light, which needs to be added to the basic object shader. The results of which first caused the lights to go out completely on all objects.
Programming can be fun and tedious going through these little steps. By ignoring the vertex colors and using the directional lighting, like the sun, the car started looking like the following image.
Continuing with the shader work to get ambient light I ended with a nice colored car and trees. Although the lighting is a bit darker than daylight. Time was spent tweaking to brighten up the ambient levels to that of day time and the colors seemed to have washed out a bit. Will continue to modify until I get it how I want.
Be sure to check for future updates, going to start working on some custom rigid body physics soon, aiming for a minimal playable by October 31st!