------------------------------------------------------------------------------
| 253 | |
| 254 | //------------------------------------------------------------------------------ |
| 255 | void vtkWebGPUComputeFrustumCuller::UpdateCamera(vtkRenderer* renderer) |
| 256 | { |
| 257 | vtkCamera* camera = renderer->GetActiveCamera(); |
| 258 | // Getting the view-projection matrix |
| 259 | vtkMatrix4x4* viewMatrix = camera->GetModelViewTransformMatrix(); |
| 260 | |
| 261 | // We're using [0, 1] for znear and zfar here to align with WebGPU convention |
| 262 | vtkMatrix4x4* projectionMatrix = |
| 263 | camera->GetProjectionTransformMatrix(renderer->GetTiledAspectRatio(), 0, 1); |
| 264 | vtkNew<vtkMatrix4x4> viewProj; |
| 265 | vtkMatrix4x4::Multiply4x4(projectionMatrix, viewMatrix, viewProj); |
| 266 | // WebGPU uses column major matrices but VTK is row major |
| 267 | viewProj->Transpose(); |
| 268 | |
| 269 | // Getting the matrix data as floats |
| 270 | std::vector<float> matrixData(16); |
| 271 | for (int i = 0; i < 16; i++) |
| 272 | { |
| 273 | matrixData[i] = static_cast<float>(viewProj->GetData()[i]); |
| 274 | } |
| 275 | |
| 276 | // Creating / updating the view-proj matrix uniform buffer |
| 277 | if (this->CameraViewProjMatrixBufferIndex == -1) |
| 278 | { |
| 279 | this->CreateViewProjMatrixBuffer(matrixData); |
| 280 | } |
| 281 | else |
| 282 | { |
| 283 | this->FrustumCullingPass->UpdateBufferData(this->CameraViewProjMatrixBufferIndex, matrixData); |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | //------------------------------------------------------------------------------ |
| 288 | void vtkWebGPUComputeFrustumCuller::OutputObjectCountMapCallback( |
no test coverage detected