So why is mobile still doubleLDR?

So why are lightmaps still doubleLDR on mobile? There is no reason for it. Afaik it was because of compatibility with OpenGL es 1, which is not supported any more.

(Read more here Lightmap clamped when switching from MAC OS X to iOS - Unity Engine - Unity Discussions )

And yet the lightmaps on mobile are still doubleLDR. Not only they look bad, they are often the source of bugs (remember when lightmaps were super dark in the editor?) and they increase code complexity all to be compatible with an API that isn’t supported any more, which is insane.

1 Like

This is something that I’ve run into once again recently. I suspect it’s because mobile texture formats have been an ongoing pain, with nice new formats not being usable if you want to also support older devices?

But it’d certainly be nice to have the option of enabling RGBM on mobile for the extra range. Are there any decent workarounds? I guess I could write a script to convert the .exr to an RGBM .png after a bake (and render with custom shaders)

(Edit: Although that’s easier said than done… as there appears to be no support for loading HDR .exr textures from an editor script? - I can copy the lightmap into a readable texture, but only from a texture that’s already been reduced to doubleLDR, which is no use…)

(Edit2: Setting a lightmap texture to import as Default rather than Lightmap seems to give an RGBM map, at least while in Android mode - So I may just need to switch that, and decode it appropriately in a custom shader)

Strangely, I’m finding that if I set a lightmap to ā€˜default’, the expected 8a rgb is too bright, and 5argb seems to match the dLDR lightmap?

That should no longer be the case in the newest versions of Unity, as HDR lightmaps are supported both for iOS and Android platforms.

1 Like

How new is newest? - I’m working in 2018.2.7 and haven’t seen the option (and the 2019.1 docs don’t seem to mention it) - The ā€˜lightmap encoding’ option Player Settings isn’t present for Android in 2018.2.7

The docs do confirm that the expected RGBM range is 0-5 now, though. I must have been looking at an old version when I saw references to 0-8.

Turned out to be easy to get RGBM working on Android though - I just needed to change the import mode of the lightmaps to ā€˜default’ (so they get encoded as RGBM), and tweak our custom shaders to decode it.

1 Like

I can’t double check now since I don’t have the alpha installed now, but I believe it’s in 2019.1. ( I guess the docs are just out of date )

That is correct, HDR lightmaps should be available in the latest 2019.1 alpha. In order to make use of HDR lightmaps on mobile, Lightmap Encoding Quality should be set to either High or Medium.

2 Likes

I am not sure if I understood your question. Lightmaps are an integral part of lighting your scene when using baked lighting, since they store all the baked GI information within them.

Simply put, HDR lightmaps allow you to use very high light intensities and bake them into the lightmap. Before this feature was available, lightmap intensity would be clamped to LDR.

Seeing that HDR lightmaps are stored in .exr format it should be possible.

2 Likes

How?

I feel there is some confusion.

Lightmaps are just textures that the lighting is stored on, as a texture.

On most platforms they are encoded/decoded as hdr (meaning, high dynamic range), so you can get super bright areas and not too much banding.

On mobiles (until now, now being 2019.1), they are double low dynamic range. Double dynamic range means the maximum light stored is white*2 and that there will probably be some banding (since it’s stretching the dynamic range).

Now, since a lightmap is just a texture, you could potentially use it as you would any other texture (as an environment, or as an emission map or whatever), but I have no idea why you would want to do that (it would look super weird), so I’m not sure what the use case would be.

As such I feel there is some confusion in the discussion somewhere.

You can already do that with emission in materials. You can have any arbitrary geometry act as a light source.

I’m not sure what you mean. You can use a spherical HDRI for environment already.

Since starting a bake deletes the old lightmaps I’m not sure how you would use it as a source and a destination for lighting at the same time.

So you would have to do something like duplicate the lightmaps/lightmap, and then have custom shaders load it as an emission texture? That could be possible.

You lost me. Lightmapping isn’t really a realtime process.

What does ā€œlight is emittedā€ mean, though? Realtime light? That casts shadows? That can’t happen.

You can and should just use light probes instead.

Not with the progressive lightmapper.

Maybe with Enlighten.

Watch this video :

BUT, I doubt you can get that to be as well defined (high precompute resolution) and performant as in that video in an actual scene of some complexity.