Module three_d::renderer

source ·
Expand description

High-level features for easy rendering of different types of objects with different types of shading. Can be combined seamlessly with the mid-level features in the core module as well as functionality in the context module.

This module contains five main traits

  • Geometry - a geometric representation in 3D space
  • Material - a material that can be applied to a geometry or the screen
  • Effect - an effect that can be applied to a geometry or the screen after the rest of the scene has been rendered
  • Object - an object in 3D space which has both geometry and material information (use the Gm struct to combine any Material and Geometry into an object)
  • Light - a light that shines onto objects in the scene (some materials are affected by lights, others are not)

Common implementations of these traits are found in their respective modules but it is also possible to do a custom implementation by implementing one of the four traits.

There are several ways to render something. Objects can be rendered directly using Object::render or used in a render call, for example RenderTarget::render. Geometries can be rendered with a given material using Geometry::render_with_material or combined into an object using the Gm struct and again used in a render call.

Re-exports§

Modules§

  • A collection of controls for example to control the camera.
  • A collection of effects implementing the Effect trait.
  • A collection of geometries implementing the Geometry trait.
  • A collection of lights implementing the Light trait.
  • A collection of materials implementing the Material trait.
  • A collection of objects implementing the Object trait.

Structs§

  • Represents a camera used for viewing 2D and 3D objects.

Enums§

  • Color space mapping used for mapping to/from color spaces when rendering.
  • Error in the renderer module.
  • Tone mapping is the process of mapping HDR color values computed with physical based rendering in the range [0,∞) into LDR values that can be displayed on the screen in the range [0,1].

Functions§

  • Apply the given Effect to the entire sceen. Must be called in the callback given as input to a RenderTarget, ColorTarget or DepthTarget write method. Use an empty array for the lights argument, if the effect does not require lights to be rendered.
  • Apply the given Material to the entire sceen. Must be called in the callback given as input to a RenderTarget, ColorTarget or DepthTarget write method. Use an empty array for the lights argument, if the material does not require lights to be rendered.
  • Compare function for sorting objects based on distance from the camera. The order is opaque objects from nearest to farthest away from the camera, then transparent objects from farthest away to closest to the camera.
  • Finds the closest intersection between a ray from the given camera in the given pixel coordinate and the given geometries. The pixel coordinate must be in physical pixels, where (viewport.x, viewport.y) indicate the bottom left corner of the viewport and (viewport.x + viewport.width, viewport.y + viewport.height) indicate the top right corner. Returns None if no geometry was hit between the near (z_near) and far (z_far) plane for this camera.
  • Finds the closest intersection between a ray starting at the given position in the given direction and the given geometries. Returns None if no geometry was hit before the given maximum depth.
  • Render the given Geometry with the given Effect. Must be called in the callback given as input to a RenderTarget, ColorTarget or DepthTarget write method. Use an empty array for the lights argument, if the effect does not require lights to be rendered.
  • Render the given Geometry with the given Material. Must be called in the callback given as input to a RenderTarget, ColorTarget or DepthTarget write method. Use an empty array for the lights argument, if the material does not require lights to be rendered.