Skip to content

Commit 19ae682

Browse files
committed
move work distribution to camera props
1 parent 19a6dae commit 19ae682

File tree

6 files changed

+178
-2145
lines changed

6 files changed

+178
-2145
lines changed

examples/1_basics/16_work_distribution.ipynb

Lines changed: 155 additions & 2110 deletions
Large diffs are not rendered by default.

plotoptix/_load_lib.py

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -287,17 +287,12 @@ def _load_optix_win():
287287
optix.set_coordinates_geom.argtypes = [c_int, c_float]
288288
optix.set_coordinates_geom.restype = c_bool
289289

290-
optix.get_work_distribution.restype = c_int
291-
292-
optix.set_work_distribution.argtypes = [c_int]
293-
optix.set_work_distribution.restype = c_bool
294-
295290
optix.get_noise_threshold.restype = c_float
296291

297292
optix.set_noise_threshold.argtypes = [c_float]
298293
optix.set_noise_threshold.restype = c_bool
299294

300-
optix.setup_camera.argtypes = [c_wchar_p, c_int, c_void_p, c_void_p, c_void_p, c_float, c_float, c_float, c_float, c_float, c_float, c_float, c_float, c_float, c_float, c_float, c_bool, c_wchar_p, c_bool]
295+
optix.setup_camera.argtypes = [c_wchar_p, c_int, c_int, c_void_p, c_void_p, c_void_p, c_float, c_float, c_float, c_float, c_float, c_float, c_float, c_float, c_float, c_float, c_float, c_bool, c_wchar_p, c_bool]
301296
optix.setup_camera.restype = c_int
302297

303298
optix.update_camera.argtypes = [c_wchar_p, c_void_p, c_void_p, c_void_p, c_float, c_float, c_float, c_float, c_float, c_float, c_float]
@@ -941,16 +936,12 @@ def delete_geometry(self, name): return self._optix.delete_geometry(name)
941936

942937
def set_coordinates_geom(self, mode, thickness): return self._optix.set_coordinates_geom(mode, thickness)
943938

944-
def get_work_distribution(self): return self._optix.get_work_distribution()
945-
946-
def set_work_distribution(self, mode): return self._optix.set_work_distribution(mode)
947-
948939
def get_noise_threshold(self): return self._optix.get_noise_threshold()
949940

950941
def set_noise_threshold(self, thr): return self._optix.set_noise_threshold(thr)
951942

