Page 1 of 1
GLSL version 3 and 4
Posted: Fri Jun 12, 2020 3:55 pm
by cosmo
Hi,
at present I'm experimenting a little bit with shader programming.
Searching on the Web, I noticed all examples are written using version 1.2.
But is it possible to write GLSL code (.vert and .frag) using OpenGL version 3.0 or 4.0, so that Irrlicht can compile and run the shader code without issue?
Thank you!
Re: GLSL version 3 and 4
Posted: Fri Jun 12, 2020 6:58 pm
by CuteAlien
Yes. You have to specify the version in the first line of the shader (nothing before it - not even comments) with the #version directive.
So for example:
#version 430 compatibility
More info here:
https://www.khronos.org/opengl/wiki/Cor ... age_(GLSL)
Note that this allows you to use different shader versions, but there is still another problem. That Irrlicht doesn't pass through all functions available for OpenGL. For example until devsh recently send us a patch we couldn't send uint constants, so people had to use int constants even though newer OpenGL supported those. So basically - new shaders are ok. But new OpenGL features are sometimes not possible (yet).
Re: GLSL version 3 and 4
Posted: Sat Jun 13, 2020 9:31 am
by devsh
You can use everything on the GLSL side you want, as long as it doesn't need to interface with extra C++ code, so things not supported by irrlicht are:
- SSBOs
- UBOs
- Certain dimensions of matrices being used as uniforms (and the tranpose option)
- Atomic Counter Buffers
- Transform Feedback
- Storage Images
- Tessellation Shaders
- Instanced Draws
- Multi Draw Indirect
- Compute Shaders
But by all means you can write `#version 3xx compatibility` or `#version 4xx core` on top of your shaders and do it appropriately.
You'll just need to treat vertex shader inputs and fragment shaders with the `layout(location=x) in/out` qualifier instead of `varying` or `gl_FragColor/gl_FragData`.
Re: GLSL version 3 and 4
Posted: Sat Jun 13, 2020 10:01 am
by cosmo
Thanks, your replies is very clear and detailed!
Have a nice day!