Repository navigation
WebGPU - #75
Merged
Merged
WebGPU#75
Conversation
…tter ast all resolutions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WebGPU will now be the default renderer for ZincJS.
This requires many of the modules to be refactored and improved.
Renderer can now render on demand which will greatly reduce CPU usage on idle.
Please see the following full list for the changes:
three.js and the renderer
threeimports are nowthree/webgpu. The renderer isTHREE.WebGPURenderer, which falls back to WebGL 2.material.uniformsandonBeforeCompileno longer apply.Renderer.initialiseVisualisation()is nowasyncand must be awaited.Renderer.isWebGL2()andScene.isWebGL2()now return true only on the WebGL 2 fallback backend.Renderer.forceContextLoss()andRenderer.forceContextRestore()now do nothing.Legacy geometry removed
Geometry,Face3andDirectGeometryare deleted (src/three/Geometry.js).JSONLoader.parse()returns aBufferGeometry. It no longer providesfaces,vertices,morphTargets,morphColors, skin, bones or animations.toBufferGeometry(geometry)only clones now, and itsoptionsargument is ignored.copyMorphColorsToBufferGeometryis removed.Geometry.calculateUVs()andLines2.render()are removed.Pointsets
InstancedPoints(anInstancedMeshof camera-facing quads), not aTHREE.Points.instancePositionandmesh.pointPositions, not ingeometry.attributes.position.addPointsis capped at 500 points (DEFAULT_CAPACITY). Extra points are silently dropped.Scene.addTemporaryPoints()returns anInstancedPoints.Lines, materials and textures
LineMaterialis deleted. Lines useLine2NodeMaterialinstead.material.resolutionno longer exists. The resolution is now stored as_resolutionon the mesh.material.vertexColors, which is forced tofalse. The blend is driven bymaterial.userData.uniforms.morphColorMix.material.userData.uniforms.TextureArray.implis now aData3DTexture(it was aDataArrayTexture).Rendering and scene API
render(delta, playAnimation, cameraControls, options). TextureSlides and Glyphset gained thecameraControlsargument.SceneExporter.exportGLTF()isasync, rejects on errors, and exports withonlyVisible: true.Scene.renderGeometries()returns a boolean that says whether anything changed.THREE.Clockis replaced byTHREE.Timer.Region.clear(transverse)resetschildrenonly whentransverseis true.VideoHandlerno longer setsRGBFormat.New features
WebGPU setup
initialiseVisualisationruns, it asks the adapter for its maximummaxTextureArrayLayersandmaxStorageBuffersPerShaderStage. Texture arrays can therefore use as many layers as the hardware supports.Renderer.isWebGPU()andScene.isWebGPU().Scene.getRenderer(), which returns the WebGPU renderer for custom TSL compute.Render on demand (
9af3d80)Renderer.setRenderOnDemand(flag),isRenderOnDemand()andinvalidate(), plusScene.invalidate()andZincObject.requestRender().src/renderRequests.jslets shared resources that belong to no scene, such as async textures, ask every renderer to redraw.Glyphset transforms and colours on the GPU (
9e52df1)src/tsl/glyphTransform.js: a TSL compute port ofresolve_glyph_axesplus keyframe interpolation. It supports the NONE, MIRROR, AXES_2D and AXES_3D repeat modes.src/tsl/glyphRenderMaterial.jsbuilds each instance's transform and colour from the compute output.setMorphTimeare debounced to 500 ms.Glyphset.prepareColorForExport()andclearColorExportState()for export.Glyph.getColour().Glyph.showLabel()now prefers the glyph's own colour.Text sprites (new
src/textSprite.js)SpriteNodeMaterial, and their canvas resolution is chosen from the text's size on screen.alphaTestchanged from 0.5 to 0.05.Morph colour, texture slides and Lines2
src/tsl/morphColorMaterial.js). It keeps two long-livedmorphColor0/1attributes and copies data into them only when the keyframe pair changes.src/tsl/textureSlides.js). Time-dependent textures work by swapping image data.Lines2buffers grow as needed and are edited in place. Before, they were fixed at 300 entries.glTF
COLOR_0targets through a newZINC_morph_colourplugin. Animation tracks are prefixed with the mesh uuid, and hidden meshes are skipped.Loading and regions
SceneLoader.cancelPendingLoads(). Results that arrive after cancellation are disposed, andScene.clearAll()calls it.Region.getScene().getAllObjects()takes an optional accumulator argument.Bug fixes
Controls and picking
MODE.ROTATE_CAMERA_TRANSITION.==where it meant=.THREE.Mathreplaced withTHREE.MathUtils.CameraControls.disable()now resets the control state.Renderer and regions
Region.setMorphTimerecursed only one level.Region.clear(true)left child groups attached.Loaders
mergeGlyphDataappended the wrong set of labels.IndexedSourcesHandlerpassed the wrong argument to its error handler, and passed factory functions where it should have passed the handlers they return.MultiSourcesHandlerdisposed the wrong entry.PrimitivesLoader.parseused an undefinedloader.loadSTLandloadOBJcrashed onoptions.lodand had no error or progress handlers.toBeDwonloadedwas misspelled, so pending downloads were never reset.Primitives
resolve_glyph_axesreferenced an undefinedglyph_repeat_mode.Glyph.setColourused an undefinedcolour.Label.disposedid nothing. Labels are now also disposed together with their glyphs.dispose()were leaked.TextureSlides.disposedidn't dispose the mask texture.TextureVolumewas missing anidTextureMapdeclaration.removeVertexAtIndex(maintainLength)threw away its result.getCircularTexturetexture was flagged for update before its image had loaded.WebGPU
f0377c9). NewkeepIndexTypeanduseStandardIndexTypehelpers handle this.Performance
renderOptions, minimap scratch vectors and camera path interpolation are reused. Callback loops usefor...in.updateMatrixWorld()instead of a full render.hasMorphPositions, cached).getBoundingBoxno longer updates children's world matrices.material.needsUpdateon every uniform change.Build, tooling and docs
Tests added
Loaders and scenes
jsonLoader.test.js: the JSON loader's BufferGeometry output.loaderRegressions.test.js: morph colour, video, pointset and tubelines regressions.sceneClearRegressions.test.js: clearing scenes, cancelling loads, and loads that finish after dispose.Rendering
renderOnDemand.test.js: what triggers a frame, and how pre- and post-render callbacks behave.performanceRegressions.test.js: the performance changes listed above.webgpuShaderBuild.test.js: shaders build and render on real WebGPU.Glyphsets
glyphTransformCompute.{NONE,MIRROR,AXES_2D,AXES_3D}.test.js: the GPU compute checked against a CPU reference (glyphTransformReference.js).glyphsetGpuPipeline.test.js: the full GPU path from loading a glyphset to its instance attributes.glyphsetAnimationPipeline.test.js: playback skips instance writes and raycasting, then resyncs once on pause.glyphsetTimeSliderDebounce.test.js: rapidsetMorphTimecalls collapse into one readback.glyphsetLabelSync.test.jsandglyphShowLabelColour.test.js: label position and colour.Fixtures
test/models/timeGlyphs_{geometry,metadata}.json