Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

'Automatic' shader stripping, how does it behave?

Discussion in 'Shaders' started by Clavus, Aug 3, 2020.

  1. Clavus

    Clavus

    Joined:
    Jun 6, 2014
    Posts:
    62
    I'm working on a large project for a client on the Nintendo Switch platform and we were running into some memory issues. After profiling we discovered "Shaderlab" taking up in the excess of 600MB of memory, which seemed excessive for shader data. The project is a bit messy in terms of the amount of shaders it uses but I didn't figure it would be this big of an issue.

    After some tinkering I tried this in the Graphics Settings:
    upload_2020-8-3_9-54-14.png

    None of our scenes were using fog, realtime GI, or baked GI (baked GI option was enabled but scenes didn't have lightprobes), so visually it made no difference to the game. This made Shaderlab drop to sub-10MB in the profiler. I'm kind of stumped how big the difference was. I still have a lot of questions about how some shaders apparently balloon with the rendering features enabled, but my primary question here would be "how does 'Automatic' for the Lightmap Modes and Fog Modes settings actually work?". I always made the assumption it scanned all the scenes in the build, checked which options were being used, and stripped all the other options, but is that the case or does it include shader features based on other criteria too?