Raxo

Raxo is a work-in-pro­gress real-time ras­ter­iz­ing soft­ware ren­der­er with a high­ly flex­i­ble, full-pre­ci­sion float­ing-point pipeline. This means that it draws ani­mat­ed objects and sce­nes using soft­ware run­ning on the CPU instead of with hard­ware on the graph­ics card.

Raxo is writ­ten in tem­plat­ed C++, and I am work­ing on using just-in-time (JIT) com­pi­la­tion of assem­bly rou­ti­nes to accel­er­ate ren­der­ing, by elim­i­nat­ing cost­ly con­di­tion­als in inner loops.

GitHub project: http://github.com/GHF/Raxo (git source repos­i­to­ry)

If you can ani­mate a ball, you can ren­der a wrench pho­to­re­al­is­ti­cal­ly at inter­ac­tive rates (à la Dodge­ball).

Raxo, cur­rent­ly in heavy devel­op­ment, is a con­tin­u­a­tion of my work for Stuyvesant’s ML6: Com­put­er Graph­ics course, taught by Michael Zaman­sky. While I may lat­er write games or demos with it, it is cur­rent­ly a way for me to ful­ly explore both the “clas­si­cal” and nov­el ren­der­ing tech­niques used by and devel­oped by com­put­er graph­ics researchers and game pro­gram­mers. I will do so by imple­ment­ing those tech­niques myself, in the most badass, impres­sive, mind-numb­ing­ly fast ways I can devise.

Goals

  • Raxo is, above all, a learn­ing tool for myself. It’ll prob­a­bly become the biggest project I’ve worked on alone. Though this is a rewrite of a big­ger group project and I’ve worked on much big­ger soft­ware projects out­side of an aca­d­e­mic set­ting, I have to say that design and archi­tec­ture is hard.
  • This is how it’ll work: I’m going to learn what it is I’m try­ing to learn (still fig­ur­ing this out) by deriv­ing and imple­ment­ing. I’ll gob­ble up blog posts, research papers, and text­books, but in the end I have to turn it into code.
  • It’s got to be fast. What is com­put­er graph­ics research if not a nev­er-end­ing expe­di­ent trade­off between speed and trick­ery of the eye?
  • It’s going to be done right; more right (err, right­ly?) than the hard­ware we have now. I want prop­er fill rules, sub­pix­el pre­ci­sion where need­ed, a full float­ing-point pipeline (that’s right, tex­tures, col­or buffers, lights—all 128-bit col­or), the whole works.
  • I want to explore tech­niques pub­lished in papers but nev­er imple­ment­ed in mod­ern hard. I have a flex-func­tion pipeline and no need to release a pro­duct, so why not go ahead and play with irreg­u­lar Z-buffers for shad­ow map­ping or sil­hou­et­te maps?

Implemented features

  • A sen­si­ble C++ archi­tec­ture and pipeline. Raxo is a library; it’s a col­lec­tion of loose­ly-linked class­es that form a ren­der­ing pipeline, like OpenGL or Direc­t3D. It takes in geo­met­ric data and draws it, but with­out an ani­ma­tion appli­ca­tion or 3D mod­els, it can’t do much
  • Coor­di­nate sys­tems with homo­ge­neous coor­di­nates
  • 4×4 Matri­ces and trans­for­ma­tions (includ­ing a SSE/SSE2 imple­men­ta­tion with an amor­tized cost of about 17 instruc­tion cycles per vec­tor on mod­ern Intel CPUs)
  • Full coor­di­nate trans­for­ma­tion pipeline as in the OpenGL fixed-func­tion pipeline, from eye space coor­di­nates to view­port coor­di­nates
  • Quater­nion rep­re­sen­ta­tion of rota­tions, includ­ing con­ver­sions to and from rota­tion matri­ces, lin­ear inter­po­la­tion in spher­i­cal space, and lin­ear inter­po­la­tion in lin­ear space with nor­mal­iza­tion
  • Arbi­trary ver­tex and pix­el shaders, with arbi­trary num­ber of inter­polants (spec­i­fied at com­pile time with tem­plate para­me­ters)
  • OpenGL-style materials/lighting prop­er­ties

