[comp.graphics] Texture mapping onto 3-D objects

rao@sun9.cs.fit.edu (Rao Ranjan /ADVISOR-Shoaff) (12/17/90)

Hi netters,

Could anybody provide me some information about texture
mapping. I would like to know, if there is any
algorithms for mapping 2-D polygonal textures ( random ) on to 3-D objects ( for example 3-D solids which have curved surfaces) available. Is there any software packages available in the market that do this ? Currently I am working on my thesis in the field of computational
Visualization. 

	I really appreciate your response.
				
					Thank You,
					 
					 Ranjan S. Rao

ra2@doc.ic.ac.uk (Roger Attrill) (12/20/90)

In article <1737@winnie.fit.edu> rao@sun9.cs.fit.edu (Rao Ranjan /ADVISOR-Shoaff) writes:
>Hi netters,
>
>Could anybody provide me some information about texture
>mapping. I would like to know, if there is any
>algorithms for mapping 2-D polygonal textures ( random ) on to 3-D objects
>( for example 3-D solids which have curved surfaces) available. Is
>there any software packages available in the market that do this ?
>Currently I am working on my thesis in the field of computational
>Visualization. 
>

Yes. I've written a machine code version of RayShade V3.00. (Yes I'm crazy!).
I've incorporated this feature (along with others) into the program, and it
works a treat. There is a problem in that seeing as the 2D texture (a logo
for instance) *is* 2D, then the person creating the scenefile has to do most
of the positioning work, - scaling,rotating etc. I've initiated 2D textures
to have unit size in +x and +z directions with bottom left of the picture
at the origin. The normal points in the -y direction. The texture is then
mapped *through* an object - not *around* an object. This means it is best
suited to mapping to flat surfaced objects. However, nice effects are achieved
when mapping a face onto a distorted sphere.  If you get the source code
to Craig Kolbs' RayShade, then this is an excellent example of how to map
many different types of textures. It's not hard to add one more, and add
a routine to compute the RGB values at a given point on your 2D image, in
order to map it onto an objects' surface at the hitpoint.
 If anyone has a method of wrapping an image *around* an object, I'd be
most interested. I'd imagine this would imply some intensive computation
and would not be globally useful. Would different algorithms be needed for
each primitive type. eg for cones *and* superquadrics!!! God forbid! What
about mapping pictures of farms and cows onto fractal landscapes. Maybe
even some people skiing down snowy mountaintops. Shadows might be hard
though!!

Time to abort!

 Merry Xmas

     Rog.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|   Roger C. Attrill   | I don't always think therefore I'm not necessarily. |
|   ra2@doc.ic.ac.uk   | I couldn't have done better unless I did it myself. |
|   Imperial College   |          and other variations on a theme.           |
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

 

chris@ncmicro.lonestar.org (Chris Arps) (12/21/90)

Hows about this?  

Get the ray to object intersection point via your favorite
ray tracing method.

Then compute an inverse transform so that the point on 
the object can be mapped back the the screen.  Once you have the
point on the screen(x,y), use it as the index into your source 2D image.  

This will give you the texture/color value for the point on the
object that you are ray tracing.  

This is a simple approach and would probably need some multi-pixel
sampling of the 2D texture in order to anti-alias the resulting
spheres texture.  You will probably have to trace more than one
ray per pixel to get smooth texture maps.

I have not implemented this but have heard of it being used.
Hope it is worth something!

P.S. I just got my hands on a program that will map GIF files
onto 3d complex objects (Pixar's Renderman).  I will
be posting some PC animations using this to alt.binaries.multimedia
real soon.
-- 
Chris Arps  ***THIS SPACE FOR RENT*** *New Music*SONIC YOUTH*FAITH NO MORE*
NC/Scientific Software, Musican,      *SOCIAL DISTORTION*PETER HAMILL*YELLO
Animator, 4 Dogs,2 Birds,1 cat,1 fish *Old Music*SPIRIT*MMANN*VDGG*HENDRIX
Concerning computers - "Anything slower than instantaneous is intolerable!"

zap@lysator.liu.se (Zap Andersson) (12/21/90)

ra2@doc.ic.ac.uk (Roger Attrill) writes:

>In article <1737@winnie.fit.edu> rao@sun9.cs.fit.edu (Rao Ranjan /ADVISOR-Shoaff) writes:
>>Hi netters,
>>
>>Could anybody provide me some information about texture
>>mapping. I would like to know, if there is any
>>algorithms for mapping 2-D polygonal textures ( random ) on to 3-D objects

Well, not 2d POLYGONAL surfaces, but 2d BITMAPPED surfaces! But on the other
hand, you may use the same approach... more below...

>Yes. I've written a machine code version of RayShade V3.00. (Yes I'm crazy!).
>I've incorporated this feature (along with others) into the program, and it
>works a treat. There is a problem in that seeing as the 2D texture (a logo
>for instance) *is* 2D, then the person creating the scenefile has to do most
>of the positioning work, - scaling,rotating etc. I've initiated 2D textures
>to have unit size in +x and +z directions with bottom left of the picture
>at the origin. The normal points in the -y direction. The texture is then
>mapped *through* an object - not *around* an object. This means it is best
>suited to mapping to flat surfaced objects. However, nice effects are achieved
>when mapping a face onto a distorted sphere.  

