EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Classes | Namespaces | Enumerations | Functions | Variables
EBGeometry_Render.hpp File Reference

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_Vec.hpp"
#include "EBGeometry_RenderImplem.hpp"
Include dependency graph for EBGeometry_Render.hpp:
This graph shows which files directly or indirectly include this file:

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: the functor that Renderer runs once per pixel index, on the host or through GPU::parallelFor(). 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::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

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.
 

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.
 

Detailed Description

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. Each pixel is computed by PixelQuery, a trivially copyable functor callable on a device, 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.

Author
Robert Marskar

Enumeration Type Documentation

◆ ColorBy

enum class EBGeometry::Render::ColorBy : uint8_t
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).

◆ View

enum class EBGeometry::Render::View : uint8_t
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.

Enumerator
Front 

Yaw 0, pitch 0.

Back 

Yaw 180, pitch 0.

Right 

Yaw 90, pitch 0.

Left 

Yaw -90, pitch 0.

Top 

Pitch 90: straight down the up axis.

Bottom 

Pitch -90: straight up the up axis.

Default 

The default yaw (35) and pitch (25), from above at an angle.

Function Documentation

◆ toCode()

template<class T >
std::string EBGeometry::Render::toCode ( const Camera< T > &  a_camera,
const Settings< T > &  a_settings 
)
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.

Template Parameters
TFloating-point precision.
Parameters
[in]a_cameraCamera.
[in]a_settingsSettings.
Returns
The statements, one per line.

◆ writeImage()

bool EBGeometry::Render::writeImage ( const Image &  a_image,
const std::string &  a_filename 
)
inline

Write an image to a file, as binary PPM (P6: 8 bits per channel, no alpha), which most image programs read.

Parameters
[in]a_imageImage.
[in]a_filenameFile to write.
Returns
Whether the file was written (not for an image with fewer pixels than its size).

Variable Documentation

◆ primitivesAreFaces

template<class S >
constexpr bool EBGeometry::Render::primitivesAreFaces = false
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).

Template Parameters
SShape type.

◆ primitivesAreFaces< FlatMeshSDF< T > >

template<class T >
constexpr bool EBGeometry::Render::primitivesAreFaces< FlatMeshSDF< T > > = true
inlineconstexpr

See primitivesAreFaces.

Template Parameters
TFloating-point precision.

◆ primitivesAreFaces< MeshSDF< T, K > >

template<class T , size_t K>
constexpr bool EBGeometry::Render::primitivesAreFaces< MeshSDF< T, K > > = true
inlineconstexpr

See primitivesAreFaces.

Template Parameters
TFloating-point precision.
KBranching factor.

◆ primitivesAreFaces< TriMeshSDF< T, K, W > >

template<class T , size_t K, size_t W>
constexpr bool EBGeometry::Render::primitivesAreFaces< TriMeshSDF< T, K, W > > = true
inlineconstexpr

See primitivesAreFaces.

Template Parameters
TFloating-point precision.
KBranching factor.
WSIMD width.