GPU/Internal Registers: Difference between revisions

Steveice10 (talk | contribs)
Steveice10 (talk | contribs)
Line 6,199: Line 6,199:
== Fragment lighting registers ==
== Fragment lighting registers ==


=== GPUREG_LIGHTING_ENABLE0 ===
=== GPUREG_LIGHT''i''_SPECULAR0 ===


This register is set to 0 when fragment lighting is disabled, and to 1 when it is enabled.
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-7
| unsigned, Blue
|-
| 10-17
| unsigned, Green
|-
| 20-27
| unsigned, Red
|}
 
These registers contain the specular0 color of the corresponding light. Usually set to material_specular0*lightX_specular0.
 
=== GPUREG_LIGHT''i''_SPECULAR1 ===
 
 
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-7
| unsigned, Blue
|-
| 10-17
| unsigned, Green
|-
| 20-27
| unsigned, Red
|}
 
These registers contain the specular1 color of the corresponding light. Usually set to material_specular1*lightX_specular1.
 
=== GPUREG_LIGHT''i''_DIFFUSE ===
 
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-7
| unsigned, Blue
|-
| 10-17
| unsigned, Green
|-
| 20-27
| unsigned, Red
|}
 
These registers contain the diffuse color of the corresponding light. Usually set to material_diffuse*lightX_diffuse.
 
=== GPUREG_LIGHT''i''_AMBIENT ===


=== GPUREG_LIGHTING_ENABLE1 ===
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-7
| unsigned, Blue
|-
| 10-17
| unsigned, Green
|-
| 20-27
| unsigned, Red
|}
 
These registers contain the ambient color of the corresponding light. Usually set to material_ambient*lightX_ambient.
 
=== GPUREG_LIGHT''i''_XY ===
 
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-15
| float1.5.10, X coordinate
|-
| 16-31
| float1.5.10, Y coordinate
|}
 
These registers (along with _Z) represent the light position (for a positional light) or the light direction vector (for a directional light) of the corresponding light.
 
=== GPUREG_LIGHT''i''_Z ===
 
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-15
| float1.5.10, Z coordinate
|}
 
These registers (along with _XY) represent the light position (for a positional light) or the light direction vector (for a directional light) of the corresponding light.
 
=== GPUREG_LIGHT''i''_SPOTDIR_XY ===
 
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-12
| fixed1.1.11, X coordinate (Usually the input value is negated)
|-
| 16-28
| fixed1.1.11, Y coordinate (Usually the input value is negated)
|}
 
These registers (along with _Z) represent the spot direction (unitary) vector of the corresponding light.
 
=== GPUREG_LIGHT''i''_SPOTDIR_Z ===
 
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-12
| fixed1.1.11, Z coordinate (Usually the input value is negated)
|}


This register is set to 1 when fragment lighting is disabled, and to 0 when it is enabled.
These registers (along with _XY) represent the spot direction (unitary) vector of the corresponding light.


=== GPUREG_LIGHTING_CONFIG0 ===
=== GPUREG_LIGHT''i''_CONFIG ===


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 6,214: Line 6,333:
|-
|-
| 0
| 0
| unsigned, Shadow factor enable, usually set to bit16 OR bit18 OR bit19
| unsigned, Light type (0 = positional light, 1 = directional light)
|-
|-
| 1
| 1
| Unknown, set to 0
| unsigned, Two side diffuse (0 = one side, 1 = both sides)
|-
| 2
| unsigned, Use geometric factor 0 (0 = don't use, 1 = use)
|-
| 3
| unsigned, Use geometric factor 1 (0 = don't use, 1 = use)
|}
 
=== GPUREG_LIGHT''i''_ATTENUATION_BIAS ===
 
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-19
| float1.7.12, Distance attenuation bias
|}
 
These registers contain the distance attenuation bias value of the corresponding light. The attenuation factor is lut_DA(clip(bias + scale*distance, 0.0, 1.0)).
 
=== GPUREG_LIGHT''i''_ATTENUATION_SCALE ===
 
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-19
| float1.7.12, Distance attenuation scale
|}
 
These registers contain the distance attenuation scale value of the corresponding light. The attenuation factor is lut_DA(clip(bias + scale*distance, 0.0, 1.0)).
 
