atteneder / glTFast

Efficient glTF 3D import / export package for Unity
Other
1.24k stars 250 forks source link

GLTF Shaders are using too much space in ram #586

Open Hexer611 opened 1 year ago

Hexer611 commented 1 year ago

Hello, i have a project where i need to import glb files in runtime. I need all shader variants (at least that is what i think) so i included those in the build. I took a memory snapshot using Unity Memory Profiler, this snapshot belongs to a standalone build. I am not sure if this is a bug, is there anything i can do to decrease this ram usage?

image

Phantomxm2021 commented 1 year ago
string[] tmp_ShaderNames =
            {
                "glTF-pbrMetallicRoughness",
                "glTF-pbrMetallicRoughness-Opaque",
                "glTF-pbrSpecularGlossiness", 
                "glTF-pbrSpecularGlossiness-Opaque", 
                "glTF-pbrSpecularGlossiness-Blend", 
                "glTF-unlit",
                "glTF-pbrMetallicRoughness-Blend", 
            };
            foreach (string tmp_ShaderName in tmp_ShaderNames)
            {
                var tmp_Shader = Shader.Find($"Shader Graphs/{tmp_ShaderName}");
                if (tmp_Shader)
                    Resources.UnloadAsset(tmp_Shader);
            }

Try this code this release the shaders.

VrabelJannn commented 1 year ago

We have the same problem on our project, and I'm afraid that releasing it is not the solution. Is there any statement from the developers? If native memory is allocated by 1.02GB, and two shaders need 0.8GB, it is more than suspicious :\

image

azipf commented 3 days ago

Still prevalent on our iOS built with Unity6 and glTFast 6.8. If you only have 2GB available, having nearly half of it just for those shaders is too much!