This is my Software Renderer. You can look at it, and you can change the rendering mode. Up until mode 5 I use Painter's Algorithm on a triangle level.
It's not optimized, and not very clean. I didn't know a thing about software renderers prior to this. Next time,...
It should render anything as long as it has coordinates for vertexes, edges and triangle edges. ATM, you have to paste your coords in data.js...
I am
not handling antialiasing after the z-buffering.
I could implement some mouse rotation if I had some extra time. -Hah.. extra time...
PS: In case you're wondering, mode 4 doesn't look that way by accident. I think it's fabulous. (also proves that I fill triangles on a per-pixel level from there on)
ChangeLog:
28-09:\> Added a canvas with a 3dsmax/c4d style background.
28-09:\> Created point drawing and line drawing functions for a cube.
29-09:\> Can draw a wireframe, with perspective and a "camera": projectionTransform(translatePoint(rotatePoint(x, y, z))).
29-09:\> Can rotate the camera (actually, the object).
30-09:\> Implemented rendering a cube as triangle wireframes.
30-09:\> Implemented scanline triangle filling with a trippy <canvas> antialiasing-related transparency/flickering "problem".
30-09:\> Added a few radio buttons which change a global flag to 1 2 or 3, which is read in the game loop.
01-10:\> Wrote an efficient triangle fill function that fills using large pixels instead of lineTo. This is for an eventual z-Buffering mode.
01-10:\> Implemented the Painter's Algorithm to order the triangles for now. Though there seems to be a problem with triangles at funny angles. Which happens because of the average distance calculation of this algorithm.
04-10:\> Implemented (fixed) my z-buffer with the interpolation of my z values. Note: As of now, modes 5 and up are no longer low res. I'm actually drawing 1/1 px instead of 1/4. (so it is slow as hell)
06-10:\> Calculating vertice normals.
07-10:\> Calculated averaged vertice normals (keeping in mind adjacent triangles sharing a vertice)
08-10:\> Finally implemented diffuse lighting by interpolating the right stuff. :> ..It does look shite though. Or does it?
10-10:\> Fixed a bunch of stuff and I should be done. I've also added mode 7, which is a diffuse lighting exploit that simulates reflections from some imaginary tiny lights.
You know, this thing is fully supported on any device with a good browser. So try it on your phone, see how many fps you get. :)