952-
def setup_camera(self, name, camera_type, eye, target, up, aperture_r, aperture_fract, focal_scale, chroma_l, chroma_t, fov, rxy, cx, cy, sensor_height, blur, glock, textures, make_current):
953-
return self._optix.setup_camera_ptr(name, camera_type,
943+
def setup_camera(self, name, camera_type, work_distribution, eye, target, up, aperture_r, aperture_fract, focal_scale, chroma_l, chroma_t, fov, rxy, cx, cy, sensor_height, blur, glock, textures, make_current):
944+
return self._optix.setup_camera_ptr(name, camera_type, work_distribution,
954945
IntPtr.__overloads__[Int64](eye),
955946
IntPtr.__overloads__[Int64](target),
956947
IntPtr.__overloads__[Int64](up),
@@ -1715,16 +1706,12 @@ def delete_geometry(self, name): return self._optix.delete_geometry(name)
17151706

17161707
def set_coordinates_geom(self, mode, thickness): return self._optix.set_coordinates_geom(mode, float(thickness))
17171708

1718-
def get_work_distribution(self): return self._optix.get_work_distribution()
1719-
1720-
def set_work_distribution(self, mode): return self._optix.set_work_distribution(mode)
1721-
17221709
def get_noise_threshold(self): return self._optix.get_noise_threshold()
17231710

17241711
def set_noise_threshold(self, thr): return self._optix.set_noise_threshold(thr)
17251712

1726-
def setup_camera(self, name, camera_type, eye, target, up, aperture_r, aperture_fract, focal_scale, chroma_l, chroma_t, fov, rxy, cx, cy, sensor_height, blur, glock, textures, make_current):
1727-
return self._optix.setup_camera_ptr(name, camera_type,
1713+
def setup_camera(self, name, camera_type, work_distribution, eye, target, up, aperture_r, aperture_fract, focal_scale, chroma_l, chroma_t, fov, rxy, cx, cy, sensor_height, blur, glock, textures, make_current):
1714+
return self._optix.setup_camera_ptr(name, camera_type, work_distribution,
17281715
IntPtr(eye),
17291716
IntPtr(target),
17301717
IntPtr(up),

plotoptix/bin/RnD.SharpOptiX.dll

-512 Bytes
Binary file not shown.

plotoptix/bin/rndSharpOptiX7.dll

8 KB
Binary file not shown.

plotoptix/enums.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,15 @@ class WorkDistribution(Enum):
458458
"""
459459

460460
NoiseBalanced = 1
461-
"""More rays towards noisy pixels.
461+
"""More rays towards pixels with a higher relative noise, same as.
462+
"""
463+
464+
RelNoiseBalanced = 1
465+
"""More rays towards pixels a higher relative noise.
466+
"""
467+
468+
AbsNoiseBalanced = 2
469+
"""More rays towards pixels a higher absolute noise.
462470
"""
463471

464472
class Camera(Enum):

plotoptix/npoptix.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2144,15 +2144,6 @@ def set_param(self, **kwargs) -> None:
21442144
names ``"Hard"`` and ``"Soft"`` are accepted.
21452145
21462146
Set mode before adding lights.
2147-
2148-
- ``work_distribution``: how rays per pixel are distributed
2149-
2150-
Default value is :attr:`plotoptix.enums.WorkDistribution.Uniform`,
2151-
shooting constant number of rays per pixel (though no. of rays may
2152-
differ vor various materials of the primary hit).
2153-
2154-
Use :attr:`plotoptix.enums.WorkDistribution.NoiseBalanced` for dynamic
2155-
distribution of rays based on the estimated per pixel noise.
21562147
21572148
- ``max_accumulation_frames``
21582149
@@ -2205,12 +2196,6 @@ def set_param(self, **kwargs) -> None:
22052196
elif key == "max_accumulation_frames":
22062197
self._optix.set_max_accumulation_frames(int(value))
22072198

2208-
elif key == "work_distribution":
2209-
if isinstance(value, str): mode = WorkDistribution[value]
2210-
else: mode = value
2211-
2212-
self._optix.set_work_distribution(mode.value)
2213-
22142199
elif key == "noise_threshold":
22152200
self._optix.set_noise_threshold(float(value))
22162201

@@ -2758,6 +2743,7 @@ def setup_camera(self, name: str,
27582743
target: Optional[Any] = None,
27592744
up: Optional[Any] = None,
27602745
cam_type: Union[Camera, str] = Camera.Pinhole,
2746+
work_distribution: Union[WorkDistribution, str] = WorkDistribution.Uniform,
27612747
aperture_radius: float = -1,
27622748
aperture_fract: float = 0.15,
27632749
focal_scale: float = -1,
@@ -2794,6 +2780,12 @@ def setup_camera(self, name: str,
27942780
cam_type : Camera enum or string, optional
27952781
Type (pinhole, depth of field, ...), see :class:`plotoptix.enums.Camera`.
27962782
Cannot be changed after construction.
2783+
work_distribution :
2784+
How rays per pixel are distributed. Default value is :attr:`plotoptix.enums.WorkDistribution.Uniform`,
2785+
shooting constant number of rays per pixel (though no. of rays may
2786+
differ vor various materials of the primary hit).
2787+
See :class:`plotoptix.enums.WorkDistribution` for dynamic
2788+
distribution of rays based on the estimated per pixel noise.
27972789
aperture_radius : float, optional
27982790
Aperture radius (increases focus blur for depth of field cameras). Default
27992791
`-1` is internally reset to `0.1`.
@@ -2837,6 +2829,7 @@ def setup_camera(self, name: str,
28372829

28382830
if not isinstance(name, str): name = str(name)
28392831
if isinstance(cam_type, str): cam_type = Camera[cam_type]
2832+
if isinstance(work_distribution, str): work_distribution = WorkDistribution[work_distribution]
28402833

28412834
if name in self.camera_handles:
28422835
self.update_camera(name=name, eye=eye, target=target, up=up,
@@ -2896,7 +2889,7 @@ def setup_camera(self, name: str,
28962889
tex_list = ""
28972890
if textures is not None: tex_list = ";".join(textures)
28982891

2899-
h = self._optix.setup_camera(name, cam_type.value,
2892+
h = self._optix.setup_camera(name, cam_type.value, work_distribution.value,
29002893
eye_ptr, target_ptr, up.ctypes.data,
29012894
aperture_radius, aperture_fract,
29022895
focal_scale, chroma_l, chroma_t,

0 commit comments

Comments
 (0)