View Full Version : Point Sprite Diffuse Lighting

Jose Ricardo
08-27-2009, 07:52 AM
Hi People,

I'm using point sprite for rendering some spheres in my application. To be more convicent, I need to light it which is done by using a normal. Does someone know how I can do it using point sprite? Is it possible to calculate a normal from each point?

Thanks a lot.

Jose Ricardo

08-27-2009, 09:06 AM
Within fragment shader, read the texcoord, it give x and y of the normal. only z has to be calculated, quite simple for a sphere.
as :
1 = sqrt(x*x + y*y + z*z)
1 = (x*x + y*y + z*z)

z*z = 1 - x*x - y*y = magnitude
if (magnitude >0 and magnitude <=1) {
z= sqrt(1 - x*x - y*y);
} else kill fragment