// en.wikibooks.org/wiki/GLSL_Programming/Blender/Lighting_of_Bumpy_Surfaces// by Ferret#define NUM_LIGHTS 2varying mat3 localSurface2View;varying vec4 texCoords;varying vec4 lmCoords;varying vec4 position;uniform vec3 emission;uniform float attspec;uniform sampler2D colorMap;uniform sampler2D normalMap;uniform sampler2D lightMap;uniform vec3 fogColor;uniform float lightningshaderintensity;uniform float torchintensity;uniform int active;void main(){ vec4 encodedNormal = texture2D(normalMap, vec2(texCoords)); vec4 base = texture2D(colorMap, vec2(texCoords)); vec4 lm = texture2D(lightMap, vec2(lmCoords)); //lm *= 2.0; vec3 localCoords = normalize(vec3(2.0, 2.0, 1.0) * vec3(encodedNormal) - vec3(1.0, 1.0, 0.0)); vec3 normalDirection = normalize(localSurface2View * localCoords); vec3 viewDirection = -normalize(vec3(position)); vec3 lightDirection; float attenuation; vec3 totalLighting = (vec3(gl_LightModel.ambient) * emission); for (int i = 0;i < NUM_LIGHTS;i++) { if (0.0 == gl_LightSource[i].position.w) { attenuation = 1.0; lightDirection = normalize(vec3(gl_LightSource[i].position)); } else // point light or spotlight (or other kind of light) { vec3 positionToLightSource = vec3(gl_LightSource[i].position - position); float distance = length(positionToLightSource); float lightdist = gl_LightSource[i].constantAttenuation + (gl_LightSource[i].linearAttenuation * distance) + (gl_LightSource[i].quadraticAttenuation * sqrt(distance)); attenuation = 1.0 / lightdist; lightDirection = normalize(positionToLightSource); if (gl_LightSource[i].spotCutoff <= 90.0) { float clampedCosine = max(0.0, dot(-lightDirection, gl_LightSource[i].spotDirection)); if (clampedCosine < gl_LightSource[i].spotCosCutoff) { attenuation = 0.0; } else { attenuation = attenuation * pow(clampedCosine, gl_LightSource[i].spotExponent); } } } vec3 ambientLighting = ((vec3(gl_LightModel.ambient) * emission) + lm); vec3 diffuseReflection = attenuation * vec3(gl_LightSource[i].diffuse) * emission * max(0.0, dot(normalDirection, lightDirection)); vec3 specularReflection; if (dot(normalDirection, lightDirection) < 0.0) { specularReflection = vec3(0.0, 0.0, 0.0); } else { specularReflection = vec3(attenuation * attspec) * vec3(gl_LightSource[i].specular) * vec3(gl_FrontMaterial.specular) * pow(max(0.0, dot(reflect(-lightDirection, normalDirection), viewDirection)), gl_FrontMaterial.shininess); } totalLighting += (ambientLighting * vec3(base) + diffuseReflection * vec3(base) + specularReflection) * (1.0 / NUM_LIGHTS); } // fog float dist = distance(position, vec4(0.0, 0.0, 0.0, 1.0)); float density = (dist / 500.0) * 0.5; const float e = 2.71828; float fogFactor = (density * gl_FragCoord.z); fogFactor *= fogFactor; fogFactor = clamp(pow(e, -fogFactor), 0.0, 1.0); totalLighting = mix(fogColor, totalLighting, fogFactor); //totalLighting = vec3(lm.r, lm.g, lm.b); // lightning strike if (lightningshaderintensity > 0.0) { float luminance = 0.2126 * totalLighting.r + 0.7152 * totalLighting.g + 0.0722 * totalLighting.b; totalLighting.r = max(totalLighting.r, luminance * lightningshaderintensity*(2.0*fogFactor)); totalLighting.g = max(totalLighting.g, luminance * lightningshaderintensity*(2.0*fogFactor)); totalLighting.b = max(totalLighting.b, luminance * lightningshaderintensity*(2.0*fogFactor)); //if (totalLighting.r < 0.05) totalLighting.r = lightningshaderintensity; //if (totalLighting.g < 0.05) totalLighting.g = lightningshaderintensity; //if (totalLighting.b < 0.05) totalLighting.b = lightningshaderintensity; } // switch: No bumpmapping if (active == 0) { totalLighting = base * lm; } gl_FragColor = vec4(totalLighting*torchintensity, base.a);}

I'm not up to date in my 3d graphics experience but that looks ridiculously good! Can't really believe it's Openb3d. I'll try to find that Linepick bug.