I would like to modify the source code of standalone Cycles to output a final image that contains the result of a specific pass e.g. depth, normal, etc.
I started exploring the Cycles source code to understand how to do this and would really appreciate some guidance.
My current progress:
- The final
--outputimage is written in the
Sessiondestructor . I’m assuming the
Devicecontains all the necessary information and the
DisplayBufferonly converts it to the desired output format . Maybe the
Devicealso contains the output of different passes and there’s a way to read it?
- Available passes are defined in
Filmclass  seems to contain information about which passes will be used, storing the data in an array of passes .
- The only place I found where passes are being added is in the
BufferParams constructor. Passes are also configured in the Blender section of the code base but I assume everything there is directly related to Blender integration and not used by Cycles standalone.
scene.cpp seems to define the main pipeline
- The output shouldn’t be gamma corrected – maybe setting
trueis enough? What about
NOTE: I tried adding direct source code links but wasn’t allowed because I’m a new user.
 https://developer.blender.org/diffusion/C/browse/master/src/render/session.cpp;fb39e26c242e4584117aa7584a2d0fbd5cf5ad57$113  https://developer.blender.org/diffusion/C/browse/master/src/render/buffers.cpp;b352637d179acd4e0d525a201ec1975092527926$463  https://developer.blender.org/diffusion/C/browse/master/src/kernel/kernel_types.h;b352637d179acd4e0d525a201ec1975092527926$402  https://developer.blender.org/diffusion/C/browse/master/src/render/film.cpp;b352637d179acd4e0d525a201ec1975092527926$317  https://developer.blender.org/diffusion/C/browse/master/src/render/film.h;b352637d179acd4e0d525a201ec1975092527926$59  https://developer.blender.org/diffusion/C/browse/master/src/render/buffers.cpp;b352637d179acd4e0d525a201ec1975092527926$47  https://developer.blender.org/diffusion/C/browse/master/src/render/scene.cpp;b352637d179acd4e0d525a201ec1975092527926$263  https://developer.blender.org/diffusion/C/browse/master/src/render/session.h;b352637d179acd4e0d525a201ec1975092527926$94  https://developer.blender.org/diffusion/C/browse/master/src/render/session.cpp;b352637d179acd4e0d525a201ec1975092527926$110