1Name 2 3 WIN_specular_fog 4 5Name Strings 6 7 GL_WIN_specular_fog 8 9Version 10 11 $Date: 1997/4/3 12 13Number 14 15 114 16 17Dependencies 18 19 none 20 21Overview 22 23 Specularly lit textures enhance the realism of a scene greatly. 24 Using the current OpenGL lighting model, one cannot obtain specularly lit 25 textures. This is because in the current OpenGL lighting model lighting 26 is done ahead of texturing and texture-functions such as modulate are 27 inadequate for such a simulation. What needs to be addressed is that, 28 somehow an additional interpolant (specular color of that material) needs 29 to be propagated till that stage of the pipeline where texture-mapping is 30 performed. This interpolant is then added on to the fragment's color 31 resulting from the texturing process before proceeding with the rest of 32 the pipeline. 33 34 This can be addressed very easily in software, but hardware 35 is not so malleable. Currently most hardware does not support such a 36 37 lighting model. However, some current hardware does support fogging, 38 which takes place in the pipeline after texturing. This hardware 39 assumes that the fog blend factor f is computed per-vertex and 40 interpolates the value across the primitive. The WIN_specular_fog 41 extension enables the use of such existing fog circuitry to obtain 42 specularly lit textures without much performance degradation. 43 44 To use it the programmer simply enables the extension with a call to 45 Enable with the appropriate enumerant and sets the fog color to the 46 desired specular color. 47 48Issues 49 50 1) This extension works only if: 51 * Lighting is enabled. 52 * Texturing is enabled. 53 * Texture function is MODULATE. 54 * Two sided lighting is disabled. 55 * RenderMode is RENDER. 56 57 2) When both fogging and the extension are enabled, the FOG_HINT bit 58 is ignored. 59 60 3) One limitation is that the FOG_COLOR is used as the specular-highlight 61 color. 62 63 4) PushAttrib and PopAttrib calls save and restore the extension related 64 state when the FOG_BIT is set, along with the rest of the fog related 65 state information. 66 67 5) The highlight computed by this extension is linear-interpolation based 68 and therefore appears similar to the highlights available for untextured 69 Gouraud polygons. If Phong shading (ext #113) is enabled this similarity 70 will no longer hold as the Phong highlight is computed per-pixel. This 71 can result in the enabling of texture causing the highlight to move and 72 change shape. 73 74New Procedures and Functions 75 76 None 77 78New Tokens 79 80 Accepted by the <cap> parameter of Enable and IsEnabled: 81 82 FOG_SPECULAR_TEXTURE_WIN 0x80EC 83 84 Accepted by the <pname> parameter of GetBooleanv, GetDoublev, GetIntegerv 85 and GetFloatv 86 87 FOG_SPECULAR_TEXTURE_WIN 0x80EC 88 89Additions to Chapter 2 of the 1.1 Specification (OpenGL Operation) 90 In section 2.6 titled "Begin/End Paradigm", add to the paragraph ending 91 with "...its assigned color, and its texture coordinates", the following 92 line: 93 "In addition to these, an implementation may choose to associate a fog 94 blend factor f with the processed vertex, which is computed per vertex to 95 speed up fogging calcutaions. This value f is also used to store the 96 specular color factor computed in the lighting stage, to be applied after 97 texturing by the fog sub-system." 98 99 Modify the line "This may alter the primitive by altering....." to 100 "This may alter the primitive by altering vertex coordinates, texture 101 coordinates, fog blend-factor and color". 102 103 Figure 2.2 should be edited so that the "Associated Data" box includes 104 Fog value. 105 106 After the last paragraph of Section 2.13, "Colors and Coloring", the 107 following paragraph is added: 108 109 "If the WIN_specular_fog extension is enabled the fog value, which 110 represents the specular highlight color for the fragment, is computed 111 when lighting computation takes place." 112 113 Add the following to Section 2.13.1 as the last paragraph of subsection 114 titled "Lighting": 115 "When the WIN_specular_fog extension is enabled, the parameters used for 116 computing the color of the vertex are used to compute the fog value 117 associated with the vertex. This value represents the specular color of 118 the vertex. This value is used by the fog sub-system to add a specular 119 color to the vertex after texturing has taken place. This is a way 120 around one of OpenGL's shortcomings, where lighting is done before 121 texturing resulting in a complete loss of specular highlights." 122 123 Add the following to Section 2.13.1, subsection titled "Lighting 124 Operation", after the set of lighting equations and the line ending 125 "... V is zero": 126 "If the following conditions are met: 127 1) WIN_specular_fog is enabled, 128 2) Texturing is enabled, 129 3) Texture function is MODULATE, 130 4) Two sided lighting is disabled, 131 5) RenderMode is RENDER. 132 Then the fog value of the vertex is computed to be: 133 134 n-1 ^ srm 135 f = max (0, 1 - Sum [(att )(spot )(f )(n . h ) ]) (2.6)" 136 i=0 i i i i 137 138 = 1 , if the conditions are not met. 139 140 Renumber eq. 2.6 to 2.7. 141 142Additions to Chapter 3 of the 1.1 Specification (Rasterization) 143 144 Modify the first line of the second paragraph to: 145 "A grid square along with its parameters of assigned color, z (depth), 146 texture coordinates, normal and eye coordinates (for phong shading) 147 and f (fog blend-factor)" 148 149 In Section 3.4.1 "Basic Line Segment Rasterization", modify the line 150 151 "The value of an associated datum f......." after equation 3.1 to: 152 153 "The value of an associated datum f for the fragment, whether it be R, G, 154 B, or A (in RGBA mode) or a color index (in color index mode), or normal, 155 eye coordinate or material properties (when phong-shaded), or the s, t, or 156 r texture coordinate or fog blend factor.......... is found as" 157 158 Change the title of Section 3.9 from "Fog" to "Fog and Specular 159 Highlights" 160 161 Change the first line "If enabled..." to 162 "If either fog or WIN_specular_fog are enabled, the fog blends a fog-color 163 (which is also the specular highlight color) with a rasterized fragment's 164 post-texturing color using a blend-factor f." 165 166 Add the following line to the first paragraph: 167 "WIN_specular_fog is enabled and disabled with the Enable and Disable 168 commands using the symbolic constant FOG_SPECULAR_TEXTURE_WIN." 169 170 Change equations 3.16 3.17 and 3.18 to: 171 172 f = f' * exp (-d.z) (3.16) 173 174 f = f' * exp ((-d.z)**2) (3.17) 175 f = f' * (e - z)/(e - s) (3.18) 176 177 Modify the following line "(z is the eye-coordinate distance....)" to: 178 "(z is the eye-coordinate distance from the eye, (0,0,0,1) in eye 179 coordinates, f' is the specular color factor computed in equation 2.6 180 at the time of lighting)" 181 182 Modify the line beginning "Further, f need not ....." 183 to the following: 184 "Further, if WIN_specular_fog is enabled, f must be computed at each 185 vertex after f' has been computed during the lighting stage. f forms a 186 part of the data associated with the processed vertex and is interpolated 187 as other data are." 188 189 Modify the first line of the last paragraph in section 3.9 beginning 190 191 "The state required ..." to: 192 The state required for fog consists of a three valued integer to select 193 the fog equation, three .... a single bit to indicate whether or not fog 194 is enabled and another bit to indicate whether or not WIN_specular_fog 195 is enabled." 196 197Additions to Chapter 4 of the 1.1 Specification (Per-Fragment Operations 198and the Frame Buffer) 199 200 None 201 202Additions to Chapter 5 of the 1.1 Specification (Special Functions) 203 204 None 205 206Additions to Chapter 6 of the 1.1 Specification (State and State 207Requests) 208 209 None 210 211Dependencies on other extensions 212 213 None 214 215Errors 216 217 None 218 219New State 220 Initial 221 Get Value Get Command Type Value Attrib 222 --------- ----------- ---- ------- ------ 223 FOG_SPECULAR_TEXTURE_WIN IsEnabled B GL_FALSE WIN_specular_fog/enable 224 225New Implementation Dependent State 226 227 None 228 229