[osg-users] using modern shaders with osg - setting vertex attribute layout
antiro black
antiro42 at gmail.com
Fri Sep 1 03:56:14 PDT 2017
Hi Sebastian,
I was under the impression that the "layout(...) in ..." command was essentially a variable declaration and that hence only the location and type needed to match. I now also changed the name, this does not seem to have any effect though..
new vertex shader code:
Code:
#version 330 core
layout(location = 0) in vec4 osg_Vertex;
layout(location = 1) in vec3 osg_Normal;
layout(location = 2) in vec4 osg_Color;
layout(location = 3)in vec4 osg_MultiTexCoord0;
layout(location = 4)in vec4 osg_MultiTexCoord1;
layout(location = 5)in vec4 osg_MultiTexCoord2;
layout(location = 6)in vec4 osg_MultiTexCoord3;
layout(location = 7)in vec4 osg_MultiTexCoord4;
layout(location = 8)in vec4 osg_MultiTexCoord5;
layout(location = 9)in vec4 osg_MultiTexCoord6;
layout(location = 10)in vec4 osg_MultiTexCoord7;
out vec3 Normal;
out vec2 TexCoords;
out vec3 WorldPos;
uniform mat4 osg_ModelViewMatrix;
uniform mat3 osg_NormalMatrix;
uniform mat4 osg_ProjectionMatrix;
void main()
{
gl_Position = osg_ProjectionMatrix * osg_ModelViewMatrix * osg_Vertex;
WorldPos = (osg_ModelViewMatrix * osg_Vertex).xyz;
Normal = osg_NormalMatrix * osg_Normal;
TexCoords = osg_MultiTexCoord0.xy;
}
If I use the shader without the UseVertexAttributeAliasing enabled I see red silhouettes for the different models, when looking at the normals texture output (as if all normals are <1,0,0> ), which I expect is caused by the shader reading wrong on unitialized attributes.
with UseVertexAttributeAliasing enabled I get no output.
Thank you!
Cheers,
antiro
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=71588#71588
More information about the osg-users
mailing list