I’m doing per-pixel lighting with 3 passes per light: attenuation, diffuse and specular
I’m writting attenuation to the alpha of the frame buffer, then blending the next two passes with it adding them at the same time to whatever is already in the frame buffer…
Everything works fine when using point lights. I use a 2D radial map in two texture units. Then I compute the texCoords in a vertex program and use them like so:
Then in the combiners, the final computed alpha is: 1-(tex0+tex1)
Know I want to create a spotlight kind of attenuation. Looking at the equation of a cone, I noticed that both x and y depend on z.
I changed tex1 a little bit (by creating a spotligth form, a cone), and instead of oTex1.y = 0.5, changed it to oTex1.y = texCoords.x. This resulted that in the Y direction, the light still attenuates like a sphere, but in the X direction works fine.
I can solve this (I think, I haven’t tried) with another texture unit…
But am I missing something? Does it really need 3 texture units to make a spotlight kind of attenuation? I’m doing something wrong?
Hi. I am also working on it, but only per pixel attenuation + per pixel diffuse lighting. I have read nutty’s tutorial about per pixel diffuse lighting, which uses NV_register_combiners and NV_vp. I would like to convert it to use ARB_dot3 and ARB_vp extensions.
But something is wrong. The triangles that are not facing the light are lit as if they had reversed normals (-nx, -ny, -nz). Also some tris, that are facing the light at some weird angle, are not lit. And when I move camera, the instensity is changing as if it was specular lightig.
I am stuck. Is it possible that NV_rc DOT_3 function performs the calculations different than the ARB one?
Or have You seen some sample apps that do the thing using ARB-only extensions?