Transmission Helper Optimisation

The mipmap generation is necessary to simulate roughness. If you don’t have roughness on your materials it could indeed by disabled. We are going to add a new option to the update function to let you disable mipmap generation.

Note that scene._transmissionHelper._opaqueRenderTarget.gammaSpace = false is not necessary anymore as it is the default setting now (the helper won’t work correctly with gammaSpace=true).

Regarding the rendering, yes, technically we could make a copy of the framebuffer after the opaque objects are rendered instead of rendering those objects two times (a first time to generate the transmission helper render target and a second time for the regular rendering). However:

  • we have no built-in mechanism to inject some code after the different passes of the rendering (opaque, sprites, particle systems, transparents). I guess that would not be too difficult to add some new observers for that
  • we would depend on the framebuffer type currently in effect and of the gammaSpace setting of it. Regarding the gammaSpace setting, we could make a conversion when copying the current render buffer to the transmission texture if gammaSpace is not false in the first place, but if the type of the current render buffer is not the one we want, for eg if it is unsigned byte (as it’s generally is) and we would like half float (which is generally what we want - or full float) then we are screwed, even if creating the transmission helper with half float type the copy won’t give us back the precision we lost when outputting to unsigned byte. Also, if some image processing is applied at the material level, tone mapping or other effects are already applied in the current render buffer, which is something we don’t want in the transmission texture.

Because of the 2nd point I don’t think we can come up with a scheme that would work in all cases, so what we could do is adding the observers as explained above (if it is ok for the Babylon’s team) and then you could try to disable the transmission helper and replace it by a copy of the framebuffer (after the opaque pass) and set this texture as the refraction texture of the transparent objects (with the caveats explained above)?

Also, as explained here the transmission helper is normally not meant to stay, we should replace it by something else, that’s why we are not really documenting it (should it stay, we will add proper documentation and better reusability).