fresnel¶
Overview
Hardware device to use for ray tracing. |
|
Path trace a scene. |
|
Preview a 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.
Devicedefines hardware device to use for ray tracing.Sceneandtracerinstances must be attached to aDevice. You may attach any number of scenes and tracers to a singleDevice.When mode is
auto, the default,DeviceGPU rendering and fall back on CPU rendering if there is no GPU available or GPU support was not compiled in. Set mode togpuorcputo 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_gpuslist.Tip
Use only a single
Deviceto reduce memory consumption.The static member
available_modeslists 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 thegpumode to be available.>>> fresnel.Device.available_modes ['gpu', 'cpu', 'auto']
-
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.
Scenedefines the contents of the scene to be ray traced, including any number ofgeometryobjects, thecamera,background color,background alpha, and thelights.Every
Sceneattaches to aDevice. For convenience,Scenecreates a defaultDevicewhen device is None. If you want a non-default device, you must create it explicitly.Lights
lightsis 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
Lightobjects: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
-
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 colors
-
lights¶ Globals lights in the scene.
- Type
-
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 thePathtracer. See thePathtracer for a complete description.
-
fresnel.preview(scene, w=600, h=370, anti_alias=True)¶ Preview a scene.
- Parameters
scene (
Scene) – Scene to render.w (int) – Output image width.
h (int) – Output image height.
anti_alias (bool) – Whether to perform anti-aliasing.
preview()is a shortcut to rendering output with thePreviewtracer. See thePreviewtracer for a complete description.
Modules