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

isnan() in shader code breaks shader when a non-float is passed into it #19180

Closed
Bauxitedev opened this issue May 26, 2018 · 1 comment · Fixed by #19299
Closed

isnan() in shader code breaks shader when a non-float is passed into it #19180

Bauxitedev opened this issue May 26, 2018 · 1 comment · Fixed by #19299

Comments

@Bauxitedev
Copy link

Bauxitedev commented May 26, 2018

Godot version:
3.0.2 Mono

OS/device including version:
KDE Neon
GTX 1060

Issue description:
in a shader you can use isnan() to check if a float is NaN. However, if you pass anything that is not a float into it (such as a integer, vector, matrix, etc) it breaks the shader, yet doesn't give an error message in the editor. You do get a lot of error spam when the game runs, though:

 drivers/gles3/shader_gles3.h:377 - Condition ' !version ' is true. returned: -1

For instance try this shader:

shader_type spatial;

void fragment()
{
	ALBEDO = isnan(vec2(0,0)) ? vec3(1.0) : vec3(0.0);
}

I've assigned it on a sphere here, as you can see, the sphere gets weirdly stretched and is drawn in screen space:
bug

Steps to reproduce:

  1. Add MeshInstance to the scene, assign sphere, and assign a new ShaderMaterial to it.
  2. Put the shader above into it and observe results.

Minimal reproduction project:

shadernanbug.zip

@orausch
Copy link
Contributor

orausch commented May 31, 2018

Thanks for the reproducible bug report. I've created a pull request that should fix this bug.

I just wanted to let you know that your shader code won't compile even with the fix because isnan(vec2) returns a boolean vec2. Your code would compile if you specified which element of the vec2 you want to check. For example:

shader_type spatial;

void fragment()
{
	ALBEDO = isnan(vec2(0,0)).x ? vec3(1.0) : vec3(0.0);
}

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.

3 participants