Module renderer

Module 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§

pub use crate::core::*;
pub use material::*;
pub use effect::*;
pub use light::*;
pub use geometry::*;
pub use object::*;
pub use control::*;

Modules§

control
A collection of controls for example to control the camera.
effect
A collection of effects implementing the Effect trait.
geometry
A collection of geometries implementing the Geometry trait.
light
A collection of lights implementing the Light trait.
material
A collection of materials implementing the Material trait.
object
A collection of objects implementing the Object trait.

Structs§

Camera
Represents a camera used for viewing 2D and 3D objects.
EffectMaterialId
ID Space for effect and material shaders IDs 0x0000 through 0x4FFF are reserved for public use
Frustum
The view frustum which can be used for frustum culling.
GeometryId
ID Space for geometry shaders IDs 0x0000 through 0x7FFF are reserved for public use
IntersectionResult
Result from an intersection test
LightId
ID space for lighting shaders IDs 0x00 through 0x7F are reserved for public use
TextGeneratortext
A utility struct for generating a CpuMesh from a text string with a given font.
TextLayoutOptionstext
Options for text layout.

Enums§

ColorMapping
Color space mapping used for mapping to/from color spaces when rendering.
RendererError
Error in the renderer module.
ToneMapping
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].

Traits§

Viewer
Represents a viewer, usually some kind of camera. The default implementation of this trait is the Camera which should be adequate for most use cases.

Functions§

apply_screen_effect
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_screen_material
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.
cmp_render_order
Compare function for sorting objects based on distance from the viewer. The order is opaque objects from nearest to farthest away from the viewer, then transparent objects from farthest away to closest to the viewer.
pick
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.
ray_intersect
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_with_effect
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_with_material
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.