Hi
I am trying to bake lightmaps in blender and then use them in babylon app. As it turns out it’s not that straightforward. I am using PBR materials and I specifically want to have separate albedo and lightmap image on the objects.
I have already read this thread on the topic but I still feel like not having full picture.
Let’s say I can generate lightmaps in OpenEXR or HDR as I know that producing PNG lightmaps from Blender does not work as expected (it normalizes channels and uses only RGB channels).
What is the transformation of OpenEXR/HDR to texture format that I can:
Load into Babylon
Use as lightmap rightaway (without tranformations in babylon)
My idea is to have Blender output something that Babylon expects without any additional transformations later.
That’s almost exactly my flow currently. The problem is not how to get lightmap from Blender to Babylon but rather what should be the format of that lightmap coming out from Blender. Right now I can see that Babylon is using proprietary RGBD format which Blender does not generate. I even tried reproducing this as post process step in Blender but it results in banding in the output textures.
I can’t really see a streamlined process to have lightmaps working correctly without hacks that involve manual work.
I actually don’t think it’s a good idea to use RGBD.
Because currently the lightmap channel in babylonjs does nothing more than superimpose the lightmap colors onto the final output color.
I agree. In my opinion, the topic is still open. I think it’s worth following (I do) but I wouldn’t dare using it in a productivity environment with a strong requisit about colors/exposure. At least, not just yet. Of course, my opinion only.
Okay. What is proper way of exporting blender lightmaps which when pasted in babylon will give me exactly the same results as usual Blender render?
RGBD is simply the use of the A channel to increase the color range.
It’s not “simply”, this is the only proper way to have results that look exactly the same as my Blender renders AFAIK yet RGBD is not documented anywhere except for this piece of code, but I still cant produce nice RGBD textures just because I don’t know what exactly does this function expect.
However, from the definition can be seen, babylonjs in the shader will only reflectionTexture, refractionTexture and lightmapTexture automatically do processing
The problem is indeed a bit subtle, because I am seeing the lightmapTexture sampled directly in the standard material.
But in pbrMaterial, the conversion from sRGB to linear space is done.
This seems to imply that the LightMap in pbrMateiral requires srgb, while the standard material requires linear. Maybe someone can answer this.
the color is 0-255 there is nothing to say about this.
Because he is not really high dynamic range, he is using “A” channel to simulate high dynamic range.
I don’t know much about RGBE, but I think their final output values are the same anyway.
I think I know what is going on.
The standard materials are probably always in sRGB space, so there is no need to convert them. So both expect sRGB lightmap.
I don’t know if I’m right
I am aware that I can use that piece of code to convert .hdr to RGBD .png but I’d like to do that already in blender so that I can pass ready .gltf + lightmaps to babylon and have that working rightaway. Do you have any tips on how to convert image to RGBD?