Rendering
Intermediate script that calls Blender.
Blender control script
This script passes the rendering parameters to the Blender rendering scripts.
- _get_base_blender_args(script_name: str, scene_path: str, runtime: RuntimeEnvironment)
Return basic arguments passed to Blender.
- Parameters:
script_name – Name of the Blender script to be run. These are found under src/blender_scripts.
scene_path – Blend file to be run. For slab simulations this is found from the main project directory. For system_simulation scenes it is either the template found in root/Internal or a modified copy of it in Slab simulation directory.
- Returns:
List of basic arguments for Blender scripts. Add additional arguments after ‘–’ that are passed to the script itself.
- Raises:
FileNotFoundError – if either the script or the Blender scene cannot be found.
- _get_blender_executable_path(runtime: RuntimeEnvironment)
Returns a path to a Blender executable file.
- Parameters:
runtime – The runtime environment object which contains the path to the Blender executable.
- Returns:
Path to Blender executable.
- Raises:
FileNotFoundError – if none of the paths actually contain the executable. This can happen if there is no Blender installed or none of the installed versions is compatible.
- process_forest_control(runtime: RuntimeEnvironment, system_sim_name: str = None, global_master: bool = False, generate=True)
Generates a system_simulation control file for forest simulation by reading parameters from a Blender file.
Note
Even if there are no usages for this method, do not remove it. It is used to generate the system_simulation control file from the scene template.
- Parameters:
runtime – Runtime environment object that contains the Blender executable path.
system_sim_name – ID of the system_simulation to create the control file for. Can be None only if
global_master == True.global_master – If True, the global master control file is updated based on the parameters in system_simulation template file. The result is saved to the project root directory.
generate – If True, generate a control file. If False, apply the control file.
- Raises:
AttributeError – if either
global_master == Falseandscene_id == None, because there is nothing to be done OR ifglobal_master == Trueandscene_id is not None, because the caller might expect something else to happen than rewriting of the global master control.
- render_forest(runtime: RuntimeEnvironment, system_sim_name: str, render_mode: str, silent=True)
Render different presentations of the forest scene.
- Parameters:
runtime – Runtime environment object that contains the Blender executable path.
system_sim_name – System simulation name.
render_mode – One of the following ‘preview’, ‘spectral’ or ‘visibility’. ‘preview’ renders only some preview images that can give an idea of the scene geometry without having to open the Blender file itself. ‘spectral’ renders all spectral channels as a single image. ‘visibility’ renders visibility maps that show which object is visible in each pixel.
silent – If True, Blender output is redirected to null stream to avoid cluttering of console.
- run_parallel_slab_wl_render(runtime: RuntimeEnvironment, rend_base_path: str, wl, ad, sd, ai, mf, clear_rend_folder=True, clear_references=True, render_references=True, dry_run=False, silent=True)
Runs a Blender script that renders a slab simulation for multiple wavelengths.
This is used by the optimization solver
slab_simulation.opt.- Parameters:
runtime – Runtime environment object that contains the Blender executable path.
rend_base_path – Base path for Blender renders. This is usually
data.path_handling.directory_slab_optimization_working()wl – List of wavelengths to be used in the rendering.
ad – List of absorption densities to be used in the rendering.
sd – List of scattering densities to be used in the rendering.
ai – List of scattering anisotropies to be used in the rendering.
mf – List of mixing factors to be used in the rendering.
clear_rend_folder – If True, the main render folder will be cleared before rendering.
clear_references – If True, the reference folders will be cleared before rendering.
render_references – If True, reference images will be rendered.
dry_run – If True, nothing is rendered and just print out some debugging information.
- Silent:
If True, Blender output is redirected to null stream to avoid cluttering of console.
- run_reflectance_lab(runtime: RuntimeEnvironment, rend_base_path: str, dry_run=False, sun_power=None, silent=True)
Runs a Blender script that renders the reflectance lab scene.
Warning
This method is very much not tested. Should test so it can be used for diffuse reflective surfaces [10.6.2025].
- Parameters:
runtime – Runtime environment object that contains the Blender executable path.
rend_base_path – Base path for Blender renders.
dry_run – If True, nothing is rendered and just print out some debugging information.
sun_power – If not None, sets the sun power in the scene.
silent – If True, Blender output is redirected to null stream to avoid cluttering of console.
- run_script(script_name: str, scene_path: str, runtime: RuntimeEnvironment, script_args: list[str], silent=True)
Runs a Blender script with given arguments.
- Parameters:
script_name – Name of the Blender script to be run.
scene_path – Path to the Blender scene file that is used by the script.
runtime – Runtime environment object that contains the Blender executable path.
script_args – List of arguments to be passed to the Blender script.
silent – If True, redirect Blender output to null stream to avoid cluttering of console.
- run_slab_wl_render(runtime: RuntimeEnvironment, rend_base_path: str, wl: float, ad: float, sd: float, ai: float, mf: float, clear_rend_folder=True, clear_references=True, render_references=True, dry_run=False, silent=True)
Renders a single image of the slab simulation with given slab material parameters.
This is used by the optimization solver
slab_simulation.opt.- Parameters:
runtime – Runtime environment object that contains the Blender executable path.
rend_base_path – Base path for Blender renders. This is usually
data.path_handling.directory_slab_optimization_working()wl – List of wavelengths to be used in the rendering.
ad – List of absorption densities to be used in the rendering.
sd – List of scattering densities to be used in the rendering.
ai – List of scattering anisotropies to be used in the rendering.
mf – List of mixing factors to be used in the rendering.
clear_rend_folder – If True, the main render folder will be cleared before rendering.
clear_references – If True, the reference folders will be cleared before rendering.
render_references – If True, reference images will be rendered.
dry_run – If True, nothing is rendered and just print out some debugging information.
silent – If True, Blender output is redirected to null stream to avoid cluttering of console.
- setup_system_sim_scene(runtime: RuntimeEnvironment, system_sim_name: str, slab_material_names=None)
Set up the system simulation for rendering.
Most importantly, this applies the material and light values frame by frame to reflect the values needed to each spectral band.
Warning
If this is not called before rendering, the results are arbitrary.
- Parameters:
runtime – Runtime environment object that contains the Blender executable path.
system_sim_name – Name of the system simulation to be set up.
slab_material_names – Names of the slab materials (must mach the ones used in the Blender file) as a list of strings like: [‘Slab material 1’, ‘Slab material 2’,…].