differt.scene.AbstractPathTracer#
- class AbstractPathTracer[source]#
Bases:
AbstractPathSolverAbstract base class for exact path tracing solvers.
A path tracer generates path candidates (arrays of triangle indices together with interaction-type tags) and then traces them through the scene to produce
TracedPaths.Attributes
Methods
generate_path_candidates(scene, order[, ...])Return a tuple of
(path_candidates, interaction_types).generate_path_candidates_chunks_iter(scene, ...)Return an iterator of chunked path candidate tuples.
trace_path_candidates(scene, ...)Core logic to trace the exact paths from the proposed candidates.
trace_paths(scene, order[, chunk_size, ...])Trace paths for the given scene and order(s).
Detailed documentation
- abstractmethod generate_path_candidates(scene, order, specular_reflection=True, diffuse_scattering=False)[source]#
Return a tuple of
(path_candidates, interaction_types).path_candidatescontains triangle indices.interaction_typesclassifies the bounce (e.g.,0for specular). A value of-1in either array indicates an “inactive” interaction or padded bounce (used when combining paths of different reflection orders).- Parameters:
- Return type:
tuple[num_path_candidates max_order'],num_path_candidates max_order']]- Returns:
A 2-tuple of
(path_candidates, interaction_types).
- generate_path_candidates_chunks_iter(scene, order, *args, chunk_size, pad_chunks=False, **kwargs)[source]#
Return an iterator of chunked path candidate tuples.
The default implementation calls
generate_path_candidatesonce and then slices the result. Subclasses may override this to generate candidates lazily.- Parameters:
scene (
TriangleScene) – The scene.*args (
Any) – Forwarded togenerate_path_candidates.chunk_size (
int) – Number of candidates per chunk.pad_chunks (
bool) – IfTrue, the last chunk is zero-padded (with-1) tochunk_size.**kwargs (
Any) – Forwarded togenerate_path_candidates.
- Return type:
SizedIterator[tuple[chunk_size max_order'],chunk_size max_order']]]- Returns:
A
SizedIteratorover(path_candidates, interaction_types)chunks.
- abstractmethod trace_path_candidates(scene, path_candidates, interaction_types)[source]#
Core logic to trace the exact paths from the proposed candidates.
- Parameters:
scene (
TriangleScene) – The scene.path_candidates (
num_path_candidates max_order']) – Triangle indices for each candidate.interaction_types (
num_path_candidates max_order']) – Interaction type for each bounce.
- Return type:
- Returns:
The traced paths.
- trace_paths(scene, order, chunk_size=None, pad_chunks=False)[source]#
Trace paths for the given scene and order(s).
If
chunk_sizeis provided, returns an iterator ofTracedPaths(one per chunk); otherwise returns a singleTracedPaths.- Parameters:
- Return type:
- Returns:
Traced paths, or an iterator thereof.