Disabling shader pre-processor displays editor-only error about unknown built-ins
Godot version
4.0.3.stable
System information
Linux - Godot v4.0.3.stable - Vulkan (Forward+)
Issue description
Disabling the shader pre-processor with #pragma disable_preprocessor causes errors to be displayed about built-ins being unknown. However, the shader will correctly compile and function as normal - the error is only in the shader editor.
Example screenshot:
Steps to reproduce
- Open project
- Open
error-example.gdshaderin shader editor - Observe error
Minimal reproduction project
godot-4-shader-preprocessor-editor-error-minimal-reproduction-project-main.zip
Can also be found at: https://github.com/MenacingMecha/godot-4-shader-preprocessor-editor-error-minimal-reproduction-project
CC @bitsawer @Chaosus
This issue comes from putting the disable_preprocessor line before the shader_type definition. Re-ordering to:
shader_type canvas_item;
#pragma disable_preprocessor
void fragment() {
COLOR = texture(TEXTURE, UV);
}
removes the error.
We should do two things as a result:
- Clarify in the processor docs that
#pragma disable_preprocessorhas to be below the shader_type definition; and - Add an error to the engine if something is above the shader_type definition