Wednesday, September 21, 2011

Bears with bounding volumes

I recently started to add some primitive collision detection to be able to place objects to scene without them overlapping each other. I calculate bounding volumes during parsing of the object data. Whenever a new vertex comes in I test it for current min and max for x, y and z. Then in the end I calculate midpoint for the mesh as well. I added a debug mode to see the bounding volumes during rendering and this is the result. This is all simple and makes development and debugging much easier. Highly recommended step to do at the very beginning.



I've also rewritten the scenegraph part of the engine so that all CPU work (like the matrix calculation) happens before any GPU work. This meant a lot of refactoring but now I can enjoy much higher FPS rates even with a lot of complex geometry like exploding the buddha mesh and so on.

As next step I will experiment more with the explosion stuff, I want to add more physics. I already did some trials to rotate triangles while they fly but it did not really look that good, I probably will try to add per triangle velocity vertex attribute and apply gravity so that the pieces fall down. One problem also is that when I do the explosion in vertex shader my bounding volumes are not reflected to this change as shown below.


Tuesday, August 09, 2011

Exploding objects

Few months have passed and I've basically rewritten all internals of the engine. Now there is much more generic scenegraph with nodes that reference to objects that then may have one or multiple meshes. While cleaning things up I removed a lot of unnecessary calls bringing some performance up and making it simpler to test more complex scenes. There is a factory class to create terrains and tunnels dynamically and in the future possible other meshes. I also wrote freetype2 support so that it is easy to test and use different fonts.


I started to write 'effect' support which in practice means that scene will pick a particular shader program attached to the node and animate its attributes, offsets and so on. First I started to work on 'explosion' that animates vertices along face normal with an offset. I'm pretty satisfied with the results so far. Plan is to either fade away pieces while making them smaller, or possibly just let them hit the floor after initial 'radial' movement.


Monday, May 23, 2011

Normal tricks

I just spent some time rewriting the model loader. Old one was originally done to a software rasterizer and did not handle per vertex normals correctly. Now that I *finally* rewrote it, I can remove quite a lot of code that just sit there because of dependency reasons with the old SW engine :) Now mesh can have 2 modes, one with face normals that make the object look a bit like a sculpted wooden statue and another mode with per vertex normals that implement Blinn-Phong 'correctly'.

Wood statue :

For wood statue each vertex in a face gets the face normal, so each vertex normal points to the same direction.

Blinn-Phong :



For Blinn-Phong each vertex normal is the normalized sum of normals of all adjacent faces to the vertex.

Saturday, May 14, 2011

Light scattering

I got bored with the engine and decided to just play with effects for now. Here is real time light scattering, like explained in in Fabien Sanglard's blog. I plan to mix this with the earlier bloom shader and see if the thing still runs 60fps. It seems Acer laptop did not like light scattering though, both CPU and GPU temperature peaked very high and my laptop powered off itself, maybe some optimizations needed, eh :)

Tuesday, May 03, 2011

Hairy Balls!


I started to try out a bit more experimental things and implemented sort of a grass effect by abusing the normal data and drawing some GL_LINES per vertex. Looks nice, needs some more touch though ... more on that hopefully later.

Friday, April 29, 2011

Happy Buddha


Lighting is now fixed and speculars are finally moving according to camera and light position. In the end bug was simple but hard to notice, I forgot to normalize camera vector in the shader which made it *very* big compared to light vector in the lighting equation so light movement did not cause any changes and only camera did. Also pick feature got fixed on the way while porting recent changes to win32 build. Now it is time for new features and optimize the mesh loader, it takes ages to load buddha model :)

Thursday, April 28, 2011

tiger power


I rewrote my model loader and now there is support for multiple polygon groups and texture coordinates. Thanks to models and nice texture atlases from http://www.kunzhou.net/tex-models.htm I'm able to test that engine works. And then the bad news, while doing all this I noticed that lighting does not actually work, picking does not work anymore and some other misc stuff, but it was necessary price to get rid of old obj loader, time to fix these things.

Thursday, April 21, 2011

let there be light


Took a step forward to more 'game engine' approach and implemented a first person camera control with mouse and strafe with keyboard. Added terrain and much more sophisticated lighting and material model.

Wednesday, April 20, 2011

Teddybears


Dear diary, once again I started to build a small 3D engine, this time with OpenGL (ES) 2.0. Engine works fine with Linux PVR SDK, MESA software GLES 2.0 and MS Windows Nvidia OpenGL SDK. Engine contains a simple scene with objects (supports only .obj format at the moment) and a final full screen postprocessing pass. Objects are stored in VBOs and simple light model + bloom/blur is implemented using shaders. Engine provides a resource hash and memory management for shaders, textures, FBOs and other GL resources. Picking support (red teddy has been selected) now uses FBO and renders one extra frame with simple color shader. The end goal is currently to have a simple sandbox where to test different OpenGL features.