20#ifndef EBGEOMETRY_RENDER_HPP
21#define EBGEOMETRY_RENDER_HPP
42template <
class T,
size_t K>
45template <
class T,
size_t K,
size_t W>
50namespace EBGeometry::Render {
67inline constexpr bool primitivesAreFaces<FlatMeshSDF<T>> =
true;
74template <
class T,
size_t K>
75inline constexpr bool primitivesAreFaces<MeshSDF<T, K>> =
true;
83template <
class T,
size_t K,
size_t W>
84inline constexpr bool primitivesAreFaces<TriMeshSDF<T, K, W>> =
true;
204 const T a_fieldOfView = T(40));
245 uint32_t m_width = 960;
250 uint32_t m_height = 960;
255 uint32_t m_supersampling = 2;
260 uint32_t m_threads = 0;
265 bool m_shadows =
true;
270 bool m_occlusion =
true;
296 static constexpr uint32_t PrimitiveColors = 16;
309 bool m_recordPrimitives =
false;
314 static constexpr uint32_t NoPrimitive = 0xFFFFFFFFU;
319 static constexpr uint32_t AllPrimitives = 0xFFFFFFFEU;
325 uint32_t m_highlightPrimitive = NoPrimitive;
347 T m_cutOpacity = T(0.6);
359 bool m_lightFromCamera =
true;
370 T m_lightIntensity = T(1.05);
375 T m_ambient = T(0.35);
380 T m_specular = T(0.45);
386 T m_shininess = T(32);
406 bool m_floorChecker =
true;
411 T m_floorCheckerSize = T(0);
416 bool m_section =
false;
432 T m_contourWidth = T(2);
443 T m_isoSpacing = T(0);
454 T m_sheetOpacity = T(0.35);
504 uint32_t m_width = 0;
509 uint32_t m_height = 0;
529 [[nodiscard]]
inline uint32_t
530 at(
const uint32_t a_column,
const uint32_t a_row)
const noexcept;
540[[nodiscard]]
inline bool
561 uint64_t m_insideHits = 0;
566 uint64_t m_unresolved = 0;
571 bool m_cameraInside =
false;
576 bool m_complete =
true;
597 uint8_t m_insideHits = 0;
602 uint8_t m_unresolved = 0;
607 uint8_t m_cameraInside = 0;
612 uint32_t m_primitive = 0xFFFFFFFFU;
615namespace RenderDetail {
637 uint8_t m_insideHits = 0;
642 uint8_t m_unresolved = 0;
647 uint8_t m_cameraInside = 0;
659 a_result.
m_rgba, a_result.m_hits, a_result.m_insideHits, a_result.m_unresolved, a_result.m_cameraInside};
747template <
class T,
class S>
816 [[nodiscard]] inline const
Settings<T>&
817 settings() const noexcept;
829 render(const S& a_shape, const
Camera<T>& a_camera,
Image& a_image) const;
847 render(const S& a_shape,
848 const
Camera<T>& a_camera,
850 const std::atomic<
bool>& a_cancel,
851 std::atomic<uint32_t>* a_rowsDone =
nullptr) const;
866 renderOnDevice(const S& a_deviceShape, const
Camera<T>& a_camera,
Image& a_image) const;
883 renderOnDevice(const S& a_deviceShape,
884 const
Camera<T>& a_camera,
886 const std::atomic<
bool>& a_cancel,
887 std::atomic<uint32_t>* a_rowsDone =
nullptr) const;
904 [[nodiscard]] inline
HitT<T>
905 pick(const S& a_shape, const
Camera<T>& a_camera, T a_column, T a_row) const;
918 check(const
Camera<T>& a_camera) const;
928 collect(const std::vector<RenderDetail::StoredPixel>& a_results,
929 std::vector<uint32_t>& a_primitives,
930 Image& a_image) const;
935#include "EBGeometry_RenderImplem.hpp"
A fixed-size array that compiles for both host and device.
Declarations of bounding volume types used in bounding volume hierarchies.
The tape's front end: Expr, a host-side value that describes a composed object, and the free function...
GPU portability layer: host/device decoration macros and backend detection.
#define EBGEOMETRY_HOST_DEVICE
Mark a function as callable from both host and device code (no-op on host compilers).
Definition EBGeometry_GPU.hpp:80
#define EBGEOMETRY_HOST
Mark a function as callable from host code only (no-op on host compilers).
Definition EBGeometry_GPU.hpp:83
Ray queries on any shape: where a ray, or the segment between two points, first crosses its surface (...
bool 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...
constexpr bool primitivesAreFaces
Whether a shape's primitives (HitT::m_primitive) are the faces of one object rather than objects: tru...
Definition EBGeometry_Render.hpp:60
View
A direction to look at a box from, for Camera::fit(): along the axes of the plane perpendicular to th...
Definition EBGeometry_Render.hpp:102
@ Bottom
Pitch -90: straight up the up axis.
@ Default
The default yaw (35) and pitch (25), from above at an angle.
@ Top
Pitch 90: straight down the up axis.
ColorBy
How surfaces are colored.
Definition EBGeometry_Render.hpp:90
@ Normal
The surface normal's direction as a color (each component from -1 to 1 mapped to 0 to 1).
@ Uniform
One color (Settings::m_color) everywhere.
Declaration of 2D and 3D point/vector classes with templated precision, and free functions on them.
Axis-aligned bounding box (AABB) enclosing a set of 3D points.
Definition EBGeometry_BoundingVolumes.hpp:37
Renders shapes into images.
Definition EBGeometry_Render.hpp:797
Renderer(const Settings< T > &a_settings=Settings< T >()) noexcept
Renderer with given settings.
Three-dimensional vector class with arithmetic operators.
Definition EBGeometry_Vec.hpp:258
static constexpr Vec3T< T > zeros() noexcept
Return a vector with x = y = z = 0.
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_Affine.hpp:26
Fixed-size array with host- and device-callable members.
Definition EBGeometry_Array.hpp:33
Where a ray first crosses a surface.
Definition EBGeometry_Ray.hpp:96
How a query marches, where a shape has no ray form.
Definition EBGeometry_Ray.hpp:155
A camera orbiting a target point.
Definition EBGeometry_Render.hpp:122
T m_fieldOfView
Vertical field of view, in degrees.
Definition EBGeometry_Render.hpp:146
void frame(Vec3T< T > &a_forward, Vec3T< T > &a_right, Vec3T< T > &a_up) const noexcept
The camera's frame: unit vectors forward (towards the target), right and up on the screen.
T m_distance
Distance from the eye to the target.
Definition EBGeometry_Render.hpp:141
bool m_orthographic
Parallel rays instead of rays from the eye: no perspective, so sizes do not shrink with distance.
Definition EBGeometry_Render.hpp:160
Vec3T< T > m_target
The point the camera looks at.
Definition EBGeometry_Render.hpp:126
static Camera fit(const BoundingVolumes::AABBT< T > &a_box, const Vec3T< T > &a_up=Vec3T< T >(T(0), T(1), T(0)))
A camera that sees the whole of a box, from the default direction.
T m_nearClip
How far along each camera ray it starts (0: at the eye): anything nearer is not seen.
Definition EBGeometry_Render.hpp:165
Vec3T< T > m_up
The up axis (need not be of unit length).
Definition EBGeometry_Render.hpp:151
static Camera lookAt(const Vec3T< T > &a_eye, const Vec3T< T > &a_target, const Vec3T< T > &a_up=Vec3T< T >(T(0), T(1), T(0)), const T a_fieldOfView=T(40))
A camera at a given eye, looking at a given point.
Vec3T< T > eye() const noexcept
Where the eye is.
void horizontal(Vec3T< T > &a_first, Vec3T< T > &a_second) const noexcept
Two unit vectors that span the plane perpendicular to the up axis: yaw 90 looks from the first,...
static Camera fit(const BoundingVolumes::AABBT< T > &a_box, View a_view, const Vec3T< T > &a_up=Vec3T< T >(T(0), T(1), T(0)))
A camera that sees the whole of a box, from a given direction.
T m_pitch
Degrees above the plane perpendicular to the up axis, from -90 to 90.
Definition EBGeometry_Render.hpp:136
T m_yaw
Degrees about the up axis.
Definition EBGeometry_Render.hpp:131
An image: width x height pixels, row by row from the top, each 0xRRGGBBAA.
Definition EBGeometry_Render.hpp:500
std::vector< uint32_t > m_primitives
With Settings::m_recordPrimitives, for each pixel the primitive its first ray hit (HitT::m_primitive)...
Definition EBGeometry_Render.hpp:521
std::vector< uint32_t > m_pixels
The pixels, row by row from the top.
Definition EBGeometry_Render.hpp:514
uint32_t at(const uint32_t a_column, const uint32_t a_row) const noexcept
One pixel.
One pixel of a rendered image: the functor that Renderer runs once per pixel index,...
Definition EBGeometry_Render.hpp:749
RenderDetail::CameraView< T > m_view
The camera's eye and axes, worked out once rather than per pixel.
Definition EBGeometry_Render.hpp:768
PixelQuery(const S &a_shape, const Camera< T > &a_camera, const Settings< T > &a_settings) noexcept
The pixel functor for a shape, a camera and settings.
Settings< T > m_settings
The settings.
Definition EBGeometry_Render.hpp:763
S m_shape
The shape.
Definition EBGeometry_Render.hpp:753
PixelResult operator()(const uint32_t &a_index) const noexcept
Shade pixel a_index (row a_index / width, column a_index % width).
Camera< T > m_camera
The camera.
Definition EBGeometry_Render.hpp:758
What PixelQuery computes for one pixel.
Definition EBGeometry_Render.hpp:583
What every pixel needs from the camera, worked out once per frame: the eye, the view's axes and the f...
Definition EBGeometry_Render.hpp:673
Vec3T< T > m_up
Unit up of the image.
Definition EBGeometry_Render.hpp:692
T m_distance
Distance from the eye to the target.
Definition EBGeometry_Render.hpp:717
Vec3T< T > m_second
Horizontal unit vectors (see Camera::horizontal()).
Definition EBGeometry_Render.hpp:707
Vec3T< T > m_right
Unit right of the image.
Definition EBGeometry_Render.hpp:687
Vec3T< T > m_eye
The eye.
Definition EBGeometry_Render.hpp:677
bool m_orthographic
Whether the camera is orthographic.
Definition EBGeometry_Render.hpp:733
Vec3T< T > m_forward
Unit direction the camera looks in.
Definition EBGeometry_Render.hpp:682
T m_footprint
How wide a pixel is at distance t along a camera ray: m_footprint + m_footprintPerLength t (the first...
Definition EBGeometry_Render.hpp:723
Vec3T< T > m_axis
Unit up axis of the scene.
Definition EBGeometry_Render.hpp:697
T m_tanHalf
Tangent of half the vertical field of view.
Definition EBGeometry_Render.hpp:712
Vec3T< T > m_first
Horizontal unit vectors (see Camera::horizontal()).
Definition EBGeometry_Render.hpp:702
T m_footprintPerLength
See m_footprint.
Definition EBGeometry_Render.hpp:728
A pixel as a render stores it: PixelResult without the object, which is stored apart and only when as...
Definition EBGeometry_Render.hpp:623
static StoredPixel of(const PixelResult &a_result) noexcept
The stored part of a pixel's result.
Definition EBGeometry_Render.hpp:656
uint32_t m_rgba
The pixel, 0xRRGGBBAA.
Definition EBGeometry_Render.hpp:627
What to render and how. A plain value; every field has a default.
Definition EBGeometry_Render.hpp:241
RayOptions< T > m_rays
How rays march (see firstHit()). A scale of 0 takes the shape's box diagonal, or the camera distance ...
Definition EBGeometry_Render.hpp:470
static Array< Vec3T< T >, PrimitiveColors > unsetColors() noexcept
Every entry of m_primitiveColors unset.
What a render saw.
Definition EBGeometry_Render.hpp:547