This idea has been rolling around in my head for a while now, and I wanted to get some serious discussion about it. I'm fairly certain its already been at least demo'd by somebody (Simpsons did it) but here it is anyway. I've thought of various additions to the method, but I'll describe the most crude. The idea is based on the concept that very few pixels on screen are affected by a large number of unique point lights; most are only affected by 2 or 3.
Using a standard 32 bit float4 buffer, I could do an initial draw pass rendering only light volumes. I can have up to 255 lights per channel in this buffer, representing a volume within the view frustum, say, the [nearplane .256] range. Based on the principle that most of the screen will have 4 or less lights per pixel, I can do a single pass here. This provides me with a map of which lights will affect which fragments.
I can then do a standard forward lighting pass. Directional lights can be drawn at this stage, and point lights can be determined from the buffer. Using the values within the light index buffer, I can do a set of texture lookups to determine the position, colour and radius of each light, which would require two texture lookups per light (in its simplest form there are 7 elements, 3 position, 3 colour, and 1 radius)
This crude version of the system has a few obvious problems which would need to be solved before it could be used. It does not actually attempt to detect if there are more than the expected 4 lights affecting each fragment of the light index buffer. If this is the case, there will be ugly artifacts. I'm not certain how I would detect the edge cases, which would require further passes to render.
The number of texture samplings could paralyse the geometry pass, although it would be fairly cheap point sampling.
However it also has an obvious advantage: many point lights for translucent geometry, a single draw pass, and far less graphics memory being required.
Are there any issues I have not considered here?
Don't thank me, thank the moon's gravitation pull! Post in My Journal and help me to not procrastinate!
1. Even if the technique works fine, it seems somewhat limited. I see one issue in , more or less, mutal exclusive requirements. You would only benefit from such a complex approach when using lot of lights, on the other hand, using more lights will increase the probabilty of using more than 4 lights per pixel.
2. When you want to support, lets say, 4 lights, you need 4 channels. But when rendering a surface, you don't know which channel has been used already. Either you predefine certain light to certain channels (more restrictions, more artifacts) or you need to read-back the buffer (buffer swapping whenever rendering a new light).
3. Artifacts will most probably occurre on pixel level (no surface/model context), that is, moving the camera could lead to nasty noisy artifacts.
The similarity to deferred lighting is great, but with high potential of artifacts and some really strong restrictions. At first it sounds good, but the danger of artifacts, which will destroy the visual illusion, is quite high. Thought the real killer argument could be 2..
Nevertheless, this is a nice research topic, maybe you can pull off some clever tricks to get it running. Good luck
I've known species for a while. I told him i was working on a deferred shading renderer and he said: "even i can write a deferred shader." not to say that you are writing a conventional deferred shader, as you explain. but my only two cents on the matter is to "try it."
Grab a copy of render monkey and plumb out your design. I'm not sure how the restriction of 4 got introduced, I think it was probably during the ambiguous moment where you make light contributions indexable per pixel, up to 256 indexes. when really you are limited to your rgb color packing capabilities into your render targets. which is probably 4.
all of this complication definitely seems like more of burden when you start to run asset conversion tools on your production content and realize you need hundreds of shader variations to make pix happy and so on. simplicity is definitely very favorable. i suggest a very traditional deferred shader.
A specific annoyance is that we have a terrain shader which lets you index up to 4 materials from a pallet and blend them into a result. It has terrible artifacts along the edges where pixels use slightly (or wildly) different material blend orders on the seam.
My light indexed renderer work like this: -during occlusion culling (software) I generate a low-res zbuffer -I cull all lightsources against this zbuffer -I draw all visible lightsources (based on the bounding sphere) as a bitmask into a low-res texture (I call it "tiled light index texture") -in the forward pass:
the ugly: -limited to 32lights for now, my light mask index had 32bit (I could also extend it to 64 or 128 if I'd use int4 as texture format) the good: - due to the culling (also for occlusion), I can quite a lot reduce the lights that need shadowmap generation - due to tiled handling of the indices, all shading is coherent for the HW, just like it is naturally working, no diverging branching, e.g. if a lightsource has shadows or falloff or... -for non transparent objects, I could actually create an optimized tiled light index texture that just includes lights that actually touch the surface, but for that purpose I'd have to generate a more accurate zbuffer, and as I was working on a mobile device, I did not really have the spare cpu cycles.
(ok, two lies, 1. my light count was limited to 12 for performance reasons, 2. the final system wasn't using this tech, as the scene was usually anyway covered by 1-5 big lights that were more effectively handled by a specialized shader for every combination, it was faster. all tiny lights were added deferred, not having proper specular etc. but they were too tiny to notice anyway).