Take the 2-minute tour ×

I'm working on a raytracer and I don't want reinvent the wheel when it comes to file formats for 3D scenes. I also want to be able to test my program with scenes made by others. I'm a programmer not a 3D modeller.

Is there a 3D scene format specific or well-suited for raytracing?

share|improve this question
Related: stackoverflow.com/questions/4364537/… –  Marcus Fritzsch Jan 19 '11 at 12:21
add comment

3 Answers

up vote 3 down vote accepted

When I wrote my ray tracer, I wrote an exporter for Blender (it's free). Blender itself can load dozens of formats, then a simple 20 line python script will give you the points you need.

The super nice feature is that within Blender you can convert all the model's faces to triangles. Most ray tracers will only work with triangles (or convert polygons to triangles internally). So having Blender do the heavy work of crunching those polygons is super nice.

To start with 20 lines of code will allow you to export just the polygons. From there, you can extend it to output materials, normals, etc. I like this method, because I can get the data I want in the format I want, but still have the option of importing more complex models.

Other methods will work, but you first have to figure out how to parse a file, then get it in the format you want. I'd rather code a ray tracer than a parser.

share|improve this answer
Actually most real ray tracers cope perfectly well with geometric solids. It's modelling software and raster-based renderers that typically only cope with triangles (or quads). –  Alnitak Apr 21 '11 at 10:33
Well that's not what I said in my comment was it? Go back and re-read my answer. I was talking about exporting triangles and talking about how Blender makes it easier by reducing quads and polygons to triangles. Geometric solids are easily supported by ray tracers, but I've never seen a single ray tracer keep polygons in polygon format. Instead they will convert them to triangles first as this simplifies the pipeline. Geometric solids were never mentioned in this question. –  Timothy Baldridge Apr 21 '11 at 13:36
You said "Most ray tracers will only work with triangles" which to most readers would mean exactly that (and hence excluding geometric solids). –  Alnitak Apr 21 '11 at 15:14
Taken out of context, yes, but read the whole paragraph that starts with "The super nice feature is that within Blender you can convert all the model's faces to triangles." Meaning that we're discussing faces and triangles. –  Timothy Baldridge Apr 21 '11 at 15:45
add comment

There really isn't a format specific to ray tracing (unless you count PovRay format). Ray tracing is a method of rendering images, which can be applied to any scene. People modeling scenes will be using the modeling software of their choice and save usually in the default format of the modeler.

It looks like you don't have any requirements to load a particular format (or you wouldn't be asking) so I'm guessing you just want to be able to import various geometry from around the net for testing. If that's the case, check out the ompf forum at: http://ompf.org/ They have a section with links to freely available scenes. You can get a feel for what's common there.

Another option is utilize the Open Asset Import Library: http://assimp.sourceforge.net/

this can import a large number of file formats for you. It loads them all into an internal data structure, which you can then process as you see fit. It uses a BSD license so it should be reasonably license compatible with whatever you're doing.

share|improve this answer
add comment

I don't believe there's any particular scene format in use, because different modellers require different parameters, and setup directives, etc.

The WaveFront .obj format is however very popular for describing individual objects within a scene, and many files in that format are available on the internet.

share|improve this answer
Well, the WaveFront format seems to be quite easy but it isn't particular well-suited for raytracing because of it's is vertex and face oriented style. It just crossed my mind that I could use the POV-Ray format. –  Fair Dinkum Thinkum Jan 19 '11 at 13:00
That's true, you can't describe a parametric solid in OBJ format. However, POVRay format is a "Scene Description Language", with complicated programming constructs, etc. It's very much more than just "put this sphere here". –  Alnitak Jan 19 '11 at 13:07
add comment

Your Answer


