fresnel¶
Overview
fresnel.Device |
Hardware device to use for ray tracing. |
fresnel.Scene |
Content of the scene to ray trace. |
Details
The fresnel ray tracing package.
-
class
fresnel.
Device
(mode='auto', n=None)¶ Hardware device to use for ray tracing.
Parameters: - mode (str) – Specify execution mode: Valid values are
auto
,gpu
, andcpu
. - n (int) – Specify the number of cpu threads / gpus this device will use. None sets no limit.
Device
defines hardware device to use for ray tracing.Scene
andtracer
instances must be attached to aDevice
. You may attach any number of scenes and tracers to a singleDevice
.See also
- Devices
- Tutorial: Using devices.
- Tracer methods
- Tutorial: Using tracers with devices.
When mode is
auto
, the default,Device
GPU rendering and fall back on CPU rendering if there is no GPU available or GPU support was not compiled in. Set mode togpu
orcpu
to force a specific mode.Important
By default (n==None), this device will use all available GPUs or CPU cores. Set n to the number of GPUs or CPU cores this device should use. When selecting n GPUs, the device selects the first n in the
available_gpus
list.Tip
Use only a single
Device
to reduce memory consumption.The static member
available_modes
lists which modes are available. For a mode to be available, the corresponding module must be enabled at compile time. Additionally, there must be at least one GPU present for thegpu
mode to be available.>>> fresnel.Device.available_modes ['gpu', 'cpu', 'auto']
- mode (str) – Specify execution mode: Valid values are
-
class
fresnel.
Scene
(device=None, camera='auto', lights=[<fresnel.light.Light object>, <fresnel.light.Light object>])¶ Content of the scene to ray trace.
Parameters: device ( Device
) – Device to create this Scene on.Scene
defines the contents of the scene to be ray traced, including any number ofgeometry
objects, thecamera
,background color
,background alpha
, and thelights
.Every
Scene
attaches to aDevice
. For convenience,Scene
creates a defaultDevice
when device is None. If you want a non-default device, you must create it explicitly.See also
- Introduction
- Tutorial: Introduction to scenes
- Scene properties
- Tutorial: Setting scene properties.
- Lighting setups
- Tutorial: Using lighting setups with scenes.
- Devices
- Tutorial: Using devices.
Lights
lights
is a sequence of up to 4 directional lights that apply to the scene globally. Each light has a direction and color. You can assign lights using one of the predefined setups:scene.lights = fresnel.light.butterfly()
You can assign a sequence of
Light
objects:scene.lights = [fresnel.light.Light(direction=(1,2,3))]
You can modify the lights in place:
>>> print(len(scene.lights)) 2 >>> l.append(fresnel.light.Light(direction=(1,0,0), color=(1,1,1))) >>> print(len(3)) 1 >>> print(l[2]).direction (1,0,0) >>> l[0].direction = (-1,0,0) >>> print(l[0]).direction (-1,0,0)
-
camera
¶ Camera view parameters, or ‘auto’ to automatically choose a camera.
Type: camera.Camera
-
background_color
¶ Background color (r,g,b) as a tuple or other 3-length python object, in the linearized color space. Use
fresnel.color.linear()
to convert standard sRGB colorsType: tuple[float]
-
lights
¶ Globals lights in the scene.
Type: list[light.Light]
-
get_extents
()¶ Get the extents of the scene
Returns: [[minimum x, minimum y, minimum z], [maximum x, maximum y, maximum z]]
-
fresnel.
pathtrace
(scene, w=600, h=370, samples=64, light_samples=1)¶ Path trace a scene.
Parameters: - scene (
Scene
) – Scene to render. - w (int) – Output image width.
- h (int) – Output image height.
- samples (int) – Number of times to sample the pixels of the scene.
- light_samples (int) – Number of light samples to take for each pixel sample.
pathtrace()
is a shortcut to rendering output with thePath
tracer. See thePath
tracer for a complete description.- scene (
-
fresnel.
preview
(scene, w=600, h=370, aa_level=0)¶ Preview a scene.
Parameters: - scene (
Scene
) – Scene to render. - w (int) – Output image width.
- h (int) – Output image height.
- aa_level (int) – Amount of anti-aliasing to perform
preview()
is a shortcut to rendering output with thePreview
tracer. See thePreview
tracer for a complete description.- scene (
Modules