1) Texture Mapping of Spheres (what's wrong w/ the following)
Say you have a sphere translated back to the origin with
- R, radius
- phi, angle in the yz plane, (0 < phi < PI)
- theta, angle in the xy plane, (0 < theta < 2*PI)
The parametric eq is x = R*cos(theta)*sin(phi)
y = R*sin(theta)*cos(phi)
z = R*cos(phi)
Given a point of intersection (x,y,z)
phi = arcos(R/z)
theta = arctan(y/x)
To cover entire sphere, texture coords would then be
u = theta/ (2*PI)
v = 1 - phi/PI
Okay, what in the world is wrong w/ the above assumptions. This
stuff is right out of Watt and Watt, but I can't seem to get it to
work. I'm not getting the entire texture (I think only the bottom half)
on the sphere and I have some odd radius of symmetry. I have a
feeling that the inverse trig functions are causing my problems.
Any suggestions????
2) Bump mapping
I've looked in Watt and Watt, FvD, Graphics Gems I-III, etc. and I even
have the original paper written by Blinn. However, I have yet to see
an implementation of the original algorithm proposed by Blinn.
Frankly, every time I've seen Bump Mapping mentioned in any text, it's
just glossed over. I understand it pretty much, I just would like to
see an actualy implementation. I guess my real question would be, how
do you find the partial derivative of the bump function when your
"bump function" is just a b/w bump map with varying heights. This is
the way I would like to implement this as opposed to procedural bump
mapping.
Any help on either of my quesions would be much appreciated!
Thanks,
Todd Siemers
tsie...@indiana.edu
--
Approved for posting on iu.rotc.air-force:
C/2Lt Todd D. Siemers
Projects Officer
An easy way is to store your bump map as a set of 2D normal vectors.
Then, you can find the angle of incidence each lightsource against
it with a dot product. A bump map texture could be something like
typedef struct
{
float UNormal; // 0=facing straight out
float VNormal;
} BumpMapTexture[USize][VSize];
Of course, for space reasons, it would be best to store bump
components as bytes or words.
You'd determine the UNormal from a greyscale texture by taking
the X differences, i.e. (Texture[U+1][V] - Texture[U][V])/Max,
and the VNormal from the Y differences.
-Tim