PBR Refraction roughness (blurriness)

You can’t render the blur pass into the same texture you are reading from, you get a “Feedback loop formed between Framebuffer and active Texture.” error because of that. So, you must create an additional texture T that you will render into, and bind this texture as the refraction texture of your material:

Some comments about this PG:

  • I commented the packFloat = true thing, I don’t know the purpose of this in the shadow generator code and it makes the blurring fail
  • Now that the pbr.refractionTexture property is set with the new T texture, you must add the regular refractionTexture in the scene.customRenderTargets array so that it gets generated. Indeed, RTTs (like T) assigned to some texture properties of the standard/PBR material are automatically generated each frame, but RTTs that are not are not automatically generated, you must tell the system you want them to be generated by adding them to scene.customRenderTargets
  • T is a regular RenderTargetTexture, so it gets generated each frame, meaning it is cleared and the meshes from its renderList are rendered into this texture. As this list is empty we are fine in that area, but the texture still gets cleared, something we don’t want as it happens after the blur have been generated, nullifying this processing. To avoid this clearing, we add an observer to T.onClearObservable that does nothing.