Cycles code analysis


The purpose if analyzing Cycles is to understand if its approach to adding a new renderer in Blender can be used for BEER as well.

The main purpose of the analysis right now is to understand how this code is integrated into Blender itself, i.e how it is called and how it is able to access the data about the current scene in Blender and how to render it.
Secondary objective is to understand how it sets up its own data to be able to have them saved together with a .blend file

A quick overview of its source layout is available here

  • Cycles is written in C++
  • it consists mostly of a bunch of classes that descrive the Scene and its data and can act on it
  • since it must work with CPU, GPU and network renderer codes, it has a Shader Virtual Machine that virtualizes away the rendering environment
  • to be able to run across a network as a distributed renderer it seems to need (or maybe, it needed) a standalone interface, defined in intern/cycles/app/cycles_standalone.cpp that can optionally have a GUI. I don’t know if this is still current however
  • the invocation of Cycles from a running Blender instance is done in intern/cycles/blender/blender_session.cpp
  • Data from Blender in-memory structure is ‘converted’ to Cycles objects of class BlenderSync, using functions defined in intern/cycles/blender/blender_sync.cpp that are able to use Blender RNA structure objects to set up Cycles objects.

From existing docs on the Internal Renderer stored here it’s clear that this “each renderer defines its own internal data structures starting from the generic Blender ones” is standard («Conversion from Blender data structures is now usually in the same file, i.e. camera.c contains the code to convert a blender camera into a render camera.»)


Uhhh… YEAH! (too noob to say anything else) :stuck_out_tongue:


To make this clear: this is my best guess based on a very quick reading of the code: I started from an object ( Light definition) then I searched back the code where it was used, finding the Scene class… then I searched for where that class was used and was happy to see they were using code from the RNA, that should be a collection of all Blender’s data structures).
If someone has better insights… :smiley:
I’ll make the post a “wikipost”, this means anybody can change it


“wikipost” is that wrench thing right?


The marker is a “pencil on a paper” under the poster’s icon. To activate it, you need to click on the . . . (three dots) icon, that will become a wrench, then select Wiki post (or Un-wiki post) that right now is the only option available