HackerPoet / PySpace

GLSL Fractal Ray Marcher in Python
MIT License
1.16k stars 149 forks source link

Shader compilation failed #8

Closed suuuehgi closed 5 years ago

suuuehgi commented 5 years ago
> $ python ray_marcher_demo.py 
pygame 1.9.4
Hello from the pygame community. https://www.pygame.org/contribute.html
Compiling Vertex Shader...
b'0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, 3.00 ES, 3.10 ES, and 3.20 ES\n'
Traceback (most recent call last):
  File "ray_marcher_demo.py", line 253, in <module>
    program = shader.compile(camera)
  File "/tmp/PySpace/pyspace/shader.py", line 73, in compile
    program = self.compile_program(v_shader, f_shader)
  File "/tmp/PySpace/pyspace/shader.py", line 102, in compile_program
    vertex_shader = self.compile_shader(vertex_source, GL_VERTEX_SHADER)
  File "/tmp/PySpace/pyspace/shader.py", line 92, in compile_shader
    raise ValueError('Shader compilation failed')
ValueError: Shader compilation failed

Any idea how to fix this?

Thanks a lot!

eh8 commented 5 years ago

bump ^

HackerPoet commented 5 years ago

You would need to update your graphics driver to support GLSL 330 If this isn't available for your hardware, you'd have to port the shader to an older version.

suuuehgi commented 5 years ago

Thanks for the reply! I use the current driver version with Mesa 18.3.3 that should support GLSL 330 afaics.


EDIT:

> glxinfo | grep "core profile"
Max core profile version: 4.5
OpenGL core profile version string: 4.5 (Core Profile) Mesa 18.3.3
OpenGL core profile shading language version string: 4.50

Also changing the version to #version 320 es in pyspace/vert.glsl and pyspace/frag.glsl does not work.

flyingrub commented 5 years ago

same issue, also on archlinux.

jonfairbanks commented 5 years ago

Similar issue on a fresh install of Ubuntu 18.04

ghost commented 5 years ago

Same for me, on Arch Linux. And my Mesa version is 19.0.5 Also, i'd love to see this programm works on my computer, so, please, do something :pray:

HackerPoet commented 5 years ago

Is this still the same error message as before? error: GLSL 3.30 is not supported. It could be a problem with PyOpenGL not reading the version correctly...

suuuehgi commented 5 years ago

Is this still the same error message as before? (error: GLSL 3.30 is not supported.)

Yes:

> python3 ray_marcher_demo.py 
pygame 1.9.4
Hello from the pygame community. https://www.pygame.org/contribute.html
Compiling Vertex Shader...
b'0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, 3.00 ES, 3.10 ES, and 3.20 ES\n'
HackerPoet commented 5 years ago

I did some quick googling and found the same problem and a solution: https://gamedev.stackexchange.com/a/139240

Basically, pygame is built on SDL1, but there is a drop-in replacement ported to SDL2 that has support for gl_set_attribute to give a context hint with the version number before opening the window. The important lines to add are these:

import pygame_sdl2
pygame_sdl2.init()
pygame_sdl2.display.gl_set_attribute(pygame_sdl2.GL_CONTEXT_MAJOR_VERSION, 3)
pygame_sdl2.display.gl_set_attribute(pygame_sdl2.GL_CONTEXT_MINOR_VERSION, 3)

Let me know if this works for anyone.

HackerPoet commented 5 years ago

Actually ignore my last comment.

I decided to downgrade the GLSL requirement to 1.20 so this should not cause an error anymore (I did the same thing in Marble Marcher). The fix has been pushed in. I'll consider this issue closed now, but please open a new issue if there's any new problems.

suuuehgi commented 5 years ago

It works! Thanks a ton! (^-^)/