I'm wondering about the shader vs standard drawing performance. I'm doing a lighting system and I started to wander what is fastest method:
1.) Draw multiple times fullscreen textures
No shader at all. You have your scene and render it. If you want some special effects on your scene you render them again over the scene. Everything is in the texture and blending mode.
Example: you have a scene and want to light it with 3 big lights (large radius, large textures). You render the scene, that's one fullscreen draw. You render the 3 lights to offscreen texture to combine them, thats a couple of big resoulution draws. Finally render the light texture over the screen.. that's a 2nd fullscreen draw. So that's ~3 fullscreen draws.
My thoughts: seems kind of slow to render and change pixel output more then once, but since this is the primary thing graphic card are used for it could be faster then alternatives.
2. Use shader and scene data to only draw once, but calculate the color as if blended
So you wrote a fragment shader that has access to all lighting data, and instead of drawing the light you calculate the final color using data from original scene color and light position and distance.
Example: you send position, distance, strength?, color?, for all 3 lights in your scene to the vertex shader. Using your shader you render the scene, and the shader calculates the light intensity for each pixel by looping through all 3 lights and calculates lighting effect based on distance of pixel to every light source.
My thoughts: this sounds good when you think that you'll draw the scene only once as output, but then again you have to preform lots of additional calculations to get the final color, which is what happens when you drow the scene multiple times anyway, so this may be faster then method 1 as you don't mess around with other buffers in FBO (depth, stencil, ...) and opengl state.
So my question is really what is the fastest way to draw? Is it using shaders and multitextureing or just simply draw multiple times? Also.. if it's shaders, I wonder what operations (and how many) can you do before drawing normally starts being faster.. is it like 10 multiplications or more like 2 sqrt() or what?
Stuff like this are on my mind right now, can't shake em off
Please provide any insight if you have it or if someone has a performance benchmark for stuff like this a link would be great. Tnx all for being patient and reading all of this.