=== GPUREG_LIGHTING_AMBIENT ===
 
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-7
| unsigned, Blue
|-
| 10-17
| unsigned, Green
|-
| 20-27
| unsigned, Red
|}
 
This register contains the initial value of the fragment primary color before the partial colors that correspond to each enabled light are added. Usually set to material_emission + material_ambient*scene_ambient.
 
=== GPUREG_LIGHTING_NUM_LIGHTS ===
 
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-2
| unsigned, Number of active lights - 1
|}
 
=== GPUREG_LIGHTING_CONFIG0 ===
 
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0
| unsigned, Shadow factor enabled (0 = disabled, 1 = enabled) (usually accompanied by bit 16, 17, or 18)
|-
|-
| 2-3
| 2-3
| unsigned, "Fresnel selector" (see below)
| unsigned, Fresnel selector
|-
|-
| 4-7
| 4-7
| unsigned, "Config", "Light env config" (see below)
| unsigned, Light environment configuration
|-
|-
| 8-15
| 8-11
| Unknown, set to 4
| 0x4
|-
|-
| 16
| 16
| unsigned, "Shadow primary", 0=disabled, 1=enabled
| unsigned, Apply shadow attenuation to primary color (0 = don't apply, 1 = apply)
|-
|-
| 17
| 17
| unsigned, "Shadow secondary", 0=disabled, 1=enabled
| unsigned, Apply shadow attenuation to secondary color (0 = don't apply, 1 = apply)
|-
|-
| 18
| 18
| unsigned, "Invert shadow", 0=disabled, 1=enabled
| unsigned, Invert shadow attenuation (0 = don't invert, 1 = invert)
|-
|-
| 19
| 19
| unsigned, "Shadow alpha", 0=disabled, 1=enabled
| unsigned, Apply shadow attenuation to alpha component (0 = don't apply, 1 = apply)
|-
| 20-21
| Unknown, set to 0
|-
|-
| 22-23
| 22-23
| unsigned, "Bump selector", texture unit for bumpmapping
| unsigned, Bump map texture unit
|-
|-
| 24-25
| 24-25
| unsigned, "Shadow selector", texture unit for shadow mapping
| unsigned, Shadow map texture unit
|-
| 26
| Unknown, set to 0
|-
|-
| 27
| 27
| unsigned, "Clamp highlights", 0=disabled, 1=enabled
| unsigned, Clamp highlights (0 = disabled, 1 = enabled)
|-
|-
| 28-29
| 28-29
| unsigned, "Bump mode", "Light env texy usage" (see below)
| unsigned, Bump mode
|-
|-
| 30
| 30
| unsigned, "Bump renorm", 0=enabled, 1=disabled
| unsigned, Recalculate bump vectors (0 = enabled, 1 = disabled) (usually set to 1 when bump mode is not 0)
|-
|-
| 31
| 31
| Unknown, set to 1
| 0x1
|}
|}


Fresnel selector constants:
Fresnel selector values:


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 6,272: Line 6,453:
|-
|-
| 0
| 0
| NO_FRESNEL
| None
|-
|-
| 1
| 1
| PRI_ALPHA_FRESNEL
| Primary alpha
|-
|-
| 2
| 2
| SEC_ALPHA_FRESNEL
| Secondary alpha
|-
|-
| 3
| 3
| PRI_SEC_ALPHA_FRESNEL
| Primary and secondary alpha
|}
|}


The light environment configuration controls which LUTs are available for use. If a LUT is not available in the selected configuration, its value will always read a constant 1.0 regardless of the enable state in GPUREG_LIGHTING_CONFIG1. If lut_RR is enabled but not lut_RG or lut_RB, the output of lut_RR is used for the three components; Red, Green and Blue.
The light environment configuration controls which LUTs are available for use. If a LUT is not available in the selected configuration, its value will always read a constant 1.0 regardless of the enable state in GPUREG_LIGHTING_CONFIG1. If RR is enabled but not RG or RB, the output of RR is used for the three components; Red, Green and Blue.


