Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

regcombine.cpp

Go to the documentation of this file.
00001 // regcombine.cpp
00002 // 
00003 // Copyright (C) 2001, Chris Laurel <claurel@shatters.net>
00004 //
00005 // Some functions for setting up the nVidia register combiners
00006 // extension for pretty rendering effects.
00007 //
00008 // This program is free software; you can redistribute it and/or
00009 // modify it under the terms of the GNU General Public License
00010 // as published by the Free Software Foundation; either version 2
00011 // of the License, or (at your option) any later version.
00012 
00013 #include "gl.h"
00014 #include "glext.h"
00015 #include "regcombine.h"
00016 
00017 #if 0
00018 namespace rc
00019 {
00020     enum {
00021         Combiner0 = GL_COMBINER0_NV,
00022         Combiner1 = GL_COMBINER1_NV,
00023         Combiner2 = GL_COMBINER2_NV,
00024         Combiner3 = GL_COMBINER3_NV,
00025     };
00026 
00027     enum {
00028         A  = GL_VARIABLE_A_NV,
00029         B  = GL_VARIABLE_B_NV,
00030         C  = GL_VARIABLE_C_NV,
00031         D  = GL_VARIABLE_D_NV,
00032         E  = GL_VARIABLE_E_NV,
00033         F  = GL_VARIABLE_F_NV,
00034         G  = GL_VARIABLE_G_NV,
00035     };
00036 
00037     enum {
00038         RGBPortion   = GL_RGB,
00039         AlphaPortion = GL_ALPHA,
00040         BluePortion  = GL_BLUE,
00041     };
00042 
00043     enum {
00044         UnsignedIdentity    = GL_UNSIGNED_IDENTITY_NV,
00045         UnsignedInvert      = GL_UNSIGNED_INVERT_NV,
00046         ExpandNormal        = GL_EXPAND_NORMAL_NV,
00047     };
00048 };
00049 #endif
00050 
00051 namespace rc
00052 {
00053     void parameter(GLenum, Color);
00054 };
00055 
00056 
00057 void rc::parameter(GLenum which, Color color)
00058 {
00059     float f[4];
00060     f[0] = color.red();
00061     f[1] = color.green();
00062     f[2] = color.blue();
00063     f[3] = color.alpha();
00064     glx::glCombinerParameterfvNV(which, f);
00065 }
00066 
00067 void SetupCombinersBumpMap(Texture& bumpTexture,
00068                            Texture& normalizationTexture,
00069                            Color ambientColor)
00070 {
00071     glEnable(GL_REGISTER_COMBINERS_NV);
00072 
00073     glDisable(GL_LIGHTING);
00074     glx::glActiveTextureARB(GL_TEXTURE1_ARB);
00075     glEnable(GL_TEXTURE_CUBE_MAP_EXT);
00076     normalizationTexture.bind();
00077 
00078     glx::glActiveTextureARB(GL_TEXTURE0_ARB);
00079     glEnable(GL_TEXTURE_2D);
00080     bumpTexture.bind();
00081 
00082     // Just a single combiner stage required . . .
00083     glx::glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, 1);
00084 
00085     float ambient[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
00086     ambient[0] = ambientColor.red();
00087     ambient[1] = ambientColor.green();
00088     ambient[2] = ambientColor.blue();
00089     glx::glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV, ambient);
00090 
00091     // Compute N dot L in the RGB portion of combiner 0
00092     // Load register A with a normal N from the normal map
00093     glx::glCombinerInputNV(GL_COMBINER0_NV, GL_RGB,
00094                            GL_VARIABLE_A_NV, GL_TEXTURE0_ARB,
00095                            GL_EXPAND_NORMAL_NV, GL_RGB);
00096 
00097     // Load register B with the normalized light direction L
00098     glx::glCombinerInputNV(GL_COMBINER0_NV, GL_RGB,
00099                            GL_VARIABLE_B_NV, GL_TEXTURE1_ARB,
00100                            GL_EXPAND_NORMAL_NV, GL_RGB);
00101 
00102     // Compute N dot L
00103     glx::glCombinerOutputNV(GL_COMBINER0_NV, GL_RGB,
00104                             GL_SPARE0_NV, GL_DISCARD_NV, GL_DISCARD_NV,
00105                             GL_NONE, GL_NONE, GL_TRUE, GL_FALSE, GL_FALSE);
00106 
00107     // Compute the self-shadowing term in the alpha portion of combiner 0
00108     // A = 1
00109     glx::glCombinerInputNV(GL_COMBINER0_NV, GL_ALPHA, GL_VARIABLE_A_NV,
00110                            GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
00111     // B = L.z
00112     glx::glCombinerInputNV(GL_COMBINER0_NV, GL_ALPHA, GL_VARIABLE_B_NV,
00113                            GL_TEXTURE1_ARB, GL_EXPAND_NORMAL_NV, GL_BLUE);
00114     // C = 1
00115     glx::glCombinerInputNV(GL_COMBINER0_NV, GL_ALPHA, GL_VARIABLE_C_NV,
00116                            GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
00117     // D = L.z
00118     glx::glCombinerInputNV(GL_COMBINER0_NV, GL_ALPHA, GL_VARIABLE_D_NV,
00119                            GL_TEXTURE1_ARB, GL_EXPAND_NORMAL_NV, GL_BLUE);
00120 
00121     // Create a steep ramp function for self-shadowing
00122     // SPARE0 = 4*(A*B+C*D) = 4*(1*L.z + 1*L.z) = 8 * L.z
00123     glx::glCombinerOutputNV(GL_COMBINER0_NV, GL_ALPHA,
00124                             GL_DISCARD_NV, GL_DISCARD_NV, GL_SPARE0_NV,
00125                             GL_SCALE_BY_FOUR_NV, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);
00126 
00127     // A = SPARE0_alpha = per-pixel self-shadowing term
00128     glx::glFinalCombinerInputNV(GL_VARIABLE_A_NV,
00129                                 GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_ALPHA);
00130     glx::glFinalCombinerInputNV(GL_VARIABLE_B_NV,
00131                                 GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00132     // C = zero
00133     glx::glFinalCombinerInputNV(GL_VARIABLE_C_NV,
00134                                 GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00135     // D = ambient color
00136     glx::glFinalCombinerInputNV(GL_VARIABLE_D_NV,
00137                                 GL_CONSTANT_COLOR0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00138     // G = diffuse illumination contribution = L dot N
00139     glx::glFinalCombinerInputNV(GL_VARIABLE_G_NV,
00140                                 GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_ALPHA);
00141 }
00142 
00143 
00144 // Set up register combiners for per-pixel diffuse lighting, with a base
00145 // texture, ambient color, material color, and normal cube map.  We could use
00146 // just a plain old color cube map, but we use a normal map instead for
00147 // consistency with bump mapped surfaces.  Only one pass with a single
00148 // combiner is required.
00149 void SetupCombinersSmooth(Texture& baseTexture,
00150                           Texture& normalizationTexture,
00151                           Color ambientColor,
00152                           bool invert)
00153 {
00154     glEnable(GL_REGISTER_COMBINERS_NV);
00155 
00156     glDisable(GL_LIGHTING);
00157     glx::glActiveTextureARB(GL_TEXTURE1_ARB);
00158     glEnable(GL_TEXTURE_CUBE_MAP_EXT);
00159     normalizationTexture.bind();
00160     glx::glActiveTextureARB(GL_TEXTURE0_ARB);
00161     glEnable(GL_TEXTURE_2D);
00162     baseTexture.bind();
00163 
00164     // Just a single combiner stage required . . .
00165     glx::glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, 1);
00166 
00167     float ambient[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
00168     ambient[0] = ambientColor.red();
00169     ambient[1] = ambientColor.green();
00170     ambient[2] = ambientColor.blue();
00171     glx::glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV, ambient);
00172 
00173     // A = primary color
00174     glx::glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_A_NV,
00175                            GL_PRIMARY_COLOR_NV, GL_UNSIGNED_IDENTITY_NV,
00176                            GL_RGB);
00177     // B = base texture color
00178     glx::glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_B_NV,
00179                            GL_TEXTURE0_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00180     // SPARE1_rgb = primary * texture
00181     glx::glCombinerOutputNV(GL_COMBINER0_NV, GL_RGB,
00182                             GL_SPARE1_NV, GL_DISCARD_NV, GL_DISCARD_NV,
00183                             GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);
00184 
00185     // A = 1
00186     glx::glCombinerInputNV(GL_COMBINER0_NV, GL_ALPHA, GL_VARIABLE_A_NV,
00187                            GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
00188     // B = L.z
00189     glx::glCombinerInputNV(GL_COMBINER0_NV, GL_ALPHA, GL_VARIABLE_B_NV,
00190                            GL_TEXTURE1_ARB, GL_EXPAND_NORMAL_NV,
00191                            GL_BLUE);
00192     // SPARE0_alpha = 1 * L.z
00193     glx::glCombinerOutputNV(GL_COMBINER0_NV, GL_ALPHA,
00194                             GL_SPARE0_NV, GL_DISCARD_NV, GL_DISCARD_NV,
00195                             GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);
00196 
00197     // E = SPARE1_rgb = base texture color * primary
00198     glx::glFinalCombinerInputNV(GL_VARIABLE_E_NV,
00199                                 GL_SPARE1_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00200     // F = ambient color
00201     glx::glFinalCombinerInputNV(GL_VARIABLE_F_NV,
00202                                 GL_CONSTANT_COLOR0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00203     // A = SPARE1_rgb = base texture color * primary
00204     glx::glFinalCombinerInputNV(GL_VARIABLE_A_NV,
00205                                 GL_SPARE1_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00206     // B = SPARE0_alpha = L.z
00207     glx::glFinalCombinerInputNV(GL_VARIABLE_B_NV,
00208                                 GL_SPARE0_NV,
00209                                 invert ? GL_UNSIGNED_INVERT_NV : GL_UNSIGNED_IDENTITY_NV,
00210                                 GL_ALPHA);
00211     // C = zero
00212     glx::glFinalCombinerInputNV(GL_VARIABLE_C_NV,
00213                                 GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00214     // D = SPARE1_rgb = E*F = texture * primary * ambient color
00215     glx::glFinalCombinerInputNV(GL_VARIABLE_D_NV,
00216                                 GL_E_TIMES_F_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00217     // G = 1
00218     glx::glFinalCombinerInputNV(GL_VARIABLE_G_NV,
00219                                 GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
00220 
00221 }
00222 
00223 
00224 // Normal map should be bound as texture 1 and the base map should be bound
00225 // as texture 0.
00226 void SetupCombinersDecalAndBumpMap(Texture& bumpTexture,
00227                                    Color ambientColor,
00228                                    Color diffuseColor)
00229 {
00230     glEnable(GL_REGISTER_COMBINERS_NV);
00231     glx::glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, 2);
00232 
00233     rc::parameter(GL_CONSTANT_COLOR0_NV, ambientColor);
00234     rc::parameter(GL_CONSTANT_COLOR1_NV, diffuseColor);
00235 
00236     // Compute N dot L in the RGB portion of combiner 0
00237     // Load register A with a normal N from the bump map
00238     glx::glCombinerInputNV(GL_COMBINER0_NV, GL_RGB,
00239                            GL_VARIABLE_A_NV, GL_TEXTURE1_ARB,
00240                            GL_EXPAND_NORMAL_NV, GL_RGB);
00241 
00242     // Load register B with the primary color, which contains the surface
00243     // space light direction L.  Because the color is linearly interpolated
00244     // across triangles, the direction may become denormalized; however, in
00245     // Celestia, planet surfaces are tessellated finely enough that this
00246     // is not a problem.
00247     glx::glCombinerInputNV(GL_COMBINER0_NV, GL_RGB,
00248                            GL_VARIABLE_B_NV, GL_PRIMARY_COLOR_NV,
00249                            GL_EXPAND_NORMAL_NV, GL_RGB);
00250 
00251     // Product C*D computes diffuse color * texture
00252     glx::glCombinerInputNV(GL_COMBINER0_NV, GL_RGB,
00253                            GL_VARIABLE_C_NV, GL_TEXTURE0_ARB,
00254                            GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00255     glx::glCombinerInputNV(GL_COMBINER0_NV, GL_RGB,
00256                            GL_VARIABLE_D_NV, GL_CONSTANT_COLOR1_NV,
00257                            GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00258     
00259     // Compute N dot L in spare0 and diffuse * decal texture in spare1
00260     glx::glCombinerOutputNV(GL_COMBINER0_NV, GL_RGB,
00261                             GL_SPARE0_NV, GL_SPARE1_NV, GL_DISCARD_NV,
00262                             GL_NONE, GL_NONE, GL_TRUE, GL_FALSE, GL_FALSE);
00263 
00264     // Compute the self-shadowing term in the alpha portion of combiner 0
00265     // A = 1
00266     glx::glCombinerInputNV(GL_COMBINER0_NV, GL_ALPHA, GL_VARIABLE_A_NV,
00267                            GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
00268     // B = L.z
00269     glx::glCombinerInputNV(GL_COMBINER0_NV, GL_ALPHA, GL_VARIABLE_B_NV,
00270                            GL_PRIMARY_COLOR_NV, GL_EXPAND_NORMAL_NV, GL_BLUE);
00271     // C = 1
00272     glx::glCombinerInputNV(GL_COMBINER0_NV, GL_ALPHA, GL_VARIABLE_C_NV,
00273                            GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
00274     // D = L.z
00275     glx::glCombinerInputNV(GL_COMBINER0_NV, GL_ALPHA, GL_VARIABLE_D_NV,
00276                            GL_PRIMARY_COLOR_NV, GL_EXPAND_NORMAL_NV, GL_BLUE);
00277 
00278     // Create a steep ramp function for self-shadowing
00279     // SPARE0 = 4*(A*B+C*D) = 4*(1*L.z + 1*L.z) = 8 * L.z
00280     glx::glCombinerOutputNV(GL_COMBINER0_NV, GL_ALPHA,
00281                             GL_DISCARD_NV, GL_DISCARD_NV, GL_SPARE0_NV,
00282                             GL_SCALE_BY_FOUR_NV, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);
00283 
00284     // In the second combiner, sum the ambient color and product of the
00285     // diffuse and self-shadowing terms.
00286     glx::glCombinerInputNV(GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_A_NV,
00287                            GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_ALPHA);
00288     glx::glCombinerInputNV(GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_B_NV,
00289                            GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00290     glx::glCombinerInputNV(GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_C_NV,
00291                            GL_CONSTANT_COLOR0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00292     glx::glCombinerInputNV(GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_D_NV,
00293                            GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
00294     glx::glCombinerOutputNV(GL_COMBINER1_NV, GL_RGB,
00295                             GL_DISCARD_NV, GL_DISCARD_NV, GL_SPARE0_NV,
00296                             GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);
00297     
00298     // E = SPARE0 = fragment brightness, including ambient, diffuse, and
00299     // self shadowing.
00300     glx::glFinalCombinerInputNV(GL_VARIABLE_E_NV,
00301                                 GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00302     // F = spare1 = decal texture rgb * diffuse color
00303     glx::glFinalCombinerInputNV(GL_VARIABLE_F_NV,
00304                                 GL_SPARE1_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00305 
00306     // A = fog factor
00307     glx::glFinalCombinerInputNV(GL_VARIABLE_A_NV,
00308                                 GL_FOG, GL_UNSIGNED_IDENTITY_NV, GL_ALPHA);
00309     // B = color
00310     glx::glFinalCombinerInputNV(GL_VARIABLE_B_NV,
00311                                 GL_E_TIMES_F_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00312     // C = fog color
00313     glx::glFinalCombinerInputNV(GL_VARIABLE_C_NV,
00314                                 GL_FOG, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00315     // D = zero
00316     glx::glFinalCombinerInputNV(GL_VARIABLE_D_NV,
00317                                 GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00318 
00319     // G = diffuse illumination contribution = L dot N
00320     glx::glFinalCombinerInputNV(GL_VARIABLE_G_NV,
00321                                 GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_ALPHA);
00322 }
00323 
00324 
00325 // Set up the combiners to a texture with gloss map in the alpha channel.
00326 void SetupCombinersGlossMap(int glossMap)
00327 {
00328     glEnable(GL_REGISTER_COMBINERS_NV);
00329 
00330     // Just a single combiner stage required . . .
00331     glx::glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, 1);
00332 
00333     // A = primary color
00334     glx::glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_A_NV,
00335                            GL_PRIMARY_COLOR_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00336     // B = base texture color
00337     glx::glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_B_NV,
00338                            GL_TEXTURE0_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00339     // C = secondary color
00340     glx::glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_C_NV,
00341                            GL_SECONDARY_COLOR_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00342     if (glossMap != 0)
00343     {
00344         // D = texture1 rgb (gloss mask)
00345         glx::glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_D_NV,
00346                                glossMap, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00347     }
00348     else
00349     {
00350         // D = texture alpha (gloss mask)
00351         glx::glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_D_NV,
00352                                GL_TEXTURE0_ARB, GL_UNSIGNED_IDENTITY_NV, GL_ALPHA);
00353     }
00354 
00355     // SPARE0_rgb = primary * texture.rgb + secondary * texture.alpha
00356     glx::glCombinerOutputNV(GL_COMBINER0_NV, GL_RGB,
00357                             GL_DISCARD_NV, GL_DISCARD_NV, GL_SPARE0_NV,
00358                             GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);
00359 
00360     // A = SPARE0_rgb
00361     glx::glFinalCombinerInputNV(GL_VARIABLE_A_NV,
00362                               GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00363     // B = 1
00364     glx::glFinalCombinerInputNV(GL_VARIABLE_B_NV,
00365                                 GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
00366     // C = zero
00367     glx::glFinalCombinerInputNV(GL_VARIABLE_C_NV,
00368                                 GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00369     // D = zero
00370     glx::glFinalCombinerInputNV(GL_VARIABLE_D_NV,
00371                                 GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00372     // G = 1
00373     glx::glFinalCombinerInputNV(GL_VARIABLE_G_NV,
00374                                 GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
00375 }
00376 
00377 
00378 // Set up the combiners to a texture with gloss in the alpha channel.
00379 void SetupCombinersGlossMapWithFog(int glossMap)
00380 {
00381     glEnable(GL_REGISTER_COMBINERS_NV);
00382 
00383     // Just a single combiner stage required . . .
00384     glx::glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, 1);
00385 
00386     // A = primary color
00387     glx::glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_A_NV,
00388                            GL_PRIMARY_COLOR_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00389     // B = base texture color
00390     glx::glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_B_NV,
00391                            GL_TEXTURE0_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00392     // C = secondary color
00393     glx::glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_C_NV,
00394                            GL_SECONDARY_COLOR_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00395     if (glossMap != 0)
00396     {
00397         // D = texture1 rgb (gloss mask)
00398         glx::glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_D_NV,
00399                                glossMap, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00400     }
00401     else
00402     {
00403         // D = texture alpha (gloss mask)
00404         glx::glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_D_NV,
00405                                GL_TEXTURE0_ARB, GL_UNSIGNED_IDENTITY_NV, GL_ALPHA);
00406     }
00407 
00408     // SPARE0_rgb = primary * texture.rgb + secondary * texture.alpha
00409     glx::glCombinerOutputNV(GL_COMBINER0_NV, GL_RGB,
00410                             GL_DISCARD_NV, GL_DISCARD_NV, GL_SPARE0_NV,
00411                             GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);
00412 
00413     // A = fog factor
00414     glx::glFinalCombinerInputNV(GL_VARIABLE_A_NV,
00415                                 GL_FOG, GL_UNSIGNED_IDENTITY_NV, GL_ALPHA);
00416     // B = spare0_rgb
00417     glx::glFinalCombinerInputNV(GL_VARIABLE_B_NV,
00418                                 GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00419     // C = fog color
00420     glx::glFinalCombinerInputNV(GL_VARIABLE_C_NV,
00421                                 GL_FOG, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00422     // D = zero
00423     glx::glFinalCombinerInputNV(GL_VARIABLE_D_NV,
00424                                 GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
00425     // G = 1
00426     glx::glFinalCombinerInputNV(GL_VARIABLE_G_NV,
00427                                 GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
00428 }
00429 
00430 
00431 void DisableCombiners()
00432 {
00433     glDisable(GL_REGISTER_COMBINERS_NV);
00434     glx::glActiveTextureARB(GL_TEXTURE1_ARB);
00435     glDisable(GL_TEXTURE_CUBE_MAP_EXT);
00436     glDisable(GL_TEXTURE_2D);
00437     glx::glActiveTextureARB(GL_TEXTURE0_ARB);
00438 }

Generated on Sat Jan 14 22:30:28 2006 for Celestia by  doxygen 1.4.1