Performance of Bloom Effect in Three.js

The frame rate ranges from 50 to 60fps without the bloom effect being applied.

renderer.render( scene, camera );

However, once the bloom effect is added, the frame rate drops significantly to just 10fps.

camera.layers.set( BLOOM_SCENE );
bloomComposer.render();
camera.layers.set( ENTIRE_SCENE );
finalComposer.render();   

Is there a way to resolve this issue and improve performance? Check out the demo link provided below for reference. https://codepen.io/anson-chan/pen/QXeKqm?editors=1010

Answer №1

It appears that there are several challenges to address in this scenario.

One major issue is the large number of cubes present in the scene, each with its own material and draw call. To ensure optimal performance, it's recommended to keep the number of draw calls around 500 and limit the polygons to approximately 1.5 million to avoid being "draw call bound". Implementing techniques such as hardware instancing or utilizing libraries like THREE.BAS for cube instancing can help optimize rendering efficiency.

(https://github.com/zadvorsky/three.bas)

()

Additionally, the resize handler may need adjustment to resize to the canvas size rather than the window bounds. Ensure that render passes are resized accordingly within the code to reflect the actual canvas size for accurate display rendering.

Consider using

renderer.resize(renderer.domElement.width, renderer.domElement.height, false)
to control canvas resizing through CSS rules and set appropriate sizes for effects passes and the effectsComposer. By setting the 'false' parameter, you can prevent unintended resizes triggered by THREE.js manipulating the canvas style dimensions based on window changes.

Furthermore, performing blur/bloom effects can be resource-intensive as it involves scaling down the framebuffer multiple times to achieve the desired effect. This challenge is exacerbated by the aforementioned sizing discrepancies.

If running on a retina display with devicePixelRatio greater than 1, adjust settings accordingly to mitigate additional display sizing complexities caused by higher pixel ratios.

These issues interact and impact overall GPU performance, underscoring the importance of strategic management and workload optimization to maximize efficiency.

We hope these insights prove helpful in addressing the encountered obstacles.

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

Sharing data from AJAX calls in Vue using vue-resource

After using Vue resource, I'm attempting to create an AJAX call that is based on the data received from a prior AJAX call. I have successfully bound the data fetched from /me to the userDetails prop. However, when trying to pass userDetails.id into t ...

Choose the option from the jQuery dropdown list based on the displayed text instead of the value

In continuation of my previous question on jQuery getting values from multiple selects together, I am working with a select list like this: <select name="access" class="change" id="staff_off" runat="server"> <option value="8192">Off< ...

Encountering a ValueError when attempting to validate form fields with Django and JavaScript

I encountered an error while trying to validate a field using Javascript and Django. Error: ValueError at /insert/ invalid literal for int() with base 10: '' Request Method: POST Request URL: http://127.0.0.1:8000/insert/ Django Version: ...

Combining array objects in Node.js

Received an array in the request body: [ { "month": "JUL", "year": "2018" }, { "month": "JAN", "year": "2018" }, { "month": "MAR", "year": "2018" } ] The input consists of two parameters (month:enum and ye ...

Experience the innovative feature of React Splide Carousel where a peek of the next image is shown until you reach

My current challenge arises when I reach the last slide in the slider. I am trying to prevent it from looping and instead stop with no extra space or any other images peeking out. To address this, I have utilized the padding: '5%' option, which ...

The properties and methods of TypeScript classes that are exported do not exist (error code TS 2339)

I have a module containing various helper classes, each defined in their own files such as controller.ts and stateService.ts. To export all of them, I understand that creating an index.ts file that imports and exports them all serves as the interface to th ...

Encountering a problem while attempting to incorporate SQLite into a Node.js environment

I've encountered issues while attempting to import SQLite into node. Here is my import statement: import * as sqlite from './sqlite'; But unfortunately, I am receiving the following error message: node:internal/process/esm_loader:74 int ...

Encountered the issue: "Received the error message 'MongooseServerSelectionError: Server selection timed out after 30000 ms.'"

I encountered the following error: MongooseServerSelectionError: Server selection timed out after 30000 ms while working with MongoDB Atlas. I attempted changing the useUnifiedTopology setting to false, which prevented my application from crashing. However ...

Passing a method as a parameter type

As I delve into learning JavaScript from Objective-C, I find myself pondering whether it is possible to have a method with parameter types in Objective-C. Let's take the example of the findIndex() JavaScript function that identifies and returns the in ...

How to run 'npm' scripts externally in package.json on Windows?

In the world of development, running arbitrary commands using npm run is a common practice. This involves adding a scripts hash to your package.json: "scripts": { "build-js": "browserify browser/main.js | uglifyjs -mc > static/bundle.js" } To exec ...

Sending PHP variable to xmlhttp.responseText

I haven't come across this specific situation before, so I thought I would ask for help. My JavaScript code is using AJAX to call a PHP file, run the script in it, and then return a concatenated PHP variable via xmlhttp.responseText to alert that resp ...

What is the best way to convert Arabic language HTML into a PDF document on the client side?

Utilizing jsPDF and vue js, I successfully implemented a feature to export PDFs. However, I encountered an issue with Arabic characters not displaying properly. Can anyone provide assistance in resolving this problem? ...

What is the best way to adjust the size of an image as I navigate down a webpage?

I've been working on designing a navigation bar for a website, but I'm running into some issues. My goal is to have the logo shrink as the user scrolls down the site. I've experimented with webkit animations and various javascript/jQuery fun ...

Quickest method for deriving a boolean value from multiple boolean inputs

Within a document, the keys isOccupied and vacant are being destructured. const { isOccupied, vacant } = doc || {}; boolDetermination = (isOccupied, vacant) => { if (isOccupied && isOccupied === vacant) { < --- Return isOccupied value ...

The navigation/hamburger icon vanishes after a click on a page link

I'm in the process of creating a single-page scrolling website. However, I am encountering an issue with the navigation bar. Specifically, when I click on a page link from the nav bar at screen widths less than 780px (when the hamburger icon appears), ...

Unable to confirm form validation with Vue

Recently, I started working with Vue and encountered a problem while running the code below. The error message "ReferenceError: $vAddress is not defined" keeps popping up. Despite my efforts to search for solutions online, I couldn't find any that add ...

Creating a Pyraminx using triangular shapes

Attempting to create a Pyraminx, a tetrahedron made up of multiple triangles, through my coding. The approach I am taking may not be very precise. You can find my code here: https://codepen.io/jeffprod/pen/XWbBZLN. The issue I'm facing is manually in ...

What is the process for recording a video?

After researching extensively, I am eager to use a plugin that combines jQuery and flash to record a video using the system's Webcam. I came across scriptcam, but unfortunately, I encountered an issue where the plugin hangs on document load and the li ...

When anchor is set programmatically, the focus outline is not displayed

I am currently facing an issue with my application where I am programmatically setting focus on elements in certain scenarios. While it generally works well, I have noticed that when I set the focus on an anchor element using $("#link1").focus(), the focus ...

How can I invalidate the Authorization header in a request?

After delving into the Basic Authentication algorithm and successfully implementing it, I've encountered an issue. The Authorization header in the request seems to never expire, allowing the client to continuously access protected content without re-a ...