Light env config constants:
Light environment configuration values:


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 6,294: Line 6,475:
|-
|-
| 0
| 0
| LIGHT_ENV_LAYER_CONFIG0
| Configuration 0
| lut_D0, lut_RR, lut_SP, lut_DA
| D0, RR, SP, DA
|-
|-
| 1
| 1
| LIGHT_ENV_LAYER_CONFIG1
| Configuration 1
| lut_FR, lut_RR, lut_SP, lut_DA
| FR, RR, SP, DA
|-
|-
| 2
| 2
| LIGHT_ENV_LAYER_CONFIG2
| Configuration 2
| lut_D0, lut_D1, lut_RR, lut_DA
| D0, D1, RR, DA
|-
|-
| 3
| 3
| LIGHT_ENV_LAYER_CONFIG3
| Configuration 3
| lut_D0, lut_D1, lut_FR, lut_DA
| D0, D1, FR, DA
|-
|-
| 4
| 4
| LIGHT_ENV_LAYER_CONFIG4
| Configuration 4
| All except for lut_FR
| All except for FR
|-
|-
| 5
| 5
| LIGHT_ENV_LAYER_CONFIG5
| Configuration 5
| All except for lut_D1
| All except for D1
|-
|-
| 6
| 6
| LIGHT_ENV_LAYER_CONFIG6
| Configuration 6
| All except for lut_RB and lut_RG
| All except for RB and RG
|-
|-
| 8 (sic)
| 8
| LIGHT_ENV_LAYER_CONFIG7
| Configuration 7
| All
| All
|}
|}


Bump mode constants:
Bump mode values:


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 6,333: Line 6,514:
|-
|-
| 0
| 0
| BUMP_NOT_USED
| Not used
|-
|-
| 1
| 1
| BUMP_AS_BUMP
| Use as bump map
|-
|-
| 2
| 2
| BUMP_AS_TANG
| Use as tangent map
|}
|}
Bit 30 is set when bump mode is not zero.