Aha, this is 'projective' texture mapping. Another approach of this is
different TYPES of projection, i.e. 'BALL' and 'CYLINDER' projections are
most common, i.e. for 'cylinder' you might use the ANGLE in the x/y or
any other (perhaps arbitrary) plane as ONE 'texture map coordinate' and
the DISTANCE from that plane as the other. 'BALL' type is really polar
coordinates from a central point (perhaps in relation to an arbitrary plane,
if you like)

> If anyone has a method of wrapping an image *around* an object, I'd be
>most interested. I'd imagine this would imply some intensive computation

Well, it's really VERY simple: See  to ut that your routine that intersects
a ray with an object also returns the 'local surface coordinates' for that
primitive! For a sphere, it's the 'latitude' and 'longditude', for a 
superquadric it is the parameters (quite simple B->)  andfor other surfaces
you may use different tecniques depending on primitive. But in some
cases, projective mapping is more appropriate, and in some, 'wrapping' is
more appropriate, i.e. Wood patterns look best projected, but a picture
of a girl should be WRAPPED onto a folded polygonal mesh, to make it look
like a folded/wrinkeled/whatever photo of the very same girl! 


>and would not be globally useful. Would different algorithms be needed for
>each primitive type. eg for cones *and* superquadrics!!! God forbid! What
>about mapping pictures of farms and cows onto fractal landscapes.

Not a real problem, unless you REALLY want them to 'stand out' of the 
surface. THen you are beyond even simple 'bump mapping' and into 'displacement
mapping' i.e. the surface is ACTUALLY DISPLACED by the map, no tricks. This,
however, is 'slightly' easier (very large understatement B->) to do in
polygon based (Z buffer and the like) renderers than in raytracing. Imagine
the intersection calculation for a sphere, whose surface is displaced with
a fractal noise function, PLUS a wavy pattern of concentric waves?
Nah, then I stick to bump-mapping, a 'slight' bit easier (same understatement)
What you need to do THEN, is that you intersection routine must not ONLY
return the local coordinates, but also two vectors that show the directions
in wich these coordinates increase. Then your mapping should get a hold of
the delta in color on your 2d image (both delta in X and delta in Y) and
then twiddle ye normal vector the 'delta' amount along the vector you just got.
Needless to say, my raytracer (commercial product) does all this.

> Maybe
>even some people skiing down snowy mountaintops. Shadows might be hard
>though!!

I'll try to render such an image. Would be fun ;-)

>Time to abort!

Yeah, rite, system halted and all that..

> Merry Xmas

Merry to all netters!

>     Rog.

>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>|   Roger C. Attrill   | I don't always think therefore I'm not necessarily. |
>|   ra2@doc.ic.ac.uk   | I couldn't have done better unless I did it myself. |
>|   Imperial College   |          and other variations on a theme.           |
>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

> 
--
* * * * * * * * * * * * * * * * *
* My signature is smaller than  *
* yours!  - zap@lysator.liu.se  *
* * * * * * * * * * * * * * * * *

craig@weedeater.math.yale.edu (Craig Kolb) (12/24/90)

In article <2674@gould.doc.ic.ac.uk> ra2@doc.ic.ac.uk (Roger Attrill) writes:
->I would like to know, if there is any
->algorithms for mapping 2-D polygonal textures ( random ) on to 3-D objects
->( for example 3-D solids which have curved surfaces) available. Is
->there any software packages available in the market that do this ?

>Yes. I've written a machine code version of RayShade V3.00. (Yes I'm crazy!).
>If anyone has a method of wrapping an image *around* an object, I'd be
>most interested.

Rayshade 4.0, beta-testing at an FTP site near you next month,
supports several methods for mapping images onto objects, including
spherical, cylindrical, 'linear' and UV mappings.

Eric Haines' chapter in Glassner's "An Introduction to Ray Tracing"
contains a discussion of and pseudocode for computing UV coordinates
for a number of primitive objects.

Cheers,
Craig