Shader Problem (presumably)

I’m playing around with opengl and shading. Doing so I achieve some transparency effect which I cannot explain (see image).

I suspected normals at first, checked them in blender, event regenerated them, tried out everything in webgl using three.js and it looks all fine - as it should. So I believe what that tells me is that the problem is not related to normals.

Now using it in my opengl program with SDL and assimp to load the model I see through the teapot, bits that should be obscurred. I have depth test enabled also and played around with the shaders but to no avail.

My shaders are the kind that should do the job for ambient and diffuse light with a light source.
The teapot is just given any color and I don’t set the alpha channel to use transparency…

    #version 300 es
    in vec3 position;
    in vec3 normal;
    uniform mat4 model;
    uniform mat4 view;
    uniform mat4 projection;
    out vec3 norm;
    out vec3 pos;
    void main() {
        pos = vec3(model * vec4(position, 1.0)).xyz;
        gl_Position = projection * view * vec4(pos, 1.0);
        norm = normalize(mat3(transpose(inverse(model))) * normal);

and the fragment shader:

    #version 300 es
    #ifdef GL_ES
    precision highp float;
    in vec3 norm;
    in vec3 pos;
    uniform vec3 ambientLight;
    uniform vec3 objectColor;
    uniform vec3 sunDirection;
    uniform vec3 sunLightColor;
    out vec4 fragColor;
    void main() {
        vec3 lightDir = normalize(sunDirection - pos);
        float diff = max(dot(norm, lightDir), 0.0);
        vec3 diffuse = diff * sunLightColor;
        fragColor = normalize(vec4((ambientLight + diffuse) * objectColor, 1.0));

Any ideas from people who have experience with these sort of effects will be appreciated.

Hi waman
Fell across this post that may be usefull
failing depthtest

Carsten, thank you very much, I owe you :wink:

It wasn’t quite one of the issues described in that thread but definitely got me into the right direction.

Actually the mistake is rather embarrassing given what I expected… turns out I set my window system attributes such as the depth test prior to the creation of the GL context which did exactly nothing :roll_eyes: