Closed winston-yallow closed 1 year ago
On further investigation, it seems like relative includes aren't supported. At least the debug console output says "Can't open file from path 'res://common.gdshaderinc'" when trying to use a relative path, suggesting that it tries to find the file at the project root.
I'm not sure if it's intended that paths need to be absolute. If yes, then the error in the shader editor tab should be clearer. Instead of saying that the method expected no arguments, it would be good to say that the include didn't work and therefore the function is not available.
I have the same problem, except I'm not using relative paths... I have shaders like
#include "smooth_terrain/shaders/transvoxel.gdshaderinc"
Producing such errors:
ERROR: Can't open file from path 'res://smooth_terrain/smooth_terrain/shaders/transvoxel.gdshaderinc'.
at: (core\io\file_access.cpp:699)
Where smooth_terrain
IS a folder under res://
.
This shader worked fine during alphas and betas, until recently it broke with that error where functions can't have arguments.
smooth_terrain
appears twice in the path though, Godot tried to make the path relative.
Still, the error is wrong, because the including shader did not mention the problem at the #include
line, rather complaining about a confusing error on a function call.
Please open a new issue with a reproduction project.
Godot version
v4.0.beta15.official [4fa6edc88]
System information
Windows 10 (10.0.19045 Build 19045) | Forward+ | Vulkan API 1.3.206 | AMD Radeon RX 6800 XT
Issue description
If there is a function with arguments within a
.gdshaderinc
file, then this function can not be used in other shaders that include this via a relative include. The error in the other shaders is "Too many arguments for "example()" call. Expected at most 0 but received 1". Using an absolute path for the include resolves the error.Note: The relative include does work in the special case of both files being in the project root.
Steps to reproduce
Minimal reproduction project
shader-include-bug.zip