How do I create a quality setting that turns on a keyword?

Unity - Manual: Shader variant stripping (unity3d.com)
“create the following”
“A ‘low quality’ setting that turns on DYNAMIC_LIGHTING.”

Does it mean turning on a keyword on this UI?
Unity - Manual: Quality (unity3d.com)

Thanks.

No. This page talks about custom shader keywords. They do not end up being controlled by the Quality UI.

So, the answer to the question in the title: How do I create a quality setting that turns on a keyword?

This is usually project-specific. For some projects one could create a button that toggles the state of this keyword at runtime. For others it may be set in stone for a given platform and the unneeded variants can be stripped using IPreprocessShaders callback.

That didn’t answer the question or even show an understanding of the question.

The title question: How do I create a quality setting that turns on a keyword?, which is an abstract of what the doc says: “create the following” “A ‘low quality’ setting that turns on DYNAMIC_LIGHTING.”

The doc is talking about a concept of “quality setting”, which, after these discussions, does not seem to be the same as Project Settings > Quality. If so, it is confusing to use the same concept for other things.

The doc looks like saying, you can create a quality setting in Project Settings > Quality and use it to set keywords.

No, you can’t use it for this purpose. See my first answer.

1 Like

The answer to the question could simply be creating a shader header file like this:

#if SHADER_API_DESKTOP
    #define DYNAMIC_LIGHTING
    #define SOFT_SHADOWS
    #define HIGH_QUALITY_LIGHTMAPS
#elif SHADER_API_MOBILE
    #define DYNAMIC_LIGHTING
#endif

This way, you just get 1 variant for each platform.

Yes, you could also do that.