MappedAndSolidTexture.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Last Edited by: Crow, February 14, 1989 5:40:59 pm PST
Perlin, August 5, 1985 0:23:18 am PDT
DIRECTORY
Atom     USING [ PropList ],
Rope     USING [ ROPE ],
G3dRender,
ThreeDBasics  USING [ ShapeInstance, VertexInfoProc ];
MappedAndSolidTexture: CEDAR DEFINITIONS
~ BEGIN
Basic Types
Context: TYPE ~ G3dRender.Context;
Pair: TYPE ~ G3dRender.Pair;
Patch: TYPE ~ G3dRender.Patch;
SpotProc: TYPE ~ G3dRender.SpotProc;
VertexInfoProc: TYPE ~ ThreeDBasics.VertexInfoProc;
ShapeInstance: TYPE ~ ThreeDBasics.ShapeInstance;
TextureMap: TYPE ~ G3dRender.TextureMap;
TextureFunction: TYPE ~ G3dRender.TextureFunction;
LORA: TYPE ~ LIST OF REF ANY;
Procedures for Controlling Texture
AddSolidTexture: PROC[context: Context, shapeName: Rope.ROPE, name: ATOM ];
Allows client to pass name of solid texturing procedure for shape as an ATOM
AddMappedTexture: PROC[context: Context, shapeName: Rope.ROPE,
         texture: REF TextureMap];
Sets up supplied texture map
SumAllMappedTextures: PROC[context: Context, shapeName: Rope.ROPE];
Converts texture maps to summed area table form for antialiasing
RemoveAllTexture: PROC[context: Context, shapeName: Rope.ROPE];
Deletes all texture references for object
Procedures for Auxiliary Clipping and Shading
LoadVtxAux: VertexInfoProc;
Loads data into vtx.aux, where it can be interpolated and clipped with other patch data
LerpVtxAux: VertexInfoProc;
Interpolates data in vtx.aux, called back from clipper, etc.
ShadeVtx: VertexInfoProc;
Custom shading code for texturing (defaults to standard shader in this version)
Support Procedures for setting up texture for tiler
AdjustTexture: PROC[poly: REF Patch, texture: LORA, halfXRange, halfYRange: REAL ← .5];
Adjusts mapped texture coordinates to avoid coordinate wraparound
Procedures for Evaluating Texture at a Spot
GetTxtrAt: SpotProc;
Layers textures from a list to onto a pixel
Procedures for solid texture calculation
RegisterTextureFunction: PROC[ name: ATOM, proc: SpotProc, props: Atom.PropList ← NIL ];
Registers a procedure for computing on a spot (usually for solid textures)
GetRegisteredTextureFunction: PROC[name: ATOM] RETURNS[ txtrFn: TextureFunction ];
Returns a previously registered procedure
Chaos: PROC[x, y, z: REAL] RETURNS [REAL];
A function built on noise, used in some solid texture functions
Noise: PROC[vx, vy, vz: REAL] RETURNS [REAL];
Perlin's noise function. Fills space with random blobs
Procedures for Computing Texture Coordinates
ScaleTxtrCoords: PROC [ context: Context, shapeName: Rope.ROPE,
        scale, xRatio, yRatio: REAL 𡤁.0 ];
Scales texture coordinates of vertices. xRatio, etc. can be used to set scale assymetrically.
eg. texture.x ← texture.x * scale * xRatio.
Accumulated scale factor is stored on shape shadingProps list ($TextureScale).
MakeTxtrCoordsFromVtxNos: PROC[ context: Context, shapeName: Rope.ROPE,
             vtcesInRow, numberOfRows: NAT,
         row0col0, rowNcol0, rowNcolM, row0ColM: Pair ];
For objects which are rectangular polygon grids pulled into a surface shape, eg. surfaces of revolution, this maps a texture onto the rectangular grid.
MakeTxtrCoordsFromNormals: PROC[ context: Context, shapeName: Rope.ROPE,
        botLeft: Pair ← [0.0, 0.0], topLeft: Pair ← [0.0, 1.0],
        topRight: Pair ← [1.0, 1.0], botRight: Pair ← [1.0, 0.0],
           sw: Pair ← [180.0, -90.0], nw: Pair ← [180.0, 90.0],
           ne: Pair ← [-180.0, 90.0], se: Pair ← [-180.0, -90.0] ];
This takes the surface normals and maps from spherical coordinates into a rectangular texture. botLeft, topLeft, etc. allow mapping multiple, or skewed, instances of the texture onto the rectangle. longMin, longMax, etc. allow the area affected to be limited to a certain range of sperical coordinates.
Procedures for Reading and Preparing Texture Files
TextureFromAIS: PROC[context: Context, fileName: Rope.ROPE,
        type: ATOM ← $Intensity, factor: REAL ← 1.0]
      RETURNS[texture: REF TextureMap];
Reads AIS file and converts it to texture map form. Factor is for scaling, (height of bump map - default 1, other uses may come)
SumTexture: PROC[texture: REF TextureMap];
Turn texture map into Summed Table form for anti-aliased texture
END.