Skip to content
Karim SALAMA edited this page Aug 4, 2018 · 3 revisions

For a given output, the color of each pixel is calculated using the eval function in each node from right to left. This could be quite expensive in terms of computation. This is why optimizing the rendering process can be extremely useful.

At first, eval was a pure virtual function implemented in each Node subclass, defining the node's behavior. This naive method was not the most efficient for two main reasons :

  1. Constant nodes causing unnecessary function calls
  2. Nodes could call the eval function several times, returning the same value for one pixel

Emergence has had 3 main optimizations:

[1] Each node has a cache memory that is updated every time it's invalid. The cache is invalidated recursively by the X and Y gates on each iteration. This method could only reduce the rendering time for graphs composed of mostly constant nodes, otherwise the rendering time could even be increased in some cases. A pure virtual kernel was added later for each node defining only it's behavior to reduce code redundancy.

[2] Node can be constant. Constant nodes return their cache memory directly instead of recalculating its value. Node having only constant parameters are constant. The first optimization is undone.

[3] Each pixel has an id. The value of each node is evaluated one time per pixel according to its id.

Clone this wiki locally