From BlenderWiki

Jump to: navigation, search
Note: This is an archived version of the Blender Developer Wiki. The current and active wiki is available on wiki.blender.org.

GSoC 2008 - Week 1 report

This week

This week, I completed the most important part of the first phase, creating the first Freestyle-based renders within Blender. Up to last week, I had only managed to open the 3ds file with lib3ds and hadn't gotten the view map calculations working. The basic execution process is divided in these few steps:

  1. instantiate the config path, the controller and the view
  2. set the controller's view to the instantiated view and set up the view dimensions
  3. load a 3ds file
  4. insert a style module
  5. compute the view map
  6. draw the strokes
  7. render the image

The original Freestyle program uses a Qt widget QGLViewer to display and manipulate 3D objects (step 6 and 7). I found out this week that the widget's functionality is also needed for the view map calculations (step 5). I managed to modify QGLViewer's code (which is open source) to only keep the strict necessary for the job. After a few trials, I got it working.

The strokes are rendered using commands in a style module, coded in Python. Python commands are executed through a class called PythonInterpreter, that routes calls to Python's C interface (PyRun_SimpleString and PyErr). Unfortunately, these methods simply crash, probably due to Blender's Python environment. Instead of fighting against the system in place, I decided to do some phase 2 work, having Freestyle use Blender's Python environment directly for its execution. It just worked. That is going to save me time in the next phase.

Once the Python commands were sent, I had to make the connection between Python and Freestyle possible, which is a SWIG wrapper. I managed to get that working: I compiled the SWIG wrapper as a shared library, used by the Python runtime. I haven't found a way to generate that library automatically with scons so right now, the wrapper module is compiled and linked manually (instructions are in the source/blender/freestyle/SConscript file)

Once that was working, I corrected a few integration bugs related to replacing Qt image library with ImBuf and got to a first render. I thought I would have to play around with the OpenGL context but that seems to work by itself (but it only works if "Render Display" is set to "Render Window"). My first render was incomplete (colors were inverted) but I realized that I had only gone up to step 6. By using the view's drawing method, the render became now correct (see http://maximecurioni.com/gsoc2008/?p=18 for examples).


Next week

Right now, the result is limited to a static scene and a static style module (compiled in code). The next step is removing this fixed information and rendering the scene model, using the camera information. I will use Blender's 3ds export capabilities to produce a 3ds file reimported later into Freestyle. I will also need to set up a Freestyle render panel to control the different options used by the view.

Before I do that, I want to make sure my work compiles and runs well on different platforms. Jean-Luc has tried compiling it and is facing issues with SWIG. I also had mfoxdogg help me compile it on Linux but didn't have a chance to finish it. I hope to do that in the next few days.


Issues

On my setup, I have no particular issue but I need to make sure that's also the case for other people. I also have had a crash with a particular 3ds file during view map calculations. I am not sure whether it is a problem with Freestyle's algorithm, lib3ds or something else. Once I get the scene model imported, I'll test it again. Stéphane (one of the original Freestyle authors) also mentioned that the image aspect ratio is maybe wrong. I set the view's dimensions to the render window's; I will have to determine whether OpenGL projection matrices need to be tweaked.


Schedule

So far, I feel I am a little bit ahead of schedule. I had planned to have my first render by the end of this week-end (the first phase is due for June 8). Even though that's a good thing, I probably spent more time than I should have and I am running a bit late in some of my school work. I will try to get some of it covered this week-end.