15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci WIN_specular_fog 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_WIN_specular_fog 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciVersion 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci $Date: 1997/4/3 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ciNumber 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ci 114 165bd8deadSopenharmony_ci 175bd8deadSopenharmony_ciDependencies 185bd8deadSopenharmony_ci 195bd8deadSopenharmony_ci none 205bd8deadSopenharmony_ci 215bd8deadSopenharmony_ciOverview 225bd8deadSopenharmony_ci 235bd8deadSopenharmony_ci Specularly lit textures enhance the realism of a scene greatly. 245bd8deadSopenharmony_ci Using the current OpenGL lighting model, one cannot obtain specularly lit 255bd8deadSopenharmony_ci textures. This is because in the current OpenGL lighting model lighting 265bd8deadSopenharmony_ci is done ahead of texturing and texture-functions such as modulate are 275bd8deadSopenharmony_ci inadequate for such a simulation. What needs to be addressed is that, 285bd8deadSopenharmony_ci somehow an additional interpolant (specular color of that material) needs 295bd8deadSopenharmony_ci to be propagated till that stage of the pipeline where texture-mapping is 305bd8deadSopenharmony_ci performed. This interpolant is then added on to the fragment's color 315bd8deadSopenharmony_ci resulting from the texturing process before proceeding with the rest of 325bd8deadSopenharmony_ci the pipeline. 335bd8deadSopenharmony_ci 345bd8deadSopenharmony_ci This can be addressed very easily in software, but hardware 355bd8deadSopenharmony_ci is not so malleable. Currently most hardware does not support such a 365bd8deadSopenharmony_ci 375bd8deadSopenharmony_ci lighting model. However, some current hardware does support fogging, 385bd8deadSopenharmony_ci which takes place in the pipeline after texturing. This hardware 395bd8deadSopenharmony_ci assumes that the fog blend factor f is computed per-vertex and 405bd8deadSopenharmony_ci interpolates the value across the primitive. The WIN_specular_fog 415bd8deadSopenharmony_ci extension enables the use of such existing fog circuitry to obtain 425bd8deadSopenharmony_ci specularly lit textures without much performance degradation. 435bd8deadSopenharmony_ci 445bd8deadSopenharmony_ci To use it the programmer simply enables the extension with a call to 455bd8deadSopenharmony_ci Enable with the appropriate enumerant and sets the fog color to the 465bd8deadSopenharmony_ci desired specular color. 475bd8deadSopenharmony_ci 485bd8deadSopenharmony_ciIssues 495bd8deadSopenharmony_ci 505bd8deadSopenharmony_ci 1) This extension works only if: 515bd8deadSopenharmony_ci * Lighting is enabled. 525bd8deadSopenharmony_ci * Texturing is enabled. 535bd8deadSopenharmony_ci * Texture function is MODULATE. 545bd8deadSopenharmony_ci * Two sided lighting is disabled. 555bd8deadSopenharmony_ci * RenderMode is RENDER. 565bd8deadSopenharmony_ci 575bd8deadSopenharmony_ci 2) When both fogging and the extension are enabled, the FOG_HINT bit 585bd8deadSopenharmony_ci is ignored. 595bd8deadSopenharmony_ci 605bd8deadSopenharmony_ci 3) One limitation is that the FOG_COLOR is used as the specular-highlight 615bd8deadSopenharmony_ci color. 625bd8deadSopenharmony_ci 635bd8deadSopenharmony_ci 4) PushAttrib and PopAttrib calls save and restore the extension related 645bd8deadSopenharmony_ci state when the FOG_BIT is set, along with the rest of the fog related 655bd8deadSopenharmony_ci state information. 665bd8deadSopenharmony_ci 675bd8deadSopenharmony_ci 5) The highlight computed by this extension is linear-interpolation based 685bd8deadSopenharmony_ci and therefore appears similar to the highlights available for untextured 695bd8deadSopenharmony_ci Gouraud polygons. If Phong shading (ext #113) is enabled this similarity 705bd8deadSopenharmony_ci will no longer hold as the Phong highlight is computed per-pixel. This 715bd8deadSopenharmony_ci can result in the enabling of texture causing the highlight to move and 725bd8deadSopenharmony_ci change shape. 735bd8deadSopenharmony_ci 745bd8deadSopenharmony_ciNew Procedures and Functions 755bd8deadSopenharmony_ci 765bd8deadSopenharmony_ci None 775bd8deadSopenharmony_ci 785bd8deadSopenharmony_ciNew Tokens 795bd8deadSopenharmony_ci 805bd8deadSopenharmony_ci Accepted by the <cap> parameter of Enable and IsEnabled: 815bd8deadSopenharmony_ci 825bd8deadSopenharmony_ci FOG_SPECULAR_TEXTURE_WIN 0x80EC 835bd8deadSopenharmony_ci 845bd8deadSopenharmony_ci Accepted by the <pname> parameter of GetBooleanv, GetDoublev, GetIntegerv 855bd8deadSopenharmony_ci and GetFloatv 865bd8deadSopenharmony_ci 875bd8deadSopenharmony_ci FOG_SPECULAR_TEXTURE_WIN 0x80EC 885bd8deadSopenharmony_ci 895bd8deadSopenharmony_ciAdditions to Chapter 2 of the 1.1 Specification (OpenGL Operation) 905bd8deadSopenharmony_ci In section 2.6 titled "Begin/End Paradigm", add to the paragraph ending 915bd8deadSopenharmony_ci with "...its assigned color, and its texture coordinates", the following 925bd8deadSopenharmony_ci line: 935bd8deadSopenharmony_ci "In addition to these, an implementation may choose to associate a fog 945bd8deadSopenharmony_ci blend factor f with the processed vertex, which is computed per vertex to 955bd8deadSopenharmony_ci speed up fogging calcutaions. This value f is also used to store the 965bd8deadSopenharmony_ci specular color factor computed in the lighting stage, to be applied after 975bd8deadSopenharmony_ci texturing by the fog sub-system." 985bd8deadSopenharmony_ci 995bd8deadSopenharmony_ci Modify the line "This may alter the primitive by altering....." to 1005bd8deadSopenharmony_ci "This may alter the primitive by altering vertex coordinates, texture 1015bd8deadSopenharmony_ci coordinates, fog blend-factor and color". 1025bd8deadSopenharmony_ci 1035bd8deadSopenharmony_ci Figure 2.2 should be edited so that the "Associated Data" box includes 1045bd8deadSopenharmony_ci Fog value. 1055bd8deadSopenharmony_ci 1065bd8deadSopenharmony_ci After the last paragraph of Section 2.13, "Colors and Coloring", the 1075bd8deadSopenharmony_ci following paragraph is added: 1085bd8deadSopenharmony_ci 1095bd8deadSopenharmony_ci "If the WIN_specular_fog extension is enabled the fog value, which 1105bd8deadSopenharmony_ci represents the specular highlight color for the fragment, is computed 1115bd8deadSopenharmony_ci when lighting computation takes place." 1125bd8deadSopenharmony_ci 1135bd8deadSopenharmony_ci Add the following to Section 2.13.1 as the last paragraph of subsection 1145bd8deadSopenharmony_ci titled "Lighting": 1155bd8deadSopenharmony_ci "When the WIN_specular_fog extension is enabled, the parameters used for 1165bd8deadSopenharmony_ci computing the color of the vertex are used to compute the fog value 1175bd8deadSopenharmony_ci associated with the vertex. This value represents the specular color of 1185bd8deadSopenharmony_ci the vertex. This value is used by the fog sub-system to add a specular 1195bd8deadSopenharmony_ci color to the vertex after texturing has taken place. This is a way 1205bd8deadSopenharmony_ci around one of OpenGL's shortcomings, where lighting is done before 1215bd8deadSopenharmony_ci texturing resulting in a complete loss of specular highlights." 1225bd8deadSopenharmony_ci 1235bd8deadSopenharmony_ci Add the following to Section 2.13.1, subsection titled "Lighting 1245bd8deadSopenharmony_ci Operation", after the set of lighting equations and the line ending 1255bd8deadSopenharmony_ci "... V is zero": 1265bd8deadSopenharmony_ci "If the following conditions are met: 1275bd8deadSopenharmony_ci 1) WIN_specular_fog is enabled, 1285bd8deadSopenharmony_ci 2) Texturing is enabled, 1295bd8deadSopenharmony_ci 3) Texture function is MODULATE, 1305bd8deadSopenharmony_ci 4) Two sided lighting is disabled, 1315bd8deadSopenharmony_ci 5) RenderMode is RENDER. 1325bd8deadSopenharmony_ci Then the fog value of the vertex is computed to be: 1335bd8deadSopenharmony_ci 1345bd8deadSopenharmony_ci n-1 ^ srm 1355bd8deadSopenharmony_ci f = max (0, 1 - Sum [(att )(spot )(f )(n . h ) ]) (2.6)" 1365bd8deadSopenharmony_ci i=0 i i i i 1375bd8deadSopenharmony_ci 1385bd8deadSopenharmony_ci = 1 , if the conditions are not met. 1395bd8deadSopenharmony_ci 1405bd8deadSopenharmony_ci Renumber eq. 2.6 to 2.7. 1415bd8deadSopenharmony_ci 1425bd8deadSopenharmony_ciAdditions to Chapter 3 of the 1.1 Specification (Rasterization) 1435bd8deadSopenharmony_ci 1445bd8deadSopenharmony_ci Modify the first line of the second paragraph to: 1455bd8deadSopenharmony_ci "A grid square along with its parameters of assigned color, z (depth), 1465bd8deadSopenharmony_ci texture coordinates, normal and eye coordinates (for phong shading) 1475bd8deadSopenharmony_ci and f (fog blend-factor)" 1485bd8deadSopenharmony_ci 1495bd8deadSopenharmony_ci In Section 3.4.1 "Basic Line Segment Rasterization", modify the line 1505bd8deadSopenharmony_ci 1515bd8deadSopenharmony_ci "The value of an associated datum f......." after equation 3.1 to: 1525bd8deadSopenharmony_ci 1535bd8deadSopenharmony_ci "The value of an associated datum f for the fragment, whether it be R, G, 1545bd8deadSopenharmony_ci B, or A (in RGBA mode) or a color index (in color index mode), or normal, 1555bd8deadSopenharmony_ci eye coordinate or material properties (when phong-shaded), or the s, t, or 1565bd8deadSopenharmony_ci r texture coordinate or fog blend factor.......... is found as" 1575bd8deadSopenharmony_ci 1585bd8deadSopenharmony_ci Change the title of Section 3.9 from "Fog" to "Fog and Specular 1595bd8deadSopenharmony_ci Highlights" 1605bd8deadSopenharmony_ci 1615bd8deadSopenharmony_ci Change the first line "If enabled..." to 1625bd8deadSopenharmony_ci "If either fog or WIN_specular_fog are enabled, the fog blends a fog-color 1635bd8deadSopenharmony_ci (which is also the specular highlight color) with a rasterized fragment's 1645bd8deadSopenharmony_ci post-texturing color using a blend-factor f." 1655bd8deadSopenharmony_ci 1665bd8deadSopenharmony_ci Add the following line to the first paragraph: 1675bd8deadSopenharmony_ci "WIN_specular_fog is enabled and disabled with the Enable and Disable 1685bd8deadSopenharmony_ci commands using the symbolic constant FOG_SPECULAR_TEXTURE_WIN." 1695bd8deadSopenharmony_ci 1705bd8deadSopenharmony_ci Change equations 3.16 3.17 and 3.18 to: 1715bd8deadSopenharmony_ci 1725bd8deadSopenharmony_ci f = f' * exp (-d.z) (3.16) 1735bd8deadSopenharmony_ci 1745bd8deadSopenharmony_ci f = f' * exp ((-d.z)**2) (3.17) 1755bd8deadSopenharmony_ci f = f' * (e - z)/(e - s) (3.18) 1765bd8deadSopenharmony_ci 1775bd8deadSopenharmony_ci Modify the following line "(z is the eye-coordinate distance....)" to: 1785bd8deadSopenharmony_ci "(z is the eye-coordinate distance from the eye, (0,0,0,1) in eye 1795bd8deadSopenharmony_ci coordinates, f' is the specular color factor computed in equation 2.6 1805bd8deadSopenharmony_ci at the time of lighting)" 1815bd8deadSopenharmony_ci 1825bd8deadSopenharmony_ci Modify the line beginning "Further, f need not ....." 1835bd8deadSopenharmony_ci to the following: 1845bd8deadSopenharmony_ci "Further, if WIN_specular_fog is enabled, f must be computed at each 1855bd8deadSopenharmony_ci vertex after f' has been computed during the lighting stage. f forms a 1865bd8deadSopenharmony_ci part of the data associated with the processed vertex and is interpolated 1875bd8deadSopenharmony_ci as other data are." 1885bd8deadSopenharmony_ci 1895bd8deadSopenharmony_ci Modify the first line of the last paragraph in section 3.9 beginning 1905bd8deadSopenharmony_ci 1915bd8deadSopenharmony_ci "The state required ..." to: 1925bd8deadSopenharmony_ci The state required for fog consists of a three valued integer to select 1935bd8deadSopenharmony_ci the fog equation, three .... a single bit to indicate whether or not fog 1945bd8deadSopenharmony_ci is enabled and another bit to indicate whether or not WIN_specular_fog 1955bd8deadSopenharmony_ci is enabled." 1965bd8deadSopenharmony_ci 1975bd8deadSopenharmony_ciAdditions to Chapter 4 of the 1.1 Specification (Per-Fragment Operations 1985bd8deadSopenharmony_ciand the Frame Buffer) 1995bd8deadSopenharmony_ci 2005bd8deadSopenharmony_ci None 2015bd8deadSopenharmony_ci 2025bd8deadSopenharmony_ciAdditions to Chapter 5 of the 1.1 Specification (Special Functions) 2035bd8deadSopenharmony_ci 2045bd8deadSopenharmony_ci None 2055bd8deadSopenharmony_ci 2065bd8deadSopenharmony_ciAdditions to Chapter 6 of the 1.1 Specification (State and State 2075bd8deadSopenharmony_ciRequests) 2085bd8deadSopenharmony_ci 2095bd8deadSopenharmony_ci None 2105bd8deadSopenharmony_ci 2115bd8deadSopenharmony_ciDependencies on other extensions 2125bd8deadSopenharmony_ci 2135bd8deadSopenharmony_ci None 2145bd8deadSopenharmony_ci 2155bd8deadSopenharmony_ciErrors 2165bd8deadSopenharmony_ci 2175bd8deadSopenharmony_ci None 2185bd8deadSopenharmony_ci 2195bd8deadSopenharmony_ciNew State 2205bd8deadSopenharmony_ci Initial 2215bd8deadSopenharmony_ci Get Value Get Command Type Value Attrib 2225bd8deadSopenharmony_ci --------- ----------- ---- ------- ------ 2235bd8deadSopenharmony_ci FOG_SPECULAR_TEXTURE_WIN IsEnabled B GL_FALSE WIN_specular_fog/enable 2245bd8deadSopenharmony_ci 2255bd8deadSopenharmony_ciNew Implementation Dependent State 2265bd8deadSopenharmony_ci 2275bd8deadSopenharmony_ci None 2285bd8deadSopenharmony_ci 229