interpolaters in shader cores

chenr

Newcomer
I wanted to know of the interpolators common in shaders today clamp their interpolant values?

the interpolant P on the three vertices are (p0, p1, p2).
if the barycentric coordinates are (u, v, 1.0 - u - v)
and the result interpolant P is
P = u * p0 + v * p1 + (1.0 - u - v) * p2
should P be clamped?
 
Clamped how? They are certainly not clamped to [0..1]. As for clamping to the inside of the triangle, for non-MSAA that's not an issue in the first place, and for MSAA you can use centroid sampling to ensure you get an interpolator that's inside the triangle in all cases.
 
@Humus: If your barycentric coordinates satisfy, u>=0, v>=0, w>=0, u+v+w=1, won't the interpolated point be guaranteed to lie inside the triangle?

@chenr: You can't clamp a vector, AFAIK.
 
Humus, It's true that not all attributes should be in the range of [0..1] so clamping is not possible (?), anyway i'll give an example of my problem.
I'm working with 2x2 fragments (a b c d) in order to be able to calculate texture coordinates derivatives (ddx = b -a, ddy = c - a).
but on the triangle edge of the fragments are outside of the triangle and would give me innacurate barycentric coordinates. how do i calculate ddx and ddy in that case in both modes (MSAA and non-MSAA) ?
 
@Humus: If your barycentric coordinates satisfy, u>=0, v>=0, w>=0, u+v+w=1, won't the interpolated point be guaranteed to lie inside the triangle?
You should have all visibility samples with 0<= u,v,w <=1, but at the centre of a pixel (which is typically used for MSAA) the condition might not hold (i.e. for a pixel near an edge of the triangle).
 
You should have all visibility samples with 0<= u,v,w <=1, but at the centre of a pixel (which is typically used for MSAA) the condition might not hold (i.e. for a pixel near an edge of the triangle).

it also doesnt hold for samples outside the triangle edge, those samples dont make their own fragments but effect the neighbouring fragment derivative calculation as i explained which might be a problem.
 
I'm working with 2x2 fragments (a b c d) in order to be able to calculate texture coordinates derivatives (ddx = b -a, ddy = c - a).
but on the triangle edge of the fragments are outside of the triangle and would give me innacurate barycentric coordinates. how do i calculate ddx and ddy in that case in both modes (MSAA and non-MSAA) ?

The fragments within a pixel quad that falls outside the triangle are still executed by the hardware so that you get valid derivatives. Those are not clamped, because that would indeed ruin the derivatives. If you're using centroid sampling where the sample position might be shifted from the center the derivatives can be a bit inaccurate though.
 
Is this relevant? - http://patft.uspto.gov/netacgi/nph-...TXT&S1=nvidia.ASNM.&OS=an/nvidia&RS=AN/nvidia

Method and system for implementing parameter clamping to a valid range in a raster stage of a graphics pipeline.

A method of determining pixel parameters, wherein the pixel parameters were clamped to a valid range. The method includes a step of accessing a geometric primitive comprising a plurality of vertices wherein each vertex has associated therewith a plurality of parameters including a pair of texture coordinates. During rasterization of said geometric primitive performed in a rasterization module of graphics pipeline, a respective pair of texture coordinates for each pixel of said geometric primitive are computed using interpolation. Each computed texture coordinate includes an integer portion and a fractional portion. Only the fractional portions of said texture coordinates are propagated to a downstream data fetch module of said graphics pipeline.
 
Yes, but that's assuming you raster only pixel centers that lie inside the primitive, which is not the case with MSAA as Simon F pointed out. As long as any single sample within the pixel is covered the pixel has to be evaluated, but unless you use centroid sampling it's evaluated at the pixel center, not at the covered sample's position, and the pixel center may in fact be outside the triangle.
 
Back
Top