N64® Functions Menu

al - Audio Library Functions
gDP - DP GBI Macros
gdSP - General GBI Macros
gSP - SP GBI Macros
gt - Turbo Microcode RDP
gu - Graphics Utilities
Math - Math Functions
nuSys - NuSystem
os - N64 Operating System
sp - Sprite Library Functions
uh - Host to Target IO
64DD - N64 Disk Drive

Nintendo® Confidential

   

gSPModifyVertex

Format
#include "gbi.h"

gSPModifyVertex(Gfx *gdl,
   unsigned int vtx,
   unsigned int where,
   unsigned int val);
gsSPModifyVertex(unsigned int vtx,
   unsigned int where,
   unsigned int val);
gsSPNearClip(nc)
Arguments
  • gdl is the pointer to the graphics display list
  • vtx specifies which of the RSP's vertices (0-15) to modify
  • where specifies which part of the vertex to modify (G_MWO_POINT_RGBA, G_MWO_POINT_ST, G_MWO_POINT_XYSCREEN or
  • G_MWO_POINT_ZSCREEN)
  • val is the new value for the part of the vertex to be modified (a 32 bit integer number)
What This Macro Does
This is an advanced macro. You need a good understanding of how vertices work in the RSP microcode before you use this macro (refer to gSPVertex
). The range of vtx has been changed with as the vertex cache increased. Its range is now the same as that for gSPVertex.

You can use this macro to modify certain sections of a vertex after it has been sent to the RSP (by the gSPVertex macro). This is useful for vertices that are shared between two or more triangles that must have different properties when associated with one triangle versus the other triangle.

For example, you might have two adjacent triangles that both need smooth-shaded color, but one is smooth-shaded red-to-yellow and the other is smooth-shaded green-to-cyan. In this case, the vertex that is shared by both triangles is sent with red/yellow color by using the gSPVertex macro. The first triangle is drawn. Then, the gSPModifyVertex macro is used to change the color to green/cyan, and the second triangle is drawn.

The primary use of the gSPModifyVertex macro is to modify the texture coordinate of a vertex so that a vertex that is shared by two triangles with different textures and different texture coordinate spaces can contain the texture coordinate for the first texture and then be modified to contain the texture coordinate for the second texture.

It is faster to use the gSPModifyVertex macro than to send a new vertex macro with a different but similar vertex because no transformations or lighting are done to the vertex when you use the gSPModifyVertex macro.

The where argument specifies which part of the vertex is to be modified. It can hold one of the following values:
  • G_MWO_POINT_RGBA - changes the color of the vertex. The val parameter is interpreted as 4 bytes: red (high byte), green, blue, and alpha (low byte).
  • G_MWO_POINT_ST - changes the S and T values (texture coordinates of the vertex). The high 16 bits of val specify the S coordinate, and the low 16 bits
  • specify the T coordinate. Each coordinate is an S10.5 number.
  • G_MWO_POINT_XYSCREEN - change the screen coordinates of the vertex. The high 16 bits of val specify the X coordinate and the low 16 bits specify the Y coordinate. Both coordinates are S13.2 numbers with 0,0 being the upper-left of the screen, positive X going right, and positive Y going down.
  • G_MWO_POINT_ZSCREEN - changes the screen Z coordinate of the vertex. The entire 32-bit val is taken as the new screen Z value. It is a 16.16 number in the range 0x00000000 to 0x03ff0000.
Note
Lighting is not performed after a gSPModifyVertex macro, so modifying the color of the vertex with G_MWO_POINT_RGBA is just that - modifying the actual color that will be output. It is not a modification of normal values. This means it cannot be used to update vertex normals for lighting.

The S and T coordinates supplied in the gSPModifyVertex macro are never multiplied by the texture scale (from the gSPTexture macro), so you must pre-scale them before sending them. For example, if you want a texture scale of 1/2 (0x8000), make the S and T values sent with the gSPModifyVertex macro half the value of the equivalent values used with the gSPVertex macro.

Example
To share a vertex between two triangles with different textures and texture coordinates, use this code:
/* load vertex by gSPVertex */
gSPVertex(...);

/* load texture of triangle 1 */
gDPLoadTextureBlock(...);

/* draw triangle 1 using vertex #3 */
gSP1Triangle(glistp++, 1,2,3,0);

/* change a value of vertex 3
   to S=3.0 and T=2.5 */
gSPModifyVertex(glistp++,
   3, G_MWO_POINT_ST, 0x00600050);

/* load texture of triangle 2 */
gDPLoadTextureBlock(...);

/* draw triangle 2 using vertex #3 */
gSP1Triangle(glistp++, 1,2,3,0);
See Also
gSPVertex
gSPTexture
gSP1Triangle



Nintendo® Confidential

Warning: all information in this document is confidential and covered by a non-disclosure agreement. You are responsible for keeping this information confidential and protected. Nintendo will vigorously enforce this responsibility.


Copyright © 1998
Nintendo of America Inc. All rights reserved
Nintendo and N64 are registered trademarks of Nintendo
Last updated January 1998