Shader issue

Hi,

I have the following fragment shader:


varying vec4 vColor;
varying vec2 vTexCoord;
 
//texture samplers
uniform sampler2D u_texture; //diffuse map
 
//additional parameters for the shader
uniform vec4 ambientColor;
 
void main() {
    vec4 diffuseColor = texture2D(u_texture, vTexCoord);
    vec3 ambient = ambientColor.rgb * ambientColor.a;
 
    vec3 final = vColor * diffuseColor.rgb * ambient;
    gl_FragColor = vec4(final, diffuseColor.a);
}

Very basic, works on my gaming pc and one of my laptops, but my other laptop with an AMD Radeon R7M260 I get the following error:

Ambient Shader: Fragment shader failed to compile with the following errors:
ERROR: 0:19: error(#162) Wrong operand types: no operation “" exists that takes a left-hand operand of type “default in highp 4-component vector of vec4” and a right operand of type “highp 3-component vector of vec3” (or there is no acceptable conversion)
ERROR: 0:19: error(#162) Wrong operand types: no operation "
” exists that takes a left-hand operand of type “default in highp 4-component vector of vec4” and a right operand of type “highp 3-component vector of vec3” (or there is no acceptable conversion)
ERROR: error(#273) 2 compilation errors. No code generated

Any help would be appreciated.

Thanks

You actually have an ‘error’, but the other drivers were just ignoring it. Simply take the [icode]vColor.rgb[/icode] to get the RGB components of your vColor. This way you have only vec3 multiplication.

Hi,

So would be this:

vec3 final = vColor.rgb * diffuseColor.rgb * ambient;

Thanks