nuclear@0: uniform sampler2D tex; nuclear@0: nuclear@0: varying vec3 lpos, wpos, vpos, norm, ldir; nuclear@0: nuclear@0: #define KD gl_FrontMaterial.diffuse.rgb nuclear@0: #define KS gl_FrontMaterial.specular.rgb nuclear@0: #define LTCOL gl_LightSource[0].diffuse.rgb nuclear@0: nuclear@0: void main() nuclear@0: { nuclear@0: vec4 texel = texture2D(tex, gl_TexCoord[0].st); nuclear@0: nuclear@0: float dist = length(wpos.xz); nuclear@0: float spot = 1.0 - smoothstep(4.0, 10.0, dist); nuclear@0: nuclear@0: vec3 n = normalize(norm); nuclear@0: vec3 v = -normalize(vpos); nuclear@0: vec3 l = normalize(ldir); nuclear@0: vec3 h = normalize(v + l); nuclear@0: nuclear@0: float ndotl = max(dot(n, l), 0.0); nuclear@0: float ndoth = max(dot(n, h), 0.0); nuclear@0: nuclear@0: vec3 ambient = gl_LightModel.ambient.rgb * texel.rgb; nuclear@0: vec3 diffuse = KD * LTCOL * ndotl * texel.rgb; nuclear@0: vec3 specular = KS * LTCOL * pow(ndoth, gl_FrontMaterial.shininess); nuclear@0: nuclear@0: gl_FragColor.rgb = (ambient + diffuse + specular) * spot; nuclear@0: gl_FragColor.a = gl_FrontMaterial.diffuse.a * texel.a; nuclear@0: }