Skip to content

Commit

Permalink
Revert "WebGPURenderer: Support BatchMesh (#27937)"
Browse files Browse the repository at this point in the history
This reverts commit 7059b85.
  • Loading branch information
RenaudRohlinger authored Mar 19, 2024
1 parent 7059b85 commit 3bb457c
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 613 deletions.
1 change: 0 additions & 1 deletion examples/files.json
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@
"webgpu_multisampled_renderbuffers",
"webgpu_materials_texture_anisotropy",
"webgpu_storage_buffer",
"webgpu_mesh_batch",
"webgpu_instancing_morph"
],
"webaudio": [
Expand Down
1 change: 0 additions & 1 deletion examples/jsm/nodes/Nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export { default as CameraNode, cameraProjectionMatrix, cameraProjectionMatrixIn
export { default as VertexColorNode, vertexColor } from './accessors/VertexColorNode.js';
export { default as CubeTextureNode, cubeTexture } from './accessors/CubeTextureNode.js';
export { default as InstanceNode, instance } from './accessors/InstanceNode.js';
export { default as BatchNode, batch } from './accessors/BatchNode.js';
export { default as MaterialNode, materialAlphaTest, materialColor, materialShininess, materialEmissive, materialOpacity, materialSpecularColor, materialSpecularStrength, materialReflectivity, materialRoughness, materialMetalness, materialNormal, materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialRotation, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialLineScale, materialLineDashSize, materialLineGapSize, materialLineWidth, materialLineDashOffset, materialPointWidth } from './accessors/MaterialNode.js';
export { default as MaterialReferenceNode, materialReference } from './accessors/MaterialReferenceNode.js';
export { default as RendererReferenceNode, rendererReference } from './accessors/RendererReferenceNode.js';
Expand Down
84 changes: 0 additions & 84 deletions examples/jsm/nodes/accessors/BatchNode.js

This file was deleted.

8 changes: 0 additions & 8 deletions examples/jsm/nodes/materials/NodeMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { materialAlphaTest, materialColor, materialOpacity, materialEmissive, ma
import { modelViewProjection } from '../accessors/ModelViewProjectionNode.js';
import { transformedNormalView } from '../accessors/NormalNode.js';
import { instance } from '../accessors/InstanceNode.js';
import { batch } from '../accessors/BatchNode.js';

import { positionLocal, positionView } from '../accessors/PositionNode.js';
import { skinningReference } from '../accessors/SkinningNode.js';
import { morphReference } from '../accessors/MorphNode.js';
Expand Down Expand Up @@ -211,12 +209,6 @@ class NodeMaterial extends ShaderMaterial {

}

if ( object.isBatchedMesh ) {

batch( object ).append();

}

if ( this.positionNode !== null ) {

positionLocal.assign( this.positionNode );
Expand Down
1 change: 0 additions & 1 deletion examples/jsm/renderers/common/Animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class Animation {
dispose() {

self.cancelAnimationFrame( this.requestId );
this.requestId = null;

}

Expand Down
6 changes: 3 additions & 3 deletions examples/jsm/renderers/common/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ class Renderer {

if ( this._initialized === false ) await this.init();

await this._renderScene( scene, camera );
this._renderScene( scene, camera );

}

Expand All @@ -330,7 +330,7 @@ class Renderer {

}

async _renderScene( scene, camera ) {
_renderScene( scene, camera ) {

// preserve render tree

Expand Down Expand Up @@ -506,7 +506,7 @@ class Renderer {
sceneRef.onAfterRender( this, scene, camera, renderTarget );

//
await this.backend.resolveTimestampAsync( renderContext, 'render' );
this.backend.resolveTimestampAsync( renderContext, 'render' );

return renderContext;

Expand Down
56 changes: 26 additions & 30 deletions examples/jsm/renderers/webgl/WebGLBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import WebGLTextureUtils from './utils/WebGLTextureUtils.js';
import WebGLExtensions from './utils/WebGLExtensions.js';
import WebGLCapabilities from './utils/WebGLCapabilities.js';
import { GLFeatureName } from './utils/WebGLConstants.js';
import { WebGLBufferRenderer } from './WebGLBufferRenderer.js';

//

Expand Down Expand Up @@ -40,8 +39,6 @@ class WebGLBackend extends Backend {
this.capabilities = new WebGLCapabilities( this );
this.attributeUtils = new WebGLAttributeUtils( this );
this.textureUtils = new WebGLTextureUtils( this );
this.bufferRenderer = new WebGLBufferRenderer( this );

this.state = new WebGLState( this );
this.utils = new WebGLUtils( this );

Expand Down Expand Up @@ -647,69 +644,68 @@ class WebGLBackend extends Backend {

//

const renderer = this.bufferRenderer;

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

if ( material.wireframe === true ) {

state.setLineWidth( material.wireframeLinewidth * this.renderer.getPixelRatio() );
renderer.mode = gl.LINES;
mode = gl.LINES;

} else {

renderer.mode = gl.TRIANGLES;
mode = gl.TRIANGLES;

}

}

//


let count;

renderer.object = object;
const instanceCount = this.getInstanceCount( renderObject );

if ( index !== null ) {

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

renderer.index = index.count;
renderer.type = indexData.type;
if ( instanceCount > 1 ) {

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

} else {
} else {

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

renderer.index = 0;
}

const vertexCount = ( drawRange.count !== Infinity ) ? drawRange.count : geometry.attributes.position.count;
info.update( object, indexCount, 1 );

count = vertexCount;
} else {

}
const positionAttribute = geometry.attributes.position;
const vertexCount = ( drawRange.count !== Infinity ) ? drawRange.count : positionAttribute.count;

const instanceCount = this.getInstanceCount( renderObject );
if ( instanceCount > 1 ) {

if ( object.isBatchedMesh ) {
gl.drawArraysInstanced( mode, 0, vertexCount, instanceCount );

renderer.renderMultiDraw( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount );
} else {

} else if ( instanceCount > 1 ) {
gl.drawArrays( mode, 0, vertexCount );

renderer.renderInstances( firstVertex, count, instanceCount );
}

} else {
//gl.drawArrays( mode, vertexCount, gl.UNSIGNED_SHORT, firstVertex );

renderer.render( firstVertex, count );
info.update( object, vertexCount, 1 );

}

//

gl.bindVertexArray( null );
Expand Down
99 changes: 0 additions & 99 deletions examples/jsm/renderers/webgl/WebGLBufferRenderer.js

This file was deleted.

Binary file removed examples/screenshots/webgpu_mesh_batch.jpg
Binary file not shown.
Loading

0 comments on commit 3bb457c

Please sign in to comment.