=== GPUREG_LIGHTING_CONFIG1 ===
=== GPUREG_LIGHTING_CONFIG1 ===
Line 6,351: Line 6,530:
|-
|-
| 0
| 0
| unsigned, Disable bit for frag light source 0 shadows
| unsigned, Fragment light source 0 shadows disabled (0 = enabled, 1 = disabled)
|-
|-
| 1
| 1
| unsigned, Disable bit for frag light source 1 shadows
| unsigned, Fragment light source 1 shadows disabled (0 = enabled, 1 = disabled)
|-
|-
| 2
| 2
| unsigned, Disable bit for frag light source 2 shadows
| unsigned, Fragment light source 2 shadows disabled (0 = enabled, 1 = disabled)
|-
|-
| 3
| 3
| unsigned, Disable bit for frag light source 3 shadows
| unsigned, Fragment light source 3 shadows disabled (0 = enabled, 1 = disabled)
|-
|-
| 4
| 4
| unsigned, Disable bit for frag light source 4 shadows
| unsigned, Fragment light source 4 shadows disabled (0 = enabled, 1 = disabled)
|-
|-
| 5
| 5
| unsigned, Disable bit for frag light source 5 shadows
| unsigned, Fragment light source 5 shadows disabled (0 = enabled, 1 = disabled)
|-
|-
| 6
| 6
| unsigned, Disable bit for frag light source 6 shadows
| unsigned, Fragment light source 6 shadows disabled (0 = enabled, 1 = disabled)
|-
|-
| 7
| 7
| unsigned, Disable bit for frag light source 7 shadows
| unsigned, Fragment light source 7 shadows disabled (0 = enabled, 1 = disabled)
|-
|-
| 8
| 8
| unsigned, Disable bit for frag light source 0 spot
| unsigned, Fragment light source 0 spot light disabled (0 = enabled, 1 = disabled)
|-
|-
| 9
| 9
| unsigned, Disable bit for frag light source 1 spot
| unsigned, Fragment light source 1 spot light disabled (0 = enabled, 1 = disabled)
|-
|-
| 10
| 10
| unsigned, Disable bit for frag light source 2 spot
| unsigned, Fragment light source 2 spot light disabled (0 = enabled, 1 = disabled)
|-
|-
| 11
| 11
| unsigned, Disable bit for frag light source 3 spot
| unsigned, Fragment light source 3 spot light disabled (0 = enabled, 1 = disabled)
|-
|-
| 12
| 12
| unsigned, Disable bit for frag light source 4 spot
| unsigned, Fragment light source 4 spot light disabled (0 = enabled, 1 = disabled)
|-
|-
| 13
| 13
| unsigned, Disable bit for frag light source 5 spot
| unsigned, Fragment light source 5 spot light disabled (0 = enabled, 1 = disabled)
|-
|-
| 14
| 14
| unsigned, Disable bit for frag light source 6 spot
| unsigned, Fragment light source 6 spot light disabled (0 = enabled, 1 = disabled)
|-
|-
| 15
| 15
| unsigned, Disable bit for frag light source 7 spot
| unsigned, Fragment light source 7 spot light disabled (0 = enabled, 1 = disabled)
|-
|-
| 16
| 16
| unsigned, Disable bit for lut_D0
| unsigned, Term 0 distribution component D0 LUT disabled (0 = enabled, 1 = disabled)
|-
|-
| 17
| 17
| unsigned, Disable bit for lut_D1
| unsigned, Term 1 distribution component D1 LUT disabled (0 = enabled, 1 = disabled)
|-
|-
| 18
| 18
| Unknown, set to 1
| 0x1
|-
|-
| 19
| 19
| unsigned, Disable bit for lut_FR
| unsigned, Fresnel FR LUT disabled (0 = enabled, 1 = disabled)
|-
|-
| 20
| 20-22
| unsigned, Disable bit for lut_RB
| unsigned, Term 1 reflection component RB LUT disabled (0 = enabled, 7 = disabled)
|-
|-
| 21
| 21
| unsigned, Disable bit for lut_RG
| unsigned, Term 1 reflection component RG LUT disabled (0 = enabled, 7 = disabled)
|-
|-
| 22
| 22
| unsigned, Disable bit for lut_RR
| unsigned, Term 1 reflection component RR LUT disabled (0 = enabled, 7 = disabled)
|-
| 23
| Unknown, set to 1
|-
|-
| 24
| 24
| unsigned, Disable bit for frag light source 0 distance attenuation
| unsigned, Fragment light source 0 distance attenuation disabled (0 = enabled, 1 = disabled)
|-
|-
| 25
| 25
| unsigned, Disable bit for frag light source 1 distance attenuation
| unsigned, Fragment light source 1 distance attenuation disabled (0 = enabled, 1 = disabled)
|-
|-
| 26
| 26
| unsigned, Disable bit for frag light source 2 distance attenuation
| unsigned, Fragment light source 2 distance attenuation disabled (0 = enabled, 1 = disabled)
|-
|-
| 27
| 27
| unsigned, Disable bit for frag light source 3 distance attenuation
| unsigned, Fragment light source 3 distance attenuation disabled (0 = enabled, 1 = disabled)
|-
|-
| 28
| 28
| unsigned, Disable bit for frag light source 4 distance attenuation
| unsigned, Fragment light source 4 distance attenuation disabled (0 = enabled, 1 = disabled)
|-
|-
| 29
| 29
| unsigned, Disable bit for frag light source 5 distance attenuation
| unsigned, Fragment light source 5 distance attenuation disabled (0 = enabled, 1 = disabled)
|-
|-
| 30
| 30
| unsigned, Disable bit for frag light source 6 distance attenuation
| unsigned, Fragment light source 6 distance attenuation disabled (0 = enabled, 1 = disabled)
|-
|-
| 31
| 31
| unsigned, Disable bit for frag light source 7 distance attenuation
| unsigned, Fragment light source 7 distance attenuation disabled (0 = enabled, 1 = disabled)
|}
|}


=== GPUREG_LIGHTING_NUM_LIGHTS ===
=== GPUREG_LIGHTING_LUT_INDEX ===
 
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-7
| unsigned, Starting index
|-
| 8-12
| unsigned, Look-up table
|}


The number of active lights minus one (0..7) is written to this register.
This register controls which LUT and what offset into it the LUT_DATA register writes to.


=== GPUREG_LIGHTING_LIGHT_PERMUTATION ===
Lookup table values:


