Skip to content

Commit babd01c

Browse files
committed
convenience method to update area light
1 parent f558d05 commit babd01c

File tree

6 files changed

+84
-7
lines changed

6 files changed

+84
-7
lines changed

CHANGELOG.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
Release history
22
===============
33

4+
v0.8.2 - unreleased
5+
-------------------
6+
7+
Added
8+
~~~~~
9+
10+
- method to update parallelogram light using center/target 3D points and scalar lengths of u/v sides (missing in v0.8.0)
11+
412
`v0.8.1`_ - 2020-06-14
513
----------------------
614

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ Features
5252
- pinhole camera, thin-lens camera with depth of field simulation, panoramic camera for making 360 deg environment maps
5353
- geometries: particle (sphere), parallelepiped, parallelogram, tetrahedron, bezier line, mesh (generated from parametric surface or f(x,y) plots; defined with vertices and faces; import from Wavefront .obj file)
5454
- parameterized materials shading: flat, diffuse, reflective, refractive; including: light dispersion, surface roughness, subsurface scattering, and nested volumes
55-
- spherical and parallelogram light sources
56-
- environmental light and ambient occlusion
55+
- spherical and parallelogram light sources, light emission in volumes
56+
- environmental light, environmetn maps, and ambient occlusion
5757
- post-processing: tonal correction curves, levels adjustment, apply mask/overlay, AI denoiser
5858
- GPU acceleration using RT Cores and everything else what comes with `OptiX 7 <https://developer.nvidia.com/optix>`__
5959
- callbacks at the scene initialization, start and end of each frame raytracing, end of progressive accumulation
60-
- 8/16/32bps image output to `numpy <http://www.numpy.org>`__ array, or save to popular image file formats
60+
- 8/16/32bps(hdr) image output to `numpy <http://www.numpy.org>`__ array, or save to popular image file formats
6161
- hardware accelerated video output to MP4 file format using `NVENC 9.0 <https://developer.nvidia.com/nvidia-video-codec-sdk>`__
6262
- Tkinter based simple GUI window or headless raytracer
6363
- configurable multi-GPU support

docs/npoptix_lights.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Setup and update lighting
2323
.. automethod:: plotoptix.NpOptiX.setup_parallelogram_light
2424
.. automethod:: plotoptix.NpOptiX.setup_area_light
2525
.. automethod:: plotoptix.NpOptiX.update_light
26+
.. automethod:: plotoptix.NpOptiX.update_area_light
2627
.. automethod:: plotoptix.NpOptiX.light_fit
2728

2829
Read back light properties

plotoptix/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
__author__ = "Robert Sulej, R&D Team <dev@rnd.team>"
1414
__status__ = "beta"
15-
__version__ = "0.8.1"
16-
__date__ = "14 June 2020"
15+
__version__ = "0.8.2"
16+
__date__ = "22 June 2020"
1717

1818
import logging
1919

plotoptix/npoptix.py

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2880,7 +2880,7 @@ def update_light(self, name: str,
28802880
28812881
Parameters
28822882
----------
2883-
name : string, optional
2883+
name : string
28842884
Name of the light.
28852885
pos : array_like, optional
28862886
3D position.
@@ -2930,6 +2930,74 @@ def update_light(self, name: str,
29302930
self._logger.error(msg)
29312931
if self._raise_on_error: raise RuntimeError(msg)
29322932

2933+
def update_area_light(self, name: str,
2934+
center: Optional[Any] = None, target: Optional[Any] = None,
2935+
u: Optional[float] = None, v: Optional[float] = None,
2936+
color: Optional[Any] = None) -> None:
2937+
"""Setup new area (parallelogram) light.
2938+
2939+
Convenience method to update parallelogram light with ``center`` and ``target`` 3D points,
2940+
and scalar lenghts of sides ``u`` and ``v``.
2941+
2942+
Parameters
2943+
----------
2944+
name : string
2945+
Name of the new light.
2946+
center : array_like, optional
2947+
3D position of the light center.
2948+
target : array_like, optional
2949+
3D position of the light target.
2950+
u : float, optional
2951+
Horizontal side length.
2952+
v : float, optional
2953+
Vertical side length.
2954+
color : Any, optional
2955+
RGB color of the light; single value is gray, array_like is RGB
2956+
color components. Color value range is (0; inf) as it means the
2957+
light intensity.
2958+
"""
2959+
if name is None: raise ValueError()
2960+
2961+
if not isinstance(name, str): name = str(name)
2962+
2963+
if name not in self.light_handles:
2964+
msg = "Light %s does not exists." % name
2965+
self._logger.error(msg)
2966+
if self._raise_on_error: raise ValueError(msg)
2967+
return
2968+
2969+
if u is None:
2970+
u = np.linalg.norm(self.get_light_u(name))
2971+
2972+
if v is None:
2973+
v = np.linalg.norm(self.get_light_v(name))
2974+
2975+
if center is None:
2976+
center = self.get_light_pos(name) + 0.5 * (self.get_light_u(name) + self.get_light_v(name))
2977+
2978+
if target is None:
2979+
n = np.cross(self.get_light_u(name), self.get_light_v(name))
2980+
target = center + 100 * n
2981+
2982+
center = _make_contiguous_vector(center, 3)
2983+
target = _make_contiguous_vector(target, 3)
2984+
2985+
n = target - center
2986+
n = n / np.linalg.norm(n)
2987+
2988+
uvec = np.cross(n, [0, 1, 0])
2989+
uvec = uvec / np.linalg.norm(uvec)
2990+
2991+
vvec = np.cross(uvec, n)
2992+
vvec = vvec / np.linalg.norm(vvec)
2993+
2994+
uvec *= -u
2995+
vvec *= v
2996+
2997+
pos = center - 0.5 * (vvec + uvec)
2998+
2999+
self.update_light(name, pos=pos, color=color, u=uvec, v=vvec)
3000+
29333001
def light_fit(self, light: str,
29343002
camera: Optional[str] = None,
29353003
horizontal_rot: float = 45,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def get_tag(self):
119119

120120

121121
setup(name='plotoptix',
122-
version='0.8.1',
122+
version='0.8.2',
123123
url='https://rnd.team/project/plotoptix',
124124
project_urls={
125125
'Documentation': 'https://plotoptix.rnd.team',

0 commit comments

Comments
 (0)