Performance problem with outputEncoding and reflection in linux

If I open example webgl_mirror.html and add renderer.outputEncoding = THREE.sRGBEncoding; around line 56, I get a massive performance drop. The animation is stuttering and really slow. If I remove the line the animation is smooth again.

I also observed this in the release version of r113.

I use linux, ubuntu 19.10 and I can observer this both in Firefox and Chrome. (More severe in Firefox)

Has anyone else encountered this problem? Should I open a github issue?

The problem is that the encoding of the renderer and the internal render target of Reflector are different. That means all shader programs are recompiled per frame which of course totally kills the performance.

If you need sRGBEncoding, you can fix the issue by adding encoding: sRGBEncoding to the following parameters object in Reflector:

Please verify first if the above approach fixes your issue. If so, I think it could still be valuable to report this at github. Ideally objects like Reflector could automatically derive the correct encoding from WebGLRenderer in some way.

2 Likes

Hi Mugen87, this indeed fixed the problem. Question: Can I set encoding: sRGBEncodingin the release version? I donā€™t see how (or I miss something) Should I copy Reflector.js to my project? What would be a good approach fixing this for my project using r113?

Iā€™m happy to open up a github issue if this helpsā€¦

1 Like

Yes, you have to do this right now. In the meantime, Iā€™ll investigate if the encoding settings can somehow be automated.

Corresponding github issue: https://github.com/mrdoob/three.js/issues/18699

With R114 it will be possible to pass the encoding as a parameter to Reflector and Refractor.

1 Like

I have the same issue with the webgl_water example. When I add renderer.outputEncoding = THREE.sRGBEncoding; I get a huge performance drop.

We could add an encoding option to Water2.js which then passes it to Reflector and Refractor?

This should be added to the ThreeJS Documentation.