# GLSL : Could not create a geometry shader

Hey everyone,
So I’m currently learning about shaders in panda3d and I’m trying to develop a shader that would imitate the behavior of a converging lens.
The idea is following : I first compute the image point V’ of the vertex V using the parameters of the lens. Then I build the intersection of the lines that go from the edge of the lens to V’ with the screen which allows me to get the points that defines the boundaries of the patch which is the image of the vertex on the screen through the lens.
So in order to get all of it working I use the vertex shader to project V into the View Coordinates. Then I compute V’ (for example), then the geometry shader computes the points that define the boundaries of the patch and returns a triangle strip of the color of the original vertex that represents the image.

So I’ve already played with the vertex and the fragment shaders but it’s the first time that I’m getting involved with the geometry shader and I just can’t figure out how to make it work : when loading the shader in a very simple script I get the following error

`:display:gsg:glgsg(error): Could not create a GLSL geometry shader.`

Here is the code for the simple vertex, geom, and frag shaders that I’m trying to get working. Note that everything works fine without the geom shader.

``````#version 130

uniform mat4 p3d_ModelViewProjectionMatrix;

in vec4 p3d_Vertex;

void main() {
gl_Position = p3d_ModelViewProjectionMatrix*p3d_Vertex;
}
``````

``````#version 130

layout (points) in;
layout (line_strip, max_vertices=2) out;

void main() {
gl_Position = gl_in[0].gl_Position + vec4(-.1, 0, 0, 0);
EmitVertex();
gl_Position = gl_in[0].gl_Position + vec4(.1, 0, 0, 0);
EmitVertex();
EndPrimitive();
}
``````

``````#version 130

void main() {
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
``````

OS : Ubuntu 18.04 LTS
Panda3D Version : 1.10 (I think) (I installed it using pip3 last week)
Output of the lspci command :
`00:00.0 Host bridge: Intel Corporation Atom Processor Z36xxx/Z37xxx Series SoC Transaction Register (rev 0e) 00:02.0 VGA compatible controller: Intel Corporation Atom Processor Z36xxx/Z37xxx Series Graphics & Display (rev 0e) 00:13.0 SATA controller: Intel Corporation Atom Processor E3800 Series SATA AHCI Controller (rev 0e) 00:14.0 USB controller: Intel Corporation Atom Processor Z36xxx/Z37xxx, Celeron N2000 Series USB xHCI (rev 0e) 00:1a.0 Encryption controller: Intel Corporation Atom Processor Z36xxx/Z37xxx Series Trusted Execution Engine (rev 0e) 00:1b.0 Audio device: Intel Corporation Atom Processor Z36xxx/Z37xxx Series High Definition Audio Controller (rev 0e) 00:1c.0 PCI bridge: Intel Corporation Atom Processor E3800 Series PCI Express Root Port 1 (rev 0e) 00:1c.1 PCI bridge: Intel Corporation Atom Processor E3800 Series PCI Express Root Port 2 (rev 0e) 00:1f.0 ISA bridge: Intel Corporation Atom Processor Z36xxx/Z37xxx Series Power Control Unit (rev 0e) 00:1f.3 SMBus: Intel Corporation Atom Processor E3800 Series SMBus Controller (rev 0e) 01:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 15) 02:00.0 Network controller: Intel Corporation Wireless 3160 (rev 93) `

So does anyone know anything about the geometry shaders not working in this configuration ? And are geometry shaders absolutely necessary for my current project ?

Thank you very much for your help.

Are there more error messages? What does the Panda code look like? What is the output with `notify-level-glgsg debug` set?

Python code : It’s basically just loading a plane from my models and the shader, so nothing to fancy

``````from direct.showbase.ShowBase import ShowBase
from panda3d.core import DirectionalLight, AmbientLight, PointLight
from panda3d.core import LVector3

def __init__(self):
ShowBase.__init__(self)

self.setupLights()

self.plane.reparentTo(self.render)
self.plane.setHpr(20, 90, 0)
self.plane.setScale(5)

app.run()
``````

The original output from the console is :

``````  glxGraphicsPipe
:display:gsg:glgsg(error): Could not create a GLSL geometry shader.
``````

And with the notify-level-glgsg debug in the Config.prc file :

``````  glxGraphicsPipe
:display:gsg:glgsg(debug): GL_VENDOR = Intel Open Source Technology Center
:display:gsg:glgsg(debug): GL_RENDERER = Mesa DRI Intel(R) Bay Trail
:display:gsg:glgsg(debug): GL_VERSION = 3.0 Mesa 19.2.8
:display:gsg:glgsg(debug): GL_VERSION decoded to: 3.0
:display:gsg:glgsg(debug): GLX_VENDOR (client) = Mesa Project and SGI
:display:gsg:glgsg(debug): GLX_VERSION (client) = 1.4
:display:gsg:glgsg(debug): GLX_VENDOR (server) = SGI
:display:gsg:glgsg(debug): GLX_VERSION (server) = 1.4
:display:gsg:glgsg(debug): GLX_VERSION = 1.4
:display:gsg:glgsg(debug): HAS EXT GLX_SGI_swap_control 1
:display:gsg:glgsg(debug): HAS EXT GLX_ARB_create_context 1
:display:gsg:glgsg(debug): GL_VENDOR = Intel Open Source Technology Center
:display:gsg:glgsg(debug): GL_RENDERER = Mesa DRI Intel(R) Bay Trail
:display:gsg:glgsg(debug): GL_VERSION = 3.0 Mesa 19.2.8
:display:gsg:glgsg(debug): GL_VERSION decoded to: 3.0
:display:gsg:glgsg(debug): GLX_VENDOR (client) = Mesa Project and SGI
:display:gsg:glgsg(debug): GLX_VERSION (client) = 1.4
:display:gsg:glgsg(debug): GLX_VENDOR (server) = SGI
:display:gsg:glgsg(debug): GLX_VERSION (server) = 1.4
:display:gsg:glgsg(debug): GLX_VERSION = 1.4
:display:gsg:glgsg(debug): Detected GLSL version: 1.30
:display:gsg:glgsg(debug): Using compatibility profile
:display:gsg:glgsg(debug): GL Extensions:
GLX_ARB_create_context                 GLX_ARB_create_context_profile
GLX_ARB_create_context_robustness      GLX_ARB_fbconfig_float
GLX_ARB_multisample                    GLX_EXT_buffer_age
GLX_EXT_create_context_es2_profile     GLX_EXT_create_context_es_profile
GLX_EXT_fbconfig_packed_float          GLX_EXT_framebuffer_sRGB
GLX_EXT_import_context                 GLX_EXT_texture_from_pixmap
GLX_EXT_visual_info                    GLX_EXT_visual_rating
GLX_INTEL_swap_event                   GLX_MESA_copy_sub_buffer
GLX_MESA_query_renderer                GLX_MESA_swap_control
GLX_OML_swap_method                    GLX_OML_sync_control
GLX_SGIS_multisample                   GLX_SGIX_fbconfig
GLX_SGIX_pbuffer                       GLX_SGIX_visual_select_group
GLX_SGI_video_sync                     GL_3DFX_texture_compression_FXT1
GL_AMD_conservative_depth              GL_AMD_draw_buffers_blend
GL_AMD_multi_draw_indirect             GL_AMD_seamless_cubemap_per_texture
GL_ANGLE_texture_compression_dxt3      GL_ANGLE_texture_compression_dxt5
GL_APPLE_object_purgeable              GL_APPLE_packed_pixels
GL_ARB_ES2_compatibility               GL_ARB_ES3_compatibility
GL_ARB_arrays_of_arrays                GL_ARB_blend_func_extended
GL_ARB_buffer_storage                  GL_ARB_clear_buffer_object
GL_ARB_clear_texture                   GL_ARB_clip_control
GL_ARB_color_buffer_float              GL_ARB_compressed_texture_pixel_storage
GL_ARB_conservative_depth              GL_ARB_copy_buffer
GL_ARB_copy_image                      GL_ARB_cull_distance
GL_ARB_debug_output                    GL_ARB_depth_buffer_float
GL_ARB_depth_clamp                     GL_ARB_depth_texture
GL_ARB_derivative_control              GL_ARB_draw_buffers
GL_ARB_draw_buffers_blend              GL_ARB_draw_elements_base_vertex
GL_ARB_draw_indirect                   GL_ARB_draw_instanced
GL_ARB_explicit_attrib_location        GL_ARB_explicit_uniform_location
GL_ARB_fragment_coord_conventions      GL_ARB_fragment_layer_viewport
GL_ARB_framebuffer_object              GL_ARB_framebuffer_sRGB
GL_ARB_get_program_binary              GL_ARB_get_texture_sub_image
GL_ARB_half_float_pixel                GL_ARB_half_float_vertex
GL_ARB_indirect_parameters             GL_ARB_instanced_arrays
GL_ARB_internalformat_query            GL_ARB_internalformat_query2
GL_ARB_invalidate_subdata              GL_ARB_map_buffer_alignment
GL_ARB_map_buffer_range                GL_ARB_multi_bind
GL_ARB_multi_draw_indirect             GL_ARB_multisample
GL_ARB_multitexture                    GL_ARB_occlusion_query
GL_ARB_pipeline_statistics_query       GL_ARB_pixel_buffer_object
GL_ARB_point_parameters                GL_ARB_point_sprite
GL_ARB_polygon_offset_clamp            GL_ARB_program_interface_query
GL_ARB_provoking_vertex                GL_ARB_robust_buffer_access_behavior
GL_ARB_sampler_objects                 GL_ARB_seamless_cube_map
GL_ARB_texture_barrier                 GL_ARB_texture_border_clamp
GL_ARB_texture_compression             GL_ARB_texture_compression_bptc
GL_ARB_texture_compression_rgtc        GL_ARB_texture_cube_map
GL_ARB_texture_env_combine             GL_ARB_texture_env_crossbar
GL_ARB_texture_env_dot3                GL_ARB_texture_filter_anisotropic
GL_ARB_texture_float                   GL_ARB_texture_gather
GL_ARB_texture_mirror_clamp_to_edge    GL_ARB_texture_mirrored_repeat
GL_ARB_texture_multisample             GL_ARB_texture_non_power_of_two
GL_ARB_texture_query_levels            GL_ARB_texture_query_lod
GL_ARB_texture_rectangle               GL_ARB_texture_rg
GL_ARB_texture_rgb10_a2ui              GL_ARB_texture_storage
GL_ARB_texture_storage_multisample     GL_ARB_texture_swizzle
GL_ARB_texture_view                    GL_ARB_timer_query
GL_ARB_transform_feedback2             GL_ARB_transform_feedback3
GL_ARB_transform_feedback_instanced    GL_ARB_transform_feedback_overflow_query
GL_ARB_transpose_matrix                GL_ARB_uniform_buffer_object
GL_ARB_vertex_array_bgra               GL_ARB_vertex_array_object
GL_ARB_vertex_attrib_binding           GL_ARB_vertex_buffer_object
GL_ARB_vertex_type_10f_11f_11f_rev     GL_ARB_vertex_type_2_10_10_10_rev
GL_ARB_window_pos                      GL_ATI_blend_equation_separate
GL_ATI_draw_buffers                    GL_ATI_separate_stencil
GL_ATI_texture_env_combine3            GL_ATI_texture_float
GL_EXT_abgr                            GL_EXT_bgra
GL_EXT_blend_color                     GL_EXT_blend_equation_separate
GL_EXT_blend_func_separate             GL_EXT_blend_minmax
GL_EXT_blend_subtract                  GL_EXT_compiled_vertex_array
GL_EXT_copy_texture                    GL_EXT_draw_buffers2
GL_EXT_draw_instanced                  GL_EXT_draw_range_elements
GL_EXT_fog_coord                       GL_EXT_framebuffer_blit
GL_EXT_framebuffer_multisample         GL_EXT_framebuffer_multisample_blit_scaled
GL_EXT_framebuffer_object              GL_EXT_framebuffer_sRGB
GL_EXT_gpu_program_parameters          GL_EXT_multi_draw_arrays
GL_EXT_packed_depth_stencil            GL_EXT_packed_float
GL_EXT_packed_pixels                   GL_EXT_pixel_buffer_object
GL_EXT_point_parameters                GL_EXT_polygon_offset_clamp
GL_EXT_provoking_vertex                GL_EXT_rescale_normal
GL_EXT_secondary_color                 GL_EXT_separate_specular_color
GL_EXT_stencil_wrap                    GL_EXT_subtexture
GL_EXT_texture                         GL_EXT_texture3D
GL_EXT_texture_array                   GL_EXT_texture_compression_dxt1
GL_EXT_texture_compression_rgtc        GL_EXT_texture_compression_s3tc
GL_EXT_texture_cube_map                GL_EXT_texture_edge_clamp
GL_EXT_texture_env_dot3                GL_EXT_texture_filter_anisotropic
GL_EXT_texture_integer                 GL_EXT_texture_lod_bias
GL_EXT_texture_object                  GL_EXT_texture_rectangle
GL_EXT_texture_sRGB                    GL_EXT_texture_sRGB_R8
GL_EXT_texture_shared_exponent         GL_EXT_texture_snorm
GL_EXT_texture_swizzle                 GL_EXT_timer_query
GL_EXT_transform_feedback              GL_EXT_vertex_array
GL_EXT_vertex_array_bgra               GL_IBM_multimode_draw_arrays
GL_IBM_rasterpos_clip                  GL_IBM_texture_mirrored_repeat
GL_INGR_blend_func_separate            GL_INTEL_performance_query
GL_KHR_debug                           GL_KHR_no_error
GL_KHR_robustness                      GL_MESA_pack_invert
GL_MESA_window_pos                     GL_NV_blend_square
GL_NV_depth_clamp                      GL_NV_fog_distance
GL_NV_light_max_exponent               GL_NV_packed_depth_stencil
GL_NV_primitive_restart                GL_NV_texgen_reflection
GL_NV_texture_barrier                  GL_NV_texture_env_combine4
GL_NV_texture_rectangle                GL_OES_EGL_image
GL_SGIS_generate_mipmap                GL_SGIS_texture_border_clamp
GL_SGIS_texture_edge_clamp             GL_SGIS_texture_lod
GL_SUN_multi_draw_arrays
:display:gsg:glgsg(debug): HAS EXT GL_EXT_debug_marker 0
:display:gsg:glgsg(debug): HAS EXT GL_KHR_debug 1
:display:gsg:glgsg(debug): gl-debug supported, but NOT enabled.
:display:gsg:glgsg(debug): HAS EXT GL_ARB_ES3_compatibility 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_texture_storage 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_clear_texture 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_clear_buffer_object 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_seamless_cube_map 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_texture_cube_map_array 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_texture_buffer_object 0
:display:gsg:glgsg(debug): HAS EXT GL_ARB_vertex_array_bgra 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_vertex_type_10f_11f_11f_rev 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_buffer_storage 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_vertex_program 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_fragment_program 1
:display:gsg:glgsg(debug): HAS EXT GL_NV_gpu_program5 0
:display:gsg:glgsg(debug): HAS EXT GL_NV_gpu_program4 0
:display:gsg:glgsg(debug): HAS EXT GL_NV_vertex_program3 0
:display:gsg:glgsg(debug): HAS EXT GL_NV_vertex_program2 0
:display:gsg:glgsg(debug): HAS EXT GL_NV_vertex_program1_1 0
:display:gsg:glgsg(debug): HAS EXT GL_ARB_vertex_attrib_64bit 0
:display:gsg:glgsg(debug): HAS EXT GL_ARB_vertex_attrib_binding 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_instanced_arrays 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_draw_instanced 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_draw_indirect 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_direct_state_access 0
:display:gsg:glgsg(debug): HAS EXT GL_ARB_framebuffer_no_attachments 1
:display:gsg:glgsg(debug): HAS EXT GL_NV_framebuffer_multisample_coverage 0
:display:gsg:glgsg(debug): HAS EXT GL_ARB_viewport_array 0
:display:gsg:glgsg(debug): Occlusion query counter provides 64 bits.
:display:gsg:glgsg(debug): HAS EXT GL_ARB_timer_query 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_blend_func_extended 1
:display:gsg:glgsg(debug): HAS EXT GL_EXT_texture_mirror_clamp 0
:display:gsg:glgsg(debug): HAS EXT GL_ARB_texture_mirror_clamp_to_edge 1
:display:gsg:glgsg(debug): max texture dimension = 16384, max 3d texture = 2048, max 2d texture array = 2048, max cube map = 16384
:display:gsg:glgsg(debug): max_elements_vertices = 3000, max_elements_indices = 3000
:display:gsg:glgsg(debug): vertex buffer objects are supported.
:display:gsg:glgsg(debug): Supported compressed texture formats:
GL_COMPRESSED_RGB_FXT1_3DFX
GL_COMPRESSED_RGBA_FXT1_3DFX
GL_COMPRESSED_RGB_S3TC_DXT1_EXT
GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
GL_COMPRESSED_RGB8_ETC2
GL_COMPRESSED_RGBA8_ETC2_EAC
GL_COMPRESSED_R11_EAC
GL_COMPRESSED_RG11_EAC
GL_COMPRESSED_SIGNED_R11_EAC
GL_COMPRESSED_SIGNED_RG11_EAC
GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2
:display:gsg:glgsg(debug): HAS EXT GL_EXT_texture_filter_anisotropic 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_sampler_objects 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_multi_bind 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_internalformat_query2 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_bindless_texture 0
:display:gsg:glgsg(debug): HAS EXT GL_ARB_get_program_binary 1
:display:gsg:glgsg(debug): HAS EXT GL_EXT_stencil_two_side 1
:display:gsg:glgsg(debug): max lights = 8
:display:gsg:glgsg(debug): max clip planes = 8
:display:gsg:glgsg(debug): max texture stages = 8
:display:gsg:glgsg(debug): Supported program binary formats:
:display:gsg:glgsg(debug):   0x875F
:display:gsg:glgsg(debug): HAS EXT GL_NV_gpu_program5 0
:display:gsg:glgsg(debug): HAS EXT GL_NV_gpu_program4 0
:display:gsg:glgsg(debug): HAS EXT GL_NV_fragment_program2 0
:display:gsg:glgsg(debug): HAS EXT GL_NV_fragment_program 0
:display:gsg:glgsg(debug): Supported Cg profiles:
:display:gsg:glgsg(debug):   arbvp1
:display:gsg:glgsg(debug):   arbfp1
:display:gsg:glgsg(debug):   glslv
:display:gsg:glgsg(debug):   glslf
:display:gsg:glgsg(debug): Cg GLSL version = CG_GL_GLSL_120
:display:gsg:glgsg(debug): Cg latest vertex profile = arbvp1
:display:gsg:glgsg(debug): Cg latest fragment profile = arbfp1
:display:gsg:glgsg(debug): Cg latest geometry profile = unknown
:display:gsg:glgsg(debug): Cg active vertex profile = glslv
:display:gsg:glgsg(debug): Cg active fragment profile = glslf
:display:gsg:glgsg(debug): Cg active geometry profile = unknown
:display:gsg:glgsg(error): Could not create a GLSL geometry shader.
``````

Edit : reformated log

Although I’m just a beginner myself when it comes to shaders, I did find two potential problems with your geometry shader.
To make it work for me, I changed the version to `#version 330` (a lower version may work too, I’m not too sure about that) and replaced `layout (points) in;` with `layout (triangles) in;` because I assume your plane model contains a GeomTriangles primitive instead of GeomPoints.

Do these changes make it work for you?

Yeah I tried the version trick but it gave me that error :

``````shaders/lentilleConvergente.vert:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES
``````

Replacing `points` with `triangles` doesn’t seem to have any effect.

ERROR: #version: geometry shaders require es profile with version 310 or non-es profile with version 150 or above
ERROR: 1 compilation errors. No code generated.

In other words, you need at least version 150 for geometry shaders. Shame that your driver does not produce a more descriptive error message. Perhaps we should detect this on the Panda end.

The debug output, however, tells us that your driver supports OpenGL 3.0. Geometry shaders were introduced in OpenGL 3.2. It also lists the `GL_ARB_geometry_shader4` and `GL_EXT_geometry_shader4` extensions as unsupported. You may want to update your drivers to see if it supports a more recent OpenGL version.

What you can try is setting `gl-version 3 2` in Config.prc. This forces Panda to request a core-only OpenGL profile, which disables the fixed-function pipeline (requiring shaders for all objects). Some older Mesa drivers do not support newer versions of OpenGL unless the fixed-function pipeline is disabled.

If that doesn’t work, and there are no newer drivers, you will likely have to do it without geometry shaders.

So thanks to you and to you from the past (OpenGL core profile) I added `gl-version 3 2` in the Config.prc file.

Then I added `#version 330 core` to my shaders.

Enabling `gl debug #t` in the Config.prc file allowed me to confirm that you’re suggestion about triangles instead of points was correct : It printed :

``````:display:gsg:glgsg(error): GL_INVALID_OPERATION in glDrawRangeElements(mode=GL_TRIANGLE_STRIP vs geometry shader input GL_POINTS)
``````

So there seem to be no errors left, it doesn’t display anything but I guess it’s because I’m dealing with triangles instead of points. I’m gonna read a bit about dealing with triangles, thank you all for your help !

1 Like