45
45
MixinPropertyModel ,
46
46
MixinPropertyOpacity ,
47
47
MixinPropertySegments ,
48
+ MixinPropertySize ,
48
49
MixinPropertyThickness ,
49
50
MixinPropertyTypeMaterial ,
50
51
MixinPropertyWireframe ,
@@ -235,6 +236,7 @@ class VisualRGBColourspace3D(
235
236
MixinPropertyTypeMaterial ,
236
237
MixinPropertyWireframe ,
237
238
MixinPropertySegments ,
239
+ MixinPropertySize ,
238
240
MixinPropertyKwargs ,
239
241
Visual ,
240
242
):
@@ -263,6 +265,9 @@ class VisualRGBColourspace3D(
263
265
Whether to render the visual as a wireframe, i.e., only render edges.
264
266
segments
265
267
Edge segments count for the *RGB* colourspace cube.
268
+ size
269
+ Size of the underlying *RGB* colourspace cube; used for plotting HDR
270
+ related volumes.
266
271
267
272
Other Parameters
268
273
----------------
@@ -279,6 +284,7 @@ class VisualRGBColourspace3D(
279
284
- :attr:`~colour_visuals.VisualRGBColourspace3D.type_material`
280
285
- :attr:`~colour_visuals.VisualRGBColourspace3D.wireframe`
281
286
- :attr:`~colour_visuals.VisualRGBColourspace3D.segments`
287
+ - :attr:`~colour_visuals.VisualRGBColourspace3D.size`
282
288
283
289
Methods
284
290
-------
@@ -325,6 +331,7 @@ def __init__(
325
331
material : Type [gfx .MeshAbstractMaterial ] = gfx .MeshBasicMaterial ,
326
332
wireframe : bool = False ,
327
333
segments : int = 16 ,
334
+ size : float = 1 ,
328
335
** kwargs ,
329
336
):
330
337
super ().__init__ ()
@@ -340,6 +347,7 @@ def __init__(
340
347
self .type_material = material
341
348
self .wireframe = wireframe
342
349
self .segments = segments
350
+ self .size = size
343
351
self .kwargs = kwargs
344
352
345
353
self .update ()
@@ -360,12 +368,16 @@ def update(self):
360
368
)
361
369
)
362
370
363
- positions = vertices ["position" ] + 0.5
371
+ positions = ( vertices ["position" ] + 0.5 ) * self . _size
364
372
365
373
positions [positions == 0 ] = EPSILON
366
374
367
375
if self ._colour is None :
368
- colour = positions
376
+ # NOTE: The colours are normalised by the reciprocal of *self._size*
377
+ # to avoid unpleasant clipping when displaying HDR volumes, e.g.
378
+ # the full ITU-R BT.2020 volume within ICtCp which is using a size
379
+ # of 10000.
380
+ colour = positions * (1.0 / self ._size )
369
381
else :
370
382
colour = np .tile (self ._colour , (positions .shape [0 ], 1 ))
371
383
0 commit comments