VTK  9.6.20260619
vtkWebGPUSkybox.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
15
16#ifndef vtkWebGPUSkybox_h
17#define vtkWebGPUSkybox_h
18
19#include "vtkSkybox.h"
20
21#include "vtkNew.h" // for ivars
22#include "vtkRenderingWebGPUModule.h" // For export macro
23#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
24#include "vtk_wgpu.h" // for webgpu
25
26VTK_ABI_NAMESPACE_BEGIN
27class vtkMatrix3x3;
32
33class VTKRENDERINGWEBGPU_EXPORT VTK_MARSHALAUTO vtkWebGPUSkybox : public vtkSkybox
34{
35public:
39 vtkTypeMacro(vtkWebGPUSkybox, vtkSkybox);
40 void PrintSelf(ostream& os, vtkIndent indent) override;
41
45 void Render(vtkRenderer* ren, vtkMapper* mapper) override;
46
50 void ReleaseGraphicsResources(vtkWindow* window) override;
51
52protected:
54 ~vtkWebGPUSkybox() override;
55
56private:
57 vtkWebGPUSkybox(const vtkWebGPUSkybox&) = delete;
58 void operator=(const vtkWebGPUSkybox&) = delete;
59
63 std::string BuildShaderSource();
64
68 void CreatePipeline(vtkWebGPURenderWindow* wgpuRenderWindow);
69
73 void CreateBindGroup(vtkWebGPUConfiguration* wgpuConfiguration);
74
78 void UpdateUniformBuffer(vtkWebGPUConfiguration* wgpuConfiguration, vtkRenderer* ren);
79
80 // Uniform block matching the WGSL struct layout
81 struct SkyboxUniforms
82 {
83 float CameraPosition[4]; // vec4 (padded from vec3)
84 float FloorPlane[4]; // vec4
85 float FloorRight[4]; // vec4 (padded from vec3)
86 float FloorFront[4]; // vec4 (padded from vec3)
87 float FloorTexCoordScale[2]; // vec2
88 float LeftEye; // f32
89 float ProjectionMode; // f32: 0=Cube, 1=Sphere, 2=StereoSphere, 3=Floor
90 alignas(16) float RotationMatrix[12]; // mat3x3 in WGSL = 3 x vec4 (each row padded to vec4)
91 };
92
93 int LastProjection = -1;
94 bool LastGammaCorrect = false;
95
96 wgpu::RenderPipeline Pipeline;
97 wgpu::BindGroupLayout BindGroupLayout;
98 wgpu::BindGroup BindGroup;
99 wgpu::Buffer UniformBuffer;
100 wgpu::Buffer MatrixBuffer;
101 wgpu::BindGroupLayout MatrixBindGroupLayout;
102 wgpu::BindGroup MatrixBindGroup;
103 std::string PipelineKey;
104
105 vtkNew<vtkMatrix3x3> RotationMatrix;
106
107 vtkMTimeType TextureBuildTime = 0;
108};
109
110#define vtkWebGPUSkybox_OVERRIDE_ATTRIBUTES vtkWebGPUSkybox::CreateOverrideAttributes()
111VTK_ABI_NAMESPACE_END
112#endif
a simple class to control print indentation
Definition vtkIndent.h:108
abstract class specifies interface to map data to graphics primitives
Definition vtkMapper.h:97
represent and manipulate 3x3 transformation matrices
Allocate and hold a VTK object.
Definition vtkNew.h:168
Attribute for vtkObjectFactory overrides.
abstract specification for renderers
float FloorPlane[4]
Definition vtkSkybox.h:201
float FloorRight[3]
Definition vtkSkybox.h:202
float FloorTexCoordScale[2]
Definition vtkSkybox.h:203
Create a webgpu device for use in rendering and compute pipelines.
WebGPU rendering window.
~vtkWebGPUSkybox() override
void ReleaseGraphicsResources(vtkWindow *window) override
Release any graphics resources that are being consumed by this skybox.
static vtkOverrideAttribute * CreateOverrideAttributes()
static vtkWebGPUSkybox * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void Render(vtkRenderer *ren, vtkMapper *mapper) override
Actual Skybox render method.
window superclass for vtkRenderWindow
Definition vtkWindow.h:61
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:318
#define VTK_MARSHALAUTO
#define VTK_NEWINSTANCE