*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->IRIX man pages -> standard/texgen (3)              
Title
Content
Arch
Section
 

Contents


texgen(3G)							    texgen(3G)


NAME    [Toc]    [Back]

     texgen - specify automatic	generation of texture coordinates

C SPECIFICATION    [Toc]    [Back]

     void texgen(long coord, long mode,	float params[])

PARAMETERS    [Toc]    [Back]

     coord    Expects the name of the texture coordinate whose generation is
	      to be defined, enabled, or disabled.  One	of:

	      TX_S:  The s texture coordinate

	      TX_T:  The t texture coordinate

	      TX_R:  The r texture coordinate

	      TX_Q:  The q texture coordinate

     mode     Expects the mode of generation to	be specified, or an indication
	      that generation is to be either enabled or disabled.  One	of the
	      symbolic constants:

	      TG_CONTOUR:  Use the plane equation specified in params to
	      define a plane in	eye-coordinates.  Generate a texture
	      coordinate that is proportional to vertex	distance from this
	      plane.

	      TG_LINEAR:  Use the plane	equation specified in params to	define
	      a	plane in object-coordinates.  Generate a texture coordinate
	      that is proportional to vertex distance from this	plane.

	      TG_SPHEREMAP:  Generate texture coordinates based	on the vertex
	      and current normal.  When	used with the appropriate texture
	      (described below), this gives the	appearance of the reflection
	      of an environment	placed at infinity.  Typically,	both TX_S and
	      TX_T are enabled.

	      TG_ON:  Enable the (previously defined) replacement for the
	      specified	texture	coordinate.

	      TG_OFF:  Disable replacement of the specified texture coordinate
	      (the default).

     params   Expects a	4-component plane equation when	mode is	TG_CONTOUR or
	      TG_LINEAR.  Array	element	0 is plane equation component A, 1 is
	      B, 2 is C, and 3 is D.  The specified contents of	params are
	      insignificant when mode is TG_ON,	TG_OFF,	or TG_SPHEREMAP.

DESCRIPTION    [Toc]    [Back]

     Texture coordinates s, t, r, and q	can be specified directly using	the t
     command.  It is also possible to have texture coordinates generated
     automatically as a	function of object geometry.  texgen specifies,



									Page 1






