I'm currently working on a project that requires some manipulation and deviation from the usual shadow mapping program. Just a simple runthrough: I first create a 512x512 texture in OpenGL which is used as the shadow map. Then i pass this shadowmap to a Cg-coded fragment shader. This is quite standard so far. My questions are:
1. To my understanding, textures cover from (0,0) To (1,1). Let's say I want to find the depth value at (5,10) of the shadow map. Must i convert (5,10) to a floating2 vector to access the relevant depth value in the fragment program? Won't there be any precision loss here,as in after you convert, you might not access the actual point on the texture/shadowmap. Or is there any way that i can access the values in the shadow map using values ranging from (0,0) to (511,511)?
2. As quoted from "The Cg Tutorial", float4 shadowCoeff = tex2dproj(shadowMap, texCoordProj);
shadowCoeff will be of the form (c,c,c,1) where c is 0 or 1 or range from 0-1 if bilinear filtering is enabled. If this is the case, then i can't really get a scalar depth value(for some other calculation purposes) with this method.
Is there any way to get a scalar numerical depth value of any point of the shadow map as if it's an 2D array? (Preferably in OpenGL and Cg)
I'm quite new to Cg and texturing, so any help will be greatly appreiciated.