Thursday, 2 August 2012

Render Module: It's Alive!


I think the above is how I felt when it was working. Thankfully the night I got it working, I was treat to some BBQ duck which went down a treat along with the excitement of this.

Generating the Scenefile format

I'd thought I'd share a bit on Lux Render Scene file format: Scene File Format 1.0 This is based on RenderMan's scene file format (from the guys who make Toy Story!) . The structure of the scene descriptions is very similar to Povray which despite its age is very easy to read, the only difficulty is getting used to the syntax having being so familiar with c++ development. For example:

"float focaldistance" [1.5]
Nevertheless with a bit of practice it soon becomes second nature. Essentially the steps I took at producing the scene file description were to look at the output produced from the povray example included in FreeCAD and with the wiki page on Lux Render. By making this converter I could build up some of the infrastructure with the RenderPlugin and RenderClass. An output created from the RenderPlugin which is a pretty simple plane and cube is on pastebin

Using luxrender GUI I could then import and quickly find problems with the syntax. Sadly nothing works perfect the first time and I was getting outputs like the following:



It took a lot of perserverence to get correct. From here it took several tweaks to get it to work but mainly the following
  1. Triangular Mesh Indices were in the incorrect order (BRep_IncrementMesh) produces them in the incorrect order.
  2. Lot of formatting problems with the output
  3. Quite surprisingly but 'LookAt' descriptor must come before the Camera descriptor which is mentioned in the documentation!

Drum Roll Please... Finaly we got some output! 



Giving the program a few more tweaks and letting the material colour inherit from the Part Appearance colour property, eventually we get some nice looking eye candy! We can make things made in FreeCAD look sexy.


Just for proof, to show that it did originate from FreeCAD 


This is just beginning there's still more work to do and more graphical goodness to share!