Tuesday, November 22, 2011

Texture Mapping

November 22, 2011
Texture Mapping

Theta Phi Switched


Prior to Recalculation                                                           After Recalculation 
I recalculated the theta-phi /XYZ mapping with Scott, but my results were almost identical, meaning the error lies elsewhere.
  




Visualizing Theta                                                                    Visualizing Phi
We are looking down the Y axis. I am not seeing an obvious gradient from black to red (0 to 2PI) for theta. There is a slight hint around the edges (visible on the red left edge) of darkening. I set the sphere's local orthogonal basis to correspond with the world's coordinate system. 

World ------> Sphere
X                    u
Y                    v
Z                    w
Since I am measuring theta counterclockwise from the sphere's v axis, the red/black seam is expected when looking down the Y axis when the world and sphere axes correspond.
I measured phi from the sphere's positive w axis ( currently corresponding to the world's Z ). The top should be black and fade downward to bright green.







Visualizing Theta and Phi Together - Front and Rear View 
It doesn't wrap around after all... hmmm....



Noise After Angles Verified
It looks similar to the first error mentioned. One interesting thing to note is the color range - Cyan, Magenta, Yellow. Complimentary.


After Truncating Floats : Front and Back View
I added a check to verify I was accessing data with base values divisible by three and discovered this was not the case. Floats were being used as index values, but C++ does not inherently cast them to integers. Truncating the floats to ints before using them to calculate dataLocation (the index for the float array where I store my data) gave... TEXTURE! (Kind of - it is repeating...)




I found that multiplying by 16 PI limited the repetitions in theta to only front and back. Why though?
Time to revisit the 3R-->2R calculations....


November 29, 2011

The atan2 function returns values from -pi to +pi, which is what I needed. Replacing atan with atan2 (and no longer dividing by 16 PI) :





What about:

  • Making a 'Mask' from the image - reading in specular coeff.
  • Greater specular reflection from water 

// Give water greater specular 
if (currColor.z() > currColor.x() && currColor.z() > currColor.y() && currColor.z() > .2
{
shadeRec.color = rvDotl * vec3f(.5f);
}
else 
{
shadeRec.color = rvDotl * vec3f(.1f);
}



Next: 
Added Texture* _specData element to Zeugs
Read in data to determine specular coefficients (embedded into red value of map ... see below)

Resulting image: 



No comments:

Post a Comment