News:

MegaGlests' game mods menu let's you install many new mods. Even more are available on the MegaGlest Wiki and the Mods forum.

Main Menu

Shadow Mapping on Nvidia Cards

Started by asmodeus, 28 September 2008, 23:28:56

asmodeus

Before I forget I'll repost this:

Index: trunk/source/glest_game/graphics/renderer.cpp
===================================================================
--- trunk/source/glest_game/graphics/renderer.cpp (revision 176)
+++ trunk/source/glest_game/graphics/renderer.cpp (working copy)
@@ -234,9 +234,8 @@
 
  //shadow mapping
  glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FAIL_VALUE_ARB, 1.0f-shadowAlpha);
 
  glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32,
  shadowTextureSize, shadowTextureSize,
@@ -2153,7 +2152,7 @@
  Config &config= Config::getInstance();
  bool nvidiaCard= toLower(getGlVendor()).find("nvidia")!=string::npos;
  bool atiCard= toLower(getGlVendor()).find("ati")!=string::npos;
- bool shadowExtensions = isGlExtensionSupported("GL_ARB_shadow") && isGlExtensionSupported("GL_ARB_shadow_ambient");
+ bool shadowExtensions = isGlExtensionSupported("GL_ARB_shadow");
 
  //3D textures
  config.setBool("Textures3D", isGlExtensionSupported("GL_EXT_texture3D"));
@@ -2431,7 +2430,6 @@
  //shadow mapping
  if(shadows==sShadowMapping){
  checkExtension("GL_ARB_shadow", "Shadow Mapping");
- checkExtension("GL_ARB_shadow_ambient", "Shadow Mapping");
  }
 }
 

This allows nvidia cards to use shadow mapping, it should also work on ATi cards as it just removes the use of ARB_shadow_ambient which is only needed if you texture comparison fails (As it does when you compare R to the texture, stop the comparison and the shadows are no longer pitch black).  This is a slightly better way than using the NV_register_combiners (nVidia only extension) to get the current form of shadowmapping working on nvidia cards.

The shadows do look aliased when the ShadowTextureSize (in glest.ini) is set to the default 512, increasing the size corrects the issue (if your video card can handle it).

I've found this site which has a fairly good indication of which GL extensions are used on which cards for future reference:  http://www.labri.fr/perso/granier/OpenG ... cards.html

hailstone

Glest Advanced Engine - Admin/Programmer
https://sourceforge.net/projects/glestae/