O que você está procurando?
Unity Platform

Stage specific shader keywords (GLES, Vulkan)

Apr 2, 2025
Under Consideration
Safe harbor statement

The following is intended for informational purposes only, and may not be incorporated into any contract. No purchasing decisions should be made based on the following materials. Unity is not committing to deliver any functionality, features or code. The development, timing and release of all products, functionality and features are at the sole discretion of Unity, and are subject to change.

How to share roadmap feedback

If you have accepted to use functional cookies and logged in using your Unity ID at the top right of the page, then sharing feedback is as simple as clicking a card below, selecting a topic’s importance, adding your point of view, and submitting. If you prefer not to accept functional cookies or log in, you will be prompted to enter an email address and validate it, so we know how to reach out when the topic evolves. For more information read the Feedback and privacy terms.

Summary

The amount of produced shader variants grow exponentially based on keywords usage, and can lead to:

  • Increased build times due to processing and compilation of variants.
  • Increased filesize, memory usage and shader loading time due to an increased amount of included shaders.

By default, Unity generates keyword variants for each stage of your shader. If a set of keywords is only used in one of those stages, this results in identical variants for the other stage. Unity automatically identifies and deduplicates identical variants so that they do not increase build size, but they still result in wasted compilation time, increased shader loading times, and increased runtime memory usage.

To avoid this problem, when you declare a set of keywords in a hand-coded shader, you can instruct Unity to compile them only for a given shader stage. You are then responsible for ensuring that the keywords are only used in the specified shader stages.

However, stage specific keywords are currently unsupported when targeting OpenGL and Vulkan platforms.

Intended Behavior/Usecase

  • Stage specific shader keywords are supported when targeting the GLES and Vulkan backends.
Help us deliver the deliver that matter to you. Let us know how important is this for you.
By submitting you agree to the Unity’s feedback terms and privacy policy.
Discover upcoming updates and share your feedback