Skip to main content
gamedev.net
🔒 Locked

Per Pixel Lighting

Started by LShad 6 replies 550+ views
Original Post
LShad
LShad
Hi everybody, I have a problem : Ive been trying to achieve simple point lighting in Direct3D using PPL WITHOUT shaders, but also without any success... and I hope ull be able to help me. Basically, I have a simple QUAD made of two triangle formed into a strip. What I want achieve is *simple* : light this quad like the nice screenshots we see on the NVIDIA docs. But I really dont know how to do it. Ive tried bump mapping and it works fine... even point light bump mapping works (by setting the light vector for each vertex into the vertex diffuse component). What I want to have so, is a sort of circle of light on my wall (because of the point light), but I definitely dont know which render states to use. For now, without talking about bump mapping, I only want a simple point light working. So, please, could anyone help me to achieve this "dream" by posting code or explaining how to do it, do i have to use attenuation maps to do this ? etc... I already googled it a thousand times and I know the nvidia docs by heart now Thanks a lot in advance, Sebastien.
Dirge
Dirge
Per-pixel lighting is impossible without pixel-shaders. That's because you need to use a normal map to calculate the light acted upon every pixel.

Why not project a light texture onto your quad? That would accomplish your goal.

"Love all, trust a few. Do wrong to none." - Shakespeare

Dirge - Aurelio Reis
www.CodeFortress.com
Current Causes:
Nissan sues Nissan

[edited by - Dirge on August 2, 2002 11:01:53 PM]
"Artificial Intelligence: the art of making computers that behave like the ones in movies."www.CodeFortress.com
Drilian
Drilian
Per-Pixel lighting is not IMPOSSIBLE without pixel shaders.

The GeForce2 had the capability to do it, and it had no shaders.

You don''t even need a pshader to do it NOW (But it helps). You just need to use the correct DOTPRODUCT3 texture state settings with a bump map.

The deal is, "per-pixel lighting" and "bump mapping" are one and the same. All you need is a constant 0, 0, 1 normal map (all normals point up from the texture) to do per-pixel lighting.

But you NEED that map if you''re not doing it with pixel shaders, because that''s the only way it''s going to get done :D

I hope this post made sense. I changed what I was trying to say halfway through (due to a correct second reading of the question), so hopefully I still made the right point :D
Dirge
Dirge
Geforce 2''s do have Vertex Shaders but only in software, you''re right, no pixel shaders though.

You''re right, I forgot that you can accomplish dot3 bump with just the correct normal/bump texture. I thought he meant something like phong shading or anistropic lighting though, in which case pixel shaders are the way to go.

"Love all, trust a few. Do wrong to none." - Shakespeare

Dirge - Aurelio Reis
www.CodeFortress.com
Current Causes:
Nissan sues Nissan
"Artificial Intelligence: the art of making computers that behave like the ones in movies."www.CodeFortress.com
LShad
LShad
Thanks for the replies everybody, but u didnt really answered my question : I correctly rendered a point light bump mapping effect by setting different light vectors in my vertices'' diffuse components. But the problem is that I dont see the light attenuation which should normally be there : look at the wall next to your computer.... yes this one. Imagine a fairy in the middle of it, it should make a "disc" of light on the wall. This is ONLY what I want to achieve for NOW. Please help me, Im about to squash my head onto my monitor :/
Bye,
Seb.
Dirge
Dirge
Hmm, the most I can give you is the light attenuation formula: attenuation = 1 / A0 + A1 * dL + A2 * dL * dL

Where Ax are the attenuation factors and dL is the light vector. Calculate this at every vert and it should work I suppose although I''m still not so keen on why you want to do this (well, in software). Goodluck!

"Love all, trust a few. Do wrong to none." - Shakespeare

Dirge - Aurelio Reis
www.CodeFortress.com
Current Causes:
Nissan sues Nissan
"Artificial Intelligence: the art of making computers that behave like the ones in movies."www.CodeFortress.com
S1CA
S1CA
Download the papers and example code from the nVidia site covering "attenuation mapping".

The attenuation function would ideally be encoded in a volume texture, but on GF2 level h/w you don''t have those, but by picking a different function you can encode it into a 2d texture and a 1d texture and use two stages.

The idea is the result of the dot3 is modulated with your attenuation map textures so it falls off properly. This does mean however that on GF2 level h/w an attenuated per pixel point light takes 2 passes per light.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.