HARDWARE ManualVDP1 User's Manual
BackForward
VDP1 User's Manual / Chapter 5 Table

■ 5.3 Gouraud shading table

It is a table that specifies RGB data of 4 points when performing Gouraud shading processing on parts. Since each of the four points of data is 16 bits, one table requires 8 bytes. Place it at the position starting from the boundary address of 8HByte. However, do not write from 00000H to 0001FH.
VRAM is up to address 7FFFFH. Do not define a Gouraud shading table beyond address 80000H.
The table defines RGB data in the order of vertices (A), (B), (C), (D). In the case of a line, only vertices A and B are valid and correspond to the start and end points of the line. For sprites, the vertices (A), (B), (C), and (D) correspond to the upper left, upper right, lower right, and lower left.
This table is referenced from the command table when Gouraud shading is specified.

Table 5.2 Guro Shading Table
 Table address
 Corresponding vertices
 Sprites, polygons, polylines
 line
 Table start address
 Vertex (A)
 Line start point
 Table start address +2
 Vertex (B)
 Line end
 Table start address +4
 Vertex (C)
 ignore
 Table start address +6
 Vertex (D)
 ignore

Figure 5.4 RGB code format
MSB LSB
┌─┬─────────┬─────────┬─────────┐
│ │ B │ G │ R │
│ X ├─┬─┬─┬─┬─┼─┬─┬─┬─┬─┼─┬─┬─┬─┬─┤
│ │ 4 │ 3 │ 2 │ 1 │ 0 │ 4 │ 3 │ 2 │ 1 │ 0 │ 4 │ 3 │ 2 │ 1 │ 0 │
└─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┘

● Gouraud shading
Gouraud shading can be performed on parts drawn with RGB code. In Gouraud shading, the amount of change in the brightness of each RGB to be changed is specified in the Gouraud shading table for the parts of the RGB code. Valid only for RGB color codes.
Color is not guaranteed when Gouraud shading is specified for the color code of the color bank code.

● Designation of Gouraud shading
When performing Gouraud shading processing, specify Gouraud shading with the color calculation bit. The color operation bit is the start address of the command table.

It is located at bits 2 to 0 of the + 04H drawing mode word. When Gouraud shading is specified, specify the address of Gouraud shading.
For the address of the Gouraud shading table, set the start address of the command table + 1CH to the start address of the Gouraud shading table / 8H.

● Gouraud shading processing
In the Gouraud shading table, specify the RGB change amount data of 4 points (2 points for the line) of the part. The data interpolated between the four points for each RGB is added to the original color of the part.
Since each RGB value takes a value from 00H to 1FH, subtract 10H from the complemented RGB data and add it to the original color of the part. For example, if the RGB value is 10H, the original color is left, if it is 00H, it is -10H, and if it is 1FH, it is + 0FH. If the calculated value is smaller than 00H, it is set to 00H, and if it is larger than 1FH, it is set to 1FH.
The relationship between the Gouraud shading table settings and correction values is shown below.

Table 5.3 Relationship between Gouraud shading table settings and correction values
 Table settings
 Correction value for the original data
 Table settings
 Correction value for the original data
	
00H
 -10H
 10H
 0
01H
 −0FH
 11H
 + 01H
02H
 −0EH
 12H
 + 02H
03H
 −0DH
 13H
 + 03H
04H
 −0CH
 14H
 + 04H
05H
 −0BH
 15H
 + 05H
06H
 −0AH
 16H
 + 06H
07H
 −09H
 17H
 + 07H
08H
 −08H
 18H
 + 08H
09H
 -07H
 19H
 + 09H
0AH
 −06H
 1AH
 + 0AH
0BH
 -05H
 1BH
 + 0BH
0CH
 −04H
 1CH
 + 0CH
0DH
 -03H
 1DH
 + 0DH
0EH
 −02H
 1EH
 + 0EH
0FH
 -01H
 1FH
 + 0FH

In true Gouraud shading, only the brightness is changed, but in this method, each RGB is changed, so the hue also changes in some cases.
To keep the hue unchanged, define one point in the Gouraud shading table for each RGB with the same value. This will give you a white gourd.
For lines, polylines and polygons, it is processed for non-texture colors, and for sprites, it is processed for the colors referenced in the character pattern data or color lookup table.


BackForward
HARDWARE ManualVDP1 User's Manual
Copyright SEGA ENTERPRISES, LTD., 1997