Hybrid View

Shader - Using gl_LightModel.ambient => no alpha (transparency)

I'm trying to replicate fixed functionality for directional lighting in a fragment shader.
My opengl code uses glColor and glColorMaterial.
I have some double sided transparent faces (same color on the 2 sides).

It works well except when using gl_LightModel.ambient : in this case "transparent" faces are almost entirely opaque or opaque.
Here is the ambient calculation (fragment shader) :
vec4 Iamb = gl_LightModel.ambient * gl_FrontMaterial.ambient + gl_LightSource[0].ambient * gl_FrontMaterial.ambient;

So I added this in my code : Iamb.a = gl_FrontMaterial.diffuse.a;
And it works well.

I have also tried to add this at the end : gl_FragColor.a = gl_FrontMaterial.diffuse.a;
I gives another "good" result. (not the same as previously - the specular light is different not the transparency)

How to compute the alpha component to have the correct result (same as with the fixed functions) ?