Rendering to a renderTarget with outputEncoding causes shader compilation on every frame
See original GitHub issueDescription 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:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Closing for now.
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.