Render¶
Render a layer using the specified backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Layer
|
Root layer to render. |
required |
config
|
Config | None
|
Rendering configuration. If None, uses default. |
None
|
filename
|
Path | str | None
|
Output filename. |
None
|
backend
|
str | None
|
Backend name ('mitsuba' or 'blender'). If None, uses default. |
None
|
**kwargs
|
Any
|
Backend-specific options. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
RenderResult
|
class: |
RenderResult
|
main output |
|
RenderResult
|
files, or |
Examples:
>>> import hakowan as hkw
>>> layer = hkw.layer(mesh)
>>> result = hkw.render(layer, filename="output.png")
>>> result.path # PosixPath('output.png')
>>> result.outputs # {'main': PosixPath('output.png'), ...}
>>> # Mitsuba: display the rendered image in a notebook
>>> result.image
Source code in hakowan/render/__init__.py
RenderResult¶
hkw.render() returns a RenderResult bundling the in-memory image (Mitsuba),
the main output path, and the manifest of all files produced (including per-pass
sidecars).
The outcome of a :func:render call.
Attributes:
| Name | Type | Description |
|---|---|---|
backend |
str
|
Name of the backend that produced this result. |
outputs |
dict[str, Path | str]
|
Manifest mapping |
image |
Any
|
The in-memory rendered image when the backend produces one
(Mitsuba); |
path |
Path | None
|
The main output path when written to disk; |
The object is also a :pep:519 path-like (__fspath__), so it can be
passed straight to open(), :class:~pathlib.Path, etc. when a main
output file was written.
Source code in hakowan/render/__init__.py
Related Functions¶
set_default_backend¶
Set the default rendering backend for subsequent render calls.
import hakowan as hkw
# Set Blender as default
hkw.set_default_backend("blender")
# All subsequent renders will use Blender unless overridden
hkw.render(layer, filename="output.png")
Set the default rendering backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Backend name. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If backend is not registered. |
Source code in hakowan/backends/__init__.py
list_backends¶
List all available rendering backends.
import hakowan as hkw
backends = hkw.list_backends()
print(backends)
# Output: ['blender', 'mitsuba', 'webgl']
List the rendering backends whose dependencies are installed.
Availability is probed without importing the heavy backend modules.