So I've been working on another unrelated thing lately, so my time quickly disappeared for working on this project. But this week I made some time to try and solve the issue I had run into before, mainly the fact that textures were not rendered correctly. Oh, they looked fine on the iron cuirass up there, but if I was to move the camera, you can visually see the texture warping incorrectly.
So in rendering there is and issue to do with mapping 2D textures onto a 2D plane that is represented in 3D space.......anyone who has experience with 3D modelling will know about UV coordinates, and how you use them to say where the texture goes. Well when rendering if you just use those values (which are assigned to the vertices), then you end up with whats called 'affine' texture mapping, its quick and easy to do (since you just read the UV values), but its ugly. This is because you are mapping a 2D texture onto the 2D plane on the screen, however that plane's back edge might be 'into' the screen, hence it should look smaller since it is further away, but affine ignores this effect and just pastes it straight on.
The correct way to do the textures is called Perspective Correct Texture mapping, where you the special 'w' values from projection to modify the UV coords interpolation so that the further away from the camera it gets, the smaller the texture is. It really complex, and it took me days to get my head around the maths.
The biggest problem is I am now well into the area where people just dont do programming, this stuff is all done for you in openGL and other....so very few hobby programmers know anything about how it works. Which was frustrating as the only info about it would be from thesis summaries and such....which are really hard to read when you are learning. I've also now gone beyond anything I have every had to program in graphics rendering before, in university we had switched to openGL once we got to texturing. Its all brand new, but so much fun to learn.
Now for the bit you non-programmers like, pictures! well only one picture, but still:
As you can see, now that hallway form before has textures on the walls, and the whole thing is starting to look like a real thing. Basically there is three parts left to all this, one easier then the other two.
1. Lighting. At the moment everything is bright and colourful. Realisticaly I want to put a light into the scene, so things further away get darker and plain shaded objects get more definition. This is the easy one.
2. Animation. At the moment there is only basic rotation, movement and scaling. What I need to be able to rig object up to a skeleton and move them around like that.
3. Optimisation. At the moment it run 'okay'. In that hallway I was getting 30FPS, but there is so much code in there that is just useless and slowing things down. Also, many of my functions were created 'to get things started' and could be made much faster.
Tune in next time, whenever that will be.