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!
GLSL version 3 and 4
Re: GLSL version 3 and 4
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).
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: GLSL version 3 and 4
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`.
- 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
Thanks, your replies is very clear and detailed!
Have a nice day!
Have a nice day!