1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Mark Danks">
<meta name="GENERATOR" content="Mozilla/4.5 [en] (WinNT; I) [Netscape]">
<title>Texture mapping</title>
</head>
<body>
<center>
<h2>
<u>Texture Mapping</u></h2></center>
<a href="Gloss.html#Texture">Texture mapping</a> is the act of applying
pixel data to a geometric object. In GEM, this is achieved with the
<i>pix_texture</i> object. It is important to understand that the
<i>pix_texture</i> object merely sets the pix as the current texture.
It does not do any rendering! You need to use a geo object which
does texture mapping. All of the basic geo objects can texture map,
such as <i>square</i> or <i>sphere</i>.
<p><img SRC="tribar.gif" height=13 width=561>
<p>A simple example of texture mapping is the following patch:
<center>
<p><img SRC="texture.jpg" BORDER=1 height=182 width=160></center>
<p>This patch can be found at gem_texture/gem1.texture.pd. Change
the number box connected to the rotate object to see what a texture map
on a cube looks like.
<p>The <i>pix_image</i> object loads in the fractal image file. The
<i>pix_texture</i> object says that the pix data should be used as a texture
map. Notice that this is different than the previous manual section
when we used the <i>pix_draw</i> object. The final object in the
chain is the <i>cube</i> object. Because we have enabled texture
mapping with the <i>pix_texture</i> object, the cube takes the pix data
and applies it to the geometry.
<p><img SRC="tribar.gif" height=13 width=561>
<p>Texture mapping can be used with any GEM object. In the previous
manual section, you saw how to load in pix data with a variety of objects,
including <i>pix_multiimage</i> and <i>pix_video</i>. All of these
objects can be used with the <i>pix_texture</i> object.
<p>Because the pix data is applied to geometry, you can move, rotate, and
scale the image. This is extremely useful on the <i>square</i> object.
Instead of doing a one-to-one pixel mapping as occurs with the <i>pix_draw</i>
object, you can resize and reshape the image.
<p>One <b>major</b> requirement is that all pix data <b>must</b> be a power
of two in size. This means that the width and height must be a power
of two, such as 64, 128, or 256. If the width or height is not a
power of two, then the <i>pix_texture</i> object will not work correctly.
If you need to resize your pix data, then the <i>pix_resize</i> object
can do the job. However, it is very computationally expensive to
use the <i>pix_resize</i> object. It is <b>much</b> better to resize
the image before trying to load it into GEM.
<p><img SRC="tribar.gif" height=13 width=561>
<p>The example patch gem_texture/gem2.moveImages.pd is a much more complex
patch which uses alpha blending to create a transparent object, in this
case, the dancer. Make sure to turn on the rotation with the <i>metro</i>
object.
<p><img SRC="tribar.gif" height=13 width=561>
<p><a href="index.html">[return]</a>
<br>
</body>
</html>
|