AddDefine QML Type
Adds a preprocessor define to the shader compilation for a pass. More...
| Import Statement: | import QtQuick3D |
| Since: | Qt 6.11 |
| Inherits: |
Properties
Detailed Description
The AddDefine type is used to inject a #define into the shader compilation for a RenderPass. This lets you branch shader behavior at compile time depending on which pass is being executed.
In the shader code, the define can be used with the standard preprocessor #ifdef / #if directives:
#ifdef CUSTOM_PASS_MODE // code compiled only when this define is present #endif
RenderPass { commands: [ ColorAttachment { name: "color0"; target: colorTexture }, AddDefine { name: "CUSTOM_PASS_MODE" }, AddDefine { name: "OUTPUT_VERSION"; value: 2 } ] }
Property Documentation
name : string
The name of the preprocessor macro to define. This becomes the identifier used in #ifdef or #if checks in the shader code.
value : int
The integer value assigned to the preprocessor macro. Defaults to 1. When non-zero, #if NAME evaluates to true in the shader.
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.