NinjasInMojang
NinjasInMojang

Reputation: 77

GLSL complex error: implict cast from vec4 to vec3

The unnecessary vec4() vec3() are only just to debug the problem.

Full errors:

0(36) : error C7011: implicit cast from "vec4" to "vec3"
0(36) : error C1035: assignment of incompatible types

Code:

#version 330

in vec2 pass_textureCoords;
in vec3 surfaceNormal;
in vec3 toLightVector;
in vec3 toCameraVector;
in vec3 visibility;

out vec4 out_Color;

uniform sampler2D textureSampler;
uniform vec3 lightColor;
uniform float shineDamper;
uniform float reflectivity;
uniform vec3 skyColor;

void main(void) {

    vec3 unitNormal = normalize(surfaceNormal);
    vec3 unitLightVector = normalize(toLightVector);

    float nDotl = dot(unitNormal, unitLightVector);
    float brightness = max(nDotl, 0.2);
    vec3 diffuse = brightness * lightColor;

    vec3 unitVectorCameraVector = normalize(toCameraVector);
    vec3 lightDirection = -unitLightVector;
    vec3 reflectedLightDirection = reflect(lightDirection, unitNormal);

    float specularFactor = dot(reflectedLightDirection, unitVectorCameraVector);
    specularFactor = max(specularFactor, 0.0);
    float dampedFactor = pow(specularFactor, shineDamper);
    vec3 finalSpecular = dampedFactor * reflectivity *lightColor;

    out_Color = vec4(diffuse, 1.0) * texture(textureSampler, pass_textureCoords) + vec4(finalSpecular, 1.0);
    out_Color = mix(vec4(skyColor, 1.0), vec4(out_Color), visibility);
}

Upvotes: 1

Views: 1190

Answers (1)

NinjasInMojang
NinjasInMojang

Reputation: 77

The problem is that you're using vec3 as third argument into mix(). Which is not correct, as it can be only same type as other arguments' type: vec4() or use primitive type.

Upvotes: 3

Related Questions