1
0
Fork 0

in shaders, get alpha directly from diffuse material value

Just like the fixed function pipeline


Author: Tim Moore <timoore@redhat.com>
This commit is contained in:
timoore 2009-11-17 06:23:21 +00:00
parent 1e5f8c2aee
commit ca82d06aef
4 changed files with 12 additions and 7 deletions

View file

@ -2,7 +2,7 @@
varying vec4 diffuse, ambient;
varying vec3 normal, lightDir, halfVector;
varying float fogCoord;
varying float fogCoord, alpha;
uniform sampler2D texture;
@ -24,6 +24,7 @@ void main()
color += gl_FrontMaterial.specular * gl_LightSource[0].specular
* pow(NdotHV, gl_FrontMaterial.shininess);
}
color.a = alpha;
texel = texture2D(texture, gl_TexCoord[0].st);
fragColor = color * texel;
fogFactor = exp(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord);

View file

@ -10,7 +10,7 @@
varying vec4 diffuse, ambient;
varying vec3 normal, lightDir, halfVector;
varying float fogCoord;
varying float fogCoord, alpha;
void main()
{
@ -21,6 +21,7 @@ void main()
lightDir = normalize(vec3(gl_LightSource[0].position));
halfVector = normalize(gl_LightSource[0].halfVector.xyz);
diffuse = gl_Color * gl_LightSource[0].diffuse;
alpha = gl_Color.a;
ambient = gl_Color * gl_LightSource[0].ambient;
ambient += gl_Color * gl_LightModel.ambient;
fogCoord = abs(ecPosition.z);

View file

@ -2,7 +2,7 @@
varying vec4 diffuse, constantColor;
varying vec3 normal, lightDir, halfVector;
varying float fogCoord;
varying float alpha, fogCoord;
uniform sampler2D texture;
@ -24,6 +24,7 @@ void main()
color += gl_FrontMaterial.specular * gl_LightSource[0].specular
* pow(NdotHV, gl_FrontMaterial.shininess);
}
color.a = alpha;
texel = texture2D(texture, gl_TexCoord[0].st);
fragColor = color * texel;
fogFactor = exp(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord);

View file

@ -10,18 +10,20 @@
varying vec4 diffuse, constantColor;
varying vec3 normal, lightDir, halfVector;
varying float fogCoord;
varying float alpha, fogCoord;
void main()
{
vec3 ecPosition = vec3(gl_ModelViewMatrix * gl_Vertex);
vec4 ecPosition = gl_ModelViewMatrix * gl_Vertex;
vec3 ecPosition3 = vec3(gl_ModelViewMatrix * gl_Vertex) / ecPosition.w;
gl_Position = ftransform();
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
normal = gl_NormalMatrix * gl_Normal;
lightDir = normalize(vec3(gl_LightSource[0].position));
halfVector = normalize(gl_LightSource[0].halfVector.xyz);
diffuse = gl_Color * gl_LightSource[0].diffuse;
constantColor = gl_FrontLightModelProduct.sceneColor
alpha = gl_Color.a;
constantColor = gl_FrontLightModelProduct.sceneColor
+ gl_FrontMaterial.ambient * gl_LightSource[0].ambient;
fogCoord = abs(ecPosition.z);
fogCoord = abs(ecPosition3.z);
}