From BlenderWiki

Jump to: navigation, search

New Shading System Notes

Some notes that will eventually be turned into a proper release log.

What's New

  • New shading system is fully based on nodes.
  • Material presets for quick setup without the node editor.
  • Texture stack per parameter rather than shared.
  • Surface and volume shading in a single material.
  • BSDF based nodes compatible with many rendering algorithms.

Not Implemented Yet

  • Volume shading nodes and surface/volume integration.
  • Creating texture stacks from the material buttons.
  • Only a small amount of shading nodes are there now.
  • Defining presets in python.
  • Displacement and bump mapping using nodes.
  • Raytracing of BSDF node setups.
  • Visual warning for problematic BSDF node setups (non-linear combinations).


Backwards compatibility is being broken intentionally to get rid of some of the poorly working or outdated features. Some of the differences in may be due to bugs or incomplete code however, but the following features have been deprecated:

  • World exposure/range (use compositor).
  • Backbuf image (use compositor).
  • SpecTra, specular transparency (not possible to implement the same way anymore).
  • Energy Ramps (not possible anymore).
  • Jittered sampling for AO and Area lamps (use QMC).
  • Radiosity.
  • Warping and stencils in the texture stack.
  • Sticky texture coordinates.

Currently broken/incomplete is:

  • Area lamps are only working using a temporary workaround, lamps need to properly to lamp multisampling + shadow in the same loop.
  • Raytracing still works assuming the old code, this needs to be revised.

Other Code Changes

  • Many functions have been move to different files and renamed. Things still work the same as before almost everywhere, the intention was to make the existing code more clear.
  • The render global R was replaced by a variable passed to all functions that need it.
  • Shading and pass combining for solid and z-transp is now unified.
  • Render and ShadeInput structs have been split up into smaller nested structs, which are passed along instead of the full thing when possible.
  • Threaded render no longer uses sleep(), can save about half a second on a render.
  • Lamp shading loop has been reorganized, still more work needed but should be easier to understand how the final colors are achieved.

New File Organization

  • 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. This is not done for everything yet.
  • A good starting point for understanding the structure are the header files which have been cleaned up as well. An overview of most changed files:
    • camera.h camera related functions including coordinate space conversion.
    • database.h main storage for data in the scene
    • environment.h environment and atmosphere shading code
    • lamp.h lamp related functions
    • material.h material shading functions
    • object.h objects and instances
    • object_halo.h halo object create, access and rasterize
    • object_mesh.h mesh object create and access
    • object_strand.h strand object create, access, rasterize
    • part.h render parts/tiles
    • pixelfilter.h pixel filtering
    • rendercore.h scanline rendering of parts
    • render_types.h Render and nested structs
    • result.h ShadeResult and RenderResult manipulation
    • sampler.h QMC sampler
    • texture.h texture create/free/sample
    • texture_stack.h texture stack handling for material, lamp, ..
    • zbuf.h: rasterization of objects into buffers
  • Some files should still be split or better organized, hopefully these can be tackled later though the overall situation should still be better than before. In my opinion especially these files need work:
    • pipeline.c interaction with result.c should be more clear, some initialization moved
    • object_mesh.c no clear separation yet between object and object data conversion.
    • object_strand.c shouldn't have this much shading and rasterization code
    • object_halo.c contains most halo code, perhaps needs to be split up.
    • convertblender.c move object and instancing conversion to object.c.
    • rayshade.c mixes building acceleration structure and shading too much