|
EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
|
A renderer for looking at shapes: Camera, Settings, Image and Renderer, in namespace Render. More...
#include <atomic>#include <cstdint>#include <string>#include <vector>#include "EBGeometry_Array.hpp"#include "EBGeometry_BoundingVolumes.hpp"#include "EBGeometry_Expr.hpp"#include "EBGeometry_GPU.hpp"#include "EBGeometry_Ray.hpp"#include "EBGeometry_RegionSettings.hpp"#include "EBGeometry_Vec.hpp"#include "EBGeometry_RenderImplem.hpp"

Go to the source code of this file.
Classes | |
| struct | EBGeometry::Render::Camera< T > |
| A camera orbiting a target point. More... | |
| struct | EBGeometry::Render::Settings< T > |
| What to render and how. A plain value; every field has a default. More... | |
| struct | EBGeometry::Render::Image |
| An image: width x height pixels, row by row from the top, each 0xRRGGBBAA. More... | |
| struct | EBGeometry::Render::Stats |
| What a render saw. More... | |
| struct | EBGeometry::Render::PixelResult |
| What PixelQuery computes for one pixel. More... | |
| struct | EBGeometry::Render::RenderDetail::StoredPixel |
| A pixel as a render stores it: PixelResult without the object, which is stored apart and only when asked for (Settings::m_recordPrimitives), so that a frame writes and copies 8 bytes per pixel. More... | |
| struct | EBGeometry::Render::RenderDetail::CameraView< T > |
| What every pixel needs from the camera, worked out once per frame: the eye, the view's axes and the field of view's slope. More... | |
| struct | EBGeometry::Render::PixelQuery< T, S > |
| One pixel of a rendered image in the shaded view: the functor that Renderer runs once per pixel index, on the host or through GPU::parallelFor(), for ViewMode::Shaded with nothing hidden or filled. More... | |
| class | EBGeometry::Render::Renderer< T > |
| Renders shapes into images. More... | |
Namespaces | |
| namespace | EBGeometry |
| Namespace containing all of EBGeometry's functionality. | |
Enumerations | |
| enum class | EBGeometry::Render::ColorBy : uint8_t { Uniform , Primitive , Normal } |
| How surfaces are colored. More... | |
| enum class | EBGeometry::Render::ViewMode : uint8_t { Shaded , Depth , XRay , CostHit , CostCrossing } |
| What a render shows at each pixel. More... | |
| enum class | EBGeometry::Render::CostUnit : uint8_t { None , Nanoseconds , Cycles } |
| What the costs of a cost view count (Stats::m_costLow, Stats::m_costHigh). More... | |
| enum class | EBGeometry::Render::Backdrop : uint8_t { Sky , Plain , Gradient , Vignette } |
| What is drawn behind the shape, where a camera ray hits nothing (Settings::m_backdrop). More... | |
| enum class | EBGeometry::Render::FloorStyle : uint8_t { Checker , Grid , Plain , ShadowOnly , Mirror } |
| How the floor under the shape is drawn, when there is one (Settings::m_floor, Settings::m_floorStyle). More... | |
| enum class | EBGeometry::Render::Look : uint8_t { Sky , Dark , Gradient , ShadowOnly , LightGrid , Studio , Mirror , DarkGrid , Blueprint } |
| Named combinations of the backdrop and the floor (see setLook()). More... | |
| enum class | EBGeometry::Render::View : uint8_t { Front , Back , Right , Left , Top , Bottom , Default } |
| A direction to look at a box from, for Camera::fit(): along the axes of the plane perpendicular to the up axis (with the default up axis +y, Front looks from +z and Right from +x), or along the up axis. More... | |
Functions | |
| const char * | EBGeometry::Render::lookName (Look a_look) noexcept |
| A look's name, as the .ebg view block writes it: "sky", "dark", "gradient", "shadow_only", "light_grid", "studio", "mirror", "dark_grid" or "blueprint". | |
| template<class T > | |
| void | EBGeometry::Render::setLook (Settings< T > &a_settings, Look a_look) noexcept |
| Set the backdrop and the floor to a named look. | |
| template<class T > | |
| std::string | EBGeometry::Render::toCode (const Camera< T > &a_camera, const Settings< T > &a_settings) |
| A camera and settings as C++ statements that recreate them, for pasting a view found by hand (in Render::view(), key C prints them) into a program. | |
| bool | EBGeometry::Render::writeImage (const Image &a_image, const std::string &a_filename) |
| Write an image to a file, as binary PPM (P6: 8 bits per channel, no alpha), which most image programs read. | |
| double | EBGeometry::Render::costPlace (const Stats &a_stats, double a_cost) noexcept |
| Where a cost sits on a cost view's color scale: 0 at a_stats.m_costLow, 1 at a_stats.m_costHigh, on the log scale the frame's pixels were colored on, clamped to [0, 1]. With costColor(), what a colorbar matching the image needs. | |
| uint32_t | EBGeometry::Render::costColor (double a_place) noexcept |
| The color a cost view gives a place on its scale, dark (0) to bright (1), as it colors the pixels. | |
Variables | |
| template<class S > | |
| constexpr bool | EBGeometry::Render::primitivesAreFaces = false |
| Whether a shape's primitives (HitT::m_primitive) are the faces of one object rather than objects: true for the mesh SDFs, whose primitive is a face of the mesh; false for every other shape: a Tape (whose primitives are its leaves), a fused composition and an analytic shape (one object, primitive 0), and a BVH union (a BVHUnion names its members, a BVHSmoothUnion 0). | |
| template<class T > | |
| constexpr bool | EBGeometry::Render::primitivesAreFaces< FlatMeshSDF< T > > = true |
| See primitivesAreFaces. | |
| template<class T , size_t K> | |
| constexpr bool | EBGeometry::Render::primitivesAreFaces< MeshSDF< T, K > > = true |
| See primitivesAreFaces. | |
| template<class T , size_t K, size_t W> | |
| constexpr bool | EBGeometry::Render::primitivesAreFaces< TriMeshSDF< T, K, W > > = true |
| See primitivesAreFaces. | |
| constexpr uint8_t | EBGeometry::Render::NumLooks = 9 |
| How many looks there are (Look's values are 0 to NumLooks - 1). | |
A renderer for looking at shapes: Camera, Settings, Image and Renderer, in namespace Render.
Renders any shape (see isShape) into an image held in memory, by finding where each camera ray first crosses the surface (firstHit()) and shading it: diffuse and specular light from one direction, light from the sky, soft shadows and ambient occlusion, a floor under the shape, and a section plane that cuts the shape open. A surface the camera sees from inside the solid (a hole seen from within the material, or a mesh whose orientation is inverted) is tinted, so that it cannot be mistaken for an outside. Other views (ViewMode) show the depth, an x-ray of every surface, or the cost of each camera ray; chosen primitives can be seen through, and a part's inside filled. Each pixel is computed by a trivially copyable functor callable on a device (PixelQuery for the shaded view), so Renderer::render() runs it on the host's threads and Renderer::renderOnDevice() runs the same functor through GPU::parallelFor(). Render::view() (EBGeometry_Viewer.hpp) shows a shape in an interactive window, rendered this way.
|
strong |
What is drawn behind the shape, where a camera ray hits nothing (Settings::m_backdrop).
| Enumerator | |
|---|---|
| Sky | Settings::m_skyHorizon to Settings::m_skyZenith by the ray's elevation above the horizon. |
| Plain | |
| Gradient | Settings::m_gradientFrom at the top of the view to Settings::m_gradientTo at its bottom. |
| Vignette | Settings::m_gradientFrom at the center of the view to Settings::m_gradientTo at its corners. |
|
strong |
How surfaces are colored.
| Enumerator | |
|---|---|
| Uniform | One color (Settings::m_color) everywhere. |
| Primitive | A color per primitive: per leaf of a Tape, per face of a mesh SDF (see HitT::m_primitive); Settings::m_primitiveColors, then a built-in palette. |
| Normal | The surface normal's direction as a color (each component from -1 to 1 mapped to 0 to 1). |
|
strong |
What the costs of a cost view count (Stats::m_costLow, Stats::m_costHigh).
|
strong |
How the floor under the shape is drawn, when there is one (Settings::m_floor, Settings::m_floorStyle).
| Enumerator | |
|---|---|
| Checker | Squares of side Settings::m_floorCellSize in Settings::m_floorColor, every second a little darker. |
| Grid | Settings::m_floorColor with lines in Settings::m_floorLineColor every Settings::m_floorCellSize, every Settings::m_floorMajorEvery-th heavier. |
| Plain | |
| ShadowOnly | The backdrop, darkened where the shape shadows it: no floor is seen, only the shape's shadow. |
| Mirror | Settings::m_floorColor, reflecting the shape by Settings::m_floorReflectance: one more trace per pixel of the floor. |
|
strong |
Named combinations of the backdrop and the floor (see setLook()).
|
strong |
A direction to look at a box from, for Camera::fit(): along the axes of the plane perpendicular to the up axis (with the default up axis +y, Front looks from +z and Right from +x), or along the up axis.
|
strong |
What a render shows at each pixel.
| Enumerator | |
|---|---|
| Shaded | Lit surfaces, colored by Settings::m_colorBy. |
| Depth | How far from the eye the first surface is, near (bright) to far (dark) across the shape's box; the shape alone, cut by the section plane, without the floor or the plane's contour and sheet. |
| XRay | On black, every surface a ray crosses glows faintly (more seen edge-on), with modest highlights. |
| CostHit | What each pixel's firstHit() cost, one ray through its center (Settings::m_supersampling ignored): nanoseconds on the host, clock cycles on a device (see CostUnit), on a log scale over the frame (see Stats::m_costLow, costPlace(), costColor()). |
| CostCrossing | What each pixel's firstCrossing() cost, as CostHit. |
|
inlinenoexcept |
The color a cost view gives a place on its scale, dark (0) to bright (1), as it colors the pixels.
| [in] | a_place | The place, clamped to [0, 1] (see costPlace()). |
|
inlinenoexcept |
Where a cost sits on a cost view's color scale: 0 at a_stats.m_costLow, 1 at a_stats.m_costHigh, on the log scale the frame's pixels were colored on, clamped to [0, 1]. With costColor(), what a colorbar matching the image needs.
| [in] | a_stats | The frame's Stats, from a render in ViewMode::CostHit or ViewMode::CostCrossing. |
| [in] | a_cost | A cost, in a_stats.m_costUnit. |
|
inlinenoexcept |
A look's name, as the .ebg view block writes it: "sky", "dark", "gradient", "shadow_only", "light_grid", "studio", "mirror", "dark_grid" or "blueprint".
| [in] | a_look | The look. |
|
inlinenoexcept |
Set the backdrop and the floor to a named look.
Sets m_backdrop, its colors (m_skyHorizon, m_skyZenith, m_background, m_gradientFrom, m_gradientTo), m_floor, m_floorStyle, the floor's colors and lines, m_floorFade, m_floorReflectance and m_lightSize; leaves the rest (the shape's colors, the light's direction, the section) as it is. Change any of these afterwards to adjust a look.
| T | Floating-point precision. |
| [in,out] | a_settings | Settings. |
| [in] | a_look | The look. |
|
inline |
A camera and settings as C++ statements that recreate them, for pasting a view found by hand (in Render::view(), key C prints them) into a program.
Writes camera.m_... = ...; and settings.m_... = ...; for every field that differs from its default, after declarations of camera and settings; T is the precision's name in the code.
| T | Floating-point precision. |
| [in] | a_camera | Camera. |
| [in] | a_settings | Settings. |
|
inline |
Write an image to a file, as binary PPM (P6: 8 bits per channel, no alpha), which most image programs read.
| [in] | a_image | Image. |
| [in] | a_filename | File to write. |
|
inlineconstexpr |
Whether a shape's primitives (HitT::m_primitive) are the faces of one object rather than objects: true for the mesh SDFs, whose primitive is a face of the mesh; false for every other shape: a Tape (whose primitives are its leaves), a fused composition and an analytic shape (one object, primitive 0), and a BVH union (a BVHUnion names its members, a BVHSmoothUnion 0).
| S | Shape type. |
|
inlineconstexpr |
See primitivesAreFaces.
| T | Floating-point precision. |
|
inlineconstexpr |
See primitivesAreFaces.
| T | Floating-point precision. |
| K | Branching factor. |
|
inlineconstexpr |
See primitivesAreFaces.
| T | Floating-point precision. |
| K | Branching factor. |
| W | SIMD width. |