r0keeps the fragment position ,then r0 is used as the texcoord parameter of shadow2DRect. However r0’s x and y component value can be negative,can texcoord be negative value?
“the NPOTS texture image lies in a [0…w]x[0…h] range.”
and issues sections 13,14:
"13) How does the handling of the R texture component differ from
the handling of S and T?
The R texture coordinate for rectangular textures is handled
as it would be for standard two dimensional textures. Thus the coordinates range from [0..1] and the wrapping mode is unchanged from the default."
" 14) Does this extension work with OpenGL 1.4’s shadow mapping?
Yes. The one non-obvious allowance to support OpenGL 1.4’s shadow mapping is that the R texture coordinate wrap mode remains UNCHANGED for rectangular textures. Clamping of the R texture coordinate for rectangular textures uses the standard [0,1] interval rather than the [0,w_s] or [0,h_s] intervals as in the case of S and T. This is because R represents a depth value in the [0,1] range whether using a 2D or rectangular texture."
The other part that’s odd about this code is that the 3rd texture coordinate is crucial for shadowmap comparison, but here the 3rd coord is given by glFragCoord.z. I can not belive for a second that that’s valid for a proper shadow map.
The code is one sample called Depth Peeling in the NVIDIA OpenGL SDK. The function of this shader is to discard the fragment which fail the GL_COMPARE_R_TO_TEXTURE .it use the fragment.xy to be the texcoord , so i think fragment.x or.y can be negative value ,so can it sample the shadowmap texture correctly?