15bd8deadSopenharmony_ciXXX - not done yet
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ciName
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ci    SGIX_fragment_lighting_space
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ciName Strings
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ci    GL_SGIX_fragment_lighting_space
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ciVersion
125bd8deadSopenharmony_ci
135bd8deadSopenharmony_ci    $Date: 1998/05/12 23:52:07 $ $Revision: 1.14 $
145bd8deadSopenharmony_ci
155bd8deadSopenharmony_ciNumber
165bd8deadSopenharmony_ci
175bd8deadSopenharmony_ci    118
185bd8deadSopenharmony_ci
195bd8deadSopenharmony_ciDependencies
205bd8deadSopenharmony_ci
215bd8deadSopenharmony_ci    EXT_fragment_lighting is required.
225bd8deadSopenharmony_ci    EXT_coordinate_frame is required.
235bd8deadSopenharmony_ci
245bd8deadSopenharmony_ciOverview
255bd8deadSopenharmony_ci
265bd8deadSopenharmony_ci    This extension specifies that the fragment lighting vectors including
275bd8deadSopenharmony_ci    the view vector, light vectors, halfangle vectors and 
285bd8deadSopenharmony_ci    spotlight direction vectors, be transformed into either eye-space, 
295bd8deadSopenharmony_ci    object-space or tangent-space on a per-vertex basis. 
305bd8deadSopenharmony_ci    The default is eye-space. 
315bd8deadSopenharmony_ci
325bd8deadSopenharmony_ci    Combined with the ability to take a normal vector from texture memory,
335bd8deadSopenharmony_ci    as specified by the SGIX_light_texture extension, 
345bd8deadSopenharmony_ci    the ability to transform other shading vectors to the same space 
355bd8deadSopenharmony_ci    as the normal vector allows advanced shading effects such as 
365bd8deadSopenharmony_ci    bump mapping to be realized.
375bd8deadSopenharmony_ci
385bd8deadSopenharmony_ci    The tangent-space transform uses the per-vertex tangent and binormal
395bd8deadSopenharmony_ci    vector introduced by the EXT_coordinate_frame extension.
405bd8deadSopenharmony_ci
415bd8deadSopenharmony_ciIssues
425bd8deadSopenharmony_ci
435bd8deadSopenharmony_ci    * A suggestion for a different way to attack this is to introduce the
445bd8deadSopenharmony_ci    concept of a per-vertex matrix which is applied to lighting vectors.
455bd8deadSopenharmony_ci    Coupled with a new matrix-gen function, we could generate the necessary 
465bd8deadSopenharmony_ci    per-vertex matrices.
475bd8deadSopenharmony_ci
485bd8deadSopenharmony_ci    * Are we really dependent upon fragment light?
495bd8deadSopenharmony_ci
505bd8deadSopenharmony_ci    Theoretically, no, but doing lighting in a space other than 
515bd8deadSopenharmony_ci    eye-space doesn't help one much unless we can do something 
525bd8deadSopenharmony_ci    like get normal vectors from texture.  
535bd8deadSopenharmony_ci    For that reason it doesn't seem to make sense to burden per-vertex
545bd8deadSopenharmony_ci    lighting with this generality.
555bd8deadSopenharmony_ci
565bd8deadSopenharmony_ci    * If we are dependent upon fragment light are we not also dependent
575bd8deadSopenharmony_ci    upon SGIX_light_texture? 
585bd8deadSopenharmony_ci
595bd8deadSopenharmony_ci    It would seem to make little sense to implement light_space and not
605bd8deadSopenharmony_ci    light texture because the combination of the two of them is what
615bd8deadSopenharmony_ci    makes bump mapping possible. But since there is nothing gained by
625bd8deadSopenharmony_ci    making light_space dependent upon light_texture we won't make it
635bd8deadSopenharmony_ci    dependent upon light_texture
645bd8deadSopenharmony_ci
655bd8deadSopenharmony_ciNew Procedures and Functions
665bd8deadSopenharmony_ci
675bd8deadSopenharmony_ci    FragmentLightSpaceSGIX(enum space);
685bd8deadSopenharmony_ci
695bd8deadSopenharmony_ciNew Tokens
705bd8deadSopenharmony_ci
715bd8deadSopenharmony_ci    Accepted by the <space> parameter of FragmentLightSpaceSGIX:
725bd8deadSopenharmony_ci
735bd8deadSopenharmony_ci	EYE_SPACE_SGIX			0x8436
745bd8deadSopenharmony_ci	TANGENT_SPACE_SGIX		0x8437
755bd8deadSopenharmony_ci	OBJECT_SPACE_SGIX		0x8438
765bd8deadSopenharmony_ci
775bd8deadSopenharmony_ci    Accepted by the <pname> parameter of GetBooleanv, GetIntegerv,
785bd8deadSopenharmony_ci    GetFloatv, and GetDoublev:
795bd8deadSopenharmony_ci
805bd8deadSopenharmony_ci	FRAGMENT_LIGHT_SPACE_SGIX	0x843D
815bd8deadSopenharmony_ci
825bd8deadSopenharmony_ciAdditions to Chapter 2 of the 1.0 Specification (OpenGL Operation)
835bd8deadSopenharmony_ci 
845bd8deadSopenharmony_ci    The fragment_light.spec section 3.9.2 Lighting Operation is amended: 
855bd8deadSopenharmony_ci
865bd8deadSopenharmony_ci    If FragmentLightSpaceSGIX specifies 
875bd8deadSopenharmony_ci    EYE_SPACE_SGIX            <default> 
885bd8deadSopenharmony_ci    then calculations are carried out in eye space.
895bd8deadSopenharmony_ci
905bd8deadSopenharmony_ci    If FragmentLightSpaceSGIX specifies 
915bd8deadSopenharmony_ci    TANGENT_SPACE_SGIX  
925bd8deadSopenharmony_ci    then calculations are carried out in tangent space  by
935bd8deadSopenharmony_ci    constructing an orthonormal basis from the per-vertex tangent,
945bd8deadSopenharmony_ci    binormal and normal vectors and using that matrix to transform
955bd8deadSopenharmony_ci    eye-space shading vectors into tangent space on a 
965bd8deadSopenharmony_ci    per-vertex basis. The vectors are normalized before being passed
975bd8deadSopenharmony_ci    to the rasterization stage where the fragment lighting calculations 
985bd8deadSopenharmony_ci    are performed.
995bd8deadSopenharmony_ci
1005bd8deadSopenharmony_ci    The matrix is constructed as follows:
1015bd8deadSopenharmony_ci
1025bd8deadSopenharmony_ci    if NORMALIZE is enabled,
1035bd8deadSopenharmony_ci	b = cross(normal,tangent);
1045bd8deadSopenharmony_ci	t = cross(b,n);
1055bd8deadSopenharmony_ci	t = normalize(t);
1065bd8deadSopenharmony_ci	b = normalize(b);
1075bd8deadSopenharmony_ci	n = normalize(normal);
1085bd8deadSopenharmony_ci    else
1095bd8deadSopenharmony_ci	t = tangent
1105bd8deadSopenharmony_ci	b = binormal
1115bd8deadSopenharmony_ci	n = normal
1125bd8deadSopenharmony_ci
1135bd8deadSopenharmony_ci    the matrix
1145bd8deadSopenharmony_ci
1155bd8deadSopenharmony_ci    M  = ( t - - )
1165bd8deadSopenharmony_ci	 ( b - - )
1175bd8deadSopenharmony_ci	 ( n - - )
1185bd8deadSopenharmony_ci
1195bd8deadSopenharmony_ci    maps (1,0,0) to t,
1205bd8deadSopenharmony_ci         (0,1,0) to b,
1215bd8deadSopenharmony_ci         (0,0,1) to n.
1225bd8deadSopenharmony_ci
1235bd8deadSopenharmony_ci    Because it is an orthogonal matrix, its inverse is its transpose:
1245bd8deadSopenharmony_ci
1255bd8deadSopenharmony_ci    Mi = ( t b n )
1265bd8deadSopenharmony_ci	 ( | | | )
1275bd8deadSopenharmony_ci	 ( | | | )
1285bd8deadSopenharmony_ci
1295bd8deadSopenharmony_ci    and maps t to (1,0,0),
1305bd8deadSopenharmony_ci             b to (0,1,0),
1315bd8deadSopenharmony_ci             n to (0,0,1), ie, maps vectors to tangent space.
1325bd8deadSopenharmony_ci
1335bd8deadSopenharmony_ci    Any shading vectors required by the fragment lighting rasterization
1345bd8deadSopenharmony_ci    stages, which could include the view vector V, light vector VPli, 
1355bd8deadSopenharmony_ci    halfangle vector hi and spotlight direction vector, sdli, 
1365bd8deadSopenharmony_ci    are first computed in eye space on a per-vertex basis and then 
1375bd8deadSopenharmony_ci    transformed by Mi to the tangent space shading vectors, Vts, Ltsi, Htsi, sdltsi.
1385bd8deadSopenharmony_ci
1395bd8deadSopenharmony_ci    if FragmentLightSpaceSGIX specifies 
1405bd8deadSopenharmony_ci    OBJECT_SPACE_SGIX  
1415bd8deadSopenharmony_ci    then fragment lighting calculations can be carried out in object space 
1425bd8deadSopenharmony_ci    by transforming the eye-space shading vectors by the 
1435bd8deadSopenharmony_ci    inverse of the current modelview matrix and subsequently normalizing 
1445bd8deadSopenharmony_ci    them.
1455bd8deadSopenharmony_ci
1465bd8deadSopenharmony_ciAdditions to Chapter 3 of the 1.0 Specification (Rasterization)
1475bd8deadSopenharmony_ci
1485bd8deadSopenharmony_ci    None
1495bd8deadSopenharmony_ci
1505bd8deadSopenharmony_ciAdditions to Chapter 4 of the 1.0 Specification (Per-Fragment Operations
1515bd8deadSopenharmony_ciand the Frame Buffer)
1525bd8deadSopenharmony_ci
1535bd8deadSopenharmony_ci    None
1545bd8deadSopenharmony_ci
1555bd8deadSopenharmony_ciAdditions to Chapter 5 of the 1.0 Specification (Special Functions)
1565bd8deadSopenharmony_ci
1575bd8deadSopenharmony_ci    None
1585bd8deadSopenharmony_ci
1595bd8deadSopenharmony_ciAdditions to Chapter 6 of the 1.0 Specification (State and State Requests)
1605bd8deadSopenharmony_ci
1615bd8deadSopenharmony_ci    tables are extended with state values from New State section
1625bd8deadSopenharmony_ci
1635bd8deadSopenharmony_ciAdditions to the GLX Specification
1645bd8deadSopenharmony_ci
1655bd8deadSopenharmony_ci    None
1665bd8deadSopenharmony_ci
1675bd8deadSopenharmony_ciGLX Protocol
1685bd8deadSopenharmony_ci
1695bd8deadSopenharmony_ci    XXX - not yet complete
1705bd8deadSopenharmony_ci
1715bd8deadSopenharmony_ciErrors
1725bd8deadSopenharmony_ci
1735bd8deadSopenharmony_ci    INVALID_ENUM is generated if FragmentLightSpaceSGIX parameter
1745bd8deadSopenharmony_ci    <space> is not EYE_SPACE_SGIX, OBJECT_SPACE_SGIX, or TANGENT_SPACE_SGIX.
1755bd8deadSopenharmony_ci
1765bd8deadSopenharmony_ci    INVALID_OPERATION is generated if FragmentLightSpaceSGIX is called
1775bd8deadSopenharmony_ci    between the execution of Begin and the corresponding execution of End.
1785bd8deadSopenharmony_ci
1795bd8deadSopenharmony_ciNew State
1805bd8deadSopenharmony_ci    Get Value			Get Command	Type	Initial Value	Attribute
1815bd8deadSopenharmony_ci    ---------			-----------	----	-------------	---------
1825bd8deadSopenharmony_ci    FRAGMENT_LIGHT_SPACE_SGIX	GetIntegerv	Z3	EYE_SPACE_SGIX	lighting/enable
1835bd8deadSopenharmony_ci
1845bd8deadSopenharmony_ciNew Implementation Dependent State
1855bd8deadSopenharmony_ci
1865bd8deadSopenharmony_ci    None
1875bd8deadSopenharmony_ci
188