nuclear@41: uniform sampler2D tex_dif, tex_norm; nuclear@41: nuclear@41: varying vec3 pos, norm, tang; nuclear@41: nuclear@41: const float fog_start = 3.0; nuclear@41: const float fog_end = 6.0; nuclear@41: nuclear@43: const vec3 lpos = vec3(0.0, 0.0, -0.5); nuclear@43: const vec3 vdir = vec3(0.0, 0.0, 1.0); nuclear@43: nuclear@43: const vec3 lcol = vec3(1.0, 0.732, 0.437); nuclear@43: nuclear@41: void main() nuclear@41: { nuclear@41: vec3 texel = texture2D(tex_dif, gl_TexCoord[0].st).xyz; nuclear@41: nuclear@41: vec3 n = normalize(norm); nuclear@41: vec3 t = normalize(tang); nuclear@41: vec3 b = cross(n, t); nuclear@41: nuclear@41: mat3 tbn_mat = mat3( nuclear@41: t.x, b.x, n.x, nuclear@41: t.y, b.y, n.y, nuclear@41: t.z, b.z, n.z); nuclear@41: nuclear@41: vec3 ldir = tbn_mat * normalize(lpos - pos); nuclear@41: vec3 hvec = normalize(vdir + ldir); nuclear@41: nuclear@41: n = normalize(texture2D(tex_norm, gl_TexCoord[0].st).xyz * 2.0 - 1.0); nuclear@41: float ndotl = max(dot(n, ldir), 0.0); nuclear@41: float ndoth = max(dot(n, hvec), 0.0); nuclear@41: nuclear@41: vec3 diffuse = gl_FrontMaterial.diffuse.xyz * texel * ndotl; nuclear@41: vec3 specular = gl_FrontMaterial.specular.xyz * pow(ndoth, gl_FrontMaterial.shininess); nuclear@41: nuclear@41: float fog = clamp((fog_end + pos.z) / (fog_end - fog_start), 0.0, 1.0); nuclear@41: nuclear@43: gl_FragColor = vec4((diffuse + specular) * lcol * fog, 1.0); nuclear@41: }