GLSL 1.4 and vertex attributes

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
dircooles
Posts: 5
Joined: Wed Mar 17, 2010 4:03 pm
Location: Münster, Germany

GLSL 1.4 and vertex attributes

Post 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]
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Post 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
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
dircooles
Posts: 5
Joined: Wed Mar 17, 2010 4:03 pm
Location: Münster, Germany

Post 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.
kklouzal
Posts: 343
Joined: Sun Mar 28, 2010 8:14 pm
Location: USA - Arizona

Re: GLSL 1.4 and vertex attributes

Post by kklouzal »

Are vertex attributes still not a thing?
Dream Big Or Go Home.
Help Me Help You.
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Re: GLSL 1.4 and vertex attributes

Post 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.
Post Reply