Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: error C5060: out can't be used with non-varying color

Threaded View

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2013
    Posts
    4

    error C5060: out can't be used with non-varying color

    Hello.
    Does anyone know why for shaders like...

    Vertex.shader: (recompiled 32 times with difference NUM_LIGHTS for multiple lights)
    Code :
    #version 330 core
     
    layout(location = 0) in vec3 vertexPosition;
    layout(location = 1) in vec3 vertexNormal;
    layout(location = 2) in vec2 vertexTexcoord;
     
    out vec3 gouraud;
    out vec2 texcoord;
     
    uniform mat4 pMatrix; // projection matrix
    uniform mat4 vMatrix; // view matrix
    uniform mat4 mMatrix; // model matrix
    uniform mat3 nMatrix; // mMatrix -> inverted and transposed
     
    #define NUM_LIGHTS 32
    struct Light {
     
    	vec3 ambient;
    	vec3 diffuse;
    	vec3 specular;
    	vec4 position; // w == 0 -> directional
    	vec4 attenuation;
     
    };
    uniform Light lights[NUM_LIGHTS];
     
    struct Material {
     
    	vec3 ambient;
    	vec3 diffuse;
    	vec3 specular;
    	float shininess;
     
    };
    uniform Material material;
     
    void main() {
     
    	vec4 position = vec4(vertexPosition, 1.0);
     
    	vec3 vertex = vec3(mMatrix * position); // vertex in model space
    	vec3 normal = normalize(nMatrix * vertexNormal); // normal in model space
     
    	vec3 finalColor = vec3(0.0, 0.0, 0.0); // phong result
     
    	for(int i = 0; i < NUM_LIGHTS; ++i) {
     
    		if(lights[i].position.w == 0.0) { // directional light
     
    			vec3 lightDirection = normalize(lights[i].position.xyz);
     
    			vec3 N = normalize(normal); // normalize because normal will be interpolated (possible not unit vector)
    			vec3 E = normalize(-vertex);
    			vec3 R = normalize(-reflect(lightDirection, N));
     
    			finalColor += lights[i].ambient; // * material.ambient; // ambient
     
    			float lambert = max(dot(N, lightDirection), 0.0);
     
    			if(lambert > 0.0) {
     
    				finalColor += lights[i].diffuse * material.diffuse * lambert; // diffuse
     
    				float specular = pow(max(0.0, dot(reflect(-lightDirection, N), E)), material.shininess);
    				finalColor += lights[i].specular * material.specular * clamp(specular, 0.0, 1.0); // specular
     
    			}
     
    		}
    		else { // point light
     
    			vec3 lightDirection = lights[i].position.xyz - vertex;
     
    			float lightDistance = length(lightDirection);
     
    			lightDirection = normalize(lightDirection);
     
    			float attenuation = 1.0;
    			if(lights[i].attenuation[0] != 0.0) { // attenuation based on light radius
     
    				attenuation = smoothstep(lights[i].attenuation[0], 0.0, lightDistance);
     
    			}
    			else { // attenuation based on distance
     
    				attenuation = clamp(1.0 /
    								   (lights[i].attenuation[1]				 +
    									lights[i].attenuation[2] * lightDistance +
    									lights[i].attenuation[3] * pow(lightDistance, 2)), 0.0, 1.0);
     
    			}
     
    			finalColor += lights[i].ambient * material.ambient;
     
    			vec3 N = normalize(normal); // normalize because normal will be interpolated (possible not unit vector)
    			float lambert = max(dot(N, lightDirection), 0.0);
     
    			if(lambert > 0.0) {
     
    				finalColor += lights[i].diffuse * material.diffuse * lambert * attenuation; // diffuse
     
    				vec3 E = normalize(-vertex);
    				vec3 R = normalize(-reflect(lightDirection, N));
     
    				float specular = pow(max(0.0, dot(reflect(-lightDirection, N), E)), material.shininess);
    				finalColor += lights[i].specular * material.specular * clamp(specular, 0.0, 1.0) * attenuation; // specular
     
    			}
     
    		}
     
    	}
     
    	gouraud = finalColor;
    	texcoord = vertexTexcoord;
     
    	gl_Position = pMatrix * vMatrix * mMatrix * position;
     
    }

    Fragment.shader:
    Code :
    #version 330 core
     
    in vec3 gouraud;
    in vec2 texcoord;
     
    out vec3 color;
     
    uniform sampler2D diffuseMap;
     
    void main() {
     
    	// color = gouraud * texture(diffuseMap, texcoord).rgb; on 8600GT i have to change texture to texture2D
            color = gouraud * texture2D(diffuseMap, texcoord).rgb;
     
    }

    These shaders are working on intel hd 2500 but aren't working on nVidia GeForce 8600GT and nVidia 710m..
    Log output is: error C5060: out can't be used with non-varying color

    But these shader are compiled correctly on GeForce 8600GT and 710m:
    Vertex.shader:
    Code :
    #version 330 core
     
    layout(location = 0) in vec3 vertexPosition;
     
    uniform mat4 pMatrix;
    uniform mat4 vMatrix;
    uniform mat4 mMatrix;
     
    void main() {
     
    	gl_Position = pMatrix * vMatrix * mMatrix * vec4(vertexPosition, 1.0);
     
    }

    Fragment.shader:
    Code :
    #version 330 core
     
    out vec3 color;
     
    uniform vec3 pickColor;
     
    void main() {
     
    	color = pickColor;
     
    }

    What is going on?!
    GeForce 8600GT is running on Linux.
    nVidia 710m is running on Windows.

    Help :/
    Last edited by GreyMist; 11-17-2013 at 07:51 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •