Renderer¶
-
template<IsSpectral TSpectral>
class Renderer¶ Abstract base class for scene renderers.
Renderer provides the interface and common helpers for rendering a SceneView into a FrameBuffer. Derived classes implement specific rendering algorithms.
- Template Parameters:
TSpectral – The spectral type (e.g., RGB, Visible8)
Public Functions
-
Renderer() = default¶
-
virtual ~Renderer() = default¶
-
virtual void render(SceneView<TSpectral> &scene_view, FrameBuffer<TSpectral> &frame_buffer)¶
-
inline void set_samples_per_pixel(int spp)¶
Set the number of samples per pixel.
-
inline void set_max_bounces(int max_bounces)¶
Set the maximum number of bounces for path tracing.
-
inline void set_dynamic_sampling(bool dynamic_sample = true)¶
Enable or disable dynamic sampling of pixels based on variance.
-
inline void set_min_samples(int min_samples)¶
Set the minimum samples per pixel for dynamic sampling.
-
inline void set_variance_threshold(float threshold)¶
Set the variance threshold for dynamic sampling.
-
inline void set_indirect_clamp(float indirect_clamp)¶
Set the indirect lighting clamp threshold.
-
inline void set_unresolved_occlusion(bool occlusion = true)¶
Enable or disable occlusion testing of unresolved point sources.
-
inline void set_region_culling(bool enable = true)¶
Enable or disable skipping screen regions that provably contain no geometry.
Enabled by default. Purely an optimization: the image is identical either way.
-
inline void set_region_cull_margin_scale(float scale)¶
Scale the safety margin added to each tile’s direction cone.
-
inline void set_region_cull_validation(bool enable = true)¶
(CI): Trace culled regions anyway and report any that turn out to contain geometry.
Protected Functions
-
virtual Image<TSpectral> path_trace_(SceneView<TSpectral> &scene_view, FrameBuffer<TSpectral> &frame_buffer)¶
-
virtual Image<TSpectral> render_unresolved_(SceneView<TSpectral> &scene_view, FrameBuffer<TSpectral> &frame_buffer, Image<TSpectral> &wing_splat)¶
Render unresolved point sources (stars and unresolved objects) into the frame buffer.
This method implements an optimized pipeline for rendering point sources that cannot be resolved into visible geometry. It supports both delta-function (no PSF) and spatially- distributed PSF rendering with adaptive radius culling for performance.
The rendering pipeline:
Collects all stars and unresolved objects into a unified list
Builds a radius LUT and assigns per-source effective PSF radii based on irradiance
Projects sources to screen space and bins them into tiles
Renders each tile in parallel into local buffers
Combines tile buffers into the final frame buffer
- Template Parameters:
TSpectral – The spectral type (e.g., RGB, Visible8)
- Parameters:
scene_view – The scene view containing stars and unresolved objects
frame_buffer – The frame buffer to render into
-
inline std::shared_ptr<CameraModel<TSpectral>> get_camera(SceneView<TSpectral> &scene_view) const¶
-
inline std::vector<PrimitiveBatch<TSpectral>> get_primitives(SceneView<TSpectral> &scene_view) const¶
-
bool build_occupancy_cones_(SceneView<TSpectral> &scene_view, std::vector<DirectionCone> &cones) const¶
Cones subtending each TLAS occupant as seen from the camera.
Path trace a scene view into a frame buffer.
Traces camera rays through each pixel, evaluating direct lighting with shadow rays and indirect illumination via recursive path tracing with Russian roulette termination.
The rendering is parallelized over tiles using TBB. Each tile accumulates results from multiple samples per pixel (spp_) into the frame buffer.
Build the cones subtending each TLAS occupant, as seen from the camera.
Each occupant’s bounding sphere is inflated by the aperture’s bounding radius before the cone is taken. Rays do not all leave the camera origin when depth of field is on; they leave points on the aperture. Translating a line by at most R keeps it within R of the original, so a line from any aperture point that meets a sphere of radius r meets the sphere of radius r + R when re-based at the origin. Inflating the sphere therefore makes the origin-centred cone cover every aperture ray exactly.
- Template Parameters:
TSpectral – The spectral type (e.g., RGB, Visible8)
- Parameters:
scene_view – The scene view containing geometry, lights, and environment
frame_buffer – The frame buffer to render into
- Returns:
false when culling must be abandoned for this view.
-
DirectionCone tile_direction_cone_(const CameraModel<TSpectral> &camera, float x0, float y0, float x1, float y1) const¶
Cone enclosing every ray direction a tile can produce.
- Parameters:
camera – Camera model supplying the ray directions.
x0, y0, x1, y1 – The tile’s closed pixel rectangle. Jittered samples span exactly this range: pixel x is sampled over [x, x + 1).
-
void convolve_cached_(Image<TSpectral> &image, const Image<TSpectral> &kernel, const CameraModel<TSpectral> &camera, ConvolverCache &cache)¶
Convolve an image with a camera kernel, reusing a cached kernel spectrum.
Behaviour matches Image::convolve() exactly, including its small-kernel dispatch; only the lifetime of the FFT plan and kernel spectrum differs.
- Parameters:
image – Image convolved in place.
kernel – Convolution kernel.
camera – Camera the kernel came from, used to detect kernel changes.
cache – Persistent convolver to reuse.
Protected Attributes
-
ConvolverCache wings_convolver_¶
Scattered-light wings applied to the unresolved splat buffer, once per frame.
-
ConvolverCache psf_convolver_¶
Composite PSF from get_psf_convolution_kernel(), shared by the path-traced image and the defocus path: same kernel and same resolution, so one cached spectrum serves both.
-
RandomSampler<float> sampler_¶
-
bool occluder_mask_valid_ = false¶
False until path_trace_() has filled occluder_mask_ for the current frame. While false, every unresolved source is ray tested.
-
int spp_ = 10¶
-
int max_bounces_ = 3¶
-
bool unresolved_occlusion_ = true¶
-
bool region_culling_ = true¶
-
bool region_cull_validation_ = false¶
-
float region_cull_margin_scale_ = 1.0f¶
-
bool dynamic_sampling_ = false¶
-
int min_spp_ = 16¶
-
float variance_threshold_ = 0.001f¶
-
float indirect_clamp_threshold_ = std::numeric_limits<float>::infinity()¶
Protected Static Functions
-
struct ConvolverCache¶
A persistent FFT convolver plus the configuration it was built for.
Public Functions
-
ConvolverCache() = default¶
-
ConvolverCache(const ConvolverCache&) = delete¶
-
ConvolverCache &operator=(const ConvolverCache&) = delete¶
-
ConvolverCache(ConvolverCache&&) = delete¶
-
ConvolverCache &operator=(ConvolverCache&&) = delete¶
-
ConvolverCache() = default¶
-
struct DirectionCone¶
A set of ray directions, as a cone about a unit axis.