Light Baking: "Texture creation failed. 'RGB_ETC2_SRGB' is not supported"

Hi,
I’m using Hybrid Renderer 0.11 (V2) and I tried for the first time generating baked lightmaps for a subscene.
The process worked well, I see the generated lightmaps, but when closing the subscene it displays this error & the subscene-entities are invisble:
Error

Error: Texture creation failed. 'RGB_ETC2_SRGB' is not supported for Sample usage on this platform. Use 'SystemInfo.IsFormatSupported' C# API to check format support.
Exception: NullReferenceException:
  at (wrapper managed-to-native) UnityEngine.Texture.set_filterMode(UnityEngine.Texture,UnityEngine.FilterMode)
  at Unity.Rendering.LightMaps.CopyToTextureArray (System.Collections.Generic.List`1[T] source) [0x00044] in D:\Projects\myProject\Library\PackageCache\com.unity.rendering.hybrid@0.11.0-preview.44\Unity.Rendering.Hybrid\LightMaps.cs:52
  at Unity.Rendering.LightMaps.ConstructLightMaps (System.Collections.Generic.List`1[T] inColors, System.Collections.Generic.List`1[T] inDirections, System.Collections.Generic.List`1[T] inShadowMasks) [0x00000] in D:\Projects\myProject\Library\PackageCache\com.unity.rendering.hybrid@0.11.0-preview.44\Unity.Rendering.Hybrid\LightMaps.cs:67
  at Unity.Rendering.LightMapConversionContext.ProcessLightMapsForConversion () [0x0011c] in D:\Projects\myProject\Library\PackageCache\com.unity.rendering.hybrid@0.11.0-preview.44\Unity.Rendering.Hybrid\RenderMeshConversionContext.cs:188
  at Unity.Rendering.RenderMeshConversionContext.ProcessLightMapsForConversion () [0x00013] in D:\Projects\myProject\Library\PackageCache\com.unity.rendering.hybrid@0.11.0-preview.44\Unity.Rendering.Hybrid\RenderMeshConversionContext.cs:321
  at Unity.Rendering.MeshRendererConversion.OnUpdate () [0x00048] in D:\Projects\myProject\Library\PackageCache\com.unity.rendering.hybrid@0.11.0-preview.44\Unity.Rendering.Hybrid\MeshRendererConversion.cs:41
  at Unity.Entities.ComponentSystem.Update () [0x0005f] in D:\Projects\myProject\Library\PackageCache\com.unity.entities@0.17.0-preview.42\Unity.Entities\ComponentSystem.cs:114
  at Unity.Entities.ComponentSystemGroup.UpdateAllSystems () [0x000c7] in D:\Projects\myProject\Library\PackageCache\com.unity.entities@0.17.0-preview.42\Unity.Entities\ComponentSystemGroup.cs:472

It’s actual the same error @Opeth001 posted already in another thread, but without an answer: [link]( Hybrid Renderer V2 (0.4.0) page-12#post-6761242).
My current platform is Android, do I have to set an option somewhere to get it to work?

There is currently a bug related to lightmap texture formats on Android. Until we can release a fixed version, you should be able to use a locally modified version of the Hybrid Renderer package to fix the issue.

Find this line in LightMaps.cs inside the Hybrid Renderer package:

var result = new Texture2DArray(data.width, data.height, source.Count, source[0].graphicsFormat, TextureCreationFlags.MipChain);

and replace it with

bool isSRGB = GraphicsFormatUtility.IsSRGBFormat(data.graphicsFormat);
var result = new Texture2DArray(data.width, data.height, source.Count, source[0].format, true, !isSRGB);

We have also seen a bug where lightmapping shader variants might get incorrectly stripped from the build unless there is at least a single lightmapped GameObject present.

2 Likes

Oh, good to know and thank you very much!
And thanks for the hint for another potential bug :slight_smile: