question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PMREM envMap bad performance

See original GitHub issue

Recently I’ve been migrating my app from normal cubemap to PMREM and noticing 3-5x drop in performance (it was 50fps, but now is just 11fps using PMREM).

After looking around in the source code to find out the difference, I see in fragment shader, function textureCubeUV has 1 to 2 calls to bilinearCubeUV, each call will access the envMap 4 times: https://github.com/mrdoob/three.js/blob/c1ea11e4ff7aaa41334cd8d2154a5cd55b94b641/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js#L118 So each pixel will access envMap texture 4 or 8 times per frame? I guess this is where the performance drop come from.

Could the PMREM code can be improved somehow to achieve better performance?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
elalishcommented, Jun 1, 2020

@Ben-Mack 100s of different materials? The draw call overhead alone could be a bigger problem. Is there no way to combine them with texture atlasing? In any case, if you can share an example we can test with/without PMREM then we’ll have a much better chance of improving the performance.

2reactions
WestLangleycommented, Aug 30, 2021

The renderer internally converts environment maps automatically to PMREMs

…except for CubeCamera.renderTarget. See #22236.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get higher resolution environment map reflections
Hi all, does anyone know how to get higher resolution reflections? Thanks! I get very pixelated reflections in a smooth metallic material, ...
Read more >
AMD Cubemapgen for physically based rendering
A PMREM is an environment map (in our case a cubemap) where each mipmap ... due to their size (and cubemapgen badly export...
Read more >
How can i render the PMREM environment map when copying ...
I'd like to know if there is a straightforward way to render the PMREM cubemap, in this particular material template and have it...
Read more >
Environment-based lighting and reflections in three.js and ...
I used a relatively low resolution (640x480) to prioritize performance. ... PMREM stands for Prefiltered Mipmap Radiance Environment Map, ...
Read more >
[Solved]-How can i render the PMREM environment map when ...
Coding example for the question How can i render the PMREM environment map when copying MeshStandardMaterial into a ShaderMaterial-three.js.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found