Re: How can I store global variables one by one in an array?
Hi, sorry for letting this sit for a long time without a reply, but I'm still not sure I understand what you're trying to do.
If you are tracing rays in some order, when tracing one particular ray, you don't yet know where all the other rays (that you haven't trace yet) are going to hit. So you don't know when you're shading what all the other P's will necessarily be, if that's what you're trying to find out.
Are you asking for the vertices of the mesh of the geometry that you hit?
Are you just trying to find out which side of the surface a light is? The variable Ng should be the oriented surface normal, and you can compare that to the direction of the light to determine whether the light (or any other point) is in front of or behind the surface. Also dPdu and dPdv are the tangents of the surface at the shading point, and those can also be used to figure out the orientations.