Hi Joel,

I wonder if it's osg::State that has been configured to covert
gl_ModelViewMatrix to osg_ModelViewMatrix in the shader, with
inserting of the required declaration of the osg_ModelViewMartrix.  If
osg::State is inserting this declaration you can either disable the
setUseModelViewAndProjectionUniforms(false), or just remove the
declaration in your own shader.

Robert.



On 30 March 2012 06:20, Joel Graff <[email protected]> wrote:
> Hello,
>
> I'm re-implementing some shader code and I've run into a problem I've not had 
> before.  That is, I'm switching on osg uniforms and vertex attributes for 
> shaders (testing GLSL 140), as it's laid out in the osgVertexAttributes 
> example, but it seems to only partly work.
>
> Here's the shader code:
>
> Vertex:
>
> Code:
>
> #version 140
>
> uniform mat3 osg_NormalMatrix;
> uniform mat4 osg_ModelViewProjectionMatrix;
> in vec3 osg_Normal;
> in vec4 osg_Vertex;
>
> out vec3 normal;
> void main()
> {
>        normal = normalize(osg_NormalMatrix * osg_Normal);
>    gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex; //ftransform();
> }
>
>
>
>
> Fragment:
>
> Code:
>
> #version 140
>
> vec4 color1;
> vec4 color2;
> vec4 color3;
> vec4 color4;
>
> in vec3 normal;
> out vec4 glFragColor;
>
> void main()
> {
>        color1 = vec4( 1.0, 0.5, 0.5, 1.0 );
>        color2 = vec4( 0.5, 0.2, 0.2, 1.0 );
>        color3 = vec4( 0.2, 0.1, 0.1, 1.0 );
>        color4 = vec4( 0.1, 0.05, 0.05, 1.0 );
>        vec4 light0 = vec4(0.0, 0.0, 0.0, 1.0);
>    float intensity = dot(vec3(light0), normal);
>    if (intensity > 0.95) glFragColor = color1;
>    else if (intensity > 0.5) glFragColor = color2;
>    else if (intensity > 0.25) glFragColor = color3;
>    else glFragColor = color4;
> }
>
>
>
>
> Error log:
>
> Code:
>
> glLinkProgram "" FAILED
> Program "" infoLog:
> Vertex info
> ------------
> 0(3) : warning C7555: 'attribute' is deprecated, use 'in/out' insetead
> 0(6) : error C1038: declaration of "osg_ModelViewProjectionMatrix" conflicts 
> with previous declaration at 0(2)
> 0(8) : error C1038: declaration of osg_Vertex conflicts with previous 
> declaration at 0(3)
>
>
>
>
> I've used GLSL 140+ successfully in the past (OSG 2.8.x / 2.9.x), though I 
> don't have that code any longer.  The error log makes no sense, suggesting 
> I'm declaring osg_ModelViewProjectionMatrix and osg_Vertex twice, with 
> meaningless line references.  Interestingly, the osg_NormalMatrix and 
> osg_Normal declarations generate no errors.
>
> Just to ensure it wasn't something I was doing, I modded osgVertexAttributes 
> to automatically load a model and apply the same GLSL 140 code - shader gen 
> was disabled.  I didn't change any of the NodeVisitor code.  Strangely 
> enough, I received a very similar error log for the vertex shader.
>
> The GLSL 140 code was modded from the original 120 in the beginner's guide.  
> Prior to enabling the osg uniforms and vertex attributes, I tested the 
> version 120 code and it worked just fine.
>
> Maybe I missed a CMake option when I built my 3.0.1 binaries?
>
> Thanks,
>
> Joel
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=46690#46690
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to