VTK  9.7.1
vtkWebGPULight.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
11 #ifndef vtkWebGPULight_h
12 #define vtkWebGPULight_h
13 
14 #include "vtkLight.h"
15 
16 #include "vtkRenderingWebGPUModule.h" // For export macro
17 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
18 
19 VTK_ABI_NAMESPACE_BEGIN
20 class vtkRenderer;
21 class vtkCamera;
23 class VTKRENDERINGWEBGPU_EXPORT VTK_MARSHALAUTO vtkWebGPULight : public vtkLight
24 {
25 public:
26  static vtkWebGPULight* New();
28  static vtkOverrideAttribute* CreateOverrideAttributes();
29  vtkTypeMacro(vtkWebGPULight, vtkLight);
30  void PrintSelf(ostream& os, vtkIndent indent) override;
31 
32  void CacheLightInformation(vtkRenderer* renderer, vtkCamera* camera);
33  inline const void* GetCachedLightInformation() { return &(this->CachedLightInfo); }
34  static std::size_t GetCacheSizeBytes() { return sizeof(LightInfo); }
35 
36  void Render(vtkRenderer*, int) override;
37 
38 protected:
39  vtkWebGPULight() = default;
40  ~vtkWebGPULight() override = default;
41 
42  struct LightInfo
43  {
44  // Must be 80 bytes to match WGSL SceneLight struct stride.
45  // The 12-byte padding needed to align the first element after the 4-byte count
46  // is written once in WriteLightsBuffer(), not per-light.
47  // 0 : deferred, 1 : headlight, 2 : lightkit, 3 : positional
48  vtkTypeUInt32 Type = 0;
49  // 0 : not positional, 1 : positional
50  vtkTypeUInt32 Positional = 0;
51  vtkTypeFloat32 ConeAngle = 0;
52  vtkTypeFloat32 Exponent = 0;
53  vtkTypeFloat32 Color[4] = {};
54  vtkTypeFloat32 DirectionVC[4] = {}; // normalized
55  vtkTypeFloat32 PositionVC[4] = {};
56  vtkTypeFloat32 Attenuation[4] = {};
57  };
59 
60 private:
61  vtkWebGPULight(const vtkWebGPULight&) = delete;
62  void operator=(const vtkWebGPULight&) = delete;
63 };
64 
65 #define vtkWebGPULight_OVERRIDE_ATTRIBUTES vtkWebGPULight::CreateOverrideAttributes()
66 VTK_ABI_NAMESPACE_END
67 #endif
const void * GetCachedLightInformation()
Attribute for vtkObjectFactory overrides.
abstract specification for renderers
Definition: vtkRenderer.h:63
static vtkLight * New()
Create a light with the focal point at the origin and its position set to (0,0,1).
a simple class to control print indentation
Definition: vtkIndent.h:28
a virtual camera for 3D rendering
Definition: vtkCamera.h:41
a virtual light for 3D rendering
Definition: vtkLight.h:49
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
#define VTK_NEWINSTANCE
static std::size_t GetCacheSizeBytes()
OpenGL light.
LightInfo CachedLightInfo
#define VTK_MARSHALAUTO
virtual void Render(vtkRenderer *, int)
Abstract interface to renderer.
Definition: vtkLight.h:79