Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrong lightmap rendering

I have some issues understanding how the lightmap feature works. I use Runtime World (an editor) to generate a world, but when I load my world in Three.js, I get a weird kind of lightning if my lightmaps have any color (it works fine when all my lights are white).

For example, here is what the fireplace looks like in the editor:

And here is what Three.js renders:

The fireplace lightmap looks like this:

Something is wrong, but where? Is Runtime World exporting a wrong lightmap (if so, then what should the lightmap look like?)? Or is three.js rendering a wrong result?

like image 453
J. Doe Avatar asked May 13 '26 09:05

J. Doe


1 Answers

Got it. The pretty lightmap in the editor was using floating point textures, and my code was loading textures by casting them to integer-only. What I needed to do to fix this was:

  • Enable the support of the OES_texture_float and OES_texture_float_linear extensions
  • Use THREE.DataTexture instead of THREE.Texture (so that I can use THREE.FloatType)
like image 151
J. Doe Avatar answered May 19 '26 02:05

J. Doe