Fermat
Classes | Macros | Functions
BPTLibCore

Detailed Description

This module provides the core device functions available in BPTLib.

Classes

struct  PathWeights
 
struct  TempPathWeights
 
struct  LightVertex
 
struct  EyeVertex
 

Macros

#define DEBUG_S   -1
 
#define DEBUG_T   -1
 
#define DEBUG_LENGTH   0
 
#define MIN_G_DENOM   1.0e-8f
 

Functions

template<typename TPrimaryCoordinates , typename TBPTContext , typename TBPTConfig >
FERMAT_HOST_DEVICE void bpt::generate_primary_light_vertex (const uint32 light_path_id, const uint32 n_light_paths, const TPrimaryCoordinates &primary_coords, TBPTContext &context, RenderingContextView &renderer, TBPTConfig &config)
 
template<typename TPrimaryCoordinates , typename TBPTContext , typename TBPTConfig >
FERMAT_HOST_DEVICE void bpt::process_secondary_light_vertex (const uint32 queue_idx, const uint32 n_light_paths, const TPrimaryCoordinates &primary_coords, TBPTContext &context, RenderingContextView &renderer, TBPTConfig &config)
 
template<typename TPrimaryCoordinates , typename TBPTContext , typename TBPTConfig >
FERMAT_HOST_DEVICE void bpt::generate_primary_eye_vertex (const uint32 idx, const uint32 n_eye_paths, const uint32 n_light_paths, const TPrimaryCoordinates &primary_coords, TBPTContext &context, RenderingContextView &renderer, TBPTConfig &config)
 
template<typename TSampleSink , typename TPrimaryCoordinates , typename TBPTContext , typename TBPTConfig >
FERMAT_HOST_DEVICE void bpt::process_secondary_eye_vertex (const uint32 queue_idx, const uint32 n_eye_paths, const uint32 n_light_paths, TSampleSink &sample_sink, const TPrimaryCoordinates &primary_coords, TBPTContext &context, RenderingContextView &renderer, TBPTConfig &config)
 
template<typename TBPTContext , typename TBPTConfig >
FERMAT_HOST_DEVICE void bpt::connect_to_camera (const uint32 light_idx, const uint32 n_light_paths, TBPTContext &context, RenderingContextView &renderer, const TBPTConfig &config)
 
template<typename TSampleSink , typename TBPTContext >
FERMAT_HOST_DEVICE void bpt::solve_occlusion (const uint32 queue_idx, TSampleSink &sample_sink, TBPTContext &context, RenderingContextView &renderer)
 
FERMAT_HOST_DEVICE FERMAT_FORCEINLINE float mis_selector (const uint32 s, const uint32 t, const float w)
 
FERMAT_HOST_DEVICE FERMAT_FORCEINLINE float mis_power (const float w)
 
FERMAT_HOST_DEVICE FERMAT_FORCEINLINE float bpt_mis (const float pGp, const float prev_pGp, const float next_pGp, const float pGp_sum)
 
FERMAT_HOST_DEVICE FERMAT_FORCEINLINE float bpt_mis (const float pGp, const float other_pGp, const float pGp_sum)
 
FERMAT_HOST_DEVICE FERMAT_FORCEINLINE float pdf_product (const float p1, const float p2)
 
FERMAT_HOST_DEVICE FERMAT_FORCEINLINE float pdf_product (const float p1, const float p2, const float p3)
 
FERMAT_HOST_DEVICE FERMAT_FORCEINLINE uint32 channel_selector (const Bsdf::ComponentType comp)
 
FERMAT_HOST_DEVICE FERMAT_FORCEINLINE uint4 pack_edf (const Edf &edf)
 
FERMAT_HOST_DEVICE FERMAT_FORCEINLINE uint4 pack_edf (const MeshMaterial &material)
 
FERMAT_HOST_DEVICE FERMAT_FORCEINLINE uint4 pack_bsdf (const MeshMaterial &material)
 
FERMAT_HOST_DEVICE FERMAT_FORCEINLINE Edf unpack_edf (const uint4 packed_info)
 
FERMAT_HOST_DEVICE FERMAT_FORCEINLINE Bsdf unpack_bsdf (const RenderingContextView &renderer, const uint4 packed_info, const TransportType transport=kParticleTransport)
 
FERMAT_HOST_DEVICE FERMAT_FORCEINLINE cugar::Vector3f unpack_bsdf_diffuse (const uint4 packed_info)
 
FERMAT_HOST_DEVICE FERMAT_FORCEINLINE cugar::Vector3f unpack_bsdf_specular (const uint4 packed_info)
 
