Hi,

I have a problem when I apply a shader to an object in osg. I tried it on two 
machines. One with an intel G41 graphics card, which does not give me any 
problem, and the other is a NVidia GTX 480, which gives me the problem. When 
osg try to compile the shader, skip the following error:

FRAGMENT glCompileShader "" FAILED
VERTEX glCompileShader "" FAILED
glLinkProgram "" FAILED
Error: In Texture::Extensions::setupGLExtensions(..) OpenGL version test 
failed, requires valid graphics context.

Vertex program:

Code:

uniform mat4 boneMatrices[2];

attribute vec4 weights;
attribute vec4 matrixIndices;
attribute float numBones;

varying vec2 Texcoord;
varying vec3 ViewDirection;
varying vec3 LightDirection;
varying vec3 Normal;

void main( void )
{    
    vec4 normal      = vec4( gl_Normal.xyz, 0.0 );
    vec4 tempPosition    = vec4( 0.0, 0.0, 0.0, 0.0 );
    vec4 tempNormal  = vec4( 0.0, 0.0, 0.0, 0.0 );
    for(int i = 0; i < int(numBones); i++  )
    {
        // Apply influence of bone i
        tempPosition += vec4((boneMatrices[int(matrixIndices[i])] * 
gl_Vertex).xyz,1.0) * weights[i];

        // Transform normal by bone i
        tempNormal += (boneMatrices[int(matrixIndices[i])] * normal) * 
weights[i];
    }
    
    gl_Position = gl_ModelViewProjectionMatrix * tempPosition;
    Texcoord    = gl_MultiTexCoord0.xy;
    
    vec4 fvObjectPosition =  gl_ModelViewMatrix * gl_Vertex;
   
    ViewDirection  = normalize(-fvObjectPosition.xyz);
    LightDirection = normalize(gl_LightSource[0].position.xyz - 
fvObjectPosition.xyz);
    Normal         = normalize(gl_NormalMatrix * tempNormal.xyz);
}



Fragment program:

Code:

uniform sampler2D baseMap;

varying vec3 ViewDirection;
varying vec3 LightDirection;
varying vec3 Normal;
varying vec2 Texcoord;

void main( void )
{
    float NdotL = max(dot(Normal, LightDirection), 0.0);
    vec4 diffuse = NdotL * gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse;

    vec4 ambient = gl_FrontMaterial.ambient * gl_LightSource[0].ambient;
    vec4 globalAmbient = gl_LightModel.ambient * gl_FrontMaterial.ambient;

    vec3  fvReflection     = normalize( ( ( 2.0 * Normal ) * NdotL ) - 
LightDirection ); 
    float fRDotV           = max( 0.0, dot( fvReflection, ViewDirection ) );
    vec4 specular = gl_FrontMaterial.specular * gl_LightSource[0].specular * 
pow(fRDotV,200.0);

    vec4 color =  diffuse + globalAmbient + ambient + specular;
    
    gl_FragColor = texture2D( baseMap, Texcoord ) * color;        
}



I fail to understand what may be the problem... any idea?

Thank you!

Cheers,
Aitor

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





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to