So I’ve implemented a lighting engine through GLSL, and it works flawlessly. But I wanted to add a bump-mapping system, only thing is its nothing like the GL_LIGHT system, and most of the tutorials are fitted to that.
How my light works is I make a Quad that takes the whole window, and acts as a canvas for the fragment shader that goes through the light positions, uniforms, and colors, then uses them to create colored lights.
pointLight.vs:
#version 120
uniform vec2 lightLocation;
uniform vec3 lightColor;
void main(void) {
float distance = length(lightLocation - gl_FragCoord.xy);
float attenuation = 1.0 / distance;
vec4 color = vec4(attenuation, attenuation, attenuation, pow(attenuation, 3)) * vec4(lightColor, 1);
gl_FragColor = color;
}
Steps to run it (basically):
For each light:
- Enable stencil buffer
- For each block:
-
- Calculate & render shadow to STENCIL BUFFER
- Disable stencil buffer
- Draw lighting (using pixel shader) where stencil is empty
For each block (again): - Draw block
I need a way to add bump-mapping to this kind of lighting, any suggestions?