Ingame Graphics Settings and Shader Stripping

I’m working on a game that offers various options to customize the graphics settings. For example, options could include:

  • ssao on/off
  • upscaling filter bilinear/stp/fsr
  • hdr precision 32bits/64bits
  • shadows off/low/med/high
  • camera dirt via bloom post processing on/off
  • chromatic aberration post processing on/off
  • depth of field on/off
  • anti aliasing off/fxaa/smaa/taa
  • various RendererFeatures combinations
    … and so on

Unity’s shader stripping, by default, assumes that many of these variations are unused and removes them when building a Windows player. To prevent this removal, I created several render pipeline assets with different combinations and assigned each asset to a quality settings entry. This approach seems to stop Unity from discarding shader combinations.

However, I wonder if there is a more efficient way to achieve this.

Not from Unity, but I think you can also do manual striping in the build process.
Haven’t done it myself, but might be interesting!
Also adding your shaders to always included shaders keeps all variants

I’ve already worked with custom shader stripping. However, in this case, I want the opposite. I don’t want to strip or remove variations; instead, I want to keep shader variations that Unity assumes are not used and therefore gets filtered before things are passed to IPreprocessShaders, as far as I remember.

From the perspective of startup time and memory footprint, that approach is not feasible for a project with many shaders and even more shader variations.

For me I use different real configs per quality mode and then my settings script overrides what gets set by the pipeline feature.

Additionally if using Unity 6 most of these settings are in a volume anyway, you don’t need them in a quality setting if they’re included in a volume. The only real exception is SSAO cause a shader feature might be stripped. Most of the stuff you pointed out isn’t generally stripped at least from what I’ve seen.

I posted a thread here about how unity seems to have designed the setup.

Call to Asset Store Devs: Make better use of Volumes and Renderfeatures! - News & General Discussion - Unity Discussions

One thing to point out is it is possible to get the volume from the pipelineasset and use that for settings.

            var data = GraphicsSettings.currentRenderPipeline as UniversalRenderPipelineAsset;
            if (data != null) volume = data.volumeProfile;

Hey! If I understood correctly, you are interested in a way to prevent the SRPs from stripping variants for features which are unused at build time, by your render pipeline assets?

Have you tried disabling the “Strip Unsued Variants” setting? Unity - Manual: Reduce shader variants in URP

This will of course increase shader variants and build time. You will then likely need to implement custom stripping yourself (Unity - Scripting API: Build.IPreprocessShaders.OnProcessShader)