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.

Rendering to a renderTarget with outputEncoding causes shader compilation on every frame

See original GitHub issue
Description of the problem

Setting a renderer’s outputEncoding and then rendering the scene to a WebGLRenderTarget causes shaders to be recompiled on every frame, reducing the framerate to ~5fps. I believe this bug was actually introduced in r110 with https://github.com/mrdoob/three.js/pull/17651 where outputEncoding was added to the WebGLProgram cache key. Oddly, setting the now deprecated gammaOutput option to true seems to fix the issue. Not sure why. You can also reproduce the bug by using the default renderer options and setting the renderTarget’s encoding option to sRGBEncoding.

Here’s a simplified reproduction: https://jsfiddle.net/brianpeiris/50eofuc6/

Three.js version
  • Dev
  • r112
  • r111
  • r110
  • r109
Browser
  • All of them
OS
  • All of them

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
Mugen87commented, Jan 11, 2020

Closing for now.

0reactions
Mugen87commented, Jan 10, 2020

Feel free to close this issue if this is the expected behavior.

I would say it is the expected behavior since we can only achieve the result with a new shader program. I guess it would require some refactoring in order to make the renderer more flexibel (so it can handle different encodings without a recompilation). However, I’m not sure how important that is. In your app it is definitely more correct to use a common encoding.

Read more comments on GitHub >

github_iconTop Results From Across the Web

WebGLRenderer#outputEncoding – three.js docs
Compiles all materials in the scene with the camera. This is useful to precompile shaders before the first rendering. # .copyFramebufferToTexture ( position...
Read more >
UE 5.1 : Movie Render Queue - Compiling Shaders every frame
Tried a local MRQ render, and it's compiling thousands of shaders before it even starts rendering the sequence. No idea what's causing this,...
Read more >
The Big List of three.js Tips and Tricks!
Lots of tips, tricks, and suggestions for best practices while building a high performance three.js application.
Read more >
https://unpkg.com/three@0.112.1/src/renderers/WebG...
renderers/webxr/WebXRManager'; import { RenderTarget } from '. ... checkShaderErrors: boolean; } /** * The WebGL renderer displays your beautifully crafted ...
Read more >
Exploiting Programmable Graphics Hardware for Interactive ...
Figure 2.1 depicts the classical rendering pipeline common to all graphics pro- cessors before the introduction of programmable shader units.
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