Page 1 of 1

GLSL 1.4 and vertex attributes

Posted: Fri Apr 16, 2010 9:36 am
by dircooles
hi everyone,

i'm currently getting familar with irrlicht, but i still wonder whether or how irrlicht might support GLSL 1.4 or 1.5 (without compatibility mode).

my problem is, that i need to employ sampler2DArray and other features only available in GLSL versions > 1.2. and in pure GLSL 1.4 for instance, the "old fashioned" way to interact with the shader using varying, gl_TexCoord, etc. has been abandoned respectively replaced by the in and out qualifiers in GLSL.

for example, the "old" way using vertex color in GLSL vertex shaders was like

Code: Select all

#version 120

varying vec4 vertexColor;    // to be passed to fragment shader

main()
{
    ...
    vertexColor = gl_Color;
    ...
}
using access to the fixed-function pipeline variable gl_Color. with version 1.4 it should be something like this:

Code: Select all

#version 140

in vec4 vertexPos;
in vec3 vertexNormal;
in vec4 vertexColor;

out vec4 color;    // to be passed to fragment shader

main()
{
    ...
    color = vertexColor;
    ...
}
the "in" qulified variable now have to be bound with the apropriate vertex attributes. is irrlicht already capable of doing this? or are there currently any efforts to make irrlicht support this?

thanks for your replies and my applogies if this should not be the correct forum.[/code]

Posted: Fri Apr 16, 2010 4:27 pm
by hybrid
I'll move this to advanced section, because it's not a thing that everybody deals with :wink:
I don't think that this is supported in Irrlicht so far, but it could be easily added. You could have a look at COpenGLSLMaterialRenderer and check if you can add the necessary stuff in there on your own. Otherwise you have to wait until someone takes a look. Maybe also raise a feature request on our tracker.

Posted: Sat Apr 17, 2010 12:58 am
by Nadro
It require native OpenGL 3.x support. I'm very close finish preview version of OpenGL 3.x driver for Irrlicht. More info will be avaiable in this topic soon:
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=35135

Posted: Mon Apr 19, 2010 7:08 am
by dircooles
hi,

thanks for your replies and hints.

the reason why i have not already started implementing GLSL 1.4 support myself is because i would not like to create my own "branch" (in svn terms) of irrlicht, for i am quite sure that there will be some official and useful updates in irrlicht, which might conflict with my own implementations if i start changing the source. in that case, i would probably have to re-write a lot.

but i think, i'm going to implement my own COpenGLSLMaterialRenderer (maybe by inheriting from the original one) and see what happens.

@Nadro: i agree with you. the vertex format in irrlicht lacks flexibility. for instance, i could make use of a third texture-coordinate.

Re: GLSL 1.4 and vertex attributes

Posted: Wed Jan 31, 2018 11:49 am
by kklouzal
Are vertex attributes still not a thing?

Re: GLSL 1.4 and vertex attributes

Posted: Wed Jan 31, 2018 1:52 pm
by devsh
Both yes and no, this is because the meshes and everything are hardcoded to use one of 3 S3DVertex* structs.

Compatibility mode gl_Vertex, gl_Normal, gl_Color, gl_TexCoord[n] alias to generic vertex attribute slots 0,3,2 and some other mapping for texcoords.

You can use a layout qualifier (we use this everywhere in the engine to cut down on behind-the-scenes OpenGL code) in the vertex shader on your "in" variable to assign the attribute slot.