[osg-users] using modern shaders with osg - setting vertex attribute layout

antiro black antiro42 at gmail.com
Fri Sep 1 02:31:11 PDT 2017


Hi,

I am converting a project written in pure opengl to use OSG to improve compatibility and reduce maintenance.  The original project used a deferred rendering pipeline with a pretty big set of custom shaders. I would like to reuse these shaders with minimum adjustments.

In order to do this I want to use the same uniform names and the same layout for the VAO. I figured out that I can add callbacks to set the ModelView / Projection / etc matrices to uniforms with the same names as used in in the shaders, so that is taken care of. 

I do however not know how to specify the vertex attribute layout. My shaders all start with the following:
#version 330 core //so can't use gl_Normal etc
layout(location = 0) in vec3 position
layout(location = 1) in vec3 normal
layout(location = 2) in vec2 texCoords
layout(location = ....

I'm currently just using osgDB::readNodeFile() to read in the geometry and I'm assuming I need to do something more sophisticated to control how the vertex attributes are organized, but have been unable to figure out what.

If anyone could point me in the right direction, that would be most helpful!


Thank you!

Cheers,
antiro

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=71584#71584







More information about the osg-users mailing list