Basically what i want to do is check wether a pixel is facing the camera or not. If the pixel is directly facing the camera, then i want to color it completely black. When it's 90 degrees rotated, then it should have full transparency.
I guess i have all the needed stuff in my vertex shader:
varying vec3 Normal;
varying vec3 EyeDir;
varying vec4 EyePos;
void main(void)
{
gl_Position = ftransform();
Normal = normalize(gl_NormalMatrix * gl_Normal);
vec4 pos = gl_ModelViewMatrix * gl_Vertex;
EyeDir = pos.xyz;
EyePos = gl_ModelViewProjectionMatrix * gl_Vertex;
}
In my fragment shader i have two textures. One is just some random image and the other is completely black. I guess i have to "mix" them some how, depending on the position of the pixel. But i have no idea how to calculate that...
This is something i've tried, but didn't worked out as planned.
vec4 RefractionColor = texture2D(RefractionMap, index); // Apply the black material vec4 blackMat = texture2D(Black, gl_TexCoord[0].st); float shade = dot(normalize(EyeDir), normalize(Normal)); // Blend the textures RefractionColor = mix(blackMat, RefractionColor, shade); gl_FragColor = RefractionColor;
Anyone any idea how to do this..??






