Appleseed renderer integration
Name: Denis Pavlov
Email Address: firstname.lastname@example.org
IRC nickname: DenisP
Phone number: +7 9096667090
Brief Background: Currently I am enrolled in master's program in Computer Science at Higher School of Economics, Moscow, Russia. I have got a bachelor's degree in Software Engineering also from HSE. I am doing my master's thesis in physcially based rendering at Moscow State University's graphics lab.
1. Title: Appleseed renderer integration.
2. Brief Summary
BRL-CAD uses a simple ray-tracing engine for rendering images of BRL-CAD geometry. Although it allows to efficiently visualize the data, the output images are not really photorealistic, comparing to modern state of the art rendering systems. The aim of this project is to integrate Appleseed renderer into BRL-CAD. It will allow to render high quality photorealistic images of brl-cad geometry with complex materials and light sources.
3. Detailed Project Description
Basically the project consists of two parts: Plugin on the side of Appleseed and modification of BRL-CAD.
1) Appleseed's side. Appleseed supports the plugin system which allows to extend the rendering system with new BRDF's, geomteric primitives, e.t.c. We will use if for integrating Appleseed into BRL-CAD, because this approach seems more robust and production suitable than modification of Appleseed's core. The main idea is to create one geomteric primitive that wraps all the BRL-CAD's geometry. Appleseed has P roceduralObject class for analytically defined primitives with virtual functions for intersection/occlusion and building bounding box. In this project I am going to create a class BrlcadObject, derived from P roceduralObject which will represent the BRL-CAD's scene. In the constructor it will parse the BRL-CAD's database and prepare the scene. And in the intersection/occlusion function it will call rt_shootray (from shoot.c, librt). This approach will allow to cover all the brl-cad's geometry and use native routines for finding intersections. BRL-CAD's materials will be translated into Appleseed's materials with somewhat similar properties ( e.g. may use different BxDF's but result in similar appearance). And lightsources will be supported via emissive material for BRL-CAD's geometry primitives (aside from environment maps).
Now let's discuss multithreading support. Appleseed uses boost :: thread for mutithreading. Before the main rendering loop, the primary image is being divided into a number of tiles with fixed size. Then each tile is being processed in separate thread. So, at this point, all the information we can get about current thread is thread's id (via boost :: this_thread :: get_id()). For using rt_shootray() in parallel we need to allocate resources for each thread and assign them beforehand. One way to do this is to use mutex for handling thread's id and assigning a proper resource. Another way to do this is to allocate a large array of resources (>> threads' max number) and calculate the resources id as thread_id % array.size. Both approches are not ideal. The first one forces threads to block each other because of the mutex and spend a lot of time waiting. The second one may create situations when two different threads use the same resources. The optimal solution would be to change Appleseed's routine for thread's spawning so that they would carry each thread's number (and not default boost :: thread :: id hash). This approach will be considered more in depth and maybe implemented at the final stages of the project.
2) BRLCAD's side. The starting point will be developing a small command-line utility for MGED that would initialize the Appleseed renderer with brlcad's database file, render the image and visualize it in MGED's Graphics Window. Next step would be to design a separate GUI window for interactive rendering and choosing rendering parameters(such as global illumination algorithm, number of samples, features like adaptive rendering, e.t.c. and maybe lightsource settings). And the last part of the project will be developing a simple material editor for Appleseed native BxDFs (or changing the existing one). This part will be discussed with BRLCAD's devs later.
The project can be devided into several major tasks:
1. Implementation of Appleseed plugin for BRLCAD geometry and materials.
2. Developing command line utility for using Appleseed from BRLCAD.
3. Developing GUI for interactive rendering and parameters input.
4. Developing a robust material editor for Appleseed's native BxDFs.
5. Writing documentation and probably some kind of tutorial for BRLCAD users.
The whole coding period is about 13 weeks. Here's an general plan:
Up to May 14: Get familiar with the codebase, read about CAD modelling, talk with brlcad's developers.
May 14 - May 21: Develop a basic Appleseed plugin and a command-line utility for running it from BRLCAD.
May 21 - May 28: Properly assign materials to different geometric primitives within BrlcadObject.
May 28 - June 4: Translate BRLCAD's materials to Appleseed's ones. Experiment with different BxDFs from Appleseed.
June 4 - June 11: Come out with a way to create emissive materials from BRLCAD. Prepare an evaluation and submit it. At this point there will be a working prototype.
June 11 - June 18: Start working on MGED GUI for interactive rendering.
June 18 - June 2: Discuss which Appleseed's features to support, try out interactive rendering.
July 2 - July 9: Start working on material editor.
July 9 - July 16: Prepare an evaluation and submit it.
July 16 - July 23: Decide which Appleseed's materials to use. Develop GUI according to them.
July 23 - July 30: Add support to environment maps, textures, bump maps, other brlcad features if possible.
July 30 - August 6: Add final changes, test the project on different platforms, fix problems if there are any.
August 6 - August 13: Write documentation, tutorial, submit the final evaluation.
>August 13: Keep maintaining Appleseed plugin, maybe work on something interesting.
6. Why me?
I have been doing computer graphics for a few years now and I know a lot about physically-based rendering and ray tracing(you can check out the renderer I write in my spare time: github.com/pavlovdenis/Lighthesizer ). And I have got some experience with modern C++ and pure C. I also have been experimenting with appleseed plugin system and brlcad and have managed to render .g database files with default material, here are some pictures: github.com/pavlovdenis/BRLCADsandbox ).
7. Why us?
First of all, because this project involves phsically-based rendering, ray-tracing and is written in C/C++. That's very close to my research area and my skills set. I am sure this project will be both interesting and useful to me. Second, I have used Appleseed before and I am familiar with the source code. I also have been playing around with BRLCAD for some time and it seems like a great project.
8. Time availability
The semester ends somewhere at the beginning of June. After that I am absolutely free and can offer 40+ hours per week. Before that I can spare like 20-25 hours a week which is probably going to be enough on the first stages of the project.