I real­ly hate this sphere now. Its ren­der screw-ups has become a bloop­er reel for my life.

Work-in-progress

  • A “default” ras­ter­iz­er that sup­ports most of the fea­tures in OpenGL
  • Clas­si­cal Blinn-Phong light­ing, with point, direc­tion­al, and spot lights
  • Geom­e­try gen­er­a­tors and file load­ers (I’ve been star­ing at the same darn spin­ning tes­se­lat­ed sphere for more than a year now as a ref­er­ence mod­el)
  • Run-time spec­i­fied ren­der buffers—Raxo can ren­der to screen using Pix­el­Toast­er, to file, or to a null tar­get for headless test­ing
  • Con­vert­ing some inner loops to assem­bly so they can be gen­er­at­ed by AsmJit
  • Hand-cod­ed SSE/SSE2/SSE3/SSSE3/SSE4.1 (list would be longer if I had a new­er com­put­er) intrin­sics to accel­er­ate some key parts
  • Cam­era sys­tem

Planned features

  • Per­spec­tive cor­rec­tion for inter­polants
  • Shad­ow maps and shad­ow vol­umes
  • Exter­nal asset load­ing from files
  • Dif­fer­ent mesh stor­age meth­ods
  • Pre­com­put­ed mapped ambi­ent occlu­sion
  • Screen space ambi­ent occlu­sion
  • Tone map­ping and gam­ma cor­rec­tion of out­put image onto screen
  • Depth of field

And beyond…

  • Post­pro­cess­ing fil­ters (also JIT com­piled)
  • Image qual­i­ty (mul­ti-sam­pling, tex­ture fil­ter­ing, etc.)
  • Things I find in research papers
  • ???
  • PROFIT! (may­be this will help me find a job?)

See my blog post on Raxo for an expla­na­tion for some of my choic­es in cre­at­ing Raxo.

Links

  • Chris Hecker’s per­spec­tive tex­ture map­ping arti­cles – Great for learn­ing prop­er ras­ter­i­za­tion rules, sub­pix­el and sub­tex­el pre­ci­sion, lin­ear inter­po­la­tion of vari­ables, and of course, per­spec­tive-cor­rect tex­tur­ing.
  • AsmJit – Ter­ri­fic run­time assem­bler. Gen­er­ates exe­cutable func­tions from assem­bly, and does high­er-lev­el things too, like reg­is­ter allocation/memory spilling for vari­ables. Since the death of Soft­Wire, this is the best choice for JIT assem­bly. Google Chromes’s V8 and Safari’s Squir­relFish Extreme JavaScript engi­nes have JIT com­po­nents as well that can be extract­ed for use, but of course they are not designed for the same tasks.
  • Pix­el­Toast­er – Cross-plat­form frame­buffer library of cham­pi­ons.
  • ompf.org forum – Com­mu­ni­ty for real-time ray trac­ing enthu­si­asts. Full of wiz­ardry in assem­bly, approx­i­ma­tions, hard­ware hacks and of course, float­ing point col­or.
  • Ras­ter­i­za­tion on Larrabee – Read­ing Mike Abrash (author of the Black Book, devel­op­er for Quake and Pixo­mat­ic) is always inspi­ra­tional and a bit hum­bling. Even when he talks about doing things you’ve no desire of ever try­ing, you can appre­ci­ate the effort and inge­nu­ity that goes into it all. Also, Larrabee. Sweet.
  • Real Time Ren­der­ing – Nice book to have.
  • Fast­Flow – Inter­est­ing C++ par­al­lel pro­gram­ming library with dif­fer­ent abstrac­tion lay­ers for describ­ing com­put­ing prob­lems and solv­ing each in par­al­lel.
  • Brown CS123 slides – Slides from course taught by van Dam of Foley and van Dam. The 2009 course sup­pos­ed­ly uses an unpub­lished ver­sion of said book.
  • SSE Idioms