FERMAT_HOST_DEVICE FERMAT_FORCEINLINE float unpack_bsdf_roughness (const uint4 packed_info)
 
FERMAT_HOST_DEVICE FERMAT_FORCEINLINE cugar::Vector3f unpack_bsdf_diffuse_trans (const uint4 packed_info)
 
FERMAT_HOST_DEVICE FERMAT_FORCEINLINE cugar::Vector3f bump_mapping (const VertexGeometryId &geom_id, const VertexGeometry &geom, const TextureReference &bump_map, const RenderingContextView &renderer)
 
FERMAT_HOST_DEVICE void eval_connection_terms (const EyeVertex ev, const LightVertex &lv, cugar::Vector3f &out, cugar::Vector3f &f_conn, float &G, float &d)
 
FERMAT_HOST_DEVICE void eval_connection_terms (const EyeVertex ev, const LightVertex &lv, cugar::Vector3f &out, cugar::Vector3f &f_conn, float &G, float &d, float &mis_w, bool RR=true, bool direct_lighting_nee=true, bool direct_lighting_bsdf=true)
 
FERMAT_HOST_DEVICE void eval_connection_terms (const EyeVertex ev, const LightVertex &lv, cugar::Vector3f &out, cugar::Vector3f &f_s, cugar::Vector3f &f_L, float &G, float &d, float &mis_w, bool RR=true, bool direct_lighting_nee=true, bool direct_lighting_bsdf=true)
 
FERMAT_HOST_DEVICE void eval_connection (const EyeVertex ev, const LightVertex &lv, cugar::Vector3f &out, cugar::Vector3f &out_w, float &d, bool RR=true, bool direct_lighting_nee=true, bool direct_lighting_bsdf=true)
 
FERMAT_HOST_DEVICE cugar::Vector3f eval_incoming_emission (const EyeVertex &ev, const RenderingContextView &renderer, bool direct_lighting_nee, bool indirect_lighting_nee, bool use_vpls)
 
template<typename VertexType >
FERMAT_HOST_DEVICE FERMAT_FORCEINLINE bool scatter (const VertexType &v, const float z[3], Bsdf::ComponentType &out_component, cugar::Vector3f &out, float &out_p, float &out_p_proj, cugar::Vector3f &out_w, bool RR=true, bool output_alpha=true, bool evaluate_full_bsdf=false, Bsdf::ComponentType components=Bsdf::kAllComponents)
 

Function Documentation

◆ bump_mapping()

FERMAT_HOST_DEVICE FERMAT_FORCEINLINE cugar::Vector3f bump_mapping ( const VertexGeometryId geom_id,
const VertexGeometry geom,
const TextureReference bump_map,
const RenderingContextView renderer 
)
Return the normal delta due to bump-mapping

◆ connect_to_camera()

template<typename TBPTContext , typename TBPTConfig >
FERMAT_HOST_DEVICE void bpt::connect_to_camera ( const uint32  light_idx,
const uint32  n_light_paths,
TBPTContext &  context,
RenderingContextView renderer,
const TBPTConfig &  config 
)
This function connects the given light vertex to the camera. Valid connections with non-zero contribution get enqueued in the shadow queue for occlusion testing.
Parameters
light_idxthe index of the light vertex in context.light_vertices
n_light_pathsthe total number of generated light subpaths
contextthe bidirectional path tracing context
rendererthe rendering context
configthe bidirectional path tracing configuration policy

◆ eval_connection_terms() [1/3]

FERMAT_HOST_DEVICE void eval_connection_terms ( const EyeVertex  ev,
const LightVertex lv,
cugar::Vector3f out,
cugar::Vector3f f_conn,
float &  G,
float &  d 
)
inline
Evaluate all the separate terms needed for a bidirectional connection, including
  • the edge vector joining the eye and light vertex
  • the product of the BSDFs at the two vertices
  • the geometric throughput G
  • the distance between the vertices

◆ eval_connection_terms() [2/3]

FERMAT_HOST_DEVICE void eval_connection_terms ( const EyeVertex  ev,
const LightVertex lv,
cugar::Vector3f out,
cugar::Vector3f f_conn,
float &  G,
float &  d,
float &  mis_w,
bool  RR = true,
bool  direct_lighting_nee = true,
bool  direct_lighting_bsdf = true 
)
inline
Evaluate all the separate terms needed for a bidirectional connection, including
  • the edge vector joining the eye and light vertex
  • the product of the BSDFs at the two vertices
  • the geometric throughput G
  • the distance between the vertices
  • the MIS weight