texgen(3G)							    texgen(3G)



     enables, and disables such	automatic generation.  Either or both texture
     coordinates can be	generated independently.  Automatic texture coordinate
     generation	is disabled by default.

     texgen supports three generation algorithms:  TG_LINEAR, TG_CONTOUR, and
     TG_SPHEREMAP.  TG_LINEAR operates directly	on object coordinates, and is
     therefore most useful for textures	that are locked	to objects, such as
     ground texture locked to a	terain,	or metalic texture locked to a
     cylinder.	TG_CONTOUR operates on eye-coordinates.	 It supports motion of
     an	object through a `field' of texture coordinates.  TG_SPHEREMAP
     computes a	reflection based on the	vertex and normal in eye-coordinates.

     Both modes	TG_LINEAR and TG_CONTOUR define	a texture coordinate
     generation	function that is a linear function of distance from a plane.
     The plane equation	is specified as	a single, 4-component, vector in
     object coordinates.

		    | a	|
	  P	  = | b	|
	   object   | c	|
		    | d	|
     The TG_LINEAR plane equation remains in object-coordinates.  The
     TG_CONTOUR	plane equation is transformed by the ModelView matrix into
     eye-coordinates when it is	defined:

	  P    = M -1	    P
	   eye	  ModelView  object
     When a generation function	has been defined for a texture coordinate, and
     texgen has	been called with TG_ON,	each vertex presented to the graphics
     system has	that texture coordinate	value replaced with the	distance of
     the vertex	from the defined plane.	 For example, when texture coordinate
     s is generated by a TG_LINEAR function, the generation function is:

								      |	a |
	  s = V	     .P	      =	| x	   y	    z	     w	    |.|	b |
	       object  object	|  object,  object,  object,  object| |	c |
								      |	d |
     Alternately, when t is generated by a TG_CONTOUR function,	the generation
     function is:

	  t = V	  .P
	       eye  eye
     where

	  V    = V	 M
	   eye	  object  ModelView,
     and

	  P    = M -1	    P
	   eye	  ModelView  object





									Page 2






texgen(3G)							    texgen(3G)



     Note that the ModelView matrix that modifies the plane equation is	the
     ModelView matrix in effect	when texgen was	called,	while the ModelView
     matrix that modifies the vertex coordinates is the	matrix used to
     transform that vertex.

     The creation of an	appropriate texture for	TG_SPHEREMAP requires some
     explanation.  Consider a unit sphere centered at the viewpoint which
     represents	the complete environment.  The mapping of this sphere to a 2D
     texture is	captured with a	formula, given below.

     Let R be an arbitrary unit	vector based at	the viewpoint.	s and t	are
     texture coordinates in the	range 0.0 to 1.0.  The texture value is	taken
     from the point of intersection between R and the unit sphere.  The	set of
     all possible values of R captures the complete environment.  The mapping
     from R to texture coordinates s and t is:

	       mag = 2*sqrt(R.x*R.x+R.y*R.y+(R.z+1)*(R.z+1))

	       s = R.x/mag+.5

	       t = R.y/mag+.5

     The point in the environment directly behind the viewer maps to s = .5, t
     = .5.  The	intersection between the plane z = 0 and the environment maps
     to	a circle centered at s = .5, t = .5 with a radius of sqrt(2)/4.	 The
     point in the environment directly in front	of the viewer maps to a	circle
     with a radius of .5.  This	circle marks the boundary of the complete
     environment in the	texture.  In a reflection, this	boundary can be
     approached	but not	reached.  Since	the view direction is fixed for	each
     environment texture, a change in the view direction will require a	new
     texture to	be calculated.

     texgen generation functions remain	valid until they are redefined.	 They
     are enabled and disabled without redefinition by calls to texgen with
     modes TG_ON and TG_OFF.  texgen definition	has no effect on the enable
     mode of the texture generation function.

     When enabled, texgen replaces s, t, or both each time a vertex command is
     received.	A texture coordinate that is not being generated continues to
     be	specified by t commands.  Texture coordinate are transformed by	the
     Texture matrix (see mmode)	following coordinate replacement by texgen.

SEE ALSO    [Toc]    [Back]

      
      
     mmode, n, t, texdef2d, texdef3d, texbind, tevdef, tevbind,	v

NOTES    [Toc]    [Back]

     IRIS-4D G,	GT, and	GTX models, and	the Personal Iris, do not support
     texture mapping.  texgen is ignored by these machines.  The Iris Indy,
     Indigo Entry, and XL support texture mapping except for lines.  IRIS-4D
     VGX and VGXT models, the Personal Iris, Indy, Indigo Entry, XS, XS24, XZ,
     Elan and Extreme systems do not support TX_R and TX_Q.  Use getgdesc to
     determine whether texture mapping is supported.



									Page 3






texgen(3G)							    texgen(3G)



     texgen cannot be used while mmode is MSINGLE.


									PPPPaaaaggggeeee 4444
[ Back ]
 Similar pages
Name OS Title
glTexGen Tru64 control the generation of texture coordinates
glTexGend Tru64 control the generation of texture coordinates
glTexGenf Tru64 control the generation of texture coordinates
gltexgen IRIX control the generation of texture coordinates
glTexGenfv Tru64 control the generation of texture coordinates
glTexGeni Tru64 control the generation of texture coordinates
glTexGeniv Tru64 control the generation of texture coordinates
glTexGendv Tru64 control the generation of texture coordinates
glpixeltexgenparameter IRIX affects the generation of texture coordinates in pixel operations
glpixeltexgen IRIX affects the generation of texture coordinates from pixel groups
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service