User:Jbakker/projects/LookDev

Feature: Scene render engine
Currently the look dev mode uses only EEVEE as render engine. Users are requesting to use the render engine of the scene for look dev. Basically this means that any external render engine should be able to be used in look dev mode.

Functional Changes
This section describes the functional changes for when selecting Cycles. As other external engines can use the same API they can also use it, but they need to update their plugin. In the UX this change is really small. There will be a Scene Render Engine option in the shading popover when a viewport is in lookdev mode. This option by default is unset.

Example how this might look like. (This is an example that was copied paste together, not actual code :-) )



Approach
The project is not difficult, fits well with the current architecture. Would tag this as a small to medium project.

Phase 1: Preparation existing code-base When implementing I would start with the small fixes in Blender as separate patches. For example


 * the introduction of the utility functions to detect if an external engine is being used.
 * the consistency inside view3d_duplicate
 * the poll function for RENDER_OT_opengl

Phase 2: Enable external engines to be used for look dev

During this phase we implement the changes into the codebase of Blender (not yet cycles) to For testing we can add the bl_use_lookdev setting to cycles/blender/addon/__init__.py. It won't show the right result, but we can detect that everything is working as expected.

Phase 3: Enable Cycles to be used as render engine for look dev

Changes to Cycles to support rendering of the look dev mode. Cycles will not be able to render the look dev spheres.

Phase 4: Update documentation


 * RenderEngine Python API
 * Manual
 * /editors/3dviewport/
 * /editors/sequencer/
 * Release notes

Impact on the code-base
This change fits in the current architecture. There are areas that we can improve (and fix) in the existing code base during this project.


 * Add an option to RenderEngine to detect if the Look Dev is supported (bl_use_lookdev). Together with bl_use_eevee_viewport this will control the availability of the look dev mode.
 * bl_use_lookdev: This configuration setting is used to determine if the render engine can render the look dev mode by it self.
 * bl_use_eevee_viewport: when this option is available in the shading option a button will appear for Scene Render Engine.
 * When any of bl_use_lookdev or bl_use_eevee_viewport is set to true the Look Dev option will appear in any 3d viewport.
 * When both bl_use_lookdev or bl_use_eevee_viewport are set to true the Shading Pop-over will display the Scene Render Engine setting. By default this setting is unset so EEVEE is being used.
 * Look Dev Overlay: If the external engine supports bl_use_preview we will trigger preview rendering to generate the look dev previews. They will then be composited on the 3d view by the draw manager. When the external engine does not support bl_use_preview the look dev overlay will be deactivated (greyed out).
 * We will need to add a RE_USE_LOOKDEV_SPHERES for render engines to take over the rendering of the lookdev spheres. This is needed to support the current way how EEVEE renders the spheres.
 * Cycles
 * Blender Sync: detect if we are in Look Dev. When in Look Dev mode the world and lights are constructed based on the settings of the viewport. Also the background mixing will be done in the world material that is being created.
 * The HDRI's in LookDev are not loaded in memory theu
 * Viewport
 * check_rendered_viewport_visible
 * view3d_duplicate: When duplicating a view with an active external engine we should switch to workbench. We should replace the current implementation as it also switched for EEVEE, but only when in Rendered mode.
 * ED_view3d_calc_render_border: should also take into account the OB_MATERIAL + external engine. or remove this at all when there are no occurances.
 * ED_view3d_engine_type: add test to use external engine in look dev
 * Viewport Render Image/Animation poll method should check if the render engine is an internal (RE_INTERNAL).
 * ED_view3d_smooth_view_ex: Skip when external engine is being used.
 * Sequencer
 * seq_render_scene_strip: Add special case for OB_MATERIAL for bl_use_eevee_viewport = False
 * There are more edge cases here as the current implementation does not check the engine capabilities. For example an external render engine could not support Material mode, but still the sequencer strip preview can be set to material mode. We should check the capabilities of the scene engine and force the scene strip renderer to solid mode or rendered mode.
 * We should add a central utility functions if an external engine is currently used to draw a Viewport or will be used for a certain configuration. Currently this check is decentralized and implemented differently due to history (see Sequencer vs Viewport). There is no location that fits well (due to the dependency with BKE_sequencer, editors/view3d, draw and render library) my proposed location would be in (/source/blender/draw/).