PDA

View Full Version : Fixed function in VP / FP



dbugger
06-30-2003, 04:17 AM
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

PanzerSchreck
06-30-2003, 04:32 AM
fragment.position

Tom Nuydens
06-30-2003, 04:38 AM
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

dbugger
06-30-2003, 05:49 AM
Thanks for your replies! I think I'm on track again http://www.opengl.org/discussion_boards/ubb/smile.gif, thanx Tom.
Btw, has anyone done standard ffp lighting on a per pixel level before? Can't find any demos.. http://www.opengl.org/discussion_boards/ubb/frown.gif Only those glossmapped, normalization cubemapped, bumpmapped, texturemapped one's http://www.opengl.org/discussion_boards/ubb/smile.gif
Thanks again.

Madoc
06-30-2003, 10:03 AM
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.

Korval
06-30-2003, 04:31 PM
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.