diff --git a/Effects/text-default.eff b/Effects/text-default.eff new file mode 100644 index 000000000..c943c9946 --- /dev/null +++ b/Effects/text-default.eff @@ -0,0 +1,23 @@ + + + Effects/text-default + + + true + + true + + transparent + + Shaders/text.vert + Shaders/text.frag + Shaders/include_fog.frag + + + glyphTexture + sampler-2d + 0 + + + + diff --git a/Shaders/text.frag b/Shaders/text.frag new file mode 100644 index 000000000..c3e8ae177 --- /dev/null +++ b/Shaders/text.frag @@ -0,0 +1,44 @@ +#version 120 + +uniform sampler2D glyphTexture; + +varying vec4 diffuse_term; +varying vec3 normal; +varying vec4 ecPosition; + +////fog "include" ///// +vec3 fog_Func(vec3 color, int type); +////////////////////// + +void main() +{ + float alpha = texture2D(glyphTexture, gl_TexCoord[0].st).a; + if (alpha == 0.0) discard; + + float NdotL, NdotHV, fogFactor; + vec4 color = gl_Color; + vec3 lightDir = gl_LightSource[0].position.xyz; + vec3 halfVector = gl_LightSource[0].halfVector.xyz; + vec4 fragColor; + vec4 specular = vec4(0.0); + + NdotL = dot(normal, lightDir); + if (NdotL > 0.0) { + color += diffuse_term * NdotL; + NdotHV = max(dot(normal, halfVector), 0.0); + if (gl_FrontMaterial.shininess > 0.0) + specular.rgb = (gl_FrontMaterial.specular.rgb + * gl_LightSource[0].specular.rgb + * pow(NdotHV, gl_FrontMaterial.shininess)); + } + // This shouldn't be necessary, but our lighting becomes very + // saturated. Clamping the color before modulating by the texture + // is closer to what the OpenGL fixed function pipeline does. + color = clamp(color, 0.0, 1.0); + + fragColor = color + specular; + fragColor = vec4(fragColor.rgb, fragColor.a * alpha); + + fragColor.rgb = fog_Func(fragColor.rgb, 0); + gl_FragColor = fragColor; +} diff --git a/Shaders/text.vert b/Shaders/text.vert new file mode 100644 index 000000000..dddfcbe7a --- /dev/null +++ b/Shaders/text.vert @@ -0,0 +1,16 @@ +#version 120 + +varying vec4 diffuse_term; +varying vec3 normal; +varying vec4 ecPosition; + +void main() +{ + gl_Position = ftransform(); + ecPosition = gl_ModelViewMatrix * gl_Vertex; + gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; + normal = gl_NormalMatrix * gl_Normal; + diffuse_term = gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse; + gl_FrontColor = gl_FrontMaterial.emission + gl_FrontMaterial.ambient * + (gl_LightModel.ambient + gl_LightSource[0].ambient); +}