godot icon indicating copy to clipboard operation
godot copied to clipboard

Disabling shader pre-processor displays editor-only error about unknown built-ins

Open MenacingMecha opened this issue 2 years ago • 2 comments

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: Screenshot from 2023-06-20 17-55-20

Steps to reproduce

  1. Open project
  2. Open error-example.gdshader in shader editor
  3. 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

MenacingMecha avatar Jun 20 '23 17:06 MenacingMecha

CC @bitsawer @Chaosus

akien-mga avatar Jun 20 '23 18:06 akien-mga

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:

  1. Clarify in the processor docs that #pragma disable_preprocessor has to be below the shader_type definition; and
  2. Add an error to the engine if something is above the shader_type definition

clayjohn avatar Jun 20 '23 18:06 clayjohn