glTFast icon indicating copy to clipboard operation
glTFast copied to clipboard

GLTF Shaders are using too much space in ram

Open Hexer611 opened this issue 1 year ago • 6 comments

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

Hexer611 avatar Mar 13 '23 10:03 Hexer611

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.

Phantomxm2021 avatar Mar 26 '23 06:03 Phantomxm2021

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

VrabelJannn avatar Jul 17 '23 17:07 VrabelJannn