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
|
BackendName | None
|
Backend name — |
None
|
**kwargs
|
Any
|
Backend-specific keyword arguments forwarded verbatim to the
chosen backend (e.g. |
{}
|
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
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
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 |
BackendName
|
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
|
BackendName
|
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.