Original Post
So what is the best way for calculating light attentuation using the least textures units and gpu instructions? I have read some about it and this is what I have come up with so far: as a forumla A = d^2 / R^2 is used, A being attenuation, d distance to light and R radius of light (where A is 0). This can be formulated as: A = l.x^2 / R^2 + l.y^2 / R^2 + l.z^2 / R^2 l being light pos set to normal/tanget space. And if you set R' to 1 and l' to l/R you get A = l'.x^2 + l'.y^2 + l'.z^2 In the fragment shader you can now use the function: A = 1- ( (max(l'.x^2,1) + max(l'.y^2,1) + max(l'.z^2,1)) or use a 3d texture or a 2d and a 1d and end up with: A = tex2d(l'.x, l'.y) - tex1d(l'z) or A = tex3d(l'.x, l'.y, l'z) Using the 3d texture it can be done using only one texture unit and very few instructions. However a 3d texture is quite mem consuming and might have to have to low resolution. Using a 2D and 1D texture the resolution can be inscreased but one more texture unit are used. Are there any other better ways of doing this? I am trying to make this fit at least Gf3 and hopefully Gf2.