Skip to content

Commit

Permalink
WebGPURenderer: handle instanced geometries in WebGL backend (#26731)
Browse files Browse the repository at this point in the history
* handle instanced geometries
handle interleaved buffers and deduplicate
add clear() for frame buffer

* remove redundant code

* adjust support message

* support InstancedMesh and updateAttribute()

* remove version inc

* Squashed commit of the following:

commit 181e04e
Author: Mr.doob <info@mrdoob.com>
Date:   Fri Sep 29 00:10:20 2023 +0900

    r157

commit cabaf21
Author: Mr.doob <info@mrdoob.com>
Date:   Fri Sep 29 00:08:47 2023 +0900

    Updated builds.

commit 1c85c95
Author: Mr.doob <info@mrdoob.com>
Date:   Thu Sep 28 23:41:31 2023 +0900

    Improved USDZLoader example.

commit d6c8dd0
Author: Mr.doob <info@mrdoob.com>
Date:   Thu Sep 28 22:53:05 2023 +0900

    Improved compute texture examples.

commit f886330
Author: GitHubDragonFly <69928501+GitHubDragonFly@users.noreply.github.com>
Date:   Thu Sep 28 03:23:34 2023 -0400

    USDZ Loader - texture scale + offset + rotation (#26861)

commit cb64471
Author: Levi Pesin <35454228+LeviPesin@users.noreply.github.com>
Date:   Thu Sep 28 04:55:58 2023 +0930

    Nodes: Fix `addLightNode` in case of anonymizing classes (#26858)

    * Fix `addLightNode` in case of anonymizing classes

    * Address comment

    * Update AmbientLightNode.js

    * Update DirectionalLightNode.js

    * Update HemisphereLightNode.js

    * Update IESSpotLightNode.js

    * Update PointLightNode.js

    * Update SpotLightNode.js

    * Fix

commit 688b749
Author: sunag <sunagbrasil@gmail.com>
Date:   Wed Sep 27 13:42:29 2023 -0300

    WebGLNodeBuilder: Fix Multi-Material (#26841)

commit bf7a89e
Author: mrdoob <info@mrdoob.com>
Date:   Wed Sep 27 20:33:38 2023 +0900

    Fixed DeepScan issue.

commit 285c9b6
Author: YX <978345079@qq.com>
Date:   Wed Sep 27 16:32:50 2023 +0800

    Update SpriteMaterial.html (#26855)

    Fixed incorrect Chinese translation.

commit 5c00457
Author: 郭斌勇 <guobinyong@qq.com>
Date:   Wed Sep 27 16:26:37 2023 +0800

    CurvePath: Use correct line type in `closePath()`. (#26850)

    * fix #26849

    * Update CurvePath.js

    ---------

    Co-authored-by: Michael Herzog <michael.herzog@human-interactive.org>

commit 083be57
Author: Shuhei Aoyama <mt.blue81@gmail.com>
Date:   Wed Sep 27 15:53:03 2023 +0900

    GLTFLoader: Fix to handle reject on afterRoot (#26852)

commit 2d1695e
Author: Levi Pesin <35454228+LeviPesin@users.noreply.github.com>
Date:   Wed Sep 27 04:57:29 2023 +0930

    Nodes: Fix `addNodeClass` and `addNodeMaterial` in case of renaming classes (#26846)

commit 6a5d6de
Author: sunag <sunagbrasil@gmail.com>
Date:   Tue Sep 26 16:13:03 2023 -0300

    StorageTexture: Adds support for other formats. (#26842)

    * TimeNode: Define `frameId` as integer

    * Renderer: Set `info` as public

    * StorageTexture: Adds support for other formats.

    * Update example to `temporal blur`

    * fix device in getFormat()

commit 9fe5ed2
Author: sunag <sunagbrasil@gmail.com>
Date:   Tue Sep 26 16:10:10 2023 -0300

    TSL: Fix include one function under another. (#26844)

    * TSL: Fix include one function under another.

    * Add include example

commit ca5c7cb
Author: sunag <sunagbrasil@gmail.com>
Date:   Tue Sep 26 16:09:42 2023 -0300

    Examples: Rename some WebGPU Compute examples (#26845)

    * webgpu_compute -> webgpu_compute_points

    * webgpu_audio_processing -> webgpu_compute_audio

commit 379038f
Author: sunag <sunagbrasil@gmail.com>
Date:   Tue Sep 26 01:27:04 2023 -0300

    WebGPURenderer: Fix .flipY example

commit 2ccc5bc
Author: sunag <sunagbrasil@gmail.com>
Date:   Mon Sep 25 23:54:10 2023 -0300

    Nodes: Rename `construct()` to `setup()` (#26840)

    * Nodes: Rename `construct()` to `setup()`

    * deprecated alert

commit e2f5911
Author: sunag <sunagbrasil@gmail.com>
Date:   Mon Sep 25 23:45:33 2023 -0300

    WebGPURenderer: GPU FlipY (#26818)

    * GPU FlipY

    * use tempTexture.destroy()

    * fix name

    * Rename to `WebGPUTexturePassUtils` and `_getPassUtils()`

commit 0f65abb
Author: sunag <sunagbrasil@gmail.com>
Date:   Mon Sep 25 22:51:02 2023 -0300

    TextureNode: Rename `.getTextureMatrix()` -> `.getTransformedUV()` (#26839)

commit 8d241a6
Author: Marco Fugaro <marco.fugaro@gmail.com>
Date:   Tue Sep 26 02:51:33 2023 +0200

    Examples: Remove import maps polyfill (#26836)

commit 1a67ba7
Author: sunag <sunagbrasil@gmail.com>
Date:   Mon Sep 25 18:25:00 2023 -0300

    RenderNodes: Fix `context.material` reference. (#26838)

commit 15e4656
Author: Sachin S <ssk4988@gmail.com>
Date:   Mon Sep 25 04:39:03 2023 -0400

    DragControls: Add `recursive` property.  (#26747)

    * add recursive property to DragControls

    * Update DragControls.js

    Clean up.

    ---------

    Co-authored-by: Michael Herzog <michael.herzog@human-interactive.org>

commit 43d68fc
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Mon Sep 25 10:38:50 2023 +0200

    Update github/codeql-action digest to 6a28655 (#26833)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

commit 10e8823
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Mon Sep 25 10:38:42 2023 +0200

    Update actions/checkout digest to 8ade135 (#26832)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

commit e857553
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Mon Sep 25 00:14:05 2023 +0000

    Update devDependencies (non-major) (#26834)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

commit 53c642e
Author: Michael Herzog <michael.herzog@human-interactive.org>
Date:   Sun Sep 24 11:28:27 2023 +0200

    Docs: Clean up. (#26831)

commit 53ee377
Author: Guilherme Avila <3927951+sciecode@users.noreply.github.com>
Date:   Sun Sep 24 06:22:08 2023 -0300

    EXRExporter: implements support for DataTexture export (#26810)

    * EXRExporter: DataTexture support

    Signed-off-by: Guilherme Avila <3927951+sciecode@users.noreply.github.com>

    * EXRExporter: update API & docs

    Signed-off-by: Guilherme Avila <3927951+sciecode@users.noreply.github.com>

    * Examples: add misc_exporter_exr

    Signed-off-by: Guilherme Avila <3927951+sciecode@users.noreply.github.com>

    * fix MIME-type

    Signed-off-by: Guilherme Avila <3927951+sciecode@users.noreply.github.com>

    * update DataTexture usage example

    Signed-off-by: Guilherme Avila <3927951+sciecode@users.noreply.github.com>

    * update screenshot

    Signed-off-by: Guilherme Avila <3927951+sciecode@users.noreply.github.com>

    ---------

    Signed-off-by: Guilherme Avila <3927951+sciecode@users.noreply.github.com>

commit c3a746a
Author: Isaac Mason <isaac@isaacmason.com>
Date:   Sun Sep 24 18:30:05 2023 +1000

    docs: add recast-navigation-js to libraries and plugins page (#26828)

commit 89e698f
Author: Mugen87 <michael.herzog@human-interactive.org>
Date:   Sat Sep 23 19:39:04 2023 +0200

    Updated builds.

commit 27f0400
Author: 林炳权 <695601626@qq.com>
Date:   Sun Sep 24 01:32:21 2023 +0800

    RenderTarget: Clean up. (#26775)

    * RenderTarget: Clean up.

    * use `Object.assign()`

    * remove duplicate code

commit 72d0d3c
Author: Joe Pea <trusktr@gmail.com>
Date:   Sat Sep 23 10:29:01 2023 -0700

    Update Libraries-and-Plugins.html (#26819)

    * Update Libraries-and-Plugins.html

    Add Lume, add a few descriptions, and separate open source wrappers/frameworks from closed source wrappers/frameworks.

    * Update Libraries-and-Plugins.html

    * Update Libraries-and-Plugins.html

commit 9d2d7eb
Author: sunag <sunagbrasil@gmail.com>
Date:   Sat Sep 23 01:16:29 2023 -0300

    TSL: Introduce ShaderCallNode & `tslFn` improvements (#26824)

    * Add ShaderCallNode

    * cleanup

    * Use tslFn as default

commit 45505ed
Author: sunag <sunagbrasil@gmail.com>
Date:   Fri Sep 22 16:58:55 2023 -0300

    TSL: SetNode (#26785)

    * Add SetNode

    * Use viewProj.setZ()

    * cleanup

commit aa7bec9
Author: aardgoose <angus.sawyer@gmail.com>
Date:   Fri Sep 22 20:47:46 2023 +0100

    Nodes: consume labels() when used, to prevent duplicate uniform names. (#26822)

    Co-authored-by: aardgoose <angus.sawyer@email.com>

commit 5bab962
Author: aardgoose <angus.sawyer@gmail.com>
Date:   Fri Sep 22 17:38:55 2023 +0100

    WebGPURenderer: Support textureCompare() operations in WebGL backend (#26823)

    Co-authored-by: aardgoose <angus.sawyer@email.com>

commit ac901f1
Author: Mugen87 <michael.herzog@human-interactive.org>
Date:   Fri Sep 22 12:31:27 2023 +0200

    Updated builds.

commit 2ac424c
Author: aardgoose <angus.sawyer@gmail.com>
Date:   Fri Sep 22 05:40:45 2023 +0100

    WebGPURenderer: Support multiple render targets (#26808)

    * less var access (#26817)

    actually use the framebuffer we have cached

    update examples

    update screenshots

    MRT

    allow example to run

    fix WGSL code

    address comments

    update screenshot

    * remove unused var

    * cleanup

    ---------

    Co-authored-by: ycw <ycw7788@gmail.com>
    Co-authored-by: aardgoose <angus.sawyer@email.com>
    Co-authored-by: sunag <sunagbrasil@gmail.com>

commit 309e5f6
Author: ycw <ycw7788@gmail.com>
Date:   Thu Sep 21 20:35:27 2023 +0800

    less var access (#26817)

commit c1bf227
Author: ycw <ycw7788@gmail.com>
Date:   Thu Sep 21 16:14:29 2023 +0800

    AnimationUtils: Remove `arraySlice()`. (#26756)

    * use default

    * exclusive

    * rm arraySlice

    * rm test, rm docs

commit ef417f0
Author: aardgoose <angus.sawyer@gmail.com>
Date:   Wed Sep 20 17:33:28 2023 +0100

    WebGPURenderer: Basic render to texture support for WebGL backend (#26801)

    * Support texture backed render targets

    * actually use the framebuffer we have cached

    * update examples

    * update screenshots

    ---------

    Co-authored-by: aardgoose <angus.sawyer@email.com>

commit bc69abb
Author: Mugen87 <michael.herzog@human-interactive.org>
Date:   Wed Sep 20 15:56:06 2023 +0200

    Updated builds.

commit 7bf83b8
Author: Michael Herzog <michael.herzog@human-interactive.org>
Date:   Wed Sep 20 15:55:19 2023 +0200

    Shaders: Remove struct GeometricContext to improve Adreno GPU support. (#26805)

commit 32cf0d1
Author: ycw <ycw7788@gmail.com>
Date:   Wed Sep 20 17:22:22 2023 +0800

    cleanup (#26803)

commit 85f9f28
Author: sunag <sunagbrasil@gmail.com>
Date:   Tue Sep 19 18:25:56 2023 -0300

    WebGPURenderer: CCW FrontFace as default (#26807)

commit cf340b9
Author: sunag <sunagbrasil@gmail.com>
Date:   Tue Sep 19 18:25:25 2023 -0300

    TSL: Fix `.negate()` (#26804)

    * Fix dFdy().negate()

    * Fix .negate()

commit 1e673db
Author: sunag <sunagbrasil@gmail.com>
Date:   Mon Sep 18 16:39:52 2023 -0300

    Updated screenshot of the `webgpu_lights_ies_spotlight` (#26800)

commit 75b9699
Author: Tim Weißenfels <10491533+tim-we@users.noreply.github.com>
Date:   Mon Sep 18 20:01:06 2023 +0200

    Update documentation of Object3D#userData (#26799)

    * Update userData description in Object3D.html

    Updated the documentation to make clear what the default value is (otherwise one could assume it might be null or undefined).

    * Update Texture.html

    * Update Material.html

    * Update BufferGeometry.html

commit 0b0a7d7
Author: StrandedKitty <kittyhawk3011@gmail.com>
Date:   Mon Sep 18 19:45:10 2023 +0200

    Use cameraPosition uniform instead of world origin (#26766)

commit 217e20e
Author: Mugen87 <michael.herzog@human-interactive.org>
Date:   Mon Sep 18 19:43:42 2023 +0200

    Updated builds.

commit 1454e7a
Author: ycw <ycw7788@gmail.com>
Date:   Tue Sep 19 01:42:56 2023 +0800

    ObjectLoader: Refector (de)serialization of Fog and FogExp2 (#26793)

    * marshal fog/fogexp2 .name

    * use object literal

commit 1a7b805
Author: ycw <ycw7788@gmail.com>
Date:   Tue Sep 19 01:41:38 2023 +0800

    re order (#26780)

commit f4488d8
Author: Michael Herzog <michael.herzog@human-interactive.org>
Date:   Mon Sep 18 19:41:00 2023 +0200

    LightProbeGenerator: Add support for half float render targets. (#26773)

commit e74c655
Author: aardgoose <angus.sawyer@gmail.com>
Date:   Mon Sep 18 18:21:40 2023 +0100

    WebGPURenderer: Texture fixes for WebGL backend (#26797)

    * misc texture fixes

    handle VideoTexture.
    handle depth textures in GLSL shaders (depth in x component in returned
    vec4())
    map WGSL textureDimensions to GLSL textureSize()

    Examples fixed

    lights / ies /spotlights
    video / panorama
    material / video (partial)

    * remove surplus entry

    ---------

    Co-authored-by: aardgoose <angus.sawyer@email.com>

commit 18febaf
Author: sunag <sunagbrasil@gmail.com>
Date:   Mon Sep 18 07:13:40 2023 -0300

    WebGPURenderer, CubeCamera: Add `.activeMipmapLevel` (#26770)

    * CubeCamera: Add .activeMipmapLevel

    * Use CubeCamera

    * WebGPURenderer:  Add .activeMipmapLevel for set .setRenderTarget()

commit 16eaae5
Author: ycw <ycw7788@gmail.com>
Date:   Mon Sep 18 16:27:01 2023 +0800

    cleanup (#26791)

commit 633d804
Author: Michael Herzog <michael.herzog@human-interactive.org>
Date:   Mon Sep 18 10:22:45 2023 +0200

    Editor: Fix `CapsuleGeometry` parameter. (#26794)

commit fffeb0c
Author: ycw <ycw7788@gmail.com>
Date:   Mon Sep 18 15:32:50 2023 +0800

    fmt code block (#26792)

commit b6150e4
Author: WestLangley <WestLangley@users.noreply.github.com>
Date:   Mon Sep 18 01:56:38 2023 -0400

    Simplify equation (#26787)

commit 93c3589
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Sun Sep 17 22:02:02 2023 +0000

    Update devDependencies (non-major) (#26783)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

commit 4ed78c7
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Sun Sep 17 20:10:40 2023 +0200

    Update github/codeql-action digest to 04daf01 (#26782)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

commit 2c8cfdf
Author: sunag <sunagbrasil@gmail.com>
Date:   Sun Sep 17 00:10:52 2023 -0300

    WebGPURenderer: StorageTexture (#26769)

    * Add StorageTexture

    * add `webgpu_compute_texture_pingpong` example

commit 80ba01c
Author: aardgoose <angus.sawyer@gmail.com>
Date:   Sun Sep 17 03:19:42 2023 +0100

    negate dpdy only (#26776)

    Co-authored-by: aardgoose <angus.sawyer@email.com>

commit 99d705f
Author: 林炳权 <695601626@qq.com>
Date:   Sun Sep 17 00:52:53 2023 +0800

    Sprite: Clean up. (#26774)

commit c6cfa6a
Author: Michael Herzog <michael.herzog@human-interactive.org>
Date:   Sat Sep 16 10:46:13 2023 +0200

    CubeCamera: Add comment to clarify mipmap generation. (#26772)

commit 51462bf
Author: Mugen87 <michael.herzog@human-interactive.org>
Date:   Sat Sep 16 09:59:49 2023 +0200

    Updated builds.

commit b17a561
Author: Michael Herzog <michael.herzog@human-interactive.org>
Date:   Sat Sep 16 09:58:24 2023 +0200

    WebGLTextures: Increase default precision for depth buffers with WebGL 2. (#26764)

    * WebGLTextures: Increase default precision for depth buffers with WebGL 2.

    * Examples: Update screenshots.

    * Examples: Update screenshots.

    * Add webgl2_multisampled_renderbuffers to exception list.

commit 8193d58
Author: Mugen87 <michael.herzog@human-interactive.org>
Date:   Sat Sep 16 09:54:34 2023 +0200

    Updated builds.

commit 5238fae
Author: Michael Herzog <michael.herzog@human-interactive.org>
Date:   Sat Sep 16 09:53:35 2023 +0200

    WebGLRenderer: Introduce USE_LIGHT_PROBES define. (#26768)

    * WebGLRenderer: Introduce USE_LIGHT_PROBES define.

    * Examples: Make use of USE_LIGHT_PROBES.

    * Add light probe define to vertex shader

    ---------

    Co-authored-by: WestLangley <WestLangley@users.noreply.github.com>

commit fbc28ae
Author: 林炳权 <695601626@qq.com>
Date:   Fri Sep 15 16:22:16 2023 +0800

    src: Clean up. (#26763)

commit 18ae441
Author: Casey Primozic <casey@cprimozic.net>
Date:   Fri Sep 15 00:55:35 2023 -0700

    Docs: Add some missing options to `MeshPhysicalMaterial` demo. (#26753)

    * Add some missing options to `MeshPhysicalMaterial` demo

     * Add GUI options for some missing properties including sheen, ior, iridescence, and others to the material browser embedded on the docs pages for materials

    * Use real default `sheenColor in material browser

    * Re-disable dirlights in `MeshPhysicalMaterial` material browser

    * Update docs to correct the default `sheenColor`

     * Docs stated it was 0xfffff, but it's actually 0x000000
     * Fixes #26757

    * Add back deleted comment

commit 30164c9
Author: ycw <ycw7788@gmail.com>
Date:   Fri Sep 15 09:58:20 2023 +0800

    Camera: Simplify `getWorldDirection()`. (#26743)

    * refactor getWorldDirection

    * revert object3d

* update screenshot

---------

Co-authored-by: aardgoose <angus.sawyer@email.com>
  • Loading branch information
aardgoose and aardgoose committed Sep 29, 2023
1 parent 27ba7d3 commit eb54b90
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 22 deletions.
81 changes: 69 additions & 12 deletions examples/jsm/renderers/webgl/WebGLBackend.js
Expand Up @@ -214,9 +214,24 @@ class WebGLBackend extends Backend {

}

clear( /*renderContext, color, depth, stencil*/ ) {
clear( renderContext, color, depth, stencil ) {

console.warn( 'Abstract class.' );
const { gl } = this;

//

let clear = 0;

if ( color ) clear |= gl.COLOR_BUFFER_BIT;
if ( depth ) clear |= gl.DEPTH_BUFFER_BIT;
if ( stencil ) clear |= gl.STENCIL_BUFFER_BIT;

const clearColor = renderContext.clearColorValue;

if ( clear === 0 ) return;

gl.clearColor( clearColor.x, clearColor.y, clearColor.z, clearColor.a );
gl.clear( clear );

}

Expand Down Expand Up @@ -316,21 +331,30 @@ class WebGLBackend extends Backend {

let mode;
if ( object.isPoints ) mode = gl.POINTS;
else if ( object.isLine ) mode = gl.LINES;
else if ( object.isLine ) mode = gl.LINE_STRIP;
else if ( object.isLineLoop ) mode = gl.LINE_LOOP;
else if ( object.isLineSegments ) mode = gl.LINES;
else mode = gl.TRIANGLES;

//

const instanceCount = this.getInstanceCount( renderObject );

if ( index !== null ) {

const indexData = this.get( index );

const indexCount = ( drawRange.count !== Infinity ) ? drawRange.count : index.count;

gl.drawElements( mode, index.count, indexData.type, firstVertex );
if ( instanceCount > 1 ) {

gl.drawElementsInstanced( mode, index.count, indexData.type, firstVertex, instanceCount );

} else {

gl.drawElements( mode, index.count, indexData.type, firstVertex );

}


info.update( object, indexCount, 1 );

Expand All @@ -339,8 +363,16 @@ class WebGLBackend extends Backend {
const positionAttribute = geometry.attributes.position;
const vertexCount = ( drawRange.count !== Infinity ) ? drawRange.count : positionAttribute.count;

if ( instanceCount > 1 ) {

gl.drawArraysInstanced( mode, 0, vertexCount, instanceCount );

} else {

gl.drawArrays( mode, 0, vertexCount );

}

gl.drawArrays( mode, 0, vertexCount );
//gl.drawArrays( mode, vertexCount, gl.UNSIGNED_SHORT, firstVertex );

info.update( object, vertexCount, 1 );
Expand Down Expand Up @@ -613,7 +645,7 @@ class WebGLBackend extends Backend {
const vaoGPU = gl.createVertexArray();

const index = renderObject.getIndex();
const vertexBuffers = renderObject.getVertexBuffers();
const attributes = renderObject.getAttributes();

gl.bindVertexArray( vaoGPU );

Expand All @@ -625,14 +657,39 @@ class WebGLBackend extends Backend {

}

for ( let i = 0; i < vertexBuffers.length; i ++ ) {
for ( let i = 0; i < attributes.length; i ++ ) {

const attribute = vertexBuffers[ i ];
const attribute = attributes[ i ];
const attributeData = this.get( attribute );

gl.bindBuffer( gl.ARRAY_BUFFER, attributeData.bufferGPU );
gl.enableVertexAttribArray( i );
gl.vertexAttribPointer( i, attribute.itemSize, attributeData.type, false, 0, 0 );

let stride, offset;

if ( attribute.isInterleavedBufferAttribute === true ) {

stride = attribute.data.stride * attributeData.bytesPerElement;
offset = attribute.offset * attributeData.bytesPerElement;

} else {

stride = 0;
offset = 0;

}

gl.vertexAttribPointer( i, attribute.itemSize, attributeData.type, false, stride, offset );

if ( attribute.isInstancedBufferAttribute && ! attribute.isInterleavedBufferAttribute ) {

gl.vertexAttribDivisor( i, attribute.meshPerAttribute );

} else if ( attribute.isInterleavedBufferAttribute && attribute.data.isInstancedInterleavedBuffer ) {

gl.vertexAttribDivisor( i, attribute.data.meshPerAttribute );

}

}

Expand Down Expand Up @@ -739,9 +796,9 @@ class WebGLBackend extends Backend {

}

updateAttribute( /*attribute*/ ) {
updateAttribute( attribute ) {

console.warn( 'Abstract class.' );
this.attributeUtils.updateAttribute( attribute );

}

Expand Down
13 changes: 12 additions & 1 deletion examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js
Expand Up @@ -14,6 +14,10 @@ const precisionLib = {
high: 'highp'
};

const supports = {
instance: true
};

class GLSLNodeBuilder extends NodeBuilder {

constructor( object, renderer, scene = null ) {
Expand Down Expand Up @@ -176,7 +180,7 @@ class GLSLNodeBuilder extends NodeBuilder {

if ( shaderStage === 'vertex' ) {

const attributes = this.attributes;
const attributes = this.getAttributesArray();

let location = 0;

Expand Down Expand Up @@ -285,6 +289,13 @@ class GLSLNodeBuilder extends NodeBuilder {

}

isAvailable( name ) {

return supports[ name ] === true;

}


isFlipY() {

return true;
Expand Down
42 changes: 36 additions & 6 deletions examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js
Expand Up @@ -14,11 +14,24 @@ class WebGLAttributeUtils {
const array = attribute.array;
const usage = attribute.usage || gl.STATIC_DRAW;

const bufferGPU = gl.createBuffer();
const bufferAttribute = attribute.isInterleavedBufferAttribute ? attribute.data : attribute;
const bufferData = backend.get( bufferAttribute );

gl.bindBuffer( bufferType, bufferGPU );
gl.bufferData( bufferType, array, usage );
gl.bindBuffer( bufferType, null );
let bufferGPU = bufferData.bufferGPU;

if ( bufferGPU === undefined ) {

bufferGPU = gl.createBuffer();

gl.bindBuffer( bufferType, bufferGPU );
gl.bufferData( bufferType, array, usage );
gl.bindBuffer( bufferType, null );

bufferData.bufferGPU = bufferGPU;
bufferData.bufferType = bufferType;
bufferData.version = bufferAttribute.version;

}

//attribute.onUploadCallback();

Expand Down Expand Up @@ -73,12 +86,29 @@ class WebGLAttributeUtils {
backend.set( attribute, {
bufferGPU,
type,
bytesPerElement: array.BYTES_PER_ELEMENT,
version: attribute.version
bytesPerElement: array.BYTES_PER_ELEMENT
} );

}

updateAttribute( attribute ) {

const backend = this.backend;
const { gl } = backend;

const array = attribute.array;
const bufferAttribute = attribute.isInterleavedBufferAttribute ? attribute.data : attribute;
const bufferData = backend.get( bufferAttribute );
const bufferType = bufferData.bufferType;

gl.bindBuffer( bufferType, bufferData.bufferGPU );
gl.bufferSubData( bufferType, 0, array );
gl.bindBuffer( bufferType, null );

bufferData.version = bufferAttribute.version;

}

}

export default WebGLAttributeUtils;
Binary file modified examples/screenshots/webgpu_lines_fat.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions examples/webgpu_lines_fat.html
Expand Up @@ -28,6 +28,8 @@
import * as THREE from 'three';

import WebGPU from 'three/addons/capabilities/WebGPU.js';
import WebGL from 'three/addons/capabilities/WebGL.js';

import WebGPURenderer from 'three/addons/renderers/webgpu/WebGPURenderer.js';

import Stats from 'three/addons/libs/stats.module.js';
Expand All @@ -54,11 +56,11 @@

function init() {

if ( WebGPU.isAvailable() === false ) {
if ( WebGPU.isAvailable() === false && WebGL.isWebGL2Available() === false ) {

document.body.appendChild( WebGPU.getErrorMessage() );

throw new Error( 'No WebGPU support' );
throw new Error( 'No WebGPU or WebGL2 support' );

}

Expand Down
1 change: 0 additions & 1 deletion test/e2e/puppeteer.js
Expand Up @@ -117,7 +117,6 @@ const exceptionList = [
'webgpu_compute_texture_pingpong',
'webgpu_cubemap_dynamic',
'webgpu_instance_mesh',
'webgpu_lines_fat',
'webgpu_loader_gltf',
'webgpu_loader_gltf_compressed',
'webgpu_loader_gltf_iridescence',
Expand Down

0 comments on commit eb54b90

Please sign in to comment.