Fixed function in VP / FP

Hi all!
What I’m trying to achieve is a simple per pixel point light using ARB vertex and fragment programs. The thing is that I just want the ordinary per vertex functionality but per fragment instead == no extra textures(bumpmap, glossmap etc.), or texcoords.
Now I got stuck on attenuation, how do I get the position of a fragment in the fp?

Thanks / David

fragment.position

No, fragment.position gives you the screen-space position (i.e. in viewport coordinates) and depth. What you should do is write the world-space or eye-space position (depending on where you want to do your lighting) to an unused register in your vertex program, and read it back from there in your fragment program.

– Tom

Thanks for your replies! I think I’m on track again , thanx Tom.
Btw, has anyone done standard ffp lighting on a per pixel level before? Can’t find any demos… Only those glossmapped, normalization cubemapped, bumpmapped, texturemapped one’s
Thanks again.

I’ve done something of the sort. It’s pretty simple really. Assuming you know what the OGL lighting equation looks like, moving it to vertex and fragment programs is easy and there are quite a few ways of implementing it. Theres’s also a lot of space for trading accuracy/quality for perf.
I believe Humus has quite a complete article on doing per pixel lighting, you might want to look at that.

Btw, has anyone done standard ffp lighting on a per pixel level before? Only those glossmapped, normalization cubemapped, bumpmapped, texturemapped one’s

Really, it isn’t that different, if you looked at what they are doing. Bump map demos are simply altering the normal per-pixel. As such, they must already have some concept of where the normal is. Simply change the shader so that it doesn’t get any value from a bump map. Essentially, you’re making a flat bump map texture.

Oh, and you’re going to need a normalization of some kind, either in code or via a texture.

Just do some research on how bump mapping is done, then take out the bumps.