#### Archived

This topic is now archived and is closed to further replies.

# per pixel math.

This topic is 5932 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey all, I''m trying to do per pixel lighting in opengl. I''ve been reading the AGDC pdf on per pixel shading, and they claim I need to mode the light vector into texture space. They say I need to create plane equations of the form Ax + Bs + Ct + D = 0 Ay + Bs + Ct + D = 0 Az + Bs + Ct + D = 0 and then solve for dsdx, dsdy, dsdz. Ok, here are my questions. When they say dsdx, etc do they mean ds/dx(ie. derivate of x with respect to s)? If so, as far as I can see the form of the problem becomes: Ax/B + Ct/B + D/B = S etc... do I do a partial derivtaion with respect to x, and treat the Ct/B + D/B as a constant(in which case it disappers I belive)? If I did that, then the answer to every one of those plane equations is A/B, an answer I''m fairly sure is not right :-). But I''m really not sure what I''m doing wrong. could anyone help me? Thanks, Jesse Jesse Laeuchli www.laeuchli.com/jesse/

##### Share on other sites
when you do per pixel lighting you have to calculate the angle beetween the normal found at that pixel and the ray coming from the light source, so you have to find the equation of the plane and then solve for x, or y in your main rasterizer loop you don''t have to derivate the plane equation ( since to my knowledge it has not any sense ).Hope it helps , i think that dsdx is the slope of the bilinear interpolator when you find the correct textel position.
Sorry for my english
(stl sucks)