{| class="wikitable" border="1"
{| class="wikitable" border="1"
! Bits
! Value
! Description
! Description
|-
|-
| 0-2
| 0
| unsigned, ID of the 1st enabled light (0..7)
| D0
|-
|-
| 4-6
| 1
| unsigned, ID of the 2nd enabled light (0..7)
| D1
|-
|-
| 8-10
| 3
| unsigned, ID of the 3rd enabled light (0..7)
| FR
|-
|-
| 12-14
| 4
| unsigned, ID of the 4th enabled light (0..7)
| RB
|-
|-
| 16-18
| 5
| unsigned, ID of the 5th enabled light (0..7)
| RG
|-
|-
| 20-22
| 6
| unsigned, ID of the 6th enabled light (0..7)
| RR
|-
|-
| 24-26
| 8-15
| unsigned, ID of the 7th enabled light (0..7)
| SP0-7
|-
|-
| 28-30
| 16-23
| unsigned, ID of the 8th enabled light (0..7)
| DA0-7
|}
|}


=== GPUREG_LIGHTING_LUTINPUT_SELECT ===
=== GPUREG_LIGHTING_ENABLE1 ===


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 6,488: Line 6,675:
! Description
! Description
|-
|-
| 0-3
| 0
| unsigned, Input selector for lut_D0
| unsigned, Disabled (0 = enabled, 1 = disabled)
|-
|}
| 4-7
 
| unsigned, Input selector for lut_D1
This register is set to 1 when fragment lighting is disabled, and to 0 when it is enabled.
|-
 
| 8-11
=== GPUREG_LIGHTING_LUT_DATA''i'' ===
| unsigned, Input selector for lut_SP
 
{| class="wikitable" border="1"
! Bits
! Description
|-
|-
| 12-15
| 0-23
| unsigned, Input selector for lut_FR
| LUT data
|-
| 16-19
| unsigned, Input selector for lut_RB
|-
| 20-23
| unsigned, Input selector for lut_RG
|-
| 24-27
| unsigned, Input selector for lut_RR
|}
|}


Input selector values:
Lighting LUT data is written here.
 
A LUT contains data for the input domain [-1.0, 1.0], which is indexed using a signed 8-bit number [-128, 127]. Therefore a LUT contains 256 entries. The index of a value is (int)(x/127.0f) & 0xFF.
 
DA: The input domain is [0.0, 1.0], and the index is an unsigned 8-bit number [0, 255] instead.
 
Format of an entry:


{| class="wikitable" border="1"
{| class="wikitable" border="1"
! Value
! Bits
! Description
! Description
|-
|-
| 0
| 0-11
| N·H
| fixed0.0.12, Entry value
|-
|-
| 1
| 12-23
| V·H
| fixed1.0.11, Absolute value of the difference between the next entry and this entry, used to implement linear interpolation
|-
| 2
| N·V
|-
| 3
| L·N
|-
| 4
| -L·P (aka Spotlight aka SP)
|-
| 5
| cos φ (aka CP)
|}
|}


Line 6,542: Line 6,717:
|-
|-
| 1
| 1
| unsigned, abs() flag for the input of lut_D0 (0=enabled, 1=disabled)
| unsigned, abs() flag for the input of D0 (0 = enabled, 1 = disabled)
|-
|-
| 5
| 5
| unsigned, abs() flag for the input of lut_D1 (0=enabled, 1=disabled)
| unsigned, abs() flag for the input of D1 (0 = enabled, 1 = disabled)
|-
|-
| 9
| 9
| unsigned, abs() flag for the input of lut_SP (0=enabled, 1=disabled)
| unsigned, abs() flag for the input of SP (0 = enabled, 1 = disabled)
|-
|-
| 13
| 13
| unsigned, abs() flag for the input of lut_FR (0=enabled, 1=disabled)
| unsigned, abs() flag for the input of FR (0 = enabled, 1 = disabled)
|-
|-
| 17
| 17
| unsigned, abs() flag for the input of lut_RB (0=enabled, 1=disabled)
| unsigned, abs() flag for the input of RB (0 = enabled, 1 = disabled)
|-
|-
| 21
| 21
| unsigned, abs() flag for the input of lut_RG (0=enabled, 1=disabled)
| unsigned, abs() flag for the input of RG (0 = enabled, 1 = disabled)
|-
|-
| 25
| 25
| unsigned, abs() flag for the input of lut_RR (0=enabled, 1=disabled)
| unsigned, abs() flag for the input of RR (0 = enabled, 1 = disabled)
|}
|}


This register controls whether the absolute value of the input is taken before using a LUT.
This register controls whether the absolute value of the input is taken before using a LUT.


