Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

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

Discussion in 'Graphics for ECS' started by Samsle, Oct 9, 2021.

  1. Samsle

    Samsle

    Joined:
    Mar 31, 2020
    Posts:
    113
    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:
    Code (CSharp):
    1. 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.
    2. Exception: NullReferenceException:
    3.   at (wrapper managed-to-native) UnityEngine.Texture.set_filterMode(UnityEngine.Texture,UnityEngine.FilterMode)
    4.   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
    5.   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
    6.   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
    7.   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
    8.   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
    9.   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
    10.   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.
    My current platform is Android, do I have to set an option somewhere to get it to work?
     
  2. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    351
    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:
    Code (CSharp):
    1. var result = new Texture2DArray(data.width, data.height, source.Count, source[0].graphicsFormat, TextureCreationFlags.MipChain);
    and replace it with
    Code (CSharp):
    1. bool isSRGB = GraphicsFormatUtility.IsSRGBFormat(data.graphicsFormat);
    2. 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.
     
    customphase and Samsle like this.
  3. Samsle

    Samsle

    Joined:
    Mar 31, 2020
    Posts:
    113
    Oh, good to know and thank you very much!
    And thanks for the hint for another potential bug :)