Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top