◆ eval_connection_terms() [3/3]

FERMAT_HOST_DEVICE void eval_connection_terms ( const EyeVertex  ev,
const LightVertex lv,
cugar::Vector3f out,
cugar::Vector3f f_s,
cugar::Vector3f f_L,
float &  G,
float &  d,
float &  mis_w,
bool  RR = true,
bool  direct_lighting_nee = true,
bool  direct_lighting_bsdf = true 
)
inline
Evaluate all the separate terms needed for a bidirectional connection, including
  • the edge vector joining the eye and light vertex
  • the product of the BSDFs at the two vertices
  • the geometric throughput G
  • the distance between the vertices
  • the MIS weight

◆ eval_incoming_emission()

FERMAT_HOST_DEVICE cugar::Vector3f eval_incoming_emission ( const EyeVertex ev,
const RenderingContextView renderer,
bool  direct_lighting_nee,
bool  indirect_lighting_nee,
bool  use_vpls 
)
inline
Evaluate the surface emission in the incoming direction at a eye vertex

◆ generate_primary_eye_vertex()

template<typename TPrimaryCoordinates , typename TBPTContext , typename TBPTConfig >
FERMAT_HOST_DEVICE void bpt::generate_primary_eye_vertex ( const uint32  idx,
const uint32  n_eye_paths,
const uint32  n_light_paths,
const TPrimaryCoordinates &  primary_coords,
TBPTContext &  context,
RenderingContextView renderer,
TBPTConfig &  config 
)
This function generates the primary eye vertex for a given path, expressed by the path id, and its primary sample space coordinates.
Parameters
light_path_idthe id of the light subpath
n_light_pathsthe total number of generated light subpaths
primary_coordsthe primary sample space coordinates generator
contextthe bidirectional path tracing context
rendererthe rendering context
configthe bidirectional path tracing configuration policy

◆ generate_primary_light_vertex()

template<typename TPrimaryCoordinates , typename TBPTContext , typename TBPTConfig >
FERMAT_HOST_DEVICE void bpt::generate_primary_light_vertex ( const uint32  light_path_id,
const uint32  n_light_paths,
const TPrimaryCoordinates &  primary_coords,
TBPTContext &  context,
RenderingContextView renderer,
TBPTConfig &  config 
)
This function generates the primary light vertex for a given path, expressed by the path id, and its primary sample space coordinates.
Parameters
light_path_idthe id of the light subpath
n_light_pathsthe total number of generated light subpaths
primary_coordsthe primary sample space coordinates generator
contextthe bidirectional path tracing context
rendererthe rendering context
configthe bidirectional path tracing configuration policy

◆ mis_power()

FERMAT_HOST_DEVICE FERMAT_FORCEINLINE float mis_power ( const float  w)

w

◆ pack_bsdf()

FERMAT_HOST_DEVICE FERMAT_FORCEINLINE uint4 pack_bsdf ( const MeshMaterial material)
Pack an BSDF into a uint4

◆ pack_edf() [1/2]

FERMAT_HOST_DEVICE FERMAT_FORCEINLINE uint4 pack_edf ( const Edf edf)
Pack an EDF into a uint4

◆ pack_edf() [2/2]

FERMAT_HOST_DEVICE FERMAT_FORCEINLINE uint4 pack_edf ( const MeshMaterial material)
Pack an EDF into a uint4

◆ process_secondary_eye_vertex()

template<typename TSampleSink , typename TPrimaryCoordinates , typename TBPTContext , typename TBPTConfig >
FERMAT_HOST_DEVICE void bpt::process_secondary_eye_vertex ( const uint32  queue_idx,
const uint32  n_eye_paths,
const uint32  n_light_paths,
TSampleSink &  sample_sink,
const TPrimaryCoordinates &  primary_coords,
TBPTContext &  context,
RenderingContextView renderer,
TBPTConfig &  config 
)
This function processes the secondary eye vertex corresponding to a given entry in the path tracing queue, stored in the bidirectional path tracing context. Specifically, processing a queue entry means performing the following operations:
  • fetching the corresponding ray and hit (or miss) information from the queue
  • interpolating the local geometry of the hit (or that of the environment on a miss)
  • reconstructing the local BSDF
  • performing Next-Event Estimation, if enabled, and handing the resulting sample (a full path) to the output sample sink
  • computing the local emission at the hit towards the incoming direction, i.e. forming a full path through pure forward path tracing, and passing the resulting sample to the output sample sink
  • sampling another scattering/absorption event
This function assumes a set of light subpaths have already been sampled and it is possible to sample and perform connections between the pre-existing light vertices and each new eye vertex. The light vertices are assumed to be stored in a TBPTContext::light_vertices member, see BPTContextBase.
Parameters
queue_idxthe index of the queue entry
n_eye_pathsthe total number of generated eye subpaths
n_light_pathsthe total number of generated light subpaths
sample_sinkthe output sample sink, processing all bidirectional paths formed processing this vertex
primary_coordsthe primary sample space coordinates generator
contextthe bidirectional path tracing context
rendererthe rendering context
configthe bidirectional path tracing configuration policy

◆ process_secondary_light_vertex()

template<typename TPrimaryCoordinates , typename TBPTContext , typename TBPTConfig >
FERMAT_HOST_DEVICE void bpt::process_secondary_light_vertex ( const uint32  queue_idx,
const uint32  n_light_paths,
const TPrimaryCoordinates &  primary_coords,
TBPTContext &  context,
RenderingContextView renderer,
TBPTConfig &  config 
)
This function processes the secondary light vertex corresponding to a given entry in the path tracing queue, stored in the bidirectional path tracing context. Specifically, processing a queue entry means performing the following operations:
  • fetching the corresponding ray and hit (or miss) information from the queue
  • interpolating the local geometry of the hit (or that of the environment on a miss)
  • reconstructing the local BSDF
  • potentially storing the resulting light vertex, based on the passed configuration/policy
  • sampling another scattering/absorption event
Parameters
queue_idxthe index of the queue entry
n_light_pathsthe total number of generated light subpaths
primary_coordsthe primary sample space coordinates generator
contextthe bidirectional path tracing context
rendererthe rendering context
configthe bidirectional path tracing configuration policy

◆ scatter()

template<typename VertexType >
FERMAT_HOST_DEVICE FERMAT_FORCEINLINE bool scatter ( const VertexType &  v,
const float  z[3],
Bsdf::ComponentType out_component,
cugar::Vector3f out,
float &  out_p,
float &  out_p_proj,
cugar::Vector3f out_w,
bool  RR = true,
bool  output_alpha = true,
bool  evaluate_full_bsdf = false,
Bsdf::ComponentType  components = Bsdf::kAllComponents 
)
sample a scattering/absorption event at a given vertex

◆ solve_occlusion()

template<typename TSampleSink , typename TBPTContext >
FERMAT_HOST_DEVICE void bpt::solve_occlusion ( const uint32  queue_idx,
TSampleSink &  sample_sink,
TBPTContext &  context,
RenderingContextView renderer 
)
Resolve the occlusion for the specified entry in the shadow queue, and pass the resulting sample to the sink. Specifically, if the queue entry contains a (ray tracing) hit, the sample will be considered shadowed and its contribution will be set to zero. Otherwise, the sample's contribution will be left unmodified.
Parameters
queue_idxthe index of the queue entry
sample_sinkthe output sample sink, processing all bidirectional paths formed processing this vertex
contextthe bidirectional path tracing context
rendererthe rendering context

◆ unpack_bsdf()

FERMAT_HOST_DEVICE FERMAT_FORCEINLINE Bsdf unpack_bsdf ( const RenderingContextView renderer,
const uint4  packed_info,
const TransportType  transport = kParticleTransport 
)
Unpack an BSDF from a uint4

◆ unpack_bsdf_diffuse()

FERMAT_HOST_DEVICE FERMAT_FORCEINLINE cugar::Vector3f unpack_bsdf_diffuse ( const uint4  packed_info)
Unpack the diffuse component of a uint4-packed BSDF

◆ unpack_bsdf_diffuse_trans()

FERMAT_HOST_DEVICE FERMAT_FORCEINLINE cugar::Vector3f unpack_bsdf_diffuse_trans ( const uint4  packed_info)
Unpack the diffuse transmission component of a uint4-packed BSDF

◆ unpack_bsdf_roughness()

FERMAT_HOST_DEVICE FERMAT_FORCEINLINE float unpack_bsdf_roughness ( const uint4  packed_info)
Unpack the roughness component of a uint4-packed BSDF

◆ unpack_bsdf_specular()

FERMAT_HOST_DEVICE FERMAT_FORCEINLINE cugar::Vector3f unpack_bsdf_specular ( const uint4  packed_info)
Unpack the specular component of a uint4-packed BSDF

◆ unpack_edf()

FERMAT_HOST_DEVICE FERMAT_FORCEINLINE Edf unpack_edf ( const uint4  packed_info)
Unpack an EDF from a uint4