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!