GLSL version 3 and 4

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
cosmo
Posts: 17
Joined: Sat May 06, 2017 1:29 pm

GLSL version 3 and 4

Post 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!
CuteAlien
Admin
Posts: 9646
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: GLSL version 3 and 4

Post 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).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Re: GLSL version 3 and 4

Post 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`.
cosmo
Posts: 17
Joined: Sat May 06, 2017 1:29 pm

Re: GLSL version 3 and 4

Post by cosmo »

Thanks, your replies is very clear and detailed!
Have a nice day!
Post Reply