WebGL-based Prefiltered Mipmaped Radiance Environment Map (PMREM) generator

Thanks to @WestLangley‘s Physical material, we now need a proper prefiltered mipmapped radiance environment map generator to generate both the prefiltered specular cube maps as well as the prefiltered irradiance/diffuse cube maps.

We can use this tool to create them off line, but it is very inconvenient also this tool is slow:


It would best if we could generate them using the GPU so that generate was fast. If generation becomes less than 50ms on most hardware, we can use this live rather than downloading the PMREMs. Having it run real-time would be incredibly useful for doing live LightProbes (that would be awesome!)


  • Float32 input textures in a cube map pattern (which cube map pattern doesn’t matter, because we can likely convert to any format from any format.)
  • Ability to generate guassian or cosine power filtered specular cube maps.
  • Ability to specify the set of filter sizes desired. Sometimes people want a full mipmap full, other times they just want 4 levels.
  • Ability to create an irradiance map (for DiffuseLightProbes)
  • Output should also be in a cubemap float32 format (we can convert to any format afterwards.)
  • We’ll want to have some utility methods to map one cubemap type to another – such as latlong to samplerCube, to 2D packed cubemap (i.e. cubeToUV), and eventually to the tetrahedral format. This will be useful for both the input and output conversion.

I highly recommend that we make the texture format RGBM encoding/decoding to be optional, because sometimes you want this and other times you do not.

My recommendation is that we use a samplerCube internally to this function to keep it simple.

BTW PlayCanvas has one of these here:


Does anyone want to try their hand at this?

Author: Fantashit

1 thought on “WebGL-based Prefiltered Mipmaped Radiance Environment Map (PMREM) generator

Comments are closed.