Problem with shader code

Hi, I am having some issues with my shader code that I cant seem to figure out, It seems to work on computers that have integrated graphics cards, but not nvidia, slightly lost at why this is. The errors I am getting is

0(76) : error C7011: implicit cast from "vec4" to "vec3"
(0) : error C2003: incompatible options for link

But where It is indicated, the two variables that I am assuming it to be are both vec4's, the error seems to the on the last line of the code, at the return statement, but I do not understand why. I have only started to learn GLSL, the past few months, and it seems that errors arent always indicated where they should be, but I cant seems to see where else in the code this error would be coming from. Could anyone possibly point out where it could be coming from.

#version 330 core

out vec4 FragColor;

struct Material {
    sampler2D diffuse;
    sampler2D specular;    
    float shininess;

struct PointLight {
vec3 position;

float constant;
float linear;
float quadratic;

vec3 ambient;
vec3 diffuse;
vec3 specular;

in vec3 vertexPosition;
in vec3 norm;
in vec2 ex_TexCoord;

#define NR_POINT_LIGHTS 23

uniform PointLight pointLights[NR_POINT_LIGHTS];
uniform Material material;
uniform vec3 viewPos;

 vec4 result;

 vec3 CalcPointLight(PointLight light, vec3 viewDirection);

void main()
    // vec3 viewDirection = normalize(viewPos - vertexPosition);
    vec3 viewDirection = normalize(-vertexPosition);

  for(int i = 0; i < NR_POINT_LIGHTS; i++)
  result += CalcPointLight(pointLights[i], viewDirection); 

  FragColor = result;


 vec3 CalcPointLight (PointLight light, vec3 viewDirection)

 vec3 viewPosition = normalize (-vertexPosition).xyz;

 float att_distance = distance(vertexPosition, light.position);

 vec3 ambient = light.ambient * texture(material.diffuse, ex_TexCoord).rgb;

 vec3 lightPos = normalize(light.position - vertexPosition);	    //ex_L

 vec3 lightDir = normalize(-vertexPosition).xyz;     

 float diff = max(dot(normalize(norm),normalize(lightPos)), 0.0);
 vec3 diffuse = light.diffuse * diff * texture(material.diffuse, ex_TexCoord).rgb;  

 vec3 reflectDir = normalize(reflect(normalize(-lightPos),normalize(norm)));	                
 //float spec = pow(max(dot(lightDir, reflectDir), 0.0), material.shininess);

 float spec = pow(max(dot(reflectDir, viewPosition), 0.0), material.shininess);

  vec3 specular = light.specular * spec * texture(material.specular, ex_TexCoord).rgb;  

float ex_attenuation = 1.0f / (light.constant + light.linear * att_distance + 0.01 * att_distance * 

 result = vec4(ambient + diffuse * ex_attenuation, 1.0);

 return result;

You’re declaring result as a vec4, then returning it from CalcPointLight which is declared as returning a vec3.

oh that was a dumb mistake, thank you very much, i spent so long looking, and changing the variables and i never even looked at the function return type. Thank you very much

May I ask how you debug the shader code? Thanks

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.