thanks for the quick response! Here's more details on what I"m doing:
I'm actually displaying the surface normals of my object as RGB colors. All normals have been normalized, ie. unit length, and I transform each normal to an RGB color as follows: c = (n + 1)/2
where n is a unit length 3-vector normal, 1 is a vector of 1's, and 2 is simply a scalar. This essentially makes the components of c lie between 0 and 1 (since the components of n lie between -1 and 1).
When I render the object, the colors I see represent the normals. This is likely to be interpolated, since it will be rare that each pixel will exactly correspond to a vertex in my triangular mesh. It is more likely the case that a pixel will come from the inside of a triangle, and thus the color will be interpolated from the colors at the vertices.
My formula above is linear, so that interpolating c would interpolate n by the same amount. This is easy to prove. But when I read back the pixel values (using glReadPixels) and transform them into normals using
n = 2*c - 1, I get normals whose lengths are > 1, even though I began with unit-length normals.
There are many such cases: > 700 out of a 50x50 image. Some have lengths as much as 1.15. I doubt floating point roundoff errors alone can account for this.
Main Topics
Browse All Topics





by: CJ_SPosted on 2001-11-18 at 02:01:44ID: 6640387
In theory they indeed should equal to 1 since floating point number are ebing used. In total it "SHOULD" be 1...what kind of values do you get? MUCH greater that 1 or only a small difference (floating point rounding).
CJ