nuclear@20: /* MRT assignments nuclear@35: * 0 - RGB: position, A: shininess nuclear@20: * 1 - RGB: normal nuclear@60: * 2 - RGB: diffuse color, A: shininess str. nuclear@60: * 3 - unused nuclear@20: */ nuclear@20: nuclear@20: uniform sampler2D tex_dif, tex_norm; nuclear@20: nuclear@35: varying vec3 pos, norm, tang; nuclear@35: nuclear@35: const float fog_start = 3.0; nuclear@35: const float fog_end = 6.0; nuclear@16: nuclear@16: void main() nuclear@16: { nuclear@20: vec3 n = normalize(norm); nuclear@35: vec3 t = normalize(tang); nuclear@35: vec3 b = cross(n, t); nuclear@35: nuclear@35: mat3 tbn_mat = mat3( nuclear@35: t.x, t.y, t.z, nuclear@35: b.x, b.y, b.z, nuclear@35: n.x, n.y, n.z); nuclear@35: nuclear@35: // grab normal from the normal map, remap it and transform it to view space nuclear@35: n = texture2D(tex_norm, gl_TexCoord[0].st).xyz * 2.0 - 1.0; nuclear@37: n = normalize(tbn_mat * n); nuclear@35: nuclear@35: float fog = clamp((fog_end + pos.z) / (fog_end - fog_start), 0.0, 1.0); nuclear@20: nuclear@16: vec4 texel = texture2D(tex_dif, gl_TexCoord[0].st); nuclear@35: vec3 diffuse = fog * (gl_FrontMaterial.diffuse * texel).xyz; nuclear@35: vec3 spec = fog * gl_FrontMaterial.specular.xyz; nuclear@20: float sstr = (spec.x + spec.y + spec.z) / 3.0; nuclear@20: nuclear@34: gl_FragData[0] = vec4(pos, gl_FrontMaterial.shininess); nuclear@35: gl_FragData[1] = vec4(n, 0.0); nuclear@20: gl_FragData[2] = vec4(diffuse, sstr); nuclear@33: //gl_FragData[3] = vec4(0.0, 0.0, 0.0, 0.0); nuclear@16: }