PDA

View Full Version : non uniform per-pixel lighting?



olddave
12-30-2004, 09:53 AM
Hi, I'm not sure if my subject heading used the correct terminology, but its basically what I want to try and accomplish.

I was reading the per-pixel lighting tutorial
by Ron Frazier, which is what I want to do, but it seems to assume some measure of uniformity among light intensity. What if I want to have varying degrees of intensity? For example I might want
to have a light that projects in non-circular patterns.

So in thinking about how I could get this to work, I thought that maybe I could use the same attenuation equations Frazier developed, but at selected vertices on my surface, scale these by some factor modeling how intense I want the light to be at that point.

Which leads to the question: At the fragment level how do you scale by a variable value? register combiners? fragment program?

Ofcourse, all the above could be nonsense, so I need some expert advice.

Thanks,
Dave

jwatte
12-30-2004, 12:01 PM
Assuming your hardware supports fragment programs (or fragment shaders in GLSL) then that's absolutely the easiest way to do it.

If you want per-pixel lighting, then you have to calculate the scaling value in the fragment program, too, as othewise you'll get vertex lit artefacts when the mesh gets close to the light source.

Of course, the easiest way to just get attenuation based on vector to light, is to put the light attenuation into a cube map, and modulate with that; you can interpolate vector from vertex to light as a texture coordinate over fragments without too much loss, so you don't need a framgment program just for this effect.

zed
12-30-2004, 02:58 PM
to have a light that projects in non-circular patterns.have a look at projected textures

olddave
12-30-2004, 04:00 PM
I need to be able to dynamically change the profile of the light. I dont think projective texture mapping will allow me to accomplish this.
Dave