[osg-users] Custom shader not working on Mac OS

Pierre-Jean Petitprez pierre-jean.petitprez at inria.fr
Thu Feb 18 07:15:37 PST 2016


Hi,

I try to port my app from Linux to Mac OS (El Capitan) using OSG 3.2.
I wrote a simple system of shaders to apply a texture on a model:

Vertex shader :

Code:

attribute vec4 osg_Vertex;
uniform mat4 osg_ModelViewProjectionMatrix;
varying vec4 texCoord0;

void main(void)
{
gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;
texCoord0 = gl_MultiTexCoord0;
}



Fragment shader :

Code:

uniform sampler2D tex;
varying vec4 texCoord0;

void main(void)
{
gl_FragColor = texture2D(tex, texCoord0.st);
}




While it works as expected on Linux, on Mac my model is not displayed at all (I only see the default blue background). There is no error from the shader compilation.
I use
viewer->getCamera()->getGraphicsContext()->getState()->setUseModelViewAndProjectionUniforms(true);
 to get the osg_* variables, and also
viewer->getCamera()->getGraphicsContext()->getState()->setUseVertexAttributeAliasing(false); 
to keep the fixed pipeline possibilities (for other models in my scene).

I saw a strange thing in the log : on Mac gl_MultiTexCoord0 is converted to  osg_MultiTexCoord0 even if setUseVertexAttributeAliasing is set to false. On Linux 
gl_MultiTexCoord0 is not converted and is keeped. 
By the way if I set setUseVertexAttributeAliasing to true and replace gl_MultiTexCoord0 by osg_MultiTexCoord0, my model is properly visible (but I don't want that because I lose fixed pipeline functions).

Has anybody an idea of where this behavior comes from ?

Thank you!

Cheers,
Pierre-Jean

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








More information about the osg-users mailing list