fresnel.tracer¶
Overview
Details
Ray tracers process a Scene and render output images.
Previewgenerates a quick approximate render.Pathwhich provides soft shadows, reflections, and other effects.
- class fresnel.tracer.Path(device, w, h)¶
Bases:
TracerPath tracer.
- Parameters:
The path tracer applies advanced lighting effects, including soft shadows, reflections, and depth of field. It operates by Monte Carlo sampling. Each call to
renderperforms one sample per pixel. Theoutputimage is the mean of all the samples. Many samples are required to produce a smooth image.sampleprovides a convenience API to make many samples with a single call.- reset()¶
Clear the output buffer.
Start sampling a new image. Increment the random number seed so that the new image is statistically independent from the previous.
- sample(scene, samples, reset=True, light_samples=1)¶
Sample the image.
- Parameters:
As an unbiased renderer, the sampling noise will scale as \(\frac{1}{\sqrt{\text{total_samples}}}\), where
total_samplesissamples*light_samples.The
samplesparameter controls the number of samples from the camera (depth of field and antialiasing).light_samplesis the number of rays shot from the first intersection of the primary camera ray.Using
(samples=N, light_samples=1)would have an equal number of camera and lighting samples and would produce an excellent image. Using(samples=N // M, light_samples=M)(whereMis some integer 10-100) will similarly produce a similarly good image, providedN >> M, and may have better performance. On the GPU, usinglight_samples > 1can boost performance moderately. On the CPU, it can boost performance slightly due to improved cache coherency.- Returns:
A reference to the current
outputbuffer.- Return type:
Note
When reset is
False, subsequent calls tosamplewill continue to add samples to the current output image. Use the same number of light samples when sampling an image in this way.
- class fresnel.tracer.Preview(device, w, h, anti_alias=True)¶
Bases:
TracerPreview ray tracer.
- Parameters:
Overview
The
Previewtracer produces a preview of the scene quickly. It approximates the effect of light on materials. The output of thePreviewtracer will look very similar to that from thePathtracer, but will miss soft shadows, reflection, transmittance, depth of field and other effects.Anti-aliasing
The default value of
anti_aliasis True to smooth sharp edges in the image. The anti-aliasing level corresponds toaa_level=3in fresnel versions up to 0.11.0. Differentseedvalues will result in different output images.
- class fresnel.tracer.Tracer¶
Bases:
objectBase class for all ray tracers.
Tracerprovides operations common to all ray tracer classes.Each
Tracerinstance stores a pixel output buffer. When yourenderaScene, theoutputis updated.Note
You cannot instantiate
Tracerdirectly. Use one of the subclasses.- disable_highlight_warning()¶
Disable the highlight clipping warnings.
- enable_highlight_warning(color=(1, 0, 1))¶
Enable highlight clipping warnings.
When a pixel in the rendered image is too bright to represent, make that pixel the given color to flag the problem to the user.
- Parameters:
color (tuple) – Color to make the highlight warnings.
- histogram()¶
Compute a histogram of the image.
The histogram is computed as a lightness in the sRGB color space. The histogram is computed only over the visible pixels in the image, fully transparent pixels are ignored. The returned histogram is nbins x 4, the first column contains the lightness histogram and the next 3 contain R,B, and G channel histograms respectively.
- Returns:
(histogram, bin_positions).
- property output¶
Reference to the current output buffer.
- Type:
- render(scene)¶
Render a scene.
- Parameters:
scene (
Scene) – The scene to render.- Returns:
A reference to the current output buffer as a
fresnel.util.ImageArray.
Render the given scene and write the resulting pixels into the output buffer.