[GLSL] Weird lighting and Bump-Mapping

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?

It doesn’t look like your shaders support texturing. I’d look into that before doing bumpmapping, because the general method for it passes another texture (the bump map) into the shader and uses that textures values as the normals for the lighting instead of the vertex/face normals.

Thanks for the reply, but the shader is only used once per-frame; to shade one quad the size of the screen. I only have to worry about textures when I draw stuff on top of the lighting.

Heres how I have it set up (Runs per frame):
There is two shader programs, one for the lights, and one for the blocks.

It binds the light shader
For each light:

  • it tells the light shader that there is a lightLocation, and a lightColor, through uniforms.
  • it renders a quad the size of the screen
  • Ends the loop for the lights

It binds the block shader
Then renders the block

So what I need is a way to do bump-mapping with the uniforms on the lights.