Multi pass renderings double up shader compilation time?

Hi,

It seems THREE forces output encoding for Render-To-Texture pass to Linear, which doubles up the shader compilations for all WebGLProgram in the scene if your global output encoding is set to sRGB. By producing different programCacheKey (one set for sRGB, the other set for Linear).

This adds up the shader compilation time quite a lot quickly if your scene has numbers of complicated materials.

First of all, is this correct? I’m afraid if I’m making wrong assumptions. If it is correct, would there be any work around you would recommend to avoid it?

Thanks in advance!

Do you mind explaining in more detail your setup?

When using post-processing, color space conversion is done via post-processing and not inline. So right know you would have a separate pass via GammaCorrectionShader at the end of your pass chain. In this case, no shader are duplicated.

Hi @Mugen87,

Thanks for your answer!

I wasn’t using or aware that using post-processing will by pass the conversion. That’s great to know and that sounds like the direction I’d try.

To answer your question, my rendering flow is looking something like this:
1. Render a fade target group to a render target
*2. Render rest of scene directly to screen, with a quad textured with the texture from the above pass to blend with the scene

The reason why I’m doing this way is because I need to fade in/out a group of objects in 2d composition manner to have clean look if this makes sense.

I was actually considering to use an additional render target to render *2. to, and Blit to screen. But I wasn’t sure about the trade off from the additional cost of having another 16bit texture and additional shader pass for the Blit pass to screen.

But it seems if you can bypass the color space conversion per shaders and do it only once per pixel in the Blit pass, it sounds worth to try.

Perhaps I could also bypass tone-mapping and fog per shaders and do it once in the Blit pass as well? If so, I think it could also save another redundant compilations from the transmission pass from disabling tone map for opaque queue which is another big win for my use case.