1XXX - not done yet 2 3Name 4 5 SGIX_fragment_lighting_space 6 7Name Strings 8 9 GL_SGIX_fragment_lighting_space 10 11Version 12 13 $Date: 1998/05/12 23:52:07 $ $Revision: 1.14 $ 14 15Number 16 17 118 18 19Dependencies 20 21 EXT_fragment_lighting is required. 22 EXT_coordinate_frame is required. 23 24Overview 25 26 This extension specifies that the fragment lighting vectors including 27 the view vector, light vectors, halfangle vectors and 28 spotlight direction vectors, be transformed into either eye-space, 29 object-space or tangent-space on a per-vertex basis. 30 The default is eye-space. 31 32 Combined with the ability to take a normal vector from texture memory, 33 as specified by the SGIX_light_texture extension, 34 the ability to transform other shading vectors to the same space 35 as the normal vector allows advanced shading effects such as 36 bump mapping to be realized. 37 38 The tangent-space transform uses the per-vertex tangent and binormal 39 vector introduced by the EXT_coordinate_frame extension. 40 41Issues 42 43 * A suggestion for a different way to attack this is to introduce the 44 concept of a per-vertex matrix which is applied to lighting vectors. 45 Coupled with a new matrix-gen function, we could generate the necessary 46 per-vertex matrices. 47 48 * Are we really dependent upon fragment light? 49 50 Theoretically, no, but doing lighting in a space other than 51 eye-space doesn't help one much unless we can do something 52 like get normal vectors from texture. 53 For that reason it doesn't seem to make sense to burden per-vertex 54 lighting with this generality. 55 56 * If we are dependent upon fragment light are we not also dependent 57 upon SGIX_light_texture? 58 59 It would seem to make little sense to implement light_space and not 60 light texture because the combination of the two of them is what 61 makes bump mapping possible. But since there is nothing gained by 62 making light_space dependent upon light_texture we won't make it 63 dependent upon light_texture 64 65New Procedures and Functions 66 67 FragmentLightSpaceSGIX(enum space); 68 69New Tokens 70 71 Accepted by the <space> parameter of FragmentLightSpaceSGIX: 72 73 EYE_SPACE_SGIX 0x8436 74 TANGENT_SPACE_SGIX 0x8437 75 OBJECT_SPACE_SGIX 0x8438 76 77 Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, 78 GetFloatv, and GetDoublev: 79 80 FRAGMENT_LIGHT_SPACE_SGIX 0x843D 81 82Additions to Chapter 2 of the 1.0 Specification (OpenGL Operation) 83 84 The fragment_light.spec section 3.9.2 Lighting Operation is amended: 85 86 If FragmentLightSpaceSGIX specifies 87 EYE_SPACE_SGIX <default> 88 then calculations are carried out in eye space. 89 90 If FragmentLightSpaceSGIX specifies 91 TANGENT_SPACE_SGIX 92 then calculations are carried out in tangent space by 93 constructing an orthonormal basis from the per-vertex tangent, 94 binormal and normal vectors and using that matrix to transform 95 eye-space shading vectors into tangent space on a 96 per-vertex basis. The vectors are normalized before being passed 97 to the rasterization stage where the fragment lighting calculations 98 are performed. 99 100 The matrix is constructed as follows: 101 102 if NORMALIZE is enabled, 103 b = cross(normal,tangent); 104 t = cross(b,n); 105 t = normalize(t); 106 b = normalize(b); 107 n = normalize(normal); 108 else 109 t = tangent 110 b = binormal 111 n = normal 112 113 the matrix 114 115 M = ( t - - ) 116 ( b - - ) 117 ( n - - ) 118 119 maps (1,0,0) to t, 120 (0,1,0) to b, 121 (0,0,1) to n. 122 123 Because it is an orthogonal matrix, its inverse is its transpose: 124 125 Mi = ( t b n ) 126 ( | | | ) 127 ( | | | ) 128 129 and maps t to (1,0,0), 130 b to (0,1,0), 131 n to (0,0,1), ie, maps vectors to tangent space. 132 133 Any shading vectors required by the fragment lighting rasterization 134 stages, which could include the view vector V, light vector VPli, 135 halfangle vector hi and spotlight direction vector, sdli, 136 are first computed in eye space on a per-vertex basis and then 137 transformed by Mi to the tangent space shading vectors, Vts, Ltsi, Htsi, sdltsi. 138 139 if FragmentLightSpaceSGIX specifies 140 OBJECT_SPACE_SGIX 141 then fragment lighting calculations can be carried out in object space 142 by transforming the eye-space shading vectors by the 143 inverse of the current modelview matrix and subsequently normalizing 144 them. 145 146Additions to Chapter 3 of the 1.0 Specification (Rasterization) 147 148 None 149 150Additions to Chapter 4 of the 1.0 Specification (Per-Fragment Operations 151and the Frame Buffer) 152 153 None 154 155Additions to Chapter 5 of the 1.0 Specification (Special Functions) 156 157 None 158 159Additions to Chapter 6 of the 1.0 Specification (State and State Requests) 160 161 tables are extended with state values from New State section 162 163Additions to the GLX Specification 164 165 None 166 167GLX Protocol 168 169 XXX - not yet complete 170 171Errors 172 173 INVALID_ENUM is generated if FragmentLightSpaceSGIX parameter 174 <space> is not EYE_SPACE_SGIX, OBJECT_SPACE_SGIX, or TANGENT_SPACE_SGIX. 175 176 INVALID_OPERATION is generated if FragmentLightSpaceSGIX is called 177 between the execution of Begin and the corresponding execution of End. 178 179New State 180 Get Value Get Command Type Initial Value Attribute 181 --------- ----------- ---- ------------- --------- 182 FRAGMENT_LIGHT_SPACE_SGIX GetIntegerv Z3 EYE_SPACE_SGIX lighting/enable 183 184New Implementation Dependent State 185 186 None 187 188