C++ | Empirical raytracer

Yesterday, I decided add a windowed output to a a very basic raytracer I started to write 2 years ago. I wanted to figure out how a renderer is built inside. It comes with the following features :

  • unlimited pointlights
  • load/save alias|wavefront mesh file
  • load/save tga files
  • un-efficient antialiasing, variable sampling rate
  • no space partitionning strategy (hence VERY slow)
  • bitmap manipulation(copy, box blur…)
  • mesh manipulation(translate, scale, autofit…)
  • Render window using SDL

Here’s a row output of that thing. Text stream …

Rrenderer::Rrenderer(512, 512) Rmesh::loadFileWavefront() found 861 points, 1674 triangles Rrenderer::loadFiles(), loaded 1 file(s) Rrenderer::computeNormals(), 1 mesh(es) Rrenderer::computeBoundingBoxes(), 1 mesh(es) Rrenderer::fitScene(0.750000), scale scene by (0.806781) Rrenderer::computeBoundingBoxes(), 1 mesh(es) Rrenderer::renderScene(), rendering ... line 511 Rrenderer::renderScene(), 8794 ray/polygon hit, 11520044 ray Rrenderer::renderScene(), ray casting accuracy : 0.076337 %

… and bitmap.

Things to implement, as soon as possible : a decent adaptative AA, shadow casting, a BSP, gouraud shading.
Get a snapshot here.

Mental Ray | Rusty Metal

I was looking for some rusted metal shader for a scene I’m working on and I wanted it to be fully algorithmic, no bitmap at all.

The main idea is to have blurred reflection with some dusty bumps in the less accessible areas. This require several component to be layered : diffuse, noise, ambiant occlusion, blurred reflection …
I see many benefits in algorithmic shading :

  • small memory impact
  • no interpolation artifact
  • no more tilling issue

Here’s how it works, in pseudo-code :

amb_occ = ambiant_occlusion("cone=wide","distance=small","fallof=high"); C = diffuse() * noise("grey","orange") * amb_occ; C += specular() * noise() * amb_occ ; C += reflect("blur") * amb_occ ;

Quite simple, eh ? 😀