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

Ensure global shader sampler parameters are initialized when loading #91414

Merged

Conversation

Lateasusual
Copy link
Contributor

During editor initialization, Global Shader Parameters with Texture references are skipped since the textures may be reloaded later. Previously this also skipped creating the parameter, which would cause shaders to fail to compile during initialization due to missing global uniforms, and spam the console with errors.

This just changes it to still create the parameters with invalid RID instead of skipping it entirely.

@Lateasusual Lateasusual requested a review from a team as a code owner May 1, 2024 14:18
@Chaosus Chaosus added this to the 4.3 milestone May 1, 2024
Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense! It looks like the compatibility renderer uses the same code. Can you make this change there as well?

if (gvtype >= RS::GLOBAL_VAR_TYPE_SAMPLER2D) {
//textire
if (!p_load_textures) {
continue;
}
String path = value;
if (path.is_empty()) {
value = RID();
} else {
Ref<Resource> resource = ResourceLoader::load(path);
value = resource;
}

@Lateasusual Lateasusual force-pushed the shader-globals-not-initialized branch from d17e72f to 44364fa Compare May 1, 2024 17:12
@Lateasusual
Copy link
Contributor Author

Ah, I forgot about that, thanks!

Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

Tested locally and it also removes the !global_shader_uniforms.variables.has(p_name) error that you often get at startup when using textures in a global shader.

@akien-mga akien-mga merged commit 81bcfe6 into godotengine:master May 1, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

4 participants