32 #include <clustered_rl.h> 33 #include <vtl_mesh_view.h> 34 #include <spatial_hash.h> 49 static const uint32 INVALID_SLOT = 0xFFFFFFFF;
50 static const uint32 INVALID_SAMPLE = 0xFFFFFFFF;
63 vtl_rl(_rl), vtls(_vtls) {}
73 const bool is_secondary_diffuse,
74 const float cone_radius,
78 const float cone_scale = 32.0f;
79 const float filter_scale = is_secondary_diffuse ? 0.2f : 1.5f;
81 const uint32 base_dim = (is_secondary_diffuse ? 0 : renderer.instance) * 6;
82 const uint32 random_set =
cugar::hash(pixel + renderer.res_x * renderer.res_y * bounce);
84 const float jitter[6] = {
93 const float bbox_delta = cugar::max_comp( scene_bbox[1] - scene_bbox[0] );
98 dot(ev.in, ev.geom.normal_s) > 0.0f ? ev.geom.normal_s : -ev.geom.normal_s,
103 cugar::min( cone_radius * cone_scale, bbox_delta * 0.05f ),
114 const uint32 nee_slot,
123 if (nee_slot != INVALID_SLOT)
129 uint32 vtl_idx = vtl_rl.
sample( nee_slot, z[2], &vtl_pdf, &vtl_cluster );
132 vtls.
sample( vtl_idx,
cugar::Vector2f(z[0],z[1]), &light_vertex->prim_id, &light_vertex->uv, light_vertex_geom, light_pdf, light_edf );
135 *light_pdf *= vtl_pdf;
144 vtls.
sample( vtl_idx,
cugar::Vector2f(z[0],z[1]), &light_vertex->prim_id, &light_vertex->uv, light_vertex_geom, light_pdf, light_edf );
146 return INVALID_SAMPLE;
154 const uint32 prev_nee_slot,
161 const uint32 vtl_idx = vtls.
map(triId, uv, light_vertex_geom, light_pdf, light_edf);
162 if (prev_nee_slot != uint32(-1) && vtl_idx != uint32(-1))
165 *light_pdf *= vtl_rl.
pdf( prev_nee_slot, vtl_idx );
173 const uint32 nee_slot,
174 const uint32 nee_cluster,
179 if (nee_cluster != INVALID_SAMPLE)
181 const float new_value = cugar::max_comp(w.xyz()) * (occluded ==
false ? 1.0f : 0.0f);
183 vtl_rl.
update(nee_slot, nee_cluster, new_value);
Definition: direct_lighting_rl.h:45
FERMAT_HOST_DEVICE uint32 map(const uint32_t prim_id, const cugar::Vector2f &uv, const VertexGeometry &geom, float *pdf, Edf *edf) const
Definition: vtl_mesh_view.h:87
FERMAT_DEVICE float pdf(const uint32 cell_slot, const uint32 index) const
Definition: clustered_rl_inline.h:159
CUGAR_HOST_DEVICE uint32 quantize(const float x, const uint32 n)
Definition: numbers.h:600
FERMAT_DEVICE uint32 find_slot(const uint64 key)
Definition: clustered_rl_inline.h:117
FERMAT_DEVICE void update(const uint32 nee_slot, const uint32 nee_cluster, const cugar::Vector3f w, const bool occluded)
Definition: direct_lighting_rl.h:172
FERMAT_FORCEINLINE FERMAT_HOST_DEVICE uint64 spatial_hash(const cugar::Vector3f P, const cugar::Vector3f N, const cugar::Bbox3f bbox, const float samples[6], const float cone_radius, const uint32 normal_bits=4)
Definition: spatial_hash.h:44
FERMAT_DEVICE uint32 sample(const uint32 cell_slot, const float z, float *pdf, uint32 *cluster_idx) const
Definition: clustered_rl_inline.h:127
FERMAT_DEVICE void map(const uint32 prev_nee_slot, const uint32 triId, const cugar::Vector2f uv, const VertexGeometry light_vertex_geom, float *light_pdf, Edf *light_edf)
Definition: direct_lighting_rl.h:153
FERMAT_HOST_DEVICE void sample(const uint32 vtl_idx, const cugar::Vector2f vtl_uv, uint32_t *prim_id, cugar::Vector2f *uv, VertexGeometry *geom, float *pdf, Edf *edf) const
Definition: vtl_mesh_view.h:54
Definition: clustered_rl.h:123
Definition: bpt_utils.h:583
FERMAT_HOST_DEVICE DirectLightingRL(RLMap _rl, VTLMeshView _vtls)
Definition: direct_lighting_rl.h:60
Definition: vtl_mesh_view.h:40
FERMAT_HOST_DEVICE DirectLightingRL()
Definition: direct_lighting_rl.h:55
FERMAT_DEVICE uint32 preprocess_vertex(const RenderingContextView &renderer, const EyeVertex &ev, const uint32 pixel, const uint32 bounce, const bool is_secondary_diffuse, const float cone_radius, const cugar::Bbox3f scene_bbox)
Definition: direct_lighting_rl.h:68
FERMAT_DEVICE void update(const uint32 cell_slot, const uint32 cluster_idx, const float val, const float alpha=0.05f)
Definition: clustered_rl_inline.h:183
FERMAT_DEVICE uint32 sample(const uint32 nee_slot, const float z[3], VertexGeometryId *light_vertex, VertexGeometry *light_vertex_geom, float *light_pdf, Edf *light_edf)
Definition: direct_lighting_rl.h:113
Definition: renderer_view.h:80
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE uint32 hash(uint32 a)
Definition: numbers.h:649
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE float randfloat(unsigned i, unsigned p)
Definition: numbers.h:753