Per Pixel Lighting....Heeeeeelp lol

Started by
2 comments, last by Persian_Gamer 20 years, 1 month ago
I'm working on per pixel lighting and i've come to a problem which i can't find a solution for it. That is whenever the light goes near a low poly object's surface, up to a distance intensity of the light grows but after that it seams to fade away as we go nearer. I'm calculating the light vector on Vertex shader and passing it as oD0 or the color register. and on pixel shader i do a DOT product with the bump map. My suspect is that the light vector is not gettin' interpolated properly or somthin' like that... any ideas? well the result with attenuation and without bump maps (which requires light vector) is this: with the bump map and light vector i get somthing like this(when ever the light goes near to a wall for example look at the blue color and compare with the last image) [edited by - Persian_Gamer on February 29, 2004 12:11:25 AM]
Advertisement
This has to do with the light vector:
Once you are in the center of a big poly, the light vector gets unnormalized ( the lightvector gets too "short" ) as a result of the interpolation. Since you multiply it with the bumpnormal, your diffuse coefficient will be a lot lower than normal. You can solve this problems in 3 ways:
a) Use a normalization cubemap as texture and do a lookup to renormalize your lightvector
b) Renormalize your lightvector in your shader with real calculations ( this can only be done in ARBFp I believe , not fp20 or anything like that )
c) Renormalize your vector using the newton raphson approximation

Best results can be achieved using b... They look a little "sharper" than the other 2 in the final output
Oki thanx Dtag, thanx alot... its fixed now... but i''ve got a question... right now i''m burning 2 texture stages to simulate attenuation. I''ve read that using a cubemap its also possible. I wanna use the cubemap attenuation so i can make another slot availabe for specular map... do we use the same 2D Attenuation texture and put it on all cube''s surfaces? i read Sim Dietrich article on attenuation maps... his solution is to calculate S,T and R same way we do for 2D Attenuation maps:

(Light-Vertex)/LightRane

i don understand this part.. how can this work since STR for Cubemap is a vector and v(a,b,c) and v(na,nb,nc) will produce the same results.
any1.. ? lol

This topic is closed to new replies.

Advertisement