VTK  9.7.20261105
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 C API
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
74 bool GetUnfilterableTexture();
75
79 void CreateBindGroup(vtkWebGPUConfiguration* wgpuConfiguration);
80
84 void UpdateUniformBuffer(vtkWebGPUConfiguration* wgpuConfiguration, vtkRenderer* ren);
85
86 // Uniform block matching the WGSL struct layout
87 struct SkyboxUniforms
88 {
89 float CameraPosition[4]; // vec4 (padded from vec3)
90 float FloorPlane[4]; // vec4
91 float FloorRight[4]; // vec4 (padded from vec3)
92 float FloorFront[4]; // vec4 (padded from vec3)
93 float FloorTexCoordScale[2]; // vec2
94 float LeftEye; // f32
95 float ProjectionMode; // f32: 0=Cube, 1=Sphere, 2=StereoSphere, 3=Floor
96 alignas(16) float RotationMatrix[12]; // mat3x3 in WGSL = 3 x vec4 (each row padded to vec4)
97 };
98
99 int LastProjection = -1;
100 bool LastGammaCorrect = false;
101 bool LastUnfilterableTexture = false;
102
103 WGPURenderPipeline Pipeline = nullptr;
104 WGPUBindGroupLayout BindGroupLayout = nullptr;
105 WGPUBindGroup BindGroup = nullptr;
106 WGPUBuffer UniformBuffer = nullptr;
107 WGPUBuffer MatrixBuffer = nullptr;
108 WGPUBindGroupLayout MatrixBindGroupLayout = nullptr;
109 WGPUBindGroup MatrixBindGroup = nullptr;
110 std::string PipelineKey;
111
112 vtkNew<vtkMatrix3x3> RotationMatrix;
113
114 vtkMTimeType TextureBuildTime = 0;
115};
116
117#define vtkWebGPUSkybox_OVERRIDE_ATTRIBUTES vtkWebGPUSkybox::CreateOverrideAttributes()
118VTK_ABI_NAMESPACE_END
119#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:107
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:62
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:318
#define VTK_MARSHALAUTO
#define VTK_NEWINSTANCE