What is the total number of webgl.draw calls generated by Three.js when rendering a specific quantity of geometries, materials, and meshes?

Can you help me determine the total drawArrays/drawElements calls required by THREE.renderer.render(scene, camera)?

I speculate one call per geometry, incorporating attributes for materials/mesh properties. Is my assumption accurate or am I overlooking certain aspects?

Additionally, would implementing BufferGeometry etc have an impact on this calculation?

Answer №1

https://i.sstatic.net/uE64Q.png

Using rstats has been a game-changer for me; it provides vital information like framerate, memory usage, render details, and webgl drawcall.

This tool has greatly improved the performance of my threejs projects.

I want to give credit to Jaume Sanchez for his amazing work.

If you're interested, here is a tutorial:

Answer №2

In accordance with WestLangley's suggestion, it would be advisable to explore the THREE.WebglRenderer for information on renderer.info and review the corresponding logic.

The process of drawcalls varies slightly. For instance, if you have a single geometry like cubeGeometry, one material such as cubeMaterialRed, and five cube nodes labeled [c1,c2...,c5], there will be five draw calls. The binding of geometry would occur once in three.js, followed by five consecutive draw calls using the same shader and mostly similar uniforms (with only changes to position/rotation/scale matrix, while the color red might be bound just once).

If there are five distinct materials [cMatRed, cMatBlue... cMatPink], each with the same geometry, then five draw calls will be necessary but with varying uniform settings for the color of the material.

In the scenario of five different geometries present in five separate nodes, the binding of geometry must happen prior to each draw call.

To streamline this process, instancing can be utilized where applicable. In the second illustration, the geometry would be bound for instancing once, along with the configuration of attributes containing position/rotation/scale data and colors. Subsequently, a single draw call would render 5 geometries positioned and colored as specified in the attributes.

It is worth noting that Three.js does not currently handle batching or optimization of this nature automatically, so manual instancing is required.

Ultimately, the relationship between the number of nodes containing geometry and draw calls is typically a direct 1:1 ratio. For example, Object3D->Object3D->Mesh structure may consist of three nodes resulting in just one draw call.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Error message from BitBucket pipeline indicates that the npm command was not found

Upon deploying code to my server via the Bit Bucket scp pipeline, I encountered an issue with another pipeline meant to install node modules and start the node server. The pipeline returned a failed status and displayed the following error: ./server-run.s ...

Unable to add items to the global JavaScript array variable

My goal is to populate a global array variable within my ready function, but when I attempt to access the data later on, the array appears to be empty. This is how my ready function looks: var counter = 0; var services = []; var names = [] va ...

Change the data-theme using jQuery Mobile once the page has finished loading

I am facing an issue with my buttons in a control group that represent on/off functionality. Every time I click on one of the buttons to switch their themes, the theme reverts back once I move the mouse away from the button. How can I make sure that the ...

Line 16 is encountering issues with statically analysing the 'require(...)' function

Currently, I am working with nextjs and encountering an problem when trying to import 'markdown-toc'. The issue arises while importing markdown-toc in my Next.js project specifically in the file /pages/index.js. import toc from "markdown-to ...

Displaying properties of a class in Typescript using a default getter: Simplified guide

Here is an interface and a class that I am working with: export interface ISample { propA: string; propB: string; } export class Sample { private props = {} as ISample; public get propA(): string { return this.props.propA; } public se ...

Retrieve the final ID of a dynamic div

Unable to find a solution, I am attempting to retrieve the ID of the most recently created div on the page. The code I have been using with .last() doesn't seem to be functioning correctly. My syntax may be incorrect, as I can't seem to extract a ...

Ways to retrieve POST data in express js

When accessing a website in the browser, I use: xmlHttp.open("POST", "/", true); // true for asynchronous xmlHttp.send("data"); on the client side browser. For node js application, I'm using: app.post("/" ...

Enhancing the Performance of Asp.net MVC SPA App through Server-Side Rendering

We are aiming to optimize the performance of our single page application built in asp.net mvc. The current framework consists of: Server-side Asp.net mvc communicating with an SQL Database Client-side SPA developed using JS/Html5 + requireJS and KendoUI ...

Click the link to copy it and then paste the hyperlink

I am facing an issue with copying and pasting file names as hyperlinks. I have checkboxes next to multiple files and a share button. When I check the boxes and click on the share button, I want to copy the download URLs for those files. Although I can succ ...

Get the object method within an AJAX success callback

Is there a way for me to access the FileUploader.prototype.saveImage() method in my code? Here is an example snippet: function FileUploader(object) { this.checkInputs(object); if (this.isImageSelected()) { this.beforeInit(object); ...

"The occurrence of a `POST` error due to failed XHR loading can be attributed to Ajax

Attempting to execute a straightforward Ajax Request to transmit a JSON object from my Javascript file to my Python file in Django has presented a challenge. Occasionally, an error message XHR failed loading: POST pops up while executing it in the manner b ...

ThreeJS - Module displaying surface texture in a visual environment devoid of illumination

When it comes to rendering my scene, I work with intricate objects that boast a complex surface structure. Interestingly, I have made the deliberate choice to steer clear of using light within my scene. Currently, I rely on the MeshNormalMaterial to accura ...

Looking for a way to extract Regular Expressions from an IgGrid cell in Infragistics?

Is it possible to apply a regular expression to a igTextEditor within an igGrid Updating? I attempted to utilize the validate option, but it was unsuccessful. $("#schedulerTable").igGrid({ columns: $scope.schedulerColumns, widt ...

What is the best approach to transform a lengthy collection of 'watch' statements into a functioning solution using VueJS?

I am new to vueJS and need some help with optimizing my code. I have a long list of watch functions that are all essentially the same, but I'm not sure how to convert them into a more efficient and functional approach. These watch functions are all r ...

Format specific words or characters in a text input

In HTML, when I want to display strings in a Text Input or TextArea, I am looking for a way to have specific substrings render with a box around them. I envision these boxed substrings as being treated as a single entity, similar to how highlighting or tex ...

Passing a querystring value to a Vue.js component

I am encountering an issue with passing a value from a querystring to my Vue component. The querystring looks like this: https://someurl.com?q=test My component is structured as follows: Vue.component('externalrecipes', { props: ['results&a ...

The padding on the left and right sides does not seem to be functioning properly on the menu links

Whenever I hover over the links on my menu, underlines slide in and out. However, I am facing an issue where the padding I added to the left and right of the links is not displaying correctly. Here is a visual representation of what I am trying to achieve ...

Guide to transmitting webcam feed from server to servlet

I am trying to display the webcam connected to my server in a servlet. I have come across suggestions to use getUserMedia();, however, this only captures the user's video webcam feed and not the server's. Is there a way to achieve this? My servl ...

How Should One Properly Describe an Object with Multiple Dimensions?

PHP features multidimensional arrays, meaning an array that contains multiple arrays within it. When working with JavaScript, how does one refer to an object that holds multiple objects? Is it called a multidimensional object or is there a different termi ...

Mobile Devices and Local Storage: What You Need to Know for Safe and Efficient Use. Looking for advice from experienced developers

Need help with caching user input on an Angular11 + Firebase app? Let's discuss implementing a caching feature for a dynamic form section that can contain varying fields based on the use case. The goal is to save user input in LocalStorage to ensure ...