Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | 1x 1x | import macro from 'vtk.js/Sources/macros'; import vtkWebGPURenderEncoder from 'vtk.js/Sources/Rendering/WebGPU/RenderEncoder'; import vtkWebGPUTexture from 'vtk.js/Sources/Rendering/WebGPU/Texture'; import vtkRenderPass from 'vtk.js/Sources/Rendering/SceneGraph/RenderPass'; // ---------------------------------------------------------------------------- function vtkWebGPUOpaquePass(publicAPI, model) { // Set our className model.classHierarchy.push('vtkWebGPUOpaquePass'); // this pass implements a forward rendering pipeline // if both volumes and opaque geometry are present // it will mix the two together by capturing a zbuffer // first publicAPI.traverse = (renNode, viewNode) => { if (model.deleted) { return; } // we just render our delegates in order model._currentParent = viewNode; const device = viewNode.getDevice(); if (!model.renderEncoder) { publicAPI.createRenderEncoder(); model.colorTexture = vtkWebGPUTexture.newInstance({ label: 'opaquePassColor', }); model.colorTexture.create(device, { width: viewNode.getCanvas().width, height: viewNode.getCanvas().height, format: 'rgba16float', /* eslint-disable no-undef */ /* eslint-disable no-bitwise */ usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_SRC, }); const ctView = model.colorTexture.createView('opaquePassColorTexture'); model.renderEncoder.setColorTextureView(0, ctView); model.depthFormat = 'depth32float'; model.depthTexture = vtkWebGPUTexture.newInstance({ label: 'opaquePassDepth', }); model.depthTexture.create(device, { width: viewNode.getCanvas().width, height: viewNode.getCanvas().height, format: model.depthFormat, usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_SRC, }); const dView = model.depthTexture.createView('opaquePassDepthTexture'); model.renderEncoder.setDepthTextureView(dView); } else { model.colorTexture.resize( viewNode.getCanvas().width, viewNode.getCanvas().height ); model.depthTexture.resize( viewNode.getCanvas().width, viewNode.getCanvas().height ); } model.renderEncoder.attachTextureViews(); publicAPI.setCurrentOperation('opaquePass'); renNode.setRenderEncoder(model.renderEncoder); renNode.traverse(publicAPI); }; publicAPI.getColorTextureView = () => model.renderEncoder.getColorTextureViews()[0]; publicAPI.getDepthTextureView = () => model.renderEncoder.getDepthTextureView(); publicAPI.createRenderEncoder = () => { model.renderEncoder = vtkWebGPURenderEncoder.newInstance({ label: 'OpaquePass', }); // default settings are fine for this model.renderEncoder.setPipelineHash('op'); }; } // ---------------------------------------------------------------------------- // Object factory // ---------------------------------------------------------------------------- const DEFAULT_VALUES = { renderEncoder: null, colorTexture: null, depthTexture: null, }; // ---------------------------------------------------------------------------- export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); // Build VTK API vtkRenderPass.extend(publicAPI, model, initialValues); macro.get(publicAPI, model, ['colorTexture', 'depthTexture']); // Object methods vtkWebGPUOpaquePass(publicAPI, model); } // ---------------------------------------------------------------------------- export const newInstance = macro.newInstance(extend, 'vtkWebGPUOpaquePass'); // ---------------------------------------------------------------------------- export default { newInstance, extend }; |