pythonshadergeometry-shaderarcade

How can I fix this Python Arcade Geometry Shader error?


I have a big Problem. In the Python Arcade Library on the newest version (on Version 2.5.7 the Programm running successfull) is this error on the start from every programm:

    Traceback (most recent call last):
  File "C:Users-PycharmProjectsarcadegame.py", line 35, in <module>
    main()
  File "C:Users-PycharmProjectsarcadegame.py", line 29, in main
    window = MyGame()
  File "C:Users-PycharmProjectsarcadegame.py", line 12, in __init__
    super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
  File "C:Users-PycharmProjectsarcadevenvlibsite-packagesarcadeapplication.py", line 143, in __init__
    self._ctx: ArcadeContext = ArcadeContext(self, gc_mode=gc_mode)
  File "C:Users-PycharmProjectsarcadevenvlibsite-packagesarcadecontext.py", line 81, in __init__
    fragment_shader=":resources:shaders/sprites/sprite_list_geometry_fs.glsl",
  File "C:Users-PycharmProjectsarcadevenvlibsite-packagesarcadecontext.py", line 346, in load_program
    defines=defines,
  File "C:Users-PycharmProjectsarcadevenvlibsite-packagesarcadeglcontext.py", line 631, in program
    out_attributes=out_attributes,
  File "C:Users-PycharmProjectsarcadevenvlibsite-packagesarcadeglprogram.py", line 94, in __init__
    shader = Program.compile_shader(shader_code, shader_type)
  File "C:Users-PycharmProjectsarcadevenvlibsite-packagesarcadeglprogram.py", line 427, in compile_shader
    for i, line in enumerate(source.split("n"))
arcade.gl.exceptions.ShaderException: Error compiling geometry shader (0): ERROR: 0:25: '4294967294' : Signed integer overflow.
 
 
---- [geometry shader] ---
001: #version 330
002: layout (points) in;
003: layout (triangle_strip, max_vertices = 4) out;
004:  
005: uniform Projection {
006:     uniform mat4 matrix;
007: } proj;
008:  
009: uniform sampler2D uv_texture;
010: uniform mat3 TextureTransform;
011:  
012: in float v_angle[1];
013: in vec4 v_color[1];
014: in vec2 v_size[1];
015: in int v_texture[1];
016: in int vertex_id[1];
017:  
018: out vec2 gs_uv;
019: out vec4 gs_color;
020:  
021: #define VP_CLIP 1.0
022:  
023: void main() {
024:     // Sprite index 4294967294 means the sprite is deleted or disabled
025:     if (vertex_id[0] == 4294967294) return;
026:  
027:     // Get center of the sprite
028:     vec2 center = gl_in[0].gl_Position.xy;
029:     vec2 hsize = v_size[0] / 2.0;
030:     float angle = radians(v_angle[0]);
031:     mat2 rot = mat2(
032:         cos(angle), sin(angle),
033:         -sin(angle), cos(angle)
034:     );
035:  
036:     // Emit a quad with the right position, rotation and texture coordinates
037:     // Read texture coordinates from UV texture here
038:     vec4 uv_data = texelFetch(uv_texture, ivec2(v_texture[0], 0), 0);
039:     vec2 tex_offset = uv_data.xy;
040:     vec2 tex_size = uv_data.zw;
041:  
042:     // Upper left
043:     gl_Position = proj.matrix * vec4(rot * vec2(-hsize.x, hsize.y) + center, 0.0, 1.0);
044:     vec3 tex1 = TextureTransform * vec3((vec2(0.0, 1.0) * tex_size + tex_offset) * vec2(1, -1), 1.0);
045:     gs_uv = tex1.xy / tex1.z;
046:     gs_color = v_color[0];
047:     EmitVertex();
048:  
049:     // lower left
050:     gl_Position = proj.matrix * vec4(rot * vec2(-hsize.x, -hsize.y) + center, 0.0, 1.0);
051:     vec3 tex2 = TextureTransform * vec3((vec2(0.0, 0.0) * tex_size + tex_offset) * vec2(1, -1), 1.0);
052:     gs_uv = tex2.xy / tex2.z;
053:     gs_color = v_color[0];
054:     EmitVertex();
055:  
056:     // upper right
057:     gl_Position = proj.matrix * vec4(rot * vec2(hsize.x, hsize.y) + center, 0.0, 1.0);
058:     vec3 tex3 = TextureTransform * vec3((vec2(1.0, 1.0) * tex_size + tex_offset) * vec2(1, -1), 1.0);
059:     gs_uv = tex3.xy / tex3.z;
060:     gs_color = v_color[0];
061:     EmitVertex();
062:  
063:     // lower right
064:     gl_Position = proj.matrix * vec4(rot * vec2(hsize.x, -hsize.y) + center, 0.0, 1.0);
065:     vec3 tex4 = TextureTransform * vec3((vec2(1.0, 0.0) * tex_size + tex_offset) * vec2(1, -1), 1.0);
066:     gs_uv = tex4.xy / tex4.z;
067:     gs_color = v_color[0];
068:     EmitVertex();
069:  
070:     EndPrimitive();
071: }

The code is not important. The Error is on every Programm. I use PyCharm on Windows 10

Its something in the arcade code. Not in mine. Please help me :)


Solution

  • int is a singed data type (See Data Type (GLSL)). 4294967294 is hexadecimal fffffffe. This value can be stored in a variable of type uint (unsinged int), but not in a variable of type int. The maximum value that can be stored in int is 2147483647. For the data type int hexadecimal fffffffe is -2.
    Either use the data type uint or change the constant from 4294967294 to -2:

    if (vertex_id[0] == 4294967294) return;

    if (vertex_id[0] == -2) return;