Use of keywords in/out in GLSL.

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
pandoragami
Posts: 226
Joined: Wed Jan 26, 2011 5:37 pm
Contact:

Use of keywords in/out in GLSL.

Post by pandoragami »

I'm looking at the tutorial on this page http://www.lighthouse3d.com/tutorials/g ... -examples/ where the geometry shader is given with variables/keywords called in and out.

Geometry shader

Code: Select all

#version 150
 
layout(triangles) in;
layout (triangle_strip, max_vertices=3) out;
 
in VertexData {
    vec2 texCoord;
    vec3 normal;
} VertexIn[3];
 
out VertexData {
    vec2 texCoord;
    vec3 normal;
} VertexOut;
 
 void main()
{
  for(int i = 0; i < gl_in.length(); i++)
  {
     // copy attributes
    gl_Position = gl_in[i].gl_Position;
    VertexOut.normal = VertexIn[i].normal;
    VertexOut.texCoord = VertexIn[i].texCoord;
 
    // done with the vertex
    EmitVertex();
  }
}
Vertex Shader

Code: Select all

 
#version 410
 
layout (std140) uniform Matrices {
    mat4 projModelViewMatrix;
    mat3 normalMatrix;
};
 
in vec3 position;
in vec3 normal;
in vec2 texCoord;
 
out VertexData {
    vec2 texCoord;
    vec3 normal;
} VertexOut;
 
void main()
{
    VertexOut.texCoord = texCoord;
    VertexOut.normal = normalize(normalMatrix * normal);    
    gl_Position = projModelViewMatrix * vec4(position, 1.0);
}
 

The basic question I have is how much information do I need to send from Irrlicht in order to use these "directives". Looking at the above code in the VS do I only specify

Code: Select all

in vec3 position;
in vec3 normal;
in vec2 texCoord;
from Irrlicht or do I need to pass the structs as well with the coordinates, etc?
Post Reply