Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Builtin variables are not useable in shader functions #14904

Closed
Zylann opened this issue Dec 21, 2017 · 7 comments
Closed

Builtin variables are not useable in shader functions #14904

Zylann opened this issue Dec 21, 2017 · 7 comments

Comments

@Zylann
Copy link
Contributor

Zylann commented Dec 21, 2017

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).

@reduz
Copy link
Member

reduz commented Dec 21, 2017 via email

@Zylann
Copy link
Contributor Author

Zylann commented Dec 21, 2017

But does this make sense for TIME?

@reduz
Copy link
Member

reduz commented Dec 21, 2017

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

@Chaosus
Copy link
Member

Chaosus commented Sep 14, 2018

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

@Chaosus Chaosus added this to the 3.2 milestone Sep 14, 2018
@Zylann
Copy link
Contributor Author

Zylann commented Dec 12, 2018

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.

@akien-mga akien-mga modified the milestones: 3.2, 4.0 Nov 26, 2019
@Chaosus
Copy link
Member

Chaosus commented Mar 19, 2020

@Zylann I've added TIME as global variable for custom functions (since its available everywhere) in #37166

@akien-mga
Copy link
Member

Based on the discussion in #43150, it's not clear to me whether there's something left to implement for this, at least in the current state of the proposal. A more detailed proposal might be needed to review exactly which non-global builtins could make sense to expose as global, if any.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants