Godot: Builtin variables are not useable in shader functions

Created on 21 Dec 2017  Â·  6Comments  Â·  Source: godotengine/godot

Godot 3.0
Windows 10 64 bits
nVidia geforce 940M

I vaguely remember something about this, but I noticed that if you make a function in a shader, that function cannot access builtin variables such as TIME. Is this expected? If it is, I find it a bit annoying since such a variable can be expected to work as a global (unlike some others though, like output pixel color or output vertex).

bug core rendering

Most helpful comment

@Zylann I've added TIME as global variable for custom functions (since its available everywhere) in https://github.com/godotengine/godot/pull/37166

All 6 comments

Yes this is expected, as functions can be reused between vertex and
fragment shaders

On Dec 21, 2017 12:58 PM, "Marc" notifications@github.com wrote:

Godot 3.0
Windows 10 64 bits
nVidia geforce 940M

I vaguely remember something about this, but I noticed that if you make a
function in a shader, that function cannot access builtin variables such as
TIME. Is this expected? If it is, I find it a bit annoying since such a
variable can be expected to work as a global (unlike some others like
output pixel color or output vertex).

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/godotengine/godot/issues/14904, or mute the thread
https://github.com/notifications/unsubscribe-auth/AF-Z29Xe01dAygSASfAIOGlUpLlMMDtoks5tCoA3gaJpZM4RKAzx
.

But does this make sense for TIME?

there is no code in the shader compiler to check that built-ins are global everywhere, TIME is probably the only exception

Yeah, TIME and VIEWPORT_SIZE should be accessed globally, at some point of development

I just ran in this again, with SCREEN_TEXTURE, which should also be accessible from shader functions because I bet it's a hidden uniform. Otherwise my shader will start looking pretty ugly, passing that sampler all the way around.

@Zylann I've added TIME as global variable for custom functions (since its available everywhere) in https://github.com/godotengine/godot/pull/37166

Was this page helpful?
0 / 5 - 0 ratings