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

The parsing of the numbers in the shader needs to be revised #55587

Closed
navy-cap-echo opened this issue Dec 3, 2021 · 0 comments · Fixed by #55623
Closed

The parsing of the numbers in the shader needs to be revised #55587

navy-cap-echo opened this issue Dec 3, 2021 · 0 comments · Fixed by #55623

Comments

@navy-cap-echo
Copy link

Godot version

v4.0.dev.20211117.official [175690957]

System information

Windows 10, Vulkan, NVIDIA GeForce GTX 970

Issue description

First of all, here is the context which allowed me to discover the problem.

I try to add an unsigned integer constant to a variable by adding a U behind the number.

uint a = 10U ;

This doesn't work ! IMHO that is already a problem !

It can be bypassed by using an overkilling casting :

uint a = uint(10) ;

Then I tried to add other characters, and there surprise, the compiler does not throw a warning or an error on the wrong number format :

int  a = 50ABCDEFGHIJddsdssdsqd ;

Same with hexadecimal number :

int  b = 0x50ABCDEFGHIJKLMNOPQRSTUVWXYZ ;

Same with float number :

float fa = 1.0ABCDEFGHIJKLM ;

Steps to reproduce

  • Create a Sprite2D
  • Assign an ImageTexture to the Sprite texture (size 200x200 for example)
  • Create a ShaderMaterial for the Sprite2D material
  • Create a canvas shader with the following code :
shader_type canvas_item;

void fragment() 
{
	float fa = 1.0ABCDEFGHIJKLM ;
	int  a = 50ABCDEFGHIJddsdssdsqd ;
	int  b = 0x50ABCDEFGHIJKLMNOPQRSTUVWXYZ ;
	//uint c = 10U ; 

	COLOR = vec4(float(a)/255.0,float(b)/255.0,0.0,1.0);
}

Minimal reproduction project

No response

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.

2 participants