=== GPUREG_LIGHTING_LUTINPUT_SCALE ===
=== GPUREG_LIGHTING_LUTINPUT_SELECT ===


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 6,571: Line 6,746:
! Description
! Description
|-
|-
| 0-3
| 0-2
| unsigned, Scaler selector for lut_D0
| unsigned, Input selector for D0
|-
|-
| 4-7
| 4-6
| unsigned, Scaler selector for lut_D1
| unsigned, Input selector for D1
|-
|-
| 8-11
| 8-10
| unsigned, Scaler selector for lut_SP
| unsigned, Input selector for SP
|-
|-
| 12-15
| 12-14
| unsigned, Scaler selector for lut_FR
| unsigned, Input selector for FR
|-
|-
| 16-19
| 16-18
| unsigned, Scaler selector for lut_RB
| unsigned, Input selector for RB
|-
|-
| 20-23
| 20-22
| unsigned, Scaler selector for lut_RG
| unsigned, Input selector for RG
|-
|-
| 24-27
| 24-26
| unsigned, Scaler selector for lut_RR
| unsigned, Input selector for RR
|}
|}


Scaler selector values:
Input selector values:


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 6,600: Line 6,775:
|-
|-
| 0
| 0
| 1x
| N·H
|-
|-
| 1
| 1
| 2x
| V·H
|-
|-
| 2
| 2
| 4x
| N·V
|-
|-
| 3
| 3
| 8x
| L·N
|-
|-
| 6
| 4
| 0.25x
| -L·P (aka Spotlight aka SP)
|-
|-
| 7
| 5
| 0.5x
| cos φ (aka CP)
|}
|}


This register controls the scaling that is applied to the output of a LUT.
=== GPUREG_LIGHTING_LUTINPUT_SCALE ===
 
=== GPUREG_LIGHTING_LUT_INDEX ===
 
This register controls which LUT and what offset into it the LUT_DATA register writes to.


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 6,628: Line 6,799:
! Description
! Description
|-
|-
| 0-7
| 0-2
| unsigned, Starting entry offset (0...255)
| unsigned, Scaler selector for D0
|-
| 4-6
| unsigned, Scaler selector for D1
|-
|-
| 8-10
| 8-10
| unsigned, LUT ID (context=0) or Light ID (context=1,2)
| unsigned, Scaler selector for SP
|-
|-
| 11-12
| 12-14
| unsigned, Context ID
| unsigned, Scaler selector for FR
|}
 
LUT ID values:
 
{| class="wikitable" border="1"
! Value
! Description
|-
|-
| 0
| 16-18
| lut_D0
| unsigned, Scaler selector for RB
|-
|-
| 1
| 20-22
| lut_D1
| unsigned, Scaler selector for RG
|-
|-
| 3
| 24-26
| lut_FR
| unsigned, Scaler selector for RR
|-
| 4
| lut_RB
|-
| 5
| lut_RG
|-
| 6
| lut_RR
|}
|}


Context ID values:
This register controls the scaling that is applied to the output of a LUT.
 
Scaler selector values:


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 6,670: Line 6,830:
|-
|-
| 0
| 0
| unsigned, LUTs common to all lights - writes to the LUT selected by the ID
| 1x
|-
|-
| 1
| 1
| unsigned, lut_SP - writes to the LUT specific to the selected light
| 2x
|-
|-
| 2
| 2
| unsigned, lut_DA - writes to the LUT specific to the selected light
| 4x
|}
 
=== GPUREG_LIGHTING_LUT_DATA ===
 
Lighting LUT data is written here.
 
A LUT contains data for the input domain [-1.0, 1.0], which is indexed using a signed 8-bit number [-128, 127]. Therefore a LUT contains 256 entries. The index of a value is (int)(x/127.0f) & 0xFF.
 
lut_DA: The input domain is [0.0, 1.0], and the index is an unsigned 8-bit number [0, 255] instead.
 
Format of an entry:
 
{| class="wikitable" border="1"
! Bits
! Description
|-
|-
| 0-11
| 3
| fixed0.0.12, Entry value (12bit fractional number; floatval = x / 4096; however 0xFFF is treated as 1.0)
| 8x
|-
|-
| 12-23
| 6
| fixed1.0.11, Absolute value of the difference between the next entry and this entry, used to implement linear interpolation
| 0.25x
|}
 
=== GPUREG_LIGHTING_AMBIENT ===
 
