i was wondering, in the per-pixel attanuation program that you can download from the nvidia site, the programmer makes use of two texture units, one for 2d and one for 1d, but why doing that when u can use the 2d texture as the 1d texture? i mean, the 1d texture is just the center line of pixels in the 2d texture isn’t it?
Not sure which demo you are talking about but I wrote a few of the ones dealing with per-pixel lighting.
If I understand you correctly, there is no reason why you can’t use the same texture for both the 1D and 2D lookup. To do the 1D lookup via the 2D texture, just use 0.5 for the value of either s or t every time.
So, since you can use a single 2D texture, why would you want to use a 1D texture in addition to a 2D one? First of all, even though you can use a single texture, it still has to be loaded by 2 texture units, and it may or may not be faster to use the 1D texture instead (I cant say for sure, this is hardware dependant). The reason I used the separate texture is that it is just more natural to what you are trying to do, and it makes things a little more clear to the person trying to figure out what you are doing. To be honest, Im not sure the idea of using the 2D texture to perform the 1D lookup ever crossed my mind. When I got to optimizing things, I was a little more concerened with simplifying things to only use 1 texture unit rather than 2 (which makes the 1D vs 2D issue irrelivant in such a case). It turns out if you have the tangent space light vector available, you can simplify the calculation down to a single 2D texture lookup. If you are interested how I did so, check out my site
and look at “Advanced Per-Pixel Lighting and Shadowing”.
And just to clarify after reading the title of your thread (“per-pixel point light using one tex unit”), realize that even though what you are suggesting uses the same texture for both lookups, it still requires 2 texture units for the calculation. It just happens that both texture units share the same texture.
yes, you are right, i understand it better now, but isnt it possible to change the combiners configuration somehow, in the middle of the process to make use of only one texture unit? it just a little idea, and i havnt really thought about it yet, and if we are talking about this, maybe you could explain me a little bit further about how to use more than one omni light in a scence?
No, as things stand it is impossible to change the tex unit mid process, and is probably unlikely to change because I’m pretty sure the texture lookup takes considerably longer than the entire register combiner pipeline takes to execute.
ok, i think i perfectly unederstand you now, thnx.