PDA

View Full Version : Software Renderer



Luuk van Venrooij
30-08-2009, 09:47 PM
He all,

After a long absence from Delphi I started coding again a few weeks back. Im currently working on a new project which involves OGL 3.1. Because all transformation stuff is deprecated in OGL 3.1 I needed to brush up my math skills. Yesterday I didnt feel like coding on that project so I decided to put my brushed up math skills to the test and write a simple software renderer.

After a day of coding these are its features:
- double buffering
- proprietary mesh format (bored from my current project)
- wireframe rendering
- lighting
- flat shading
- gouraud shading
- backface culling
- perspective projection
- world space to view space transformation
- fps camera movement
- extensive math library (bored from my current project)

On my list are:
- phong shading
- texturing
- multi sampeling to improve image quality.

Of course a nice screenshot;)
http://img38.imageshack.us/img38/5405/67792180.th.jpg (http://img38.imageshack.us/i/67792180.jpg/)

Controls:
- mouse to look arround
- WASD for movement
- F1..F3 to toggle render modi

Download link:
http://www.genesisdevice.net/downloads/softwarerenderer.zip

Source is provided under GLPL. The model was made by a friend of mine in blender and exported to my own format.

Grz.

Luuk

Luuk van Venrooij
30-08-2009, 09:54 PM
Forgot to mention the original code for the gouraud shading can be found here:
http://www.swissdelphicenter.ch/torry/showcode.php?id=1780

I made improvements by minimizing scanline lookups and divides. Boosted performance from 20 fps to 50 on my machine :)

paul_nicholls
31-08-2009, 05:11 AM
Nice work Luuk! :)

I tried writing a software renderer a while back based on OpenGL (worked the same AFAIK), but I didn't get very far...

I could only draw flat coloured triangles - textured ones were deformed due to lack of perspective correction, and it was rather slow :)

cheers,
Paul

Luuk van Venrooij
01-09-2009, 08:38 AM
I have added supersampling to improve image quality:) The next thing Iam going to add is a Z-Buffer instead of triangle sort. After that texturing:D