{| class="wikitable" border="1"
! Bits
! Description
|-
|-
| 0-7
| 7
| unsigned, Blue component (0..255)
| 0.5x
|-
| 10-17
| unsigned, Green component (0..255)
|-
| 20-27
| unsigned, Red component (0..255)
|}
|}


This register contains the initial value of the fragment primary color before the partial colors that correspond to each enabled light are added. Usually set to material_emission + material_ambient*scene_ambient.
=== GPUREG_LIGHTING_LIGHT_PERMUTATION ===
 
=== GPUREG_LIGHTx_CONFIG ===


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 6,724: Line 6,854:
! Description
! Description
|-
|-
| 0
| 0-2
| unsigned, Light type (0 = positional light, 1 = directional light)
| unsigned, ID of the 1st enabled light
|-
|-
| 1
| 4-6
| unsigned, Two side diffuse (0=disable, 1=enable)
| unsigned, ID of the 2nd enabled light
|-
|-
| 2
| 8-10
| unsigned, Geometric factor 0 (0=disable, 1=enable)
| unsigned, ID of the 3rd enabled light
|-
|-
| 3
| 12-14
| unsigned, Geometric factor 1 (0=disable, 1=enable)
| unsigned, ID of the 4th enabled light
|}
 
=== GPUREG_LIGHTx_XY ===
 
{| class="wikitable" border="1"
! Bits
! Description
|-
|-
| 0-15
| 16-18
| float1.5.10, X coordinate
| unsigned, ID of the 5th enabled light
|-
|-
| 16-31
| 20-22
| float1.5.10, Y coordinate
| unsigned, ID of the 6th enabled light
|}
 
These registers (along with _Z) represent the light position (for a positional light) or the light direction vector (for a directional light) of the corresponding light.
 
=== GPUREG_LIGHTx_Z ===
 
{| class="wikitable" border="1"
! Bits
! Description
|-
|-
| 0-15
| 24-26
| float1.5.10, Z coordinate
| unsigned, ID of the 7th enabled light
|}
 
These registers (along with _XY) represent the light position (for a positional light) or the light direction vector (for a directional light) of the corresponding light.
 
=== GPUREG_LIGHTx_SPOTDIR_XY ===
 
{| class="wikitable" border="1"
! Bits
! Description
|-
|-
| 0-12
| 28-30
| fixed1.1.11, X coordinate (Usually the input value is negated)
| unsigned, ID of the 8th enabled light
|-
| 16-28
| fixed1.1.11, Y coordinate (Usually the input value is negated)
|}
|}
These registers (along with _Z) represent the spot direction (unitary) vector of the corresponding light.
=== GPUREG_LIGHTx_SPOTDIR_Z ===
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-12
| fixed1.1.11, Z coordinate (Usually the input value is negated)
|}
These registers (along with _XY) represent the spot direction (unitary) vector of the corresponding light.
=== GPUREG_LIGHTx_ATTENUATION_BIAS ===
These registers contain the distance attenuation bias value (float20 = 1.7.12) of the corresponding light. The attenuation factor is lut_DA(clip(bias + scale*distance, 0.0, 1.0)).
=== GPUREG_LIGHTx_ATTENUATION_SCALE ===
These registers contain the distance attenuation scale value (float20 = 1.7.12) of the corresponding light. The attenuation factor is lut_DA(clip(bias + scale*distance, 0.0, 1.0)).
=== GPUREG_LIGHTx_AMBIENT ===
These registers contain the ambient color (same format as GPUREG_LIGHTING_AMBIENT) of the corresponding light. Usually set to material_ambient*lightX_ambient.
=== GPUREG_LIGHTx_DIFFUSE ===
These registers contain the diffuse color (same format as GPUREG_LIGHTING_AMBIENT) of the corresponding light. Usually set to material_diffuse*lightX_diffuse.
=== GPUREG_LIGHTx_SPECULAR0 ===
These registers contain the specular0 color (same format as GPUREG_LIGHTING_AMBIENT) of the corresponding light. Usually set to material_specular0*lightX_specular0.
=== GPUREG_LIGHTx_SPECULAR1 ===
These registers contain the specular1 color (same format as GPUREG_LIGHTING_AMBIENT) of the corresponding light. Usually set to material_specular1*lightX_specular1.


== Geometry pipeline registers ==
== Geometry pipeline registers ==