Browse Source

Merge pull request #1953 from Areloch/NewBaseGameTemplateFinal

Initial implementation of the new Base Game Template
Areloch 8 years ago
parent
commit
1adab71cf1
100 changed files with 5895 additions and 70 deletions
  1. 1 1
      Engine/source/forest/glsl/windDeformationGLSL.cpp
  2. 1 1
      Engine/source/forest/hlsl/windDeformationHLSL.cpp
  3. 8 8
      Engine/source/gfx/D3D11/gfxD3D11Device.cpp
  4. 8 8
      Engine/source/gfx/D3D9/gfxD3D9Device.cpp
  5. 3 3
      Engine/source/gfx/gfxTextureManager.cpp
  6. 8 8
      Engine/source/gfx/gl/gfxGLDevice.cpp
  7. 6 6
      Engine/source/materials/shaderData.cpp
  8. 2 0
      Engine/source/module/moduleDefinition.cpp
  9. 5 0
      Engine/source/module/moduleDefinition.h
  10. 16 1
      Engine/source/module/moduleManager.cpp
  11. 0 4
      Engine/source/postFx/postEffect.cpp
  12. 1 1
      Engine/source/shaderGen/GLSL/bumpGLSL.cpp
  13. 1 1
      Engine/source/shaderGen/GLSL/pixSpecularGLSL.cpp
  14. 7 7
      Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp
  15. 2 2
      Engine/source/shaderGen/GLSL/shaderGenGLSL.cpp
  16. 1 1
      Engine/source/shaderGen/HLSL/bumpHLSL.cpp
  17. 1 1
      Engine/source/shaderGen/HLSL/pixSpecularHLSL.cpp
  18. 7 7
      Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp
  19. 5 5
      Engine/source/terrain/glsl/terrFeatureGLSL.cpp
  20. 5 5
      Engine/source/terrain/hlsl/terrFeatureHLSL.cpp
  21. 1 0
      Templates/BaseGame/BaseGame.cmake
  22. 1 0
      Templates/BaseGame/DeleteCachedDTSs.bat
  23. 15 0
      Templates/BaseGame/DeleteCachedDTSs.command
  24. 6 0
      Templates/BaseGame/DeleteDSOs.bat
  25. 19 0
      Templates/BaseGame/DeleteDSOs.command
  26. 6 0
      Templates/BaseGame/DeletePrefs.bat
  27. 3 0
      Templates/BaseGame/DeletePrefs.command
  28. 7 0
      Templates/BaseGame/cleanShaders.bat
  29. 4 0
      Templates/BaseGame/cleanShaders.command
  30. 1 0
      Templates/BaseGame/game/Template.torsion.exports
  31. 436 0
      Templates/BaseGame/game/core/audio.cs
  32. 162 0
      Templates/BaseGame/game/core/canvas.cs
  33. 51 0
      Templates/BaseGame/game/core/console/console.gui
  34. 108 0
      Templates/BaseGame/game/core/console/main.cs
  35. 70 0
      Templates/BaseGame/game/core/console/profiles.cs
  36. 102 0
      Templates/BaseGame/game/core/cursor.cs
  37. BIN
      Templates/BaseGame/game/core/fonts/Arial 10 (ansi).uft
  38. BIN
      Templates/BaseGame/game/core/fonts/Arial 12 (ansi).uft
  39. BIN
      Templates/BaseGame/game/core/fonts/Arial 14 (ansi).uft
  40. BIN
      Templates/BaseGame/game/core/fonts/Arial 16 (ansi).uft
  41. BIN
      Templates/BaseGame/game/core/fonts/Arial 36 (ansi).uft
  42. BIN
      Templates/BaseGame/game/core/fonts/Arial Bold 14 (ansi).uft
  43. BIN
      Templates/BaseGame/game/core/fonts/Arial Bold 16 (ansi).uft
  44. BIN
      Templates/BaseGame/game/core/fonts/Arial Bold 18 (ansi).uft
  45. BIN
      Templates/BaseGame/game/core/fonts/ArialBold 14 (ansi).uft
  46. BIN
      Templates/BaseGame/game/core/fonts/ArialItalic 14 (ansi).uft
  47. BIN
      Templates/BaseGame/game/core/fonts/Lucida Console 12 (ansi).uft
  48. 55 0
      Templates/BaseGame/game/core/gfxData/clouds.cs
  49. 79 0
      Templates/BaseGame/game/core/gfxData/commonMaterialData.cs
  50. 48 0
      Templates/BaseGame/game/core/gfxData/scatterSky.cs
  51. 152 0
      Templates/BaseGame/game/core/gfxData/shaders.cs
  52. 36 0
      Templates/BaseGame/game/core/gfxData/terrainBlock.cs
  53. 208 0
      Templates/BaseGame/game/core/gfxData/water.cs
  54. 36 0
      Templates/BaseGame/game/core/gfxprofile/D3D9.ATITechnologiesInc.cs
  55. 36 0
      Templates/BaseGame/game/core/gfxprofile/D3D9.NVIDIA.GeForce8600.cs
  56. 39 0
      Templates/BaseGame/game/core/gfxprofile/D3D9.NVIDIA.QuadroFXGo1000.cs
  57. 36 0
      Templates/BaseGame/game/core/gfxprofile/D3D9.NVIDIA.cs
  58. 26 0
      Templates/BaseGame/game/core/gfxprofile/D3D9.cs
  59. 102 0
      Templates/BaseGame/game/core/globals.cs
  60. 534 0
      Templates/BaseGame/game/core/helperFunctions.cs
  61. BIN
      Templates/BaseGame/game/core/images/AreaMap33.dds
  62. BIN
      Templates/BaseGame/game/core/images/button.png
  63. BIN
      Templates/BaseGame/game/core/images/caustics_1.png
  64. BIN
      Templates/BaseGame/game/core/images/caustics_2.png
  65. BIN
      Templates/BaseGame/game/core/images/checkbox.png
  66. BIN
      Templates/BaseGame/game/core/images/group-border.png
  67. BIN
      Templates/BaseGame/game/core/images/inactive-overlay.png
  68. BIN
      Templates/BaseGame/game/core/images/loadingbar.png
  69. 32 0
      Templates/BaseGame/game/core/images/materials.cs
  70. BIN
      Templates/BaseGame/game/core/images/missingTexture.png
  71. BIN
      Templates/BaseGame/game/core/images/noise.png
  72. BIN
      Templates/BaseGame/game/core/images/null_color_ramp.png
  73. BIN
      Templates/BaseGame/game/core/images/scrollBar.png
  74. BIN
      Templates/BaseGame/game/core/images/textEdit.png
  75. BIN
      Templates/BaseGame/game/core/images/thumbHighlightButton.png
  76. BIN
      Templates/BaseGame/game/core/images/unavailable.png
  77. BIN
      Templates/BaseGame/game/core/images/warnMat.dds
  78. BIN
      Templates/BaseGame/game/core/images/window.png
  79. 74 0
      Templates/BaseGame/game/core/lighting.cs
  80. 70 0
      Templates/BaseGame/game/core/lighting/advanced/deferredShading.cs
  81. 77 0
      Templates/BaseGame/game/core/lighting/advanced/init.cs
  82. 276 0
      Templates/BaseGame/game/core/lighting/advanced/shaders.cs
  83. 92 0
      Templates/BaseGame/game/core/lighting/basic/init.cs
  84. 76 0
      Templates/BaseGame/game/core/lighting/basic/shadowFilter.cs
  85. 32 0
      Templates/BaseGame/game/core/lighting/shadowMaps/init.cs
  86. 90 0
      Templates/BaseGame/game/core/main.cs
  87. 392 0
      Templates/BaseGame/game/core/parseArgs.cs
  88. 74 0
      Templates/BaseGame/game/core/postFX/GammaPostFX.cs
  89. 186 0
      Templates/BaseGame/game/core/postFX/MLAA.cs
  90. 53 0
      Templates/BaseGame/game/core/postFX/MotionBlurFx.cs
  91. 64 0
      Templates/BaseGame/game/core/postFX/caustics.cs
  92. 77 0
      Templates/BaseGame/game/core/postFX/chromaticLens.cs
  93. 72 0
      Templates/BaseGame/game/core/postFX/default.postfxpreset.cs
  94. 599 0
      Templates/BaseGame/game/core/postFX/dof.cs
  95. 113 0
      Templates/BaseGame/game/core/postFX/edgeAA.cs
  96. 63 0
      Templates/BaseGame/game/core/postFX/flash.cs
  97. 135 0
      Templates/BaseGame/game/core/postFX/fog.cs
  98. 64 0
      Templates/BaseGame/game/core/postFX/fxaa.cs
  99. 184 0
      Templates/BaseGame/game/core/postFX/glow.cs
  100. 533 0
      Templates/BaseGame/game/core/postFX/hdr.cs

+ 1 - 1
Engine/source/forest/glsl/windDeformationGLSL.cpp

@@ -60,7 +60,7 @@ MODULE_END;
 
 
 WindDeformationGLSL::WindDeformationGLSL()
-   : mDep( "shaders/common/gl/wind.glsl" )
+   : mDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/wind.glsl" ))
 {
    addDependency( &mDep );
 }

+ 1 - 1
Engine/source/forest/hlsl/windDeformationHLSL.cpp

@@ -60,7 +60,7 @@ MODULE_END;
 
 
 WindDeformationHLSL::WindDeformationHLSL()
-   : mDep( "shaders/common/wind.hlsl" )
+   : mDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/wind.hlsl" ))
 {
    addDependency( &mDep );
 }

+ 8 - 8
Engine/source/gfx/D3D11/gfxD3D11Device.cpp

@@ -670,8 +670,8 @@ void GFXD3D11Device::setupGenericShaders(GenericShaderType type)
       //shader model 4.0 is enough for the generic shaders
       const char* shaderModel = "4.0";
       shaderData = new ShaderData();
-      shaderData->setField("DXVertexShaderFile", "shaders/common/fixedFunction/colorV.hlsl");
-      shaderData->setField("DXPixelShaderFile", "shaders/common/fixedFunction/colorP.hlsl");
+      shaderData->setField("DXVertexShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/colorV.hlsl"));
+      shaderData->setField("DXPixelShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/colorP.hlsl"));
       shaderData->setField("pixVersion", shaderModel);
       shaderData->registerObject();
       mGenericShader[GSColor] =  shaderData->getShader();
@@ -680,8 +680,8 @@ void GFXD3D11Device::setupGenericShaders(GenericShaderType type)
       Sim::getRootGroup()->addObject(shaderData);
 
       shaderData = new ShaderData();
-      shaderData->setField("DXVertexShaderFile", "shaders/common/fixedFunction/modColorTextureV.hlsl");
-      shaderData->setField("DXPixelShaderFile", "shaders/common/fixedFunction/modColorTextureP.hlsl");
+      shaderData->setField("DXVertexShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/modColorTextureV.hlsl"));
+      shaderData->setField("DXPixelShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/modColorTextureP.hlsl"));
       shaderData->setField("pixVersion", shaderModel);
       shaderData->registerObject();
       mGenericShader[GSModColorTexture] = shaderData->getShader();
@@ -690,8 +690,8 @@ void GFXD3D11Device::setupGenericShaders(GenericShaderType type)
       Sim::getRootGroup()->addObject(shaderData);
 
       shaderData = new ShaderData();
-      shaderData->setField("DXVertexShaderFile", "shaders/common/fixedFunction/addColorTextureV.hlsl");
-      shaderData->setField("DXPixelShaderFile", "shaders/common/fixedFunction/addColorTextureP.hlsl");
+      shaderData->setField("DXVertexShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/addColorTextureV.hlsl"));
+      shaderData->setField("DXPixelShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/addColorTextureP.hlsl"));
       shaderData->setField("pixVersion", shaderModel);
       shaderData->registerObject();
       mGenericShader[GSAddColorTexture] = shaderData->getShader();
@@ -700,8 +700,8 @@ void GFXD3D11Device::setupGenericShaders(GenericShaderType type)
       Sim::getRootGroup()->addObject(shaderData);
 
       shaderData = new ShaderData();
-      shaderData->setField("DXVertexShaderFile", "shaders/common/fixedFunction/textureV.hlsl");
-      shaderData->setField("DXPixelShaderFile", "shaders/common/fixedFunction/textureP.hlsl");
+      shaderData->setField("DXVertexShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/textureV.hlsl"));
+      shaderData->setField("DXPixelShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/textureP.hlsl"));
       shaderData->setField("pixVersion", shaderModel);
       shaderData->registerObject();
       mGenericShader[GSTexture] = shaderData->getShader();

+ 8 - 8
Engine/source/gfx/D3D9/gfxD3D9Device.cpp

@@ -154,8 +154,8 @@ inline void GFXD3D9Device::setupGenericShaders( GenericShaderType type /* = GSCo
       ShaderData *shaderData;
 
       shaderData = new ShaderData();
-      shaderData->setField("DXVertexShaderFile", "shaders/common/fixedFunction/colorV.hlsl");
-      shaderData->setField("DXPixelShaderFile", "shaders/common/fixedFunction/colorP.hlsl");
+      shaderData->setField("DXVertexShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/colorV.hlsl"));
+      shaderData->setField("DXPixelShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/colorP.hlsl"));
       shaderData->setField("pixVersion", "3.0");
       shaderData->registerObject();
       mGenericShader[GSColor] = shaderData->getShader();
@@ -164,8 +164,8 @@ inline void GFXD3D9Device::setupGenericShaders( GenericShaderType type /* = GSCo
       Sim::getRootGroup()->addObject(shaderData);
 
       shaderData = new ShaderData();
-      shaderData->setField("DXVertexShaderFile", "shaders/common/fixedFunction/modColorTextureV.hlsl");
-      shaderData->setField("DXPixelShaderFile", "shaders/common/fixedFunction/modColorTextureP.hlsl");
+      shaderData->setField("DXVertexShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/modColorTextureV.hlsl"));
+      shaderData->setField("DXPixelShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/modColorTextureP.hlsl"));
       shaderData->setSamplerName("$diffuseMap", 0);
       shaderData->setField("pixVersion", "3.0");
       shaderData->registerObject();
@@ -175,8 +175,8 @@ inline void GFXD3D9Device::setupGenericShaders( GenericShaderType type /* = GSCo
       Sim::getRootGroup()->addObject(shaderData);
 
       shaderData = new ShaderData();
-      shaderData->setField("DXVertexShaderFile", "shaders/common/fixedFunction/addColorTextureV.hlsl");
-      shaderData->setField("DXPixelShaderFile", "shaders/common/fixedFunction/addColorTextureP.hlsl");
+      shaderData->setField("DXVertexShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/addColorTextureV.hlsl"));
+      shaderData->setField("DXPixelShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/addColorTextureP.hlsl"));
       shaderData->setSamplerName("$diffuseMap", 0);
       shaderData->setField("pixVersion", "3.0");
       shaderData->registerObject();
@@ -186,8 +186,8 @@ inline void GFXD3D9Device::setupGenericShaders( GenericShaderType type /* = GSCo
       Sim::getRootGroup()->addObject(shaderData);
 
       shaderData = new ShaderData();
-      shaderData->setField("DXVertexShaderFile", "shaders/common/fixedFunction/textureV.hlsl");
-      shaderData->setField("DXPixelShaderFile", "shaders/common/fixedFunction/textureP.hlsl");
+      shaderData->setField("DXVertexShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/textureV.hlsl"));
+      shaderData->setField("DXPixelShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/textureP.hlsl"));
       shaderData->setSamplerName("$diffuseMap", 0);
       shaderData->setField("pixVersion", "3.0");
       shaderData->registerObject();

+ 3 - 3
Engine/source/gfx/gfxTextureManager.cpp

@@ -42,9 +42,9 @@ using namespace Torque;
 
 S32 GFXTextureManager::smTextureReductionLevel = 0;
 
-String GFXTextureManager::smMissingTexturePath("core/art/missingTexture");
-String GFXTextureManager::smUnavailableTexturePath("core/art/unavailable");
-String GFXTextureManager::smWarningTexturePath("core/art/warnmat");
+String GFXTextureManager::smMissingTexturePath(Con::getVariable("$Core::MissingTexturePath"));
+String GFXTextureManager::smUnavailableTexturePath(Con::getVariable("$Core::UnAvailableTexturePath"));
+String GFXTextureManager::smWarningTexturePath(Con::getVariable("$Core::WarningTexturePath"));
 
 GFXTextureManager::EventSignal GFXTextureManager::smEventSignal;
 

+ 8 - 8
Engine/source/gfx/gl/gfxGLDevice.cpp

@@ -780,8 +780,8 @@ void GFXGLDevice::setupGenericShaders( GenericShaderType type )
       ShaderData *shaderData;
 
       shaderData = new ShaderData();
-      shaderData->setField("OGLVertexShaderFile", "shaders/common/fixedFunction/gl/colorV.glsl");
-      shaderData->setField("OGLPixelShaderFile", "shaders/common/fixedFunction/gl/colorP.glsl");
+      shaderData->setField("OGLVertexShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/gl/colorV.glsl"));
+      shaderData->setField("OGLPixelShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/gl/colorP.glsl"));
       shaderData->setField("pixVersion", "2.0");
       shaderData->registerObject();
       mGenericShader[GSColor] =  shaderData->getShader();
@@ -790,8 +790,8 @@ void GFXGLDevice::setupGenericShaders( GenericShaderType type )
       Sim::getRootGroup()->addObject(shaderData);
 
       shaderData = new ShaderData();
-      shaderData->setField("OGLVertexShaderFile", "shaders/common/fixedFunction/gl/modColorTextureV.glsl");
-      shaderData->setField("OGLPixelShaderFile", "shaders/common/fixedFunction/gl/modColorTextureP.glsl");
+      shaderData->setField("OGLVertexShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/gl/modColorTextureV.glsl"));
+      shaderData->setField("OGLPixelShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/gl/modColorTextureP.glsl"));
       shaderData->setSamplerName("$diffuseMap", 0);
       shaderData->setField("pixVersion", "2.0");
       shaderData->registerObject();
@@ -801,8 +801,8 @@ void GFXGLDevice::setupGenericShaders( GenericShaderType type )
       Sim::getRootGroup()->addObject(shaderData);
 
       shaderData = new ShaderData();
-      shaderData->setField("OGLVertexShaderFile", "shaders/common/fixedFunction/gl/addColorTextureV.glsl");
-      shaderData->setField("OGLPixelShaderFile", "shaders/common/fixedFunction/gl/addColorTextureP.glsl");
+      shaderData->setField("OGLVertexShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/gl/addColorTextureV.glsl"));
+      shaderData->setField("OGLPixelShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/gl/addColorTextureP.glsl"));
       shaderData->setSamplerName("$diffuseMap", 0);
       shaderData->setField("pixVersion", "2.0");
       shaderData->registerObject();
@@ -812,8 +812,8 @@ void GFXGLDevice::setupGenericShaders( GenericShaderType type )
       Sim::getRootGroup()->addObject(shaderData);
 
       shaderData = new ShaderData();
-      shaderData->setField("OGLVertexShaderFile", "shaders/common/fixedFunction/gl/textureV.glsl");
-      shaderData->setField("OGLPixelShaderFile", "shaders/common/fixedFunction/gl/textureP.glsl");
+      shaderData->setField("OGLVertexShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/gl/textureV.glsl"));
+      shaderData->setField("OGLPixelShaderFile", String(Con::getVariable("$Core::CommonShaderPath")) + String("/fixedFunction/gl/textureP.glsl"));
       shaderData->setSamplerName("$diffuseMap", 0);
       shaderData->setField("pixVersion", "2.0");
       shaderData->registerObject();

+ 6 - 6
Engine/source/materials/shaderData.cpp

@@ -48,10 +48,10 @@ ConsoleDocClass( ShaderData,
 	"// Used for the procedural clould system\n"
 	"singleton ShaderData( CloudLayerShader )\n"
 	"{\n"
-	"	DXVertexShaderFile   = \"shaders/common/cloudLayerV.hlsl\";\n"
-	"	DXPixelShaderFile    = \"shaders/common/cloudLayerP.hlsl\";\n"
-	"	OGLVertexShaderFile = \"shaders/common/gl/cloudLayerV.glsl\";\n"
-	"	OGLPixelShaderFile = \"shaders/common/gl/cloudLayerP.glsl\";\n"
+   "	DXVertexShaderFile   = $Core::CommonShaderPath @ \"/cloudLayerV.hlsl\";\n"
+   "	DXPixelShaderFile    = $Core::CommonShaderPath @ \"/cloudLayerP.hlsl\";\n"
+   "	OGLVertexShaderFile = $Core::CommonShaderPath @ \"/gl/cloudLayerV.glsl\";\n"
+   "	OGLPixelShaderFile = $Core::CommonShaderPath @ \"/gl/cloudLayerP.glsl\";\n"
 	"	pixVersion = 2.0;\n"
 	"};\n"
 	"@endtsexample\n\n"
@@ -109,8 +109,8 @@ void ShaderData::initPersistFields()
       "@tsexample\n"
        "singleton ShaderData( FlashShader )\n"
           "{\n"
-              "DXVertexShaderFile 	= \"shaders/common/postFx/flashV.hlsl\";\n"
-              "DXPixelShaderFile 	= \"shaders/common/postFx/flashP.hlsl\";\n\n"
+              "DXVertexShaderFile 	= $shaderGen::cachePath @ \"/postFx/flashV.hlsl\";\n"
+              "DXPixelShaderFile 	= $shaderGen::cachePath @ \"/postFx/flashP.hlsl\";\n\n"
               " //Define setting the color of WHITE_COLOR.\n"
               "defines = \"WHITE_COLOR=float4(1.0,1.0,1.0,0.0)\";\n\n"
               "pixVersion = 2.0\n"

+ 2 - 0
Engine/source/module/moduleDefinition.cpp

@@ -51,6 +51,7 @@ mModuleId(StringTable->EmptyString()),
     mSynchronized( false ),
     mDeprecated( false ),
     mCriticalMerge( false ),
+    mOverrideExitingObjects(false),
     mModuleDescription( StringTable->EmptyString() ),
     mAuthor(StringTable->EmptyString()),
     mModuleGroup(StringTable->EmptyString()),
@@ -91,6 +92,7 @@ void ModuleDefinition::initPersistFields()
     addProtectedField( "Synchronized", TypeBool, Offset(mSynchronized, ModuleDefinition), &setSynchronized, &defaultProtectedGetFn, &writeSynchronized, "Whether the module should be synchronized or not.  Optional: If not specified then the module is not synchronized." );
     addProtectedField( "Deprecated", TypeBool, Offset(mDeprecated, ModuleDefinition), &setDeprecated, &defaultProtectedGetFn, &writeDeprecated, "Whether the module is deprecated or not.  Optional: If not specified then the module is not deprecated." );
     addProtectedField( "CriticalMerge", TypeBool, Offset(mCriticalMerge, ModuleDefinition), &setDeprecated, &defaultProtectedGetFn, &writeCriticalMerge, "Whether the merging of a module prior to a restart is critical or not.  Optional: If not specified then the module is not merge critical." );
+    addProtectedField( "OverrideExistingObjects", TypeBool, Offset(mOverrideExitingObjects, ModuleDefinition), &setOverrideExistingObjects, &defaultProtectedGetFn, &writeOverrideExistingObjects, "Controls if when this module is loaded and the create function is executed, it will replace existing objects that share names or not.");
     addProtectedField( "Description", TypeString, Offset(mModuleDescription, ModuleDefinition), &setModuleDescription, &defaultProtectedGetFn, &writeModuleDescription, "The description typically used for debugging purposes but can be used for anything." );
     addProtectedField( "Author", TypeString, Offset(mAuthor, ModuleDefinition), &setAuthor, &defaultProtectedGetFn, &writeAuthor, "The author of the module." );
     addProtectedField( "Group", TypeString, Offset(mModuleGroup, ModuleDefinition), &setModuleGroup, &defaultProtectedGetFn, "The module group used typically when loading modules as a group." );

+ 5 - 0
Engine/source/module/moduleDefinition.h

@@ -89,6 +89,7 @@ private:
     bool                            mSynchronized;
     bool                            mDeprecated;
     bool                            mCriticalMerge;
+    bool                            mOverrideExitingObjects;
     StringTableEntry                mModuleDescription;
     StringTableEntry                mAuthor;;
     StringTableEntry                mModuleGroup;
@@ -141,6 +142,8 @@ public:
     inline bool             getDeprecated( void ) const                         { return mDeprecated; }
     inline void             setCriticalMerge( const bool mergeCritical )        { if ( checkUnlocked() ) { mCriticalMerge = mergeCritical; } }
     inline bool             getCriticalMerge( void ) const                      { return mCriticalMerge; }
+    inline void             setOverrideExistingObjects(const bool overrideExistingObj) { if (checkUnlocked()) { mOverrideExitingObjects = overrideExistingObj; } }
+    inline bool             getOverrideExistingObjects(void) const              { return mOverrideExitingObjects; }
     inline void             setModuleDescription( const char* pModuleDescription ) { if ( checkUnlocked() ) { mModuleDescription = StringTable->insert(pModuleDescription); } }
     inline StringTableEntry getModuleDescription( void ) const                  { return mModuleDescription; }
     inline void             setAuthor( const char* pAuthor )                    { if ( checkUnlocked() ) { mAuthor = StringTable->insert(pAuthor); } }
@@ -206,6 +209,8 @@ protected:
     static bool             setDeprecated(void* obj, const char* index, const char* data)                  { static_cast<ModuleDefinition*>(obj)->setDeprecated(dAtob(data)); return false; }
     static bool             writeDeprecated( void* obj, StringTableEntry pFieldName )   { return static_cast<ModuleDefinition*>(obj)->getDeprecated() == true; }
     static bool             writeCriticalMerge( void* obj, StringTableEntry pFieldName ){ return static_cast<ModuleDefinition*>(obj)->getCriticalMerge() == true; }    
+    static bool             setOverrideExistingObjects(void* obj, const char* index, const char* data)     { static_cast<ModuleDefinition*>(obj)->setOverrideExistingObjects(dAtob(data)); return false; }
+    static bool             writeOverrideExistingObjects(void* obj, StringTableEntry pFieldName)           { return static_cast<ModuleDefinition*>(obj)->getOverrideExistingObjects() == true; }
     static bool             setModuleDescription(void* obj, const char* index, const char* data)           { static_cast<ModuleDefinition*>(obj)->setModuleDescription(data); return false; }
     static bool             writeModuleDescription( void* obj, StringTableEntry pFieldName ) { return static_cast<ModuleDefinition*>(obj)->getModuleDescription() != StringTable->EmptyString(); }
     static bool             setAuthor(void* obj, const char* index, const char* data)                      { static_cast<ModuleDefinition*>(obj)->setAuthor(data); return false; }

+ 16 - 1
Engine/source/module/moduleManager.cpp

@@ -429,7 +429,22 @@ bool ModuleManager::loadModuleGroup( const char* pModuleGroup )
                 if ( pScopeSet->isMethod( pLoadReadyModuleDefinition->getCreateFunction() ) )
                 {
                     // Yes, so call the create method.
-                    Con::executef( pScopeSet, pLoadReadyModuleDefinition->getCreateFunction() );
+
+                     //But first, check if we're overriding objects, and if so, set our console var to make that happen while we exec our create function
+                     if (pLoadReadyModuleDefinition->getOverrideExistingObjects())
+                     {
+                        String redefineBehaviorPrev = Con::getVariable("$Con::redefineBehavior");
+                        Con::setVariable("$Con::redefineBehavior", "replaceExisting");
+                        Con::executef(pScopeSet, pLoadReadyModuleDefinition->getCreateFunction());
+                        
+                        //And now that we've executed, switch back to the prior behavior
+                        Con::setVariable("$Con::redefineBehavior", redefineBehaviorPrev.c_str());
+                     }
+                     else
+                     {
+                        //Nothing to do, just run the create function
+                        Con::executef(pScopeSet, pLoadReadyModuleDefinition->getCreateFunction());
+                     }
                 }
             }
             else

+ 0 - 4
Engine/source/postFx/postEffect.cpp

@@ -411,10 +411,6 @@ bool PostEffect::onAdd()
             texFilename[0] == '#' )
          continue;
 
-      // If '/', then path is specified, open normally
-      if ( texFilename[0] != '/' )
-         texFilename = scriptPath.getFullPath() + '/' + texFilename;
-
       // Try to load the texture.
       bool success = mTextures[i].set( texFilename, &PostFxTextureProfile, avar( "%s() - (line %d)", __FUNCTION__, __LINE__ ) );
       if (!success)

+ 1 - 1
Engine/source/shaderGen/GLSL/bumpGLSL.cpp

@@ -236,7 +236,7 @@ void BumpFeatGLSL::setTexData(   Material::StageData &stageDat,
 
 
 ParallaxFeatGLSL::ParallaxFeatGLSL()
-   : mIncludeDep( "shaders/common/gl/torque.glsl" )
+   : mIncludeDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/torque.glsl" ))
 {
    addDependency( &mIncludeDep );
 }

+ 1 - 1
Engine/source/shaderGen/GLSL/pixSpecularGLSL.cpp

@@ -30,7 +30,7 @@
 
 
 PixelSpecularGLSL::PixelSpecularGLSL()
-   : mDep( "shaders/common/gl/lighting.glsl" )
+   : mDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/lighting.glsl" ))
 {
    addDependency( &mDep );
 }

+ 7 - 7
Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp

@@ -830,7 +830,7 @@ Var* ShaderFeatureGLSL::addOutDetailTexCoord(   Vector<ShaderComponent*> &compon
 //****************************************************************************
 
 DiffuseMapFeatGLSL::DiffuseMapFeatGLSL()
-: mTorqueDep("shaders/common/gl/torque.glsl")
+: mTorqueDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/torque.glsl"))
 {
 	addDependency(&mTorqueDep);
 }
@@ -1975,7 +1975,7 @@ void ReflectCubeFeatGLSL::setTexData(  Material::StageData &stageDat,
 //****************************************************************************
 
 RTLightingFeatGLSL::RTLightingFeatGLSL()
-   : mDep( "shaders/common/gl/lighting.glsl" )
+   : mDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/lighting.glsl" ))
 {
    addDependency( &mDep );
 }
@@ -2190,7 +2190,7 @@ ShaderFeature::Resources RTLightingFeatGLSL::getResources( const MaterialFeature
 //****************************************************************************
 
 FogFeatGLSL::FogFeatGLSL()
-   : mFogDep( "shaders/common/gl/torque.glsl" )
+   : mFogDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/torque.glsl" ))
 {
    addDependency( &mFogDep );
 }
@@ -2321,7 +2321,7 @@ ShaderFeature::Resources FogFeatGLSL::getResources( const MaterialFeatureData &f
 //****************************************************************************
 
 VisibilityFeatGLSL::VisibilityFeatGLSL()
-   : mTorqueDep( "shaders/common/gl/torque.glsl" )
+   : mTorqueDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/torque.glsl" ))
 {
    addDependency( &mTorqueDep );
 }
@@ -2487,7 +2487,7 @@ void RenderTargetZeroGLSL::processPix( Vector<ShaderComponent*> &componentList,
 //****************************************************************************
 
 HDROutGLSL::HDROutGLSL()
-   : mTorqueDep( "shaders/common/gl/torque.glsl" )
+   : mTorqueDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/torque.glsl" ))
 {
    addDependency( &mTorqueDep );
 }
@@ -2508,7 +2508,7 @@ void HDROutGLSL::processPix(  Vector<ShaderComponent*> &componentList,
 #include "T3D/fx/groundCover.h"
 
 FoliageFeatureGLSL::FoliageFeatureGLSL()
-: mDep( "shaders/common/gl/foliage.glsl" )
+: mDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/foliage.glsl" ))
 {
    addDependency( &mDep );
 }
@@ -2654,7 +2654,7 @@ void ParticleNormalFeatureGLSL::processVert(Vector<ShaderComponent*> &componentL
 //****************************************************************************
 
 ImposterVertFeatureGLSL::ImposterVertFeatureGLSL()
-   :  mDep( "shaders/common/gl/imposter.glsl" )
+   :  mDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/imposter.glsl" ))
 {
    addDependency( &mDep );
 }

+ 2 - 2
Engine/source/shaderGen/GLSL/shaderGenGLSL.cpp

@@ -37,8 +37,8 @@ void ShaderGenPrinterGLSL::printShaderHeader( Stream& stream )
    stream.write( dStrlen(header1), header1 );
 
    // Cheap HLSL compatibility.
-   const char* header3 = "#include \"shaders/common/gl/hlslCompat.glsl\"\r\n";      
-   stream.write( dStrlen(header3), header3 );
+   String header3 = String("#include \"") + String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/hlslCompat.glsl\"\r\n");
+   stream.write(dStrlen(header3), header3.c_str());
 
    const char* header4 = "\r\n";      
    stream.write( dStrlen(header4), header4 );

+ 1 - 1
Engine/source/shaderGen/HLSL/bumpHLSL.cpp

@@ -268,7 +268,7 @@ void BumpFeatHLSL::setTexData(   Material::StageData &stageDat,
 
 
 ParallaxFeatHLSL::ParallaxFeatHLSL()
-   : mIncludeDep( "shaders/common/torque.hlsl" )
+   : mIncludeDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/torque.hlsl" ))
 {
    addDependency( &mIncludeDep );
 }

+ 1 - 1
Engine/source/shaderGen/HLSL/pixSpecularHLSL.cpp

@@ -30,7 +30,7 @@
 
 
 PixelSpecularHLSL::PixelSpecularHLSL()
-   : mDep( "shaders/common/lighting.hlsl" )
+   : mDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/lighting.hlsl" ))
 {
    addDependency( &mDep );
 }

+ 7 - 7
Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp

@@ -853,7 +853,7 @@ Var* ShaderFeatureHLSL::addOutDetailTexCoord(   Vector<ShaderComponent*> &compon
 //****************************************************************************
 
 DiffuseMapFeatHLSL::DiffuseMapFeatHLSL()
-: mTorqueDep("shaders/common/torque.hlsl")
+: mTorqueDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/torque.hlsl"))
 {
 	addDependency(&mTorqueDep);
 }
@@ -2168,7 +2168,7 @@ void ReflectCubeFeatHLSL::setTexData(  Material::StageData &stageDat,
 //****************************************************************************
 
 RTLightingFeatHLSL::RTLightingFeatHLSL()
-   : mDep( "shaders/common/lighting.hlsl" )
+   : mDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/lighting.hlsl" ))
 {
    addDependency( &mDep );
 }
@@ -2383,7 +2383,7 @@ ShaderFeature::Resources RTLightingFeatHLSL::getResources( const MaterialFeature
 //****************************************************************************
 
 FogFeatHLSL::FogFeatHLSL()
-   : mFogDep( "shaders/common/torque.hlsl" )
+   : mFogDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/torque.hlsl" ))
 {
    addDependency( &mFogDep );
 }
@@ -2514,7 +2514,7 @@ ShaderFeature::Resources FogFeatHLSL::getResources( const MaterialFeatureData &f
 //****************************************************************************
 
 VisibilityFeatHLSL::VisibilityFeatHLSL()
-   : mTorqueDep( "shaders/common/torque.hlsl" )
+   : mTorqueDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/torque.hlsl" ))
 {
    addDependency( &mTorqueDep );
 }
@@ -2681,7 +2681,7 @@ void RenderTargetZeroHLSL::processPix( Vector<ShaderComponent*> &componentList,
 //****************************************************************************
 
 HDROutHLSL::HDROutHLSL()
-   : mTorqueDep( "shaders/common/torque.hlsl" )
+   : mTorqueDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/torque.hlsl" ))
 {
    addDependency( &mTorqueDep );
 }
@@ -2702,7 +2702,7 @@ void HDROutHLSL::processPix(  Vector<ShaderComponent*> &componentList,
 #include "T3D/fx/groundCover.h"
 
 FoliageFeatureHLSL::FoliageFeatureHLSL()
-: mDep( "shaders/common/foliage.hlsl" )
+: mDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/foliage.hlsl" ))
 {
    addDependency( &mDep );
 }
@@ -2848,7 +2848,7 @@ void ParticleNormalFeatureHLSL::processVert(Vector<ShaderComponent*> &componentL
 //****************************************************************************
 
 ImposterVertFeatureHLSL::ImposterVertFeatureHLSL()
-   :  mDep( "shaders/common/imposter.hlsl" )
+   :  mDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/imposter.hlsl" ))
 {
    addDependency( &mDep );
 }

+ 5 - 5
Engine/source/terrain/glsl/terrFeatureGLSL.cpp

@@ -70,7 +70,7 @@ MODULE_END;
 
 
 TerrainFeatGLSL::TerrainFeatGLSL()
-   : mTorqueDep( "shaders/common/gl/torque.glsl" )
+   : mTorqueDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/torque.glsl" ))
    {      
    addDependency( &mTorqueDep );
    }
@@ -297,8 +297,8 @@ U32 TerrainBaseMapFeatGLSL::getOutputTargets( const MaterialFeatureData &fd ) co
 }
 
 TerrainDetailMapFeatGLSL::TerrainDetailMapFeatGLSL()
-   :  mTorqueDep( "shaders/common/gl/torque.glsl" ),
-      mTerrainDep( "shaders/common/terrain/terrain.glsl" )
+   :  mTorqueDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/torque.glsl" )),
+      mTerrainDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/terrain/terrain.glsl" ))
       
 {
    addDependency( &mTorqueDep );
@@ -667,8 +667,8 @@ U32 TerrainDetailMapFeatGLSL::getOutputTargets( const MaterialFeatureData &fd )
 
 
 TerrainMacroMapFeatGLSL::TerrainMacroMapFeatGLSL()
-   :  mTorqueDep( "shaders/common/gl/torque.glsl" ),
-      mTerrainDep( "shaders/common/terrain/terrain.glsl" )
+   :  mTorqueDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/gl/torque.glsl" )),
+      mTerrainDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/terrain/terrain.glsl" ))
       
 {
    addDependency( &mTorqueDep );

+ 5 - 5
Engine/source/terrain/hlsl/terrFeatureHLSL.cpp

@@ -69,7 +69,7 @@ MODULE_END;
 
 
 TerrainFeatHLSL::TerrainFeatHLSL()
-   : mTorqueDep( "shaders/common/torque.hlsl" )
+   : mTorqueDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/torque.hlsl" ))
 {      
    addDependency( &mTorqueDep );
 }
@@ -315,8 +315,8 @@ U32 TerrainBaseMapFeatHLSL::getOutputTargets( const MaterialFeatureData &fd ) co
 }
 
 TerrainDetailMapFeatHLSL::TerrainDetailMapFeatHLSL()
-   :  mTorqueDep( "shaders/common/torque.hlsl" ),
-      mTerrainDep( "shaders/common/terrain/terrain.hlsl" )
+   :  mTorqueDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/torque.hlsl" )),
+      mTerrainDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/terrain/terrain.hlsl" ))
       
 {
    addDependency( &mTorqueDep );
@@ -692,8 +692,8 @@ U32 TerrainDetailMapFeatHLSL::getOutputTargets( const MaterialFeatureData &fd )
 
 
 TerrainMacroMapFeatHLSL::TerrainMacroMapFeatHLSL()
-   :  mTorqueDep( "shaders/common/torque.hlsl" ),
-      mTerrainDep( "shaders/common/terrain/terrain.hlsl" )
+   :  mTorqueDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/torque.hlsl" )),
+      mTerrainDep(String(Con::getVariable("$Core::CommonShaderPath")) + String("/terrain/terrain.hlsl" ))
       
 {
    addDependency( &mTorqueDep );

+ 1 - 0
Templates/BaseGame/BaseGame.cmake

@@ -0,0 +1 @@
+# Project-specific Cmake configurations go here

+ 1 - 0
Templates/BaseGame/DeleteCachedDTSs.bat

@@ -0,0 +1 @@
+for /R %%a IN (*.dae) do IF EXIST "%%~pna.cached.dts" del "%%~pna.cached.dts"

+ 15 - 0
Templates/BaseGame/DeleteCachedDTSs.command

@@ -0,0 +1,15 @@
+#!/bin/sh
+
+cd "`dirname "$0"`"
+
+for i in $(find . -type f \( -iname "*.dae" \))
+do
+	len=$((${#i} - 4))
+   file=${i:0:$len}.cached.dts
+   if [ -e $file ]
+   then
+   	echo "Removing ${file}"
+   	rm $file
+   fi
+done
+

+ 6 - 0
Templates/BaseGame/DeleteDSOs.bat

@@ -0,0 +1,6 @@
+for /R %%a IN (*.cs) do IF EXIST "%%a.dso" del "%%a.dso"
+for /R %%a IN (*.cs) do IF EXIST "%%a.edso" del "%%a.edso"
+for /R %%a IN (*.gui) do IF EXIST "%%a.dso" del "%%a.dso"
+for /R %%a IN (*.gui) do IF EXIST "%%a.edso" del "%%a.edso"
+for /R %%a IN (*.ts) do IF EXIST "%%a.dso" del "%%a.dso"
+for /R %%a IN (*.ts) do IF EXIST "%%a.edso" del "%%a.edso"

+ 19 - 0
Templates/BaseGame/DeleteDSOs.command

@@ -0,0 +1,19 @@
+#!/bin/sh
+
+cd "`dirname "$0"`"
+
+for i in $(find . -type f \( -iname "*.cs" \))
+do
+   file=${i}.dso
+   if [ -e $file ]
+   then
+   	echo "Removing ${file}"
+   	rm $file
+   fi
+   file=${i}.edso
+   if [ -e $file ]
+   then
+   	echo "Removing ${file}"
+      rm $file
+   fi
+done

+ 6 - 0
Templates/BaseGame/DeletePrefs.bat

@@ -0,0 +1,6 @@
+del /s prefs.cs
+del /s config.cs
+del /s banlist.cs
+del /s config.cs.dso
+del /s prefs.cs.dso
+del /s banlist.cs.dso

+ 3 - 0
Templates/BaseGame/DeletePrefs.command

@@ -0,0 +1,3 @@
+#!/bin/sh
+
+find "`dirname "$0"`" -type f \( -name "prefs.cs" -or -name "config.cs" -or -name "banlist.cs" -or -name "prefs.cs.dso" -or -name "config.cs.dso" -or -name "banlist.cs.dso" \) -exec rm {} \;

+ 7 - 0
Templates/BaseGame/cleanShaders.bat

@@ -0,0 +1,7 @@
+REM Delete procedural shaders
+
+del /q /a:-R game\shaders\procedural\*.*
+
+REM Delete dumped shader disassembly files
+
+del /q /s /a:-R *_dis.txt

+ 4 - 0
Templates/BaseGame/cleanShaders.command

@@ -0,0 +1,4 @@
+#!/bin/sh
+
+cd "`dirname "$0"`"
+rm -rf game/shaders/procedural/*.*

+ 1 - 0
Templates/BaseGame/game/Template.torsion.exports

@@ -0,0 +1 @@
+<exports/>

+ 436 - 0
Templates/BaseGame/game/core/audio.cs

@@ -0,0 +1,436 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+//-----------------------------------------------------------------------------
+//    Source groups.
+//-----------------------------------------------------------------------------
+
+singleton SFXDescription( AudioMaster );
+singleton SFXSource( AudioChannelMaster )
+{
+   description = AudioMaster;
+};
+
+singleton SFXDescription( AudioChannel )
+{
+   sourceGroup = AudioChannelMaster;
+};
+
+singleton SFXSource( AudioChannelDefault )
+{
+   description = AudioChannel;
+};
+singleton SFXSource( AudioChannelGui )
+{
+   description = AudioChannel;
+};
+singleton SFXSource( AudioChannelEffects )
+{
+   description = AudioChannel;
+};
+singleton SFXSource( AudioChannelMessages )
+{
+   description = AudioChannel;
+};
+singleton SFXSource( AudioChannelMusic )
+{
+   description = AudioChannel;
+};
+
+// Set default playback states of the channels.
+
+AudioChannelMaster.play();
+AudioChannelDefault.play();
+
+AudioChannelGui.play();
+AudioChannelMusic.play();
+AudioChannelMessages.play();
+
+// Stop in-game effects channels.
+AudioChannelEffects.stop();
+
+//-----------------------------------------------------------------------------
+//    Master SFXDescriptions.
+//-----------------------------------------------------------------------------
+
+// Master description for interface audio.
+singleton SFXDescription( AudioGui )
+{
+   volume         = 1.0;
+   sourceGroup    = AudioChannelGui;
+};
+
+// Master description for game effects audio.
+singleton SFXDescription( AudioEffect )
+{
+   volume         = 1.0;
+   sourceGroup    = AudioChannelEffects;
+};
+
+// Master description for audio in notifications.
+singleton SFXDescription( AudioMessage )
+{
+   volume         = 1.0;
+   sourceGroup    = AudioChannelMessages;
+};
+
+// Master description for music.
+singleton SFXDescription( AudioMusic )
+{
+   volume         = 1.0;
+   sourceGroup    = AudioChannelMusic;
+};
+
+//-----------------------------------------------------------------------------
+//    SFX Functions.
+//-----------------------------------------------------------------------------
+
+/// This initializes the sound system device from
+/// the defaults in the $pref::SFX:: globals.
+function sfxStartup()
+{   
+   echo( "\nsfxStartup..." );
+   
+   // If we have a provider set, try initialize a device now.
+   
+   if( $pref::SFX::provider !$= "" )
+   {
+      if( sfxInit() )
+         return;
+      else
+      {
+         // Force auto-detection.
+         $pref::SFX::autoDetect = true;
+      }
+   }
+
+   // If enabled autodetect a safe device.
+
+   if( ( !isDefined( "$pref::SFX::autoDetect" ) || $pref::SFX::autoDetect ) &&
+       sfxAutodetect() )
+      return;
+   
+   // Failure.
+
+   error( "   Failed to initialize device!\n\n" );
+   
+   $pref::SFX::provider = "";
+   $pref::SFX::device   = "";
+   
+   return;
+}
+
+
+/// This initializes the sound system device from
+/// the defaults in the $pref::SFX:: globals.
+function sfxInit()
+{
+   // If already initialized, shut down the current device first.
+   
+   if( sfxGetDeviceInfo() !$= "" )
+      sfxShutdown();
+      
+   // Start it up!
+   %maxBuffers = $pref::SFX::useHardware ? -1 : $pref::SFX::maxSoftwareBuffers;
+   if ( !sfxCreateDevice( $pref::SFX::provider, $pref::SFX::device, $pref::SFX::useHardware, %maxBuffers ) )
+      return false;
+
+   // This returns a tab seperated string with
+   // the initialized system info.
+   %info = sfxGetDeviceInfo();
+   $pref::SFX::provider       = getField( %info, 0 );
+   $pref::SFX::device         = getField( %info, 1 );
+   $pref::SFX::useHardware    = getField( %info, 2 );
+   %useHardware               = $pref::SFX::useHardware ? "Yes" : "No";
+   %maxBuffers                = getField( %info, 3 );
+   
+   echo( "   Provider: "    @ $pref::SFX::provider );
+   echo( "   Device: "      @ $pref::SFX::device );
+   echo( "   Hardware: "    @ %useHardware );
+   echo( "   Max Buffers: " @ %maxBuffers );
+   echo( " " );
+   
+   if( isDefined( "$pref::SFX::distanceModel" ) )
+      sfxSetDistanceModel( $pref::SFX::distanceModel );
+   if( isDefined( "$pref::SFX::dopplerFactor" ) )
+      sfxSetDopplerFactor( $pref::SFX::dopplerFactor );
+   if( isDefined( "$pref::SFX::rolloffFactor" ) )
+      sfxSetRolloffFactor( $pref::SFX::rolloffFactor );
+
+   // Restore master volume.
+   
+   sfxSetMasterVolume( $pref::SFX::masterVolume );
+
+   // Restore channel volumes.
+   
+   for( %channel = 0; %channel <= 8; %channel ++ )
+      sfxSetChannelVolume( %channel, $pref::SFX::channelVolume[ %channel ] );
+      
+   return true;
+}
+
+
+/// Destroys the current sound system device.
+function sfxShutdown()
+{
+   // Store volume prefs.
+   
+   $pref::SFX::masterVolume = sfxGetMasterVolume();
+   
+   for( %channel = 0; %channel <= 8; %channel ++ )
+      $pref::SFX::channelVolume[ %channel ] = sfxGetChannelVolume( %channel );
+   
+   // We're assuming here that a null info 
+   // string means that no device is loaded.
+   if( sfxGetDeviceInfo() $= "" )
+      return;
+
+   sfxDeleteDevice();
+}
+
+
+/// Determines which of the two SFX providers is preferable.
+function sfxCompareProvider( %providerA, %providerB )
+{
+   if( %providerA $= %providerB )
+      return 0;
+      
+   switch$( %providerA )
+   {
+      // Always prefer FMOD over anything else.
+      case "FMOD":
+         return 1;
+         
+      // Prefer OpenAL over anything but FMOD.
+      case "OpenAL":
+         if( %providerB $= "FMOD" )
+            return -1;
+         else
+            return 1;
+      
+      // choose XAudio over DirectSound
+      case "XAudio":
+         if( %providerB $= "FMOD" || %providerB $= "OpenAL" )
+            return -1;
+         else
+            return 0;
+            
+      case "DirectSound":
+         if( %providerB !$= "FMOD" && %providerB !$= "OpenAL" && %providerB !$= "XAudio" )
+            return 1;
+         else
+            return -1;
+         
+      default:
+         return -1;
+   }
+}
+
+
+/// Try to detect and initalize the best SFX device available.
+function sfxAutodetect()
+{
+   // Get all the available devices.
+   
+   %devices = sfxGetAvailableDevices();
+
+   // Collect and sort the devices by preferentiality.
+   
+   %deviceTrySequence = new ArrayObject();
+   %bestMatch = -1;
+   %count = getRecordCount( %devices );
+   for( %i = 0; %i < %count; %i ++ )
+   {
+      %info = getRecord( %devices, %i );
+      %provider = getField( %info, 0 );
+         
+      %deviceTrySequence.push_back( %provider, %info );
+   }
+   
+   %deviceTrySequence.sortfkd( "sfxCompareProvider" );
+         
+   // Try the devices in order.
+   
+   %count = %deviceTrySequence.count();
+   for( %i = 0; %i < %count; %i ++ )
+   {
+      %provider = %deviceTrySequence.getKey( %i );
+      %info = %deviceTrySequence.getValue( %i );
+      
+      $pref::SFX::provider       = %provider;
+      $pref::SFX::device         = getField( %info, 1 );
+      $pref::SFX::useHardware    = getField( %info, 2 );
+      
+      // By default we've decided to avoid hardware devices as
+      // they are buggy and prone to problems.
+      $pref::SFX::useHardware = false;
+
+      if( sfxInit() )
+      {
+         $pref::SFX::autoDetect = false;
+         %deviceTrySequence.delete();
+         return true;
+      }
+   }
+   
+   // Found no suitable device.
+   
+   error( "sfxAutodetect - Could not initialize a valid SFX device." );
+   
+   $pref::SFX::provider = "";
+   $pref::SFX::device = "";
+   $pref::SFX::useHardware = "";
+   
+   %deviceTrySequence.delete();
+   
+   return false;
+}
+
+
+//-----------------------------------------------------------------------------
+//    Backwards-compatibility with old channel system.
+//-----------------------------------------------------------------------------
+
+// Volume channel IDs for backwards-compatibility.
+
+$GuiAudioType        = 1;  // Interface.
+$SimAudioType        = 2;  // Game.
+$MessageAudioType    = 3;  // Notifications.
+$MusicAudioType      = 4;  // Music.
+
+$AudioChannels[ 0 ] = AudioChannelDefault;
+$AudioChannels[ $GuiAudioType ] = AudioChannelGui;
+$AudioChannels[ $SimAudioType ] = AudioChannelEffects;
+$AudioChannels[ $MessageAudioType ] = AudioChannelMessages;
+$AudioChannels[ $MusicAudioType ] = AudioChannelMusic;
+
+function sfxOldChannelToGroup( %channel )
+{
+   return $AudioChannels[ %channel ];
+}
+
+function sfxGroupToOldChannel( %group )
+{
+   %id = %group.getId();
+   for( %i = 0;; %i ++ )
+      if( !isObject( $AudioChannels[ %i ] ) )
+         return -1;
+      else if( $AudioChannels[ %i ].getId() == %id )
+         return %i;
+         
+   return -1;
+}
+
+function sfxSetMasterVolume( %volume )
+{
+   AudioChannelMaster.setVolume( %volume );
+}
+
+function sfxGetMasterVolume( %volume )
+{
+   return AudioChannelMaster.getVolume();
+}
+
+function sfxStopAll( %channel )
+{
+   // Don't stop channel itself since that isn't quite what the function
+   // here intends.
+   
+   %channel = sfxOldChannelToGroup( %channel );
+   if (isObject(%channel))
+   {
+      foreach( %source in %channel )
+         %source.stop();
+   }
+}
+
+function sfxGetChannelVolume( %channel )
+{
+   %obj = sfxOldChannelToGroup( %channel );
+   if( isObject( %obj ) )
+      return %obj.getVolume();
+}
+
+function sfxSetChannelVolume( %channel, %volume )
+{
+   %obj = sfxOldChannelToGroup( %channel );
+   if( isObject( %obj ) )
+      %obj.setVolume( %volume );
+}
+
+/*singleton SimSet( SFXPausedSet );
+
+
+/// Pauses the playback of active sound sources.
+/// 
+/// @param %channels    An optional word list of channel indices or an empty 
+///                     string to pause sources on all channels.
+/// @param %pauseSet    An optional SimSet which is filled with the paused 
+///                     sources.  If not specified the global SfxSourceGroup 
+///                     is used.
+///
+/// @deprecated
+/// 
+function sfxPause( %channels, %pauseSet )
+{
+   // Did we get a set to populate?
+   if ( !isObject( %pauseSet ) )
+      %pauseSet = SFXPausedSet;
+      
+   %count = SFXSourceSet.getCount();
+   for ( %i = 0; %i < %count; %i++ )
+   {
+      %source = SFXSourceSet.getObject( %i );
+
+      %channel = sfxGroupToOldChannel( %source.getGroup() );
+      if( %channels $= "" || findWord( %channels, %channel ) != -1 )
+      {
+         %source.pause();
+         %pauseSet.add( %source );
+      }
+   }
+}
+
+
+/// Resumes the playback of paused sound sources.
+/// 
+/// @param %pauseSet    An optional SimSet which contains the paused sound 
+///                     sources to be resumed.  If not specified the global 
+///                     SfxSourceGroup is used.
+/// @deprecated
+///
+function sfxResume( %pauseSet )
+{
+   if ( !isObject( %pauseSet ) )
+      %pauseSet = SFXPausedSet;
+                  
+   %count = %pauseSet.getCount();
+   for ( %i = 0; %i < %count; %i++ )
+   {
+      %source = %pauseSet.getObject( %i );
+      %source.play();
+   }
+
+   // Clear our pause set... the caller is left
+   // to clear his own if he passed one.
+   %pauseSet.clear();
+}*/

+ 162 - 0
Templates/BaseGame/game/core/canvas.cs

@@ -0,0 +1,162 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+function createCanvas(%windowTitle)
+{
+   if ($isDedicated)
+   {
+      GFXInit::createNullDevice();
+      return true;
+   }
+   
+   // Create the Canvas
+   $GameCanvas = new GuiCanvas(Canvas)
+   {
+      displayWindow = $platform !$= "windows";
+   };
+
+   // Set the window title
+   if (isObject(Canvas)) 
+   {
+      Canvas.setWindowTitle(%windowTitle @ " - " @ $pref::Video::displayDevice);
+      configureCanvas();
+   } 
+   else 
+   {
+      error("Canvas creation failed. Shutting down.");
+      quit();
+   }
+}
+
+// Constants for referencing video resolution preferences
+$WORD::RES_X = 0;
+$WORD::RES_Y = 1;
+$WORD::FULLSCREEN = 2;
+$WORD::BITDEPTH = 3;
+$WORD::REFRESH = 4;
+$WORD::AA = 5;
+
+function configureCanvas()
+{
+   // Setup a good default if we don't have one already.
+   if ($pref::Video::Resolution $= "")
+      $pref::Video::Resolution = "800 600";
+   if ($pref::Video::FullScreen $= "")
+      $pref::Video::FullScreen = false;
+   if ($pref::Video::BitDepth $= "")
+      $pref::Video::BitDepth = "32";
+   if ($pref::Video::RefreshRate $= "")
+      $pref::Video::RefreshRate = "60";
+   if ($pref::Video::AA $= "")
+      $pref::Video::AA = "4";
+
+   %resX = $pref::Video::Resolution.x;
+   %resY = $pref::Video::Resolution.y;
+   %fs = $pref::Video::FullScreen;
+   %bpp = $pref::Video::BitDepth;
+   %rate = $pref::Video::RefreshRate;
+   %aa = $pref::Video::AA;
+   
+   if($cliFullscreen !$= "") {
+      %fs = $cliFullscreen;
+      $cliFullscreen = "";
+   }
+   
+   echo("--------------");
+   echo("Attempting to set resolution to \"" @ %resX SPC %resY SPC %fs SPC %bpp SPC %rate SPC %aa @ "\"");
+   
+   %deskRes    = getDesktopResolution();      
+   %deskResX   = getWord(%deskRes, $WORD::RES_X);
+   %deskResY   = getWord(%deskRes, $WORD::RES_Y);
+   %deskResBPP = getWord(%deskRes, 2);
+   
+   // We shouldn't be getting this any more but just in case...
+   if (%bpp $= "Default")
+      %bpp = %deskResBPP;
+      
+   // Make sure we are running at a valid resolution
+   if (%fs $= "0" || %fs $= "false")
+   {
+      // Windowed mode has to use the same bit depth as the desktop
+      %bpp = %deskResBPP;
+      
+      // Windowed mode also has to run at a smaller resolution than the desktop
+      if ((%resX >= %deskResX) || (%resY >= %deskResY))
+      {
+         warn("Warning: The requested windowed resolution is equal to or larger than the current desktop resolution. Attempting to find a better resolution");
+      
+         %resCount = Canvas.getModeCount();
+         for (%i = (%resCount - 1); %i >= 0; %i--)
+         {
+            %testRes = Canvas.getMode(%i);
+            %testResX = getWord(%testRes, $WORD::RES_X);
+            %testResY = getWord(%testRes, $WORD::RES_Y);
+            %testBPP  = getWord(%testRes, $WORD::BITDEPTH);
+
+            if (%testBPP != %bpp)
+               continue;
+            
+            if ((%testResX < %deskResX) && (%testResY < %deskResY))
+            {
+               // This will work as our new resolution
+               %resX = %testResX;
+               %resY = %testResY;
+               
+               warn("Warning: Switching to \"" @ %resX SPC %resY SPC %bpp @ "\"");
+               
+               break;
+            }
+         }
+      }
+   }
+   
+   $pref::Video::Resolution = %resX SPC %resY;
+   $pref::Video::FullScreen = %fs;
+   $pref::Video::BitDepth = %bpp;
+   $pref::Video::RefreshRate = %rate;
+   $pref::Video::AA = %aa;
+   
+   if (%fs == 1 || %fs $= "true")
+      %fsLabel = "Yes";
+   else
+      %fsLabel = "No";
+
+   echo("Accepted Mode: " NL
+      "--Resolution : " @  %resX SPC %resY NL 
+      "--Full Screen : " @ %fsLabel NL
+      "--Bits Per Pixel : " @ %bpp NL
+      "--Refresh Rate : " @ %rate NL
+      "--AA TypeXLevel : " @ %aa NL
+      "--------------");
+
+   // Actually set the new video mode
+   Canvas.setVideoMode(%resX, %resY, %fs, %bpp, %rate, %aa);
+
+   commandToServer('setClientAspectRatio', %resX, %resY);
+
+   // AA piggybacks on the AA setting in $pref::Video::mode.
+   // We need to parse the setting between AA modes, and then it's level
+   // It's formatted as AATypexAALevel
+   // So, FXAAx4 or MLAAx2
+   if ( isObject( FXAA_PostEffect ) )
+      FXAA_PostEffect.isEnabled = ( %aa > 0 ) ? true : false;
+}

+ 51 - 0
Templates/BaseGame/game/core/console/console.gui

@@ -0,0 +1,51 @@
+new GuiControl(ConsoleDlg) {
+   profile = "GuiDefaultProfile";
+   horizSizing = "right";
+   vertSizing = "bottom";
+   position = "0 0";
+   extent = "640 480";
+   minExtent = "8 8";
+   visible = "1";
+   helpTag = "0";
+
+   new GuiConsoleEditCtrl(ConsoleEntry) {
+      profile = "ConsoleTextEditProfile";
+      horizSizing = "width";
+      vertSizing = "top";
+      position = "0 462";
+      extent = "640 18";
+      minExtent = "8 8";
+      visible = "1";
+      altCommand = "ConsoleEntry::eval();";
+      helpTag = "0";
+      maxLength = "255";
+      historySize = "40";
+      password = "0";
+      tabComplete = "0";
+      sinkAllKeyEvents = "1";
+      useSiblingScroller = "1";
+   };
+   new GuiScrollCtrl() {
+      internalName = "Scroll";
+      profile = "ConsoleScrollProfile";
+      horizSizing = "width";
+      vertSizing = "height";
+      position = "0 0";
+      extent = "640 462";
+      minExtent = "8 8";
+      visible = "1";
+      helpTag = "0";
+      willFirstRespond = "1";
+      hScrollBar = "alwaysOn";
+      vScrollBar = "alwaysOn";
+      lockHorizScroll = "false";
+      lockVertScroll = "false";
+      constantThumbHeight = "0";
+      childMargin = "0 0";
+
+         new GuiConsole( ConsoleMessageLogView ) {
+            profile = "GuiConsoleProfile";
+            position = "0 0";
+         };
+      };
+};

+ 108 - 0
Templates/BaseGame/game/core/console/main.cs

@@ -0,0 +1,108 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+exec("./profiles.cs");
+exec("./console.gui");
+
+GlobalActionMap.bind("keyboard", "tilde", "toggleConsole");
+
+function ConsoleEntry::eval()
+{
+   %text = trim(ConsoleEntry.getValue());
+   if(%text $= "")
+      return;
+
+   // If it's missing a trailing () and it's not a variable,
+   // append the parentheses.
+   if(strpos(%text, "(") == -1 && !isDefined(%text)) {
+      if(strpos(%text, "=") == -1 && strpos(%text, " ") == -1) {
+         if(strpos(%text, "{") == -1 && strpos(%text, "}") == -1) {
+            %text = %text @ "()";
+         }
+      }
+   }
+
+   // Append a semicolon if need be.
+   %pos = strlen(%text) - 1;
+   if(strpos(%text, ";", %pos) == -1 && strpos(%text, "}") == -1) {
+      %text = %text @ ";";
+   }
+
+   // Turn off warnings for assigning from void
+   // and evaluate the snippet.
+   if(!isDefined("$Con::warnVoidAssignment"))
+      %oldWarnVoidAssignment = true;
+   else
+      %oldWarnVoidAssignment = $Con::warnVoidAssignment;
+   $Con::warnVoidAssignment = false;
+
+   echo("==>" @ %text);
+   if(   !startsWith(%text, "function ")
+       && !startsWith(%text, "datablock ")
+       && !startsWith(%text, "foreach(")
+       && !startsWith(%text, "foreach$(")
+       && !startsWith(%text, "if(")
+       && !startsWith(%text, "while(")
+       && !startsWith(%text, "for(")
+       && !startsWith(%text, "switch(")
+       && !startsWith(%text, "switch$("))
+      eval("%result = " @ %text);
+   else
+      eval(%text);
+   $Con::warnVoidAssignment = %oldWarnVoidAssignment;
+
+   ConsoleEntry.setValue("");
+
+   // Echo result.
+   if(%result !$= "")
+      echo(%result);
+}
+
+function ToggleConsole(%make)
+{
+   if (%make) {
+      if (ConsoleDlg.isAwake()) {
+         // Deactivate the console.
+         Canvas.popDialog(ConsoleDlg);
+      } else {
+         Canvas.pushDialog(ConsoleDlg, 99);         
+      }
+   }
+}
+
+function ConsoleDlg::hideWindow(%this)
+{
+   %this-->Scroll.setVisible(false);
+}
+
+function ConsoleDlg::showWindow(%this)
+{
+   %this-->Scroll.setVisible(true);
+}
+
+function ConsoleDlg::setAlpha( %this, %alpha)
+{
+   if (%alpha $= "")
+      ConsoleScrollProfile.fillColor = $ConsoleDefaultFillColor;
+   else
+      ConsoleScrollProfile.fillColor = getWords($ConsoleDefaultFillColor, 0, 2) SPC %alpha * 255.0;
+}

+ 70 - 0
Templates/BaseGame/game/core/console/profiles.cs

@@ -0,0 +1,70 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+if(!isObject(GuiConsoleProfile))
+new GuiControlProfile(GuiConsoleProfile)
+{
+   fontType = ($platform $= "macos") ? "Monaco" : "Lucida Console";
+   fontSize = ($platform $= "macos") ? 13 : 12;
+   fontColor = "255 255 255";
+   fontColorHL = "0 255 255";
+   fontColorNA = "255 0 0";
+   fontColors[6] = "100 100 100";
+   fontColors[7] = "100 100 0";
+   fontColors[8] = "0 0 100";
+   fontColors[9] = "0 100 0";
+   category = "Core";
+};
+
+if(!isObject(GuiConsoleTextProfile))
+new GuiControlProfile(GuiConsoleTextProfile)
+{   
+   fontColor = "0 0 0";
+   autoSizeWidth = true;
+   autoSizeHeight = true;   
+   textOffset = "2 2";
+   opaque = true;   
+   fillColor = "255 255 255";
+   border = true;
+   borderThickness = 1;
+   borderColor = "0 0 0";
+   category = "Core";
+};
+
+if(!isObject(ConsoleScrollProfile))
+new GuiControlProfile(ConsoleScrollProfile : GuiScrollProfile)
+{
+	opaque = true;
+	fillColor = "0 0 0 175";
+	border = 1;
+	//borderThickness = 0;
+	borderColor = "0 0 0";
+   category = "Core";
+};
+
+if(!isObject(ConsoleTextEditProfile))
+new GuiControlProfile(ConsoleTextEditProfile : GuiTextEditProfile)
+{
+   fillColor = "242 241 240 255";
+   fillColorHL = "255 255 255";   
+   category = "Core";
+};

+ 102 - 0
Templates/BaseGame/game/core/cursor.cs

@@ -0,0 +1,102 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------------------------
+// Cursor toggle functions.
+//---------------------------------------------------------------------------------------------
+$cursorControlled = true;
+function showCursor()
+{
+   if ($cursorControlled)
+      lockMouse(false);
+   Canvas.cursorOn();
+}
+
+function hideCursor()
+{
+   if ($cursorControlled)
+      lockMouse(true);
+   Canvas.cursorOff();
+}
+
+//---------------------------------------------------------------------------------------------
+// In the CanvasCursor package we add some additional functionality to the built-in GuiCanvas
+// class, of which the global Canvas object is an instance. In this case, the behavior we want
+// is for the cursor to automatically display, except when the only guis visible want no
+// cursor - usually the in game interface.
+//---------------------------------------------------------------------------------------------
+package CanvasCursorPackage
+{
+
+//---------------------------------------------------------------------------------------------
+// checkCursor
+// The checkCursor method iterates through all the root controls on the canvas checking each
+// ones noCursor property. If the noCursor property exists as anything other than false or an
+// empty string on every control, the cursor will be hidden.
+//---------------------------------------------------------------------------------------------
+function GuiCanvas::checkCursor(%this)
+{
+   %count = %this.getCount();
+   for(%i = 0; %i < %count; %i++)
+   {
+      %control = %this.getObject(%i);
+      if ((%control.noCursor $= "") || !%control.noCursor)
+      {
+         showCursor();
+         return;
+      }
+   }
+   // If we get here, every control requested a hidden cursor, so we oblige.
+   hideCursor();
+}
+
+//---------------------------------------------------------------------------------------------
+// The following functions override the GuiCanvas defaults that involve changing the content
+// of the Canvas. Basically, all we are doing is adding a call to checkCursor to each one.
+//---------------------------------------------------------------------------------------------
+function GuiCanvas::setContent(%this, %ctrl)
+{
+   Parent::setContent(%this, %ctrl);
+   %this.checkCursor();
+}
+
+function GuiCanvas::pushDialog(%this, %ctrl, %layer, %center)
+{
+   Parent::pushDialog(%this, %ctrl, %layer, %center);
+   %this.checkCursor();
+}
+
+function GuiCanvas::popDialog(%this, %ctrl)
+{
+   Parent::popDialog(%this, %ctrl);
+   %this.checkCursor();
+}
+
+function GuiCanvas::popLayer(%this, %layer)
+{
+   Parent::popLayer(%this, %layer);
+   %this.checkCursor();
+}
+
+};
+
+activatePackage(CanvasCursorPackage);

BIN
Templates/BaseGame/game/core/fonts/Arial 10 (ansi).uft


BIN
Templates/BaseGame/game/core/fonts/Arial 12 (ansi).uft


BIN
Templates/BaseGame/game/core/fonts/Arial 14 (ansi).uft


BIN
Templates/BaseGame/game/core/fonts/Arial 16 (ansi).uft


BIN
Templates/BaseGame/game/core/fonts/Arial 36 (ansi).uft


BIN
Templates/BaseGame/game/core/fonts/Arial Bold 14 (ansi).uft


BIN
Templates/BaseGame/game/core/fonts/Arial Bold 16 (ansi).uft


BIN
Templates/BaseGame/game/core/fonts/Arial Bold 18 (ansi).uft


BIN
Templates/BaseGame/game/core/fonts/ArialBold 14 (ansi).uft


BIN
Templates/BaseGame/game/core/fonts/ArialItalic 14 (ansi).uft


BIN
Templates/BaseGame/game/core/fonts/Lucida Console 12 (ansi).uft


+ 55 - 0
Templates/BaseGame/game/core/gfxData/clouds.cs

@@ -0,0 +1,55 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+// CloudLayer
+//------------------------------------------------------------------------------
+
+singleton ShaderData( CloudLayerShader )
+{
+   DXVertexShaderFile   = $Core::CommonShaderPath @ "/cloudLayerV.hlsl";
+   DXPixelShaderFile    = $Core::CommonShaderPath @ "/cloudLayerP.hlsl";
+   
+   OGLVertexShaderFile = $Core::CommonShaderPath @ "/gl/cloudLayerV.glsl";
+   OGLPixelShaderFile = $Core::CommonShaderPath @ "/gl/cloudLayerP.glsl";
+      
+   samplerNames[0] = "$normalHeightMap";
+      
+   pixVersion = 2.0;   
+};
+
+//------------------------------------------------------------------------------
+// BasicClouds
+//------------------------------------------------------------------------------
+
+singleton ShaderData( BasicCloudsShader )
+{
+   DXVertexShaderFile   = $Core::CommonShaderPath @ "/basicCloudsV.hlsl";
+   DXPixelShaderFile    = $Core::CommonShaderPath @ "/basicCloudsP.hlsl";
+   
+   OGLVertexShaderFile = $Core::CommonShaderPath @ "/gl/basicCloudsV.glsl";
+   OGLPixelShaderFile = $Core::CommonShaderPath @ "/gl/basicCloudsP.glsl";
+   
+   samplerNames[0] = "$diffuseMap";
+      
+   pixVersion = 2.0;   
+};

+ 79 - 0
Templates/BaseGame/game/core/gfxData/commonMaterialData.cs

@@ -0,0 +1,79 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+//-----------------------------------------------------------------------------
+// Anim flag settings - must match material.h
+// These cannot be enumed through script becuase it cannot
+// handle the "|" operation for combining them together
+// ie. Scroll | Wave does not work.
+//-----------------------------------------------------------------------------
+$scroll = 1;
+$rotate = 2;
+$wave   = 4;
+$scale  = 8;
+$sequence = 16;
+
+
+// Common stateblock definitions
+new GFXSamplerStateData(SamplerClampLinear)
+{
+   textureColorOp = GFXTOPModulate;
+   addressModeU = GFXAddressClamp;
+   addressModeV = GFXAddressClamp;
+   addressModeW = GFXAddressClamp;
+   magFilter = GFXTextureFilterLinear;
+   minFilter = GFXTextureFilterLinear;
+   mipFilter = GFXTextureFilterLinear;
+};
+
+new GFXSamplerStateData(SamplerClampPoint)
+{
+   textureColorOp = GFXTOPModulate;
+   addressModeU = GFXAddressClamp;
+   addressModeV = GFXAddressClamp;
+   addressModeW = GFXAddressClamp;
+   magFilter = GFXTextureFilterPoint;
+   minFilter = GFXTextureFilterPoint;
+   mipFilter = GFXTextureFilterPoint;
+};
+
+new GFXSamplerStateData(SamplerWrapLinear)
+{
+   textureColorOp = GFXTOPModulate;
+   addressModeU = GFXTextureAddressWrap;
+   addressModeV = GFXTextureAddressWrap;
+   addressModeW = GFXTextureAddressWrap;
+   magFilter = GFXTextureFilterLinear;
+   minFilter = GFXTextureFilterLinear;
+   mipFilter = GFXTextureFilterLinear;
+};
+
+new GFXSamplerStateData(SamplerWrapPoint)
+{
+   textureColorOp = GFXTOPModulate;
+   addressModeU = GFXTextureAddressWrap;
+   addressModeV = GFXTextureAddressWrap;
+   addressModeW = GFXTextureAddressWrap;
+   magFilter = GFXTextureFilterPoint;
+   minFilter = GFXTextureFilterPoint;
+   mipFilter = GFXTextureFilterPoint;
+};

+ 48 - 0
Templates/BaseGame/game/core/gfxData/scatterSky.cs

@@ -0,0 +1,48 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+new GFXStateBlockData( ScatterSkySBData )
+{
+   cullMode = "GFXCullNone";
+   
+   zDefined = true;
+   zEnable = true;
+   zWriteEnable = false;
+   
+   samplersDefined = true;
+   samplerStates[0] = SamplerClampLinear;   
+   samplerStates[1] = SamplerClampLinear;
+   vertexColorEnable = true;
+};
+
+singleton ShaderData( ScatterSkyShaderData )
+{
+   DXVertexShaderFile     = $Core::CommonShaderPath @ "/scatterSkyV.hlsl";
+   DXPixelShaderFile      = $Core::CommonShaderPath @ "/scatterSkyP.hlsl";   
+   
+   OGLVertexShaderFile     = $Core::CommonShaderPath @ "/gl/scatterSkyV.glsl";
+   OGLPixelShaderFile      = $Core::CommonShaderPath @ "/gl/scatterSkyP.glsl";   
+   
+   samplerNames[0] = "$nightSky";
+   
+   pixVersion = 2.0;
+};

+ 152 - 0
Templates/BaseGame/game/core/gfxData/shaders.cs

@@ -0,0 +1,152 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+//-----------------------------------------------------------------------------
+//  This file contains shader data necessary for various engine utility functions
+//-----------------------------------------------------------------------------
+
+
+singleton ShaderData( ParticlesShaderData )
+{
+   DXVertexShaderFile     = $Core::CommonShaderPath @ "/particlesV.hlsl";
+   DXPixelShaderFile      = $Core::CommonShaderPath @ "/particlesP.hlsl";   
+   
+   OGLVertexShaderFile     = $Core::CommonShaderPath @ "/gl/particlesV.glsl";
+   OGLPixelShaderFile      = $Core::CommonShaderPath @ "/gl/particlesP.glsl";
+   
+   samplerNames[0] = "$diffuseMap";
+   samplerNames[1] = "$prepassTex";
+   samplerNames[2] = "$paraboloidLightMap";
+   
+   pixVersion = 2.0;
+};
+
+singleton ShaderData( OffscreenParticleCompositeShaderData )
+{
+   DXVertexShaderFile     = $Core::CommonShaderPath @ "/particleCompositeV.hlsl";
+   DXPixelShaderFile      = $Core::CommonShaderPath @ "/particleCompositeP.hlsl";
+   
+   OGLVertexShaderFile     = $Core::CommonShaderPath @ "/gl/particleCompositeV.glsl";
+   OGLPixelShaderFile      = $Core::CommonShaderPath @ "/gl/particleCompositeP.glsl";
+   
+   samplerNames[0] = "$colorSource";
+   samplerNames[1] = "$edgeSource";
+   
+   pixVersion = 2.0;
+};
+
+//-----------------------------------------------------------------------------
+// Planar Reflection
+//-----------------------------------------------------------------------------
+new ShaderData( ReflectBump )
+{
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/planarReflectBumpV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/planarReflectBumpP.hlsl";
+   
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/gl/planarReflectBumpV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/gl/planarReflectBumpP.glsl";
+              
+   samplerNames[0] = "$diffuseMap";
+   samplerNames[1] = "$refractMap";
+   samplerNames[2] = "$bumpMap";
+   
+   pixVersion = 2.0;
+};
+
+new ShaderData( Reflect )
+{
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/planarReflectV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/planarReflectP.hlsl";
+   
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/gl/planarReflectV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/gl/planarReflectP.glsl";
+   
+   samplerNames[0] = "$diffuseMap";
+   samplerNames[1] = "$refractMap";
+   
+   pixVersion = 1.4;
+};
+
+//-----------------------------------------------------------------------------
+// fxFoliageReplicator
+//-----------------------------------------------------------------------------
+new ShaderData( fxFoliageReplicatorShader )
+{
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/fxFoliageReplicatorV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/fxFoliageReplicatorP.hlsl";
+   
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/gl/fxFoliageReplicatorV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/gl/fxFoliageReplicatorP.glsl";
+
+   samplerNames[0] = "$diffuseMap";
+   samplerNames[1] = "$alphaMap";
+   
+   pixVersion = 1.4;
+};
+
+singleton ShaderData( VolumetricFogPrePassShader )
+{
+   DXVertexShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/VFogPreV.hlsl";
+   DXPixelShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/VFogPreP.hlsl";
+	
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/VolumetricFog/gl/VFogPreV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/VolumetricFog/gl/VFogPreP.glsl";
+   
+   pixVersion = 3.0;
+};
+singleton ShaderData( VolumetricFogShader )
+{
+   DXVertexShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/VFogV.hlsl";
+   DXPixelShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/VFogP.hlsl";
+	
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/VolumetricFog/gl/VFogV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/VolumetricFog/gl/VFogP.glsl";	
+	
+   samplerNames[0] = "$prepassTex";
+   samplerNames[1] = "$depthBuffer";
+   samplerNames[2] = "$frontBuffer";
+   samplerNames[3] = "$density";
+   
+   pixVersion = 3.0;
+};
+singleton ShaderData( VolumetricFogReflectionShader )
+{
+   DXVertexShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/VFogPreV.hlsl";
+   DXPixelShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/VFogRefl.hlsl";
+	
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/VolumetricFog/gl/VFogPreV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/VolumetricFog/gl/VFogRefl.glsl";
+
+   pixVersion = 3.0;
+};
+singleton ShaderData( CubemapSaveShader )
+{
+   DXVertexShaderFile = "shaders/common/cubemapSaveV.hlsl";
+   DXPixelShaderFile = "shaders/common/cubemapSaveP.hlsl";
+	
+   OGLVertexShaderFile  = "shaders/common/gl/cubemapSaveV.glsl";
+   OGLPixelShaderFile   = "shaders/common/gl/cubemapSaveP.glsl";
+   
+   samplerNames[0] = "$cubemapTex";
+	
+   pixVersion = 3.0;
+};

+ 36 - 0
Templates/BaseGame/game/core/gfxData/terrainBlock.cs

@@ -0,0 +1,36 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+/// Used when generating the blended base texture.
+singleton ShaderData( TerrainBlendShader )
+{
+   DXVertexShaderFile   = $Core::CommonShaderPath @ "/terrain/blendV.hlsl";
+   DXPixelShaderFile    = $Core::CommonShaderPath @ "/terrain/blendP.hlsl";
+   
+   OGLVertexShaderFile = $Core::CommonShaderPath @ "/terrain/gl/blendV.glsl";
+   OGLPixelShaderFile = $Core::CommonShaderPath @ "/terrain/gl/blendP.glsl";
+   
+   samplerNames[0] = "layerTex";
+   samplerNames[1] = "textureMap";
+   
+   pixVersion = 2.0;
+};

+ 208 - 0
Templates/BaseGame/game/core/gfxData/water.cs

@@ -0,0 +1,208 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+
+
+//-----------------------------------------------------------------------------
+// Water
+//-----------------------------------------------------------------------------
+
+singleton ShaderData( WaterShader )
+{
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/water/waterV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/water/waterP.hlsl";
+   
+   OGLVertexShaderFile = $Core::CommonShaderPath @ "/water/gl/waterV.glsl";
+   OGLPixelShaderFile = $Core::CommonShaderPath @ "/water/gl/waterP.glsl";
+   
+   samplerNames[0] = "$bumpMap";  // noise
+   samplerNames[1] = "$prepassTex";  // #prepass
+   samplerNames[2] = "$reflectMap"; // $reflectbuff
+   samplerNames[3] = "$refractBuff";  // $backbuff
+   samplerNames[4] = "$skyMap";  // $cubemap   
+   samplerNames[5] = "$foamMap";  // foam     
+   samplerNames[6] = "$depthGradMap"; // depthMap ( color gradient ) 
+   
+   pixVersion = 3.0;
+};
+
+new GFXSamplerStateData(WaterSampler)
+{
+   textureColorOp = GFXTOPModulate;
+   addressModeU = GFXAddressWrap;
+   addressModeV = GFXAddressWrap;
+   addressModeW = GFXAddressWrap;
+   magFilter = GFXTextureFilterLinear;
+   minFilter = GFXTextureFilterAnisotropic;
+   mipFilter = GFXTextureFilterLinear;
+   maxAnisotropy = 4;
+};
+
+singleton GFXStateBlockData( WaterStateBlock )
+{
+   samplersDefined = true;
+   samplerStates[0] = WaterSampler;  // noise
+   samplerStates[1] = SamplerClampPoint;  // #prepass
+   samplerStates[2] = SamplerClampLinear; // $reflectbuff
+   samplerStates[3] = SamplerClampPoint;  // $backbuff
+   samplerStates[4] = SamplerWrapLinear;  // $cubemap   
+   samplerStates[5] = SamplerWrapLinear;  // foam     
+   samplerStates[6] = SamplerClampLinear; // depthMap ( color gradient ) 
+   cullDefined = true;
+   cullMode = "GFXCullCCW";
+};
+
+singleton GFXStateBlockData( UnderWaterStateBlock : WaterStateBlock )
+{
+   cullMode = "GFXCullCW";
+};
+
+singleton CustomMaterial( WaterMat )
+{   
+   sampler["prepassTex"] = "#prepass";
+   sampler["reflectMap"] = "$reflectbuff";
+   sampler["refractBuff"] = "$backbuff";
+   // These samplers are set in code not here.
+   // This is to allow different WaterObject instances
+   // to use this same material but override these textures
+   // per instance.
+   //sampler["bumpMap"] = "";    
+   //sampler["skyMap"] = "";
+   //sampler["foamMap"] = "";  
+   //sampler["depthGradMap"] = "";
+   
+   shader = WaterShader;
+   stateBlock = WaterStateBlock;
+   version = 3.0;
+   
+   useAnisotropic[0] = true;
+};
+
+//-----------------------------------------------------------------------------
+// Underwater
+//-----------------------------------------------------------------------------
+
+singleton ShaderData( UnderWaterShader : WaterShader )
+{   
+   defines = "UNDERWATER";   
+};
+
+singleton CustomMaterial( UnderwaterMat )
+{  
+   // These samplers are set in code not here.
+   // This is to allow different WaterObject instances
+   // to use this same material but override these textures
+   // per instance.   
+   //sampler["bumpMap"] = "core/art/water/noise02";
+   //sampler["foamMap"] = "core/art/water/foam";
+
+   sampler["prepassTex"] = "#prepass";
+   sampler["refractBuff"] = "$backbuff";   
+   
+   shader = UnderWaterShader;
+   stateBlock = UnderWaterStateBlock;
+   specular = "0.75 0.75 0.75 1.0";
+   specularPower = 48.0;
+   version = 3.0;
+};
+
+//-----------------------------------------------------------------------------
+// Basic Water
+//-----------------------------------------------------------------------------
+
+singleton ShaderData( WaterBasicShader )
+{
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/water/waterBasicV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/water/waterBasicP.hlsl";
+   
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/water/gl/waterBasicV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/water/gl/waterBasicP.glsl";
+   
+   samplerNames[0] = "$bumpMap";
+   samplerNames[2] = "$reflectMap";
+   samplerNames[3] = "$refractBuff";
+   samplerNames[4] = "$skyMap";
+   samplerNames[5] = "$depthGradMap";
+   
+   pixVersion = 2.0;
+};
+
+singleton GFXStateBlockData( WaterBasicStateBlock )
+{
+   samplersDefined = true;
+   samplerStates[0] = WaterSampler;  // noise
+   samplerStates[2] = SamplerClampLinear;  // $reflectbuff
+   samplerStates[3] = SamplerClampPoint;  // $backbuff
+   samplerStates[4] = SamplerWrapLinear;  // $cubemap
+   cullDefined = true;
+   cullMode = "GFXCullCCW";
+};
+
+singleton GFXStateBlockData( UnderWaterBasicStateBlock : WaterBasicStateBlock )
+{
+   cullMode = "GFXCullCW";
+};
+
+singleton CustomMaterial( WaterBasicMat )
+{
+   // These samplers are set in code not here.
+   // This is to allow different WaterObject instances
+   // to use this same material but override these textures
+   // per instance.     
+   //sampler["bumpMap"] = "core/art/water/noise02";
+   //sampler["skyMap"] = "$cubemap";   
+   
+   //sampler["prepassTex"] = "#prepass";
+   sampler["reflectMap"] = "$reflectbuff";
+   sampler["refractBuff"] = "$backbuff";
+    
+   cubemap = NewLevelSkyCubemap;
+   shader = WaterBasicShader;
+   stateBlock = WaterBasicStateBlock;
+   version = 2.0;
+};
+
+//-----------------------------------------------------------------------------
+// Basic UnderWater
+//-----------------------------------------------------------------------------
+
+singleton ShaderData( UnderWaterBasicShader : WaterBasicShader)
+{
+   defines = "UNDERWATER";  
+};
+
+singleton CustomMaterial( UnderwaterBasicMat )
+{
+   // These samplers are set in code not here.
+   // This is to allow different WaterObject instances
+   // to use this same material but override these textures
+   // per instance.  
+   //sampler["bumpMap"] = "core/art/water/noise02";
+   //samplers["skyMap"] = "$cubemap";  
+
+   //sampler["prepassTex"] = "#prepass";
+   sampler["refractBuff"] = "$backbuff";
+   
+   shader = UnderWaterBasicShader;
+   stateBlock = UnderWaterBasicStateBlock;
+   version = 2.0;
+};

+ 36 - 0
Templates/BaseGame/game/core/gfxprofile/D3D9.ATITechnologiesInc.cs

@@ -0,0 +1,36 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+// ATI Vendor Profile Script
+//
+// This script is responsible for setting global
+// capability strings based on the nVidia vendor.
+
+if(GFXCardProfiler::getVersion() < 64.44)
+{
+	$GFX::OutdatedDrivers = true;
+	$GFX::OutdatedDriversLink = "<a:www.ati.com>You can get newer drivers here.</a>.";
+}
+else
+{
+   $GFX::OutdatedDrivers = false;
+}

+ 36 - 0
Templates/BaseGame/game/core/gfxprofile/D3D9.NVIDIA.GeForce8600.cs

@@ -0,0 +1,36 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+// nVidia Vendor Profile Script
+//
+// This script is responsible for setting global
+// capability strings based on the nVidia vendor.
+
+if(GFXCardProfiler::getVersion() < 1.2)
+{
+   $GFX::OutdatedDrivers = true;
+   $GFX::OutdatedDriversLink = "<a:www.nvidia.com>You can get newer drivers here.</a>.";
+}
+else
+{
+   $GFX::OutdatedDrivers = false;
+}

+ 39 - 0
Templates/BaseGame/game/core/gfxprofile/D3D9.NVIDIA.QuadroFXGo1000.cs

@@ -0,0 +1,39 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+// nVidia Vendor Profile Script
+//
+// This script is responsible for setting global
+// capability strings based on the nVidia vendor.
+
+if(GFXCardProfiler::getVersion() < 53.82)
+{
+   $GFX::OutdatedDrivers = true;
+   $GFX::OutdatedDriversLink = "<a:www.nvidia.com>You can get newer drivers here.</a>.";
+}
+else
+{
+   $GFX::OutdatedDrivers = false;
+}
+
+// Silly card has trouble with this!
+GFXCardProfiler::setCapability("autoMipmapLevel", false);

+ 36 - 0
Templates/BaseGame/game/core/gfxprofile/D3D9.NVIDIA.cs

@@ -0,0 +1,36 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+// nVidia Vendor Profile Script
+//
+// This script is responsible for setting global
+// capability strings based on the nVidia vendor.
+
+if(GFXCardProfiler::getVersion() < 56.72)
+{
+	$GFX::OutdatedDrivers = true;
+	$GFX::OutdatedDriversLink = "<a:www.nvidia.com>You can get newer drivers here.</a>.";
+}
+else
+{
+   $GFX::OutdatedDrivers = false;
+}

+ 26 - 0
Templates/BaseGame/game/core/gfxprofile/D3D9.cs

@@ -0,0 +1,26 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+// Direct3D 9 Renderer Profile Script
+//
+// This script is responsible for setting global
+// capability strings based on the D3D9 renderer type.

+ 102 - 0
Templates/BaseGame/game/core/globals.cs

@@ -0,0 +1,102 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+// ----------------------------------------------------------------------------
+// DInput keyboard, mouse, and joystick prefs
+// ----------------------------------------------------------------------------
+
+$pref::Input::MouseEnabled = 1;
+$pref::Input::LinkMouseSensitivity = 1;
+$pref::Input::KeyboardEnabled = 1;
+$pref::Input::KeyboardTurnSpeed = 0.1;
+$pref::Input::JoystickEnabled = 0;
+
+// ----------------------------------------------------------------------------
+// Video Preferences
+// ----------------------------------------------------------------------------
+
+// Set directory paths for various data or default images.
+$pref::Video::ProfilePath = "core/gfxprofile";
+$pref::Video::missingTexturePath = "core/images/missingTexture.png";
+$pref::Video::unavailableTexturePath = "core/images/unavailable.png";
+$pref::Video::warningTexturePath = "core/images/warnMat.dds";
+
+$pref::Video::disableVerticalSync = 1;
+$pref::Video::mode = "800 600 false 32 60 4";
+$pref::Video::defaultFenceCount = 0;
+
+// This disables the hardware FSAA/MSAA so that we depend completely on the FXAA
+// post effect which works on all cards and in deferred mode.  Note that the new
+// Intel Hybrid graphics on laptops will fail to initialize when hardware AA is
+// enabled... so you've been warned.
+$pref::Video::disableHardwareAA = true;
+
+$pref::Video::disableNormalmapping = false;
+$pref::Video::disablePixSpecular = false;
+$pref::Video::disableCubemapping = false;
+$pref::Video::disableParallaxMapping = false;
+
+// The number of mipmap levels to drop on loaded textures to reduce video memory
+// usage.  It will skip any textures that have been defined as not allowing down
+// scaling.
+$pref::Video::textureReductionLevel = 0;
+
+$pref::Video::defaultAnisotropy = 1;
+//$pref::Video::Gamma = 1.0;
+
+/// AutoDetect graphics quality levels the next startup.
+$pref::Video::autoDetect = 1;
+
+// ----------------------------------------------------------------------------
+// Shader stuff
+// ----------------------------------------------------------------------------
+
+// This is the path used by ShaderGen to cache procedural shaders.  If left
+// blank ShaderGen will only cache shaders to memory and not to disk.
+$shaderGen::cachePath = "data/shaderCache";
+
+// Uncomment to disable ShaderGen, useful when debugging
+//$ShaderGen::GenNewShaders = false;
+   
+// Uncomment to dump disassembly for any shader that is compiled to disk.  These
+// will appear as shadername_dis.txt in the same path as the shader file.   
+//$gfx::disassembleAllShaders = true;
+
+// ----------------------------------------------------------------------------
+// Lighting and shadowing
+// ----------------------------------------------------------------------------
+
+// Uncomment to enable AdvancedLighting on the Mac (T3D 2009 Beta 3)
+//$pref::machax::enableAdvancedLighting = true;
+
+$sceneLighting::cacheSize = 20000;
+$sceneLighting::purgeMethod = "lastCreated";
+$sceneLighting::cacheLighting = 1;
+
+$pref::Shadows::textureScalar = 1.0;
+$pref::Shadows::disable = false;
+
+// Sets the shadow filtering mode.
+//  None - Disables filtering.
+//  SoftShadow - Does a simple soft shadow
+//  SoftShadowHighQuality 
+$pref::Shadows::filterMode = "SoftShadow";

+ 534 - 0
Templates/BaseGame/game/core/helperFunctions.cs

@@ -0,0 +1,534 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+// Check if a script file exists, compiled or not.
+function isScriptFile(%path)
+{
+   if( isFile(%path @ ".dso") || isFile(%path) )
+      return true;
+   
+   return false;
+}
+
+function loadMaterials()
+{
+   // Load any materials files for which we only have DSOs.
+
+   for( %file = findFirstFile( "*/materials.cs.dso" );
+        %file !$= "";
+        %file = findNextFile( "*/materials.cs.dso" ))
+   {
+      // Only execute, if we don't have the source file.
+      %csFileName = getSubStr( %file, 0, strlen( %file ) - 4 );
+      if( !isFile( %csFileName ) )
+         exec( %csFileName );
+   }
+
+   // Load all source material files.
+
+   for( %file = findFirstFile( "*/materials.cs" );
+        %file !$= "";
+        %file = findNextFile( "*/materials.cs" ))
+   {
+      exec( %file );
+   }
+
+   // Load all materials created by the material editor if
+   // the folder exists
+   if( IsDirectory( "materialEditor" ) )
+   {
+      for( %file = findFirstFile( "materialEditor/*.cs.dso" );
+           %file !$= "";
+           %file = findNextFile( "materialEditor/*.cs.dso" ))
+      {
+         // Only execute, if we don't have the source file.
+         %csFileName = getSubStr( %file, 0, strlen( %file ) - 4 );
+         if( !isFile( %csFileName ) )
+            exec( %csFileName );
+      }
+
+      for( %file = findFirstFile( "materialEditor/*.cs" );
+           %file !$= "";
+           %file = findNextFile( "materialEditor/*.cs" ))
+      {
+         exec( %file );
+      }
+   }
+}
+
+function reloadMaterials()
+{
+   reloadTextures();
+   loadMaterials();
+   reInitMaterials();
+}
+
+function loadDatablockFiles( %datablockFiles, %recurse )
+{
+   if ( %recurse )
+   {
+      recursiveLoadDatablockFiles( %datablockFiles, 9999 );
+      return;
+   }
+   
+   %count = %datablockFiles.count();
+   for ( %i=0; %i < %count; %i++ )
+   {
+      %file = %datablockFiles.getKey( %i );
+      if ( !isFile(%file @ ".dso") && !isFile(%file) )
+         continue;
+                  
+      exec( %file );
+   }
+      
+   // Destroy the incoming list.
+   //%datablockFiles.delete();
+}
+
+function recursiveLoadDatablockFiles( %datablockFiles, %previousErrors )
+{
+   %reloadDatablockFiles = new ArrayObject();
+
+   // Keep track of the number of datablocks that 
+   // failed during this pass.
+   %failedDatablocks = 0;
+   
+   // Try re-executing the list of datablock files.
+   %count = %datablockFiles.count();
+   for ( %i=0; %i < %count; %i++ )
+   {      
+      %file = %datablockFiles.getKey( %i );
+      if ( !isFile(%file @ ".dso") && !isFile(%file) )
+         continue;
+         
+      // Start counting copy constructor creation errors.
+      $Con::objectCopyFailures = 0;
+                                       
+      exec( %file );
+                                    
+      // If errors occured then store this file for re-exec later.
+      if ( $Con::objectCopyFailures > 0 )
+      {
+         %reloadDatablockFiles.add( %file );
+         %failedDatablocks = %failedDatablocks + $Con::objectCopyFailures;
+      }
+   }
+            
+   // Clear the object copy failure counter so that
+   // we get console error messages again.
+   $Con::objectCopyFailures = -1;
+                  
+   // Delete the old incoming list... we're done with it.
+   //%datablockFiles.delete();
+               
+   // If we still have datablocks to retry.
+   %newCount = %reloadDatablockFiles.count();
+   if ( %newCount > 0 )
+   {
+      // If the datablock failures have not been reduced
+      // from the last pass then we must have a real syntax
+      // error and not just a bad dependancy.         
+      if ( %previousErrors > %failedDatablocks )
+         recursiveLoadDatablockFiles( %reloadDatablockFiles, %failedDatablocks );
+                  
+      else
+      {      
+         // Since we must have real syntax errors do one 
+         // last normal exec to output error messages.
+         loadDatablockFiles( %reloadDatablockFiles, false );
+      }
+      
+      return;
+   }
+                  
+   // Cleanup the empty reload list.
+   %reloadDatablockFiles.delete();         
+}
+
+function getUserPath()
+{
+	%temp = getUserHomeDirectory();  
+	echo(%temp);  
+	if(!isDirectory(%temp))  
+	{  
+		%temp = getUserDataDirectory();  
+		echo(%temp);
+		if(!isDirectory(%temp)) 
+		{
+			%userPath = "data";  
+		}
+		else  
+		{
+			//put it in appdata/roaming
+			%userPath = %temp @ "/" @ $appName;  
+		}  
+	}  
+	else  
+	{  
+		//put it in user/documents  
+		%userPath = %temp @ "/" @ $appName;  
+	}
+	return %userPath;
+}
+
+function getPrefpath()
+{
+   $prefPath = getUserPath() @ "/preferences";
+	return $prefPath;
+}
+
+function updateTSShapeLoadProgress(%progress, %msg)
+{
+   // Check if the loading GUI is visible and use that instead of the
+   // separate import progress GUI if possible
+   if ( isObject(LoadingGui) && LoadingGui.isAwake() )
+   {
+      // Save/Restore load progress at the start/end of the import process
+      if ( %progress == 0 )
+      {
+         ColladaImportProgress.savedProgress = LoadingProgress.getValue();
+         ColladaImportProgress.savedText = LoadingProgressTxt.getValue();
+
+         ColladaImportProgress.msgPrefix = "Importing " @ %msg;
+         %msg = "Reading file into memory...";
+      }
+      else if ( %progress == 1.0 )
+      {
+         LoadingProgress.setValue( ColladaImportProgress.savedProgress );
+         LoadingProgressTxt.setValue( ColladaImportProgress.savedText );
+      }
+
+      %msg = ColladaImportProgress.msgPrefix @ ": " @ %msg;
+
+      %progressCtrl = LoadingProgress;
+      %textCtrl = LoadingProgressTxt;
+   }
+   else
+   {
+      //it's probably the editors using it
+      if(isFunction("updateToolTSShapeLoadProgress"))
+      {
+         updateToolTSShapeLoadProgress(%progress, %msg);
+      }
+   }
+
+   // Update progress indicators
+   if (%progress == 0)
+   {
+      %progressCtrl.setValue(0.001);
+      %textCtrl.setText(%msg);
+   }
+   else if (%progress != 1.0)
+   {
+      %progressCtrl.setValue(%progress);
+      %textCtrl.setText(%msg);
+   }
+
+   Canvas.repaint(33);
+}
+
+/// A helper function which will return the ghosted client object
+/// from a server object when connected to a local server.
+function serverToClientObject( %serverObject )
+{
+   assert( isObject( LocalClientConnection ), "serverToClientObject() - No local client connection found!" );
+   assert( isObject( ServerConnection ), "serverToClientObject() - No server connection found!" );      
+         
+   %ghostId = LocalClientConnection.getGhostId( %serverObject );
+   if ( %ghostId == -1 )
+      return 0;
+                
+   return ServerConnection.resolveGhostID( %ghostId );   
+}
+
+//----------------------------------------------------------------------------
+// Debug commands
+//----------------------------------------------------------------------------
+
+function netSimulateLag( %msDelay, %packetLossPercent )
+{
+   if ( %packetLossPercent $= "" )
+      %packetLossPercent = 0;
+                  
+   commandToServer( 'NetSimulateLag', %msDelay, %packetLossPercent );
+}
+
+//Various client functions
+
+function validateDatablockName(%name)
+{
+   // remove whitespaces at beginning and end
+   %name = trim( %name );
+   
+   // remove numbers at the beginning
+   %numbers = "0123456789";   
+   while( strlen(%name) > 0 )
+   {
+      // the first character
+      %firstChar = getSubStr( %name, 0, 1 );
+      // if the character is a number remove it
+      if( strpos( %numbers, %firstChar ) != -1 )
+      {
+         %name = getSubStr( %name, 1, strlen(%name) -1 );
+         %name = ltrim( %name );
+      }
+      else
+         break;
+   }
+   
+   // replace whitespaces with underscores
+   %name = strreplace( %name, " ", "_" );
+   
+   // remove any other invalid characters
+   %invalidCharacters = "-+*/%$&§=()[].?\"#,;!~<>|°^{}";
+   %name = stripChars( %name, %invalidCharacters );
+   
+   if( %name $= "" )
+      %name = "Unnamed";
+   
+   return %name;
+}
+
+//--------------------------------------------------------------------------
+// Finds location of %word in %text, starting at %start.  Works just like strPos
+//--------------------------------------------------------------------------
+
+function wordPos(%text, %word, %start)
+{
+   if (%start $= "") %start = 0;
+   
+   if (strpos(%text, %word, 0) == -1) return -1;
+   %count = getWordCount(%text);
+   if (%start >= %count) return -1;
+   for (%i = %start; %i < %count; %i++)
+   {
+      if (getWord( %text, %i) $= %word) return %i;
+   }
+   return -1;
+}
+
+//--------------------------------------------------------------------------
+// Finds location of %field in %text, starting at %start.  Works just like strPos
+//--------------------------------------------------------------------------
+
+function fieldPos(%text, %field, %start)
+{
+   if (%start $= "") %start = 0;
+   
+   if (strpos(%text, %field, 0) == -1) return -1;
+   %count = getFieldCount(%text);
+   if (%start >= %count) return -1;
+   for (%i = %start; %i < %count; %i++)
+   {
+      if (getField( %text, %i) $= %field) return %i;
+   }
+   return -1;
+}
+
+//--------------------------------------------------------------------------
+// returns the text in a file with "\n" at the end of each line
+//--------------------------------------------------------------------------
+
+function loadFileText( %file)
+{
+   %fo = new FileObject();
+   %fo.openForRead(%file);
+   %text = "";
+   while(!%fo.isEOF())
+   {
+      %text = %text @ %fo.readLine();
+      if (!%fo.isEOF()) %text = %text @ "\n";
+   }
+
+   %fo.delete();
+   return %text;
+}
+
+function setValueSafe(%dest, %val)
+{
+   %cmd = %dest.command;
+   %alt = %dest.altCommand;
+   %dest.command = "";
+   %dest.altCommand = "";
+
+   %dest.setValue(%val);
+   
+   %dest.command = %cmd;
+   %dest.altCommand = %alt;
+}
+
+function shareValueSafe(%source, %dest)
+{
+   setValueSafe(%dest, %source.getValue());
+}
+
+function shareValueSafeDelay(%source, %dest, %delayMs)
+{
+   schedule(%delayMs, 0, shareValueSafe, %source, %dest);
+}
+
+
+//------------------------------------------------------------------------------
+// An Aggregate Control is a plain GuiControl that contains other controls, 
+// which all share a single job or represent a single value.
+//------------------------------------------------------------------------------
+
+// AggregateControl.setValue( ) propagates the value to any control that has an 
+// internal name.
+function AggregateControl::setValue(%this, %val, %child)
+{
+   for(%i = 0; %i < %this.getCount(); %i++)
+   {
+      %obj = %this.getObject(%i);
+      if( %obj == %child )
+         continue;
+         
+      if(%obj.internalName !$= "")
+         setValueSafe(%obj, %val);
+   }
+}
+
+// AggregateControl.getValue() uses the value of the first control that has an
+// internal name, if it has not cached a value via .setValue
+function AggregateControl::getValue(%this)
+{
+   for(%i = 0; %i < %this.getCount(); %i++)
+   {
+      %obj = %this.getObject(%i);
+      if(%obj.internalName !$= "")
+      {
+         //error("obj = " @ %obj.getId() @ ", " @ %obj.getName() @ ", " @ %obj.internalName );
+         //error(" value = " @ %obj.getValue());
+         return %obj.getValue();
+      }
+   }
+}
+
+// AggregateControl.updateFromChild( ) is called by child controls to propagate
+// a new value, and to trigger the onAction() callback.
+function AggregateControl::updateFromChild(%this, %child)
+{
+   %val = %child.getValue();
+   if(%val == mCeil(%val)){
+      %val = mCeil(%val);
+   }else{
+      if ( %val <= -100){
+         %val = mCeil(%val);
+      }else if ( %val <= -10){
+         %val = mFloatLength(%val, 1);
+      }else if ( %val < 0){
+         %val = mFloatLength(%val, 2);
+      }else if ( %val >= 1000){
+         %val = mCeil(%val);
+      }else if ( %val >= 100){
+         %val = mFloatLength(%val, 1);
+      }else if ( %val >= 10){
+         %val = mFloatLength(%val, 2);
+      }else if ( %val > 0){
+         %val = mFloatLength(%val, 3);
+      }
+   }
+   %this.setValue(%val, %child);
+   %this.onAction();
+}
+
+// default onAction stub, here only to prevent console spam warnings.
+function AggregateControl::onAction(%this) 
+{
+}
+
+// call a method on all children that have an internalName and that implement the method.
+function AggregateControl::callMethod(%this, %method, %args)
+{
+   for(%i = 0; %i < %this.getCount(); %i++)
+   {
+      %obj = %this.getObject(%i);
+      if(%obj.internalName !$= "" && %obj.isMethod(%method))
+         eval(%obj @ "." @ %method @ "( " @ %args @ " );");
+   }
+
+}
+
+// A function used in order to easily parse the MissionGroup for classes . I'm pretty 
+// sure at this point the function can be easily modified to search the any group as well.
+function parseMissionGroup( %className, %childGroup )
+{
+   if( getWordCount( %childGroup ) == 0)
+      %currentGroup = "MissionGroup";
+   else
+      %currentGroup = %childGroup;
+      
+   for(%i = 0; %i < (%currentGroup).getCount(); %i++)
+   {      
+      if( (%currentGroup).getObject(%i).getClassName() $= %className )
+         return true;
+      
+      if( (%currentGroup).getObject(%i).getClassName() $= "SimGroup" )
+      {
+         if( parseMissionGroup( %className, (%currentGroup).getObject(%i).getId() ) )
+            return true;         
+      }
+   } 
+}
+
+// A variation of the above used to grab ids from the mission group based on classnames
+function parseMissionGroupForIds( %className, %childGroup )
+{
+   if( getWordCount( %childGroup ) == 0)
+      %currentGroup = "MissionGroup";
+   else
+      %currentGroup = %childGroup;
+      
+   for(%i = 0; %i < (%currentGroup).getCount(); %i++)
+   {      
+      if( (%currentGroup).getObject(%i).getClassName() $= %className )
+         %classIds = %classIds @ (%currentGroup).getObject(%i).getId() @ " ";
+      
+      if( (%currentGroup).getObject(%i).getClassName() $= "SimGroup" )
+         %classIds = %classIds @ parseMissionGroupForIds( %className, (%currentGroup).getObject(%i).getId());
+   } 
+   return trim( %classIds );
+}
+
+//------------------------------------------------------------------------------
+// Altered Version of TGB's QuickEditDropDownTextEditCtrl
+//------------------------------------------------------------------------------
+
+function QuickEditDropDownTextEditCtrl::onRenameItem( %this )
+{
+}
+
+function QuickEditDropDownTextEditCtrl::updateFromChild( %this, %ctrl )
+{
+   if( %ctrl.internalName $= "PopUpMenu" )
+   {
+      %this->TextEdit.setText( %ctrl.getText() );
+   }
+   else if ( %ctrl.internalName $= "TextEdit" )
+   {
+      %popup = %this->PopupMenu;
+      %popup.changeTextById( %popup.getSelected(), %ctrl.getText() );
+      %this.onRenameItem();
+   }
+}

BIN
Templates/BaseGame/game/core/images/AreaMap33.dds


BIN
Templates/BaseGame/game/core/images/button.png


BIN
Templates/BaseGame/game/core/images/caustics_1.png


BIN
Templates/BaseGame/game/core/images/caustics_2.png


BIN
Templates/BaseGame/game/core/images/checkbox.png


BIN
Templates/BaseGame/game/core/images/group-border.png


BIN
Templates/BaseGame/game/core/images/inactive-overlay.png


BIN
Templates/BaseGame/game/core/images/loadingbar.png


+ 32 - 0
Templates/BaseGame/game/core/images/materials.cs

@@ -0,0 +1,32 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+singleton Material( Empty )
+{
+};
+
+singleton Material(WarningMaterial) {
+   detailMap[0] = "missingTexture";
+   diffuseColor[0] = "25 16 0";
+   emissive[0] = false;
+   translucent = false;
+};

BIN
Templates/BaseGame/game/core/images/missingTexture.png


BIN
Templates/BaseGame/game/core/images/noise.png


BIN
Templates/BaseGame/game/core/images/null_color_ramp.png


BIN
Templates/BaseGame/game/core/images/scrollBar.png


BIN
Templates/BaseGame/game/core/images/textEdit.png


BIN
Templates/BaseGame/game/core/images/thumbHighlightButton.png


BIN
Templates/BaseGame/game/core/images/unavailable.png


BIN
Templates/BaseGame/game/core/images/warnMat.dds


BIN
Templates/BaseGame/game/core/images/window.png


+ 74 - 0
Templates/BaseGame/game/core/lighting.cs

@@ -0,0 +1,74 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+function initLightingSystems(%manager)
+{
+   echo( "\nInitializing Lighting Systems" );
+
+   // First exec the scripts for the different light managers
+   // in the lighting folder.
+   %pattern = "./lighting/*/init.cs";   
+   %file = findFirstFile( %pattern );
+   if ( %file $= "" )
+   {
+      // Try for DSOs next.
+      %pattern = "./lighting/*/init.cs.dso";
+      %file = findFirstFile( %pattern );
+   }
+
+   while( %file !$= "" )
+   {      
+      exec( %file );
+      %file = findNextFile( %pattern );
+   }
+
+   // Try the perfered one first.
+   %success = setLightManager(%manager);
+
+   // Did we completely fail to initialize a light manager?   
+   if (!%success)
+   {
+      // If we completely failed to initialize a light 
+      // manager then the 3d scene cannot be rendered.
+      quitWithErrorMessage( "Failed to set a light manager!" );
+   }
+}
+
+//---------------------------------------------------------------------------------------------
+
+function onLightManagerActivate( %lmName )
+{
+   // Call activation callbacks.
+   %activateNewFn = "onActivate" @ getWord( %lmName, 0 ) @ "LM";   
+   if( isFunction( %activateNewFn ) )
+      eval( %activateNewFn @ "();" );
+}
+
+//---------------------------------------------------------------------------------------------
+
+function onLightManagerDeactivate( %lmName )
+{
+   // Call deactivation callback.
+   %deactivateOldFn = "onDeactivate" @ getWord( %lmName, 0 ) @ "LM";
+   if( isFunction( %deactivateOldFn ) )
+      eval( %deactivateOldFn @ "();" );
+}

+ 70 - 0
Templates/BaseGame/game/core/lighting/advanced/deferredShading.cs

@@ -0,0 +1,70 @@
+singleton ShaderData( ClearGBufferShader )
+{
+   DXVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/deferredClearGBufferV.hlsl";
+   DXPixelShaderFile  = $Core::CommonShaderPath @ "/lighting/advanced/deferredClearGBufferP.hlsl";
+
+   OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile  = $Core::CommonShaderPath @ "/lighting/advanced/gl/deferredClearGBufferP.glsl";
+
+   pixVersion = 2.0;   
+};
+
+singleton ShaderData( DeferredColorShader )
+{
+   DXVertexShaderFile = $Core::CommonShaderPath @ "/postFx/postFxV.hlsl";
+   DXPixelShaderFile  = $Core::CommonShaderPath @ "/lighting/advanced/deferredColorShaderP.hlsl";
+   
+   OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile  = $Core::CommonShaderPath @ "/lighting/advanced/gl/deferredColorShaderP.glsl";
+
+   pixVersion = 2.0;   
+};
+
+// Primary Deferred Shader
+new GFXStateBlockData( AL_DeferredShadingState : PFX_DefaultStateBlock )
+{  
+   cullMode = GFXCullNone;
+   
+   blendDefined = true;
+   blendEnable = true; 
+   blendSrc = GFXBlendSrcAlpha;
+   blendDest = GFXBlendInvSrcAlpha;
+   
+   samplersDefined = true;
+   samplerStates[0] = SamplerWrapLinear;
+   samplerStates[1] = SamplerWrapLinear;
+   samplerStates[2] = SamplerWrapLinear;
+   samplerStates[3] = SamplerWrapLinear;
+};
+
+new ShaderData( AL_DeferredShader )
+{
+   DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
+   DXPixelShaderFile  = $Core::CommonShaderPath @ "/lighting/advanced/deferredShadingP.hlsl";
+   
+   OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile  = $Core::CommonShaderPath @ "/lighting/advanced/gl/deferredShadingP.glsl";
+
+   samplerNames[0] = "colorBufferTex";
+   samplerNames[1] = "lightPrePassTex";
+   samplerNames[2] = "matInfoTex";
+   samplerNames[3] = "prepassTex";
+   
+   pixVersion = 2.0;
+};
+
+singleton PostEffect( AL_DeferredShading )
+{
+   renderTime = "PFXAfterBin";
+   renderBin = "SkyBin";
+   shader = AL_DeferredShader;
+   stateBlock = AL_DeferredShadingState;
+   texture[0] = "#color";
+   texture[1] = "#lightinfo";
+   texture[2] = "#matinfo";
+   texture[3] = "#prepass";
+   
+   target = "$backBuffer";
+   renderPriority = 10000;
+   allowReflectPass = true;
+};

+ 77 - 0
Templates/BaseGame/game/core/lighting/advanced/init.cs

@@ -0,0 +1,77 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+///////////////////////////////////////////////////////////////////////////////
+// Default Prefs
+
+/*
+$pref::LightManager::sgAtlasMaxDynamicLights = "16";
+$pref::LightManager::sgDynamicShadowDetailSize = "0";
+$pref::LightManager::sgDynamicShadowQuality = "0";
+$pref::LightManager::sgLightingProfileAllowShadows = "1";
+$pref::LightManager::sgLightingProfileQuality = "0";
+$pref::LightManager::sgMaxBestLights = "10";
+$pref::LightManager::sgMultipleDynamicShadows = "1";
+$pref::LightManager::sgShowCacheStats = "0";
+$pref::LightManager::sgUseBloom = "";
+$pref::LightManager::sgUseDRLHighDynamicRange = "0";
+$pref::LightManager::sgUseDynamicRangeLighting = "0";
+$pref::LightManager::sgUseDynamicShadows = "1";
+$pref::LightManager::sgUseToneMapping = "";
+*/
+
+exec( "./shaders.cs" );
+exec( "./deferredShading.cs" );
+
+function onActivateAdvancedLM()
+{
+   // Don't allow the offscreen target on OSX.
+   if ( $platform $= "macos" )
+      return;
+                  
+   // On the Xbox360 we know what will be enabled so don't do any trickery to
+   // disable MSAA
+   if ( $platform $= "xenon" )
+      return;
+      
+   // Enable the offscreen target so that AL will work
+   // with MSAA back buffers and for HDR rendering.   
+   AL_FormatToken.enable();
+     
+   // Activate Deferred Shading
+   AL_DeferredShading.enable();
+}
+
+function onDeactivateAdvancedLM()
+{
+   // Disable the offscreen render target.
+   AL_FormatToken.disable();
+      
+   // Deactivate Deferred Shading
+   AL_DeferredShading.disable();
+}
+
+function setAdvancedLighting()
+{
+   setLightManager( "Advanced Lighting" );   
+}
+

+ 276 - 0
Templates/BaseGame/game/core/lighting/advanced/shaders.cs

@@ -0,0 +1,276 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+
+// Vector Light State
+new GFXStateBlockData( AL_VectorLightState )
+{
+   blendDefined = true;
+   blendEnable = true;
+   blendSrc = GFXBlendOne;
+   blendDest = GFXBlendOne;
+   blendOp = GFXBlendOpAdd;
+   
+   zDefined = true;
+   zEnable = false;
+   zWriteEnable = false;
+
+   samplersDefined = true;
+   samplerStates[0] = SamplerClampPoint;  // G-buffer
+   mSamplerNames[0] = "prePassBuffer";
+   samplerStates[1] = SamplerClampPoint;  // Shadow Map (Do not change this to linear, as all cards can not filter equally.)
+   mSamplerNames[1] = "shadowMap";
+   samplerStates[2] = SamplerClampPoint;  // Shadow Map (Do not change this to linear, as all cards can not filter equally.)
+   mSamplerNames[2] = "dynamicShadowMap";
+   samplerStates[3] = SamplerClampLinear;  // SSAO Mask
+   mSamplerNames[3] = "ssaoMask";
+   samplerStates[4] = SamplerWrapPoint;   // Random Direction Map
+   
+   cullDefined = true;
+   cullMode = GFXCullNone;
+   
+   stencilDefined = true;
+   stencilEnable = true;
+   stencilFailOp = GFXStencilOpKeep;
+   stencilZFailOp = GFXStencilOpKeep;
+   stencilPassOp = GFXStencilOpKeep;
+   stencilFunc = GFXCmpLess;
+   stencilRef = 0;
+};
+
+// Vector Light Material
+new ShaderData( AL_VectorLightShader )
+{
+   DXVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/farFrustumQuadV.hlsl";
+   DXPixelShaderFile  = $Core::CommonShaderPath @ "/lighting/advanced/vectorLightP.hlsl";
+
+   OGLVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/farFrustumQuadV.glsl";
+   OGLPixelShaderFile  = $Core::CommonShaderPath @ "/lighting/advanced/gl/vectorLightP.glsl";
+   
+   samplerNames[0] = "$prePassBuffer";
+   samplerNames[1] = "$shadowMap";
+   samplerNames[2] = "$dynamicShadowMap";
+   samplerNames[3] = "$ssaoMask";
+   samplerNames[4] = "$gTapRotationTex";
+   samplerNames[5] = "$lightBuffer";
+   samplerNames[6] = "$colorBuffer";
+   samplerNames[7] = "$matInfoBuffer";  
+   
+   pixVersion = 3.0;
+};
+
+new CustomMaterial( AL_VectorLightMaterial )
+{
+   shader = AL_VectorLightShader;
+   stateBlock = AL_VectorLightState;
+   
+   sampler["prePassBuffer"] = "#prepass";
+   sampler["shadowMap"] = "$dynamiclight";
+   sampler["dynamicShadowMap"] = "$dynamicShadowMap";
+   sampler["ssaoMask"] = "#ssaoMask";  
+   sampler["lightBuffer"] = "#lightinfo";
+   sampler["colorBuffer"] = "#color";
+   sampler["matInfoBuffer"] = "#matinfo";
+   
+   target = "lightinfo";
+   
+   pixVersion = 3.0;
+};
+
+//------------------------------------------------------------------------------
+
+// Convex-geometry light states
+new GFXStateBlockData( AL_ConvexLightState )
+{
+   blendDefined = true;
+   blendEnable = true;
+   blendSrc = GFXBlendOne;
+   blendDest = GFXBlendOne;
+   blendOp = GFXBlendOpAdd;
+   
+   zDefined = true;
+   zEnable = true;
+   zWriteEnable = false;
+   zFunc = GFXCmpGreaterEqual;
+
+   samplersDefined = true;
+   samplerStates[0] = SamplerClampPoint;  // G-buffer
+   mSamplerNames[0] = "prePassBuffer";
+   samplerStates[1] = SamplerClampPoint;  // Shadow Map (Do not use linear, these are perspective projections)
+   mSamplerNames[1] = "shadowMap";
+   samplerStates[2] = SamplerClampPoint;  // Shadow Map (Do not use linear, these are perspective projections)
+   mSamplerNames[2] = "dynamicShadowMap";
+   samplerStates[3] = SamplerClampLinear; // Cookie Map   
+   samplerStates[4] = SamplerWrapPoint;   // Random Direction Map
+   
+   cullDefined = true;
+   cullMode = GFXCullCW;
+   
+   stencilDefined = true;
+   stencilEnable = true;
+   stencilFailOp = GFXStencilOpKeep;
+   stencilZFailOp = GFXStencilOpKeep;
+   stencilPassOp = GFXStencilOpKeep;
+   stencilFunc = GFXCmpLess;
+   stencilRef = 0;
+};
+
+// Point Light Material
+new ShaderData( AL_PointLightShader )
+{
+   DXVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/convexGeometryV.hlsl";
+   DXPixelShaderFile  = $Core::CommonShaderPath @ "/lighting/advanced/pointLightP.hlsl";
+
+   OGLVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/convexGeometryV.glsl";
+   OGLPixelShaderFile  = $Core::CommonShaderPath @ "/lighting/advanced/gl/pointLightP.glsl";
+
+   samplerNames[0] = "$prePassBuffer";
+   samplerNames[1] = "$shadowMap";
+   samplerNames[2] = "$dynamicShadowMap";
+   samplerNames[3] = "$cookieMap";
+   samplerNames[4] = "$gTapRotationTex";
+   samplerNames[5] = "$lightBuffer";
+   samplerNames[6] = "$colorBuffer";
+   samplerNames[7] = "$matInfoBuffer";
+   
+   pixVersion = 3.0;
+};
+
+new CustomMaterial( AL_PointLightMaterial )
+{
+   shader = AL_PointLightShader;
+   stateBlock = AL_ConvexLightState;
+   
+   sampler["prePassBuffer"] = "#prepass";
+   sampler["shadowMap"] = "$dynamiclight";
+   sampler["dynamicShadowMap"] = "$dynamicShadowMap";
+   sampler["cookieMap"] = "$dynamiclightmask";
+   sampler["lightBuffer"] = "#lightinfo";
+   sampler["colorBuffer"] = "#color";
+   sampler["matInfoBuffer"] = "#matinfo";
+   
+   target = "lightinfo";
+   
+   pixVersion = 3.0;
+};
+
+// Spot Light Material
+new ShaderData( AL_SpotLightShader )
+{
+   DXVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/convexGeometryV.hlsl";
+   DXPixelShaderFile  = $Core::CommonShaderPath @ "/lighting/advanced/spotLightP.hlsl";
+
+   OGLVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/convexGeometryV.glsl";
+   OGLPixelShaderFile  = $Core::CommonShaderPath @ "/lighting/advanced/gl/spotLightP.glsl";
+   
+   samplerNames[0] = "$prePassBuffer";
+   samplerNames[1] = "$shadowMap";
+   samplerNames[2] = "$dynamicShadowMap";
+   samplerNames[3] = "$cookieMap";
+   samplerNames[4] = "$gTapRotationTex";
+   samplerNames[5] = "$lightBuffer";
+   samplerNames[6] = "$colorBuffer";
+   samplerNames[7] = "$matInfoBuffer";
+
+   pixVersion = 3.0;
+};
+
+new CustomMaterial( AL_SpotLightMaterial )
+{
+   shader = AL_SpotLightShader;
+   stateBlock = AL_ConvexLightState;
+   
+   sampler["prePassBuffer"] = "#prepass";
+   sampler["shadowMap"] = "$dynamiclight";
+   sampler["dynamicShadowMap"] = "$dynamicShadowMap";
+   sampler["cookieMap"] = "$dynamiclightmask";
+   sampler["lightBuffer"] = "#lightinfo";
+   sampler["colorBuffer"] = "#color";
+   sampler["matInfoBuffer"] = "#matinfo";
+   
+   target = "lightinfo";
+   
+   pixVersion = 3.0;
+};
+
+/// This material is used for generating prepass 
+/// materials for objects that do not have materials.
+new Material( AL_DefaultPrePassMaterial )
+{
+   // We need something in the first pass else it 
+   // won't create a proper material instance.  
+   //
+   // We use color here because some objects may not
+   // have texture coords in their vertex format... 
+   // for example like terrain.
+   //
+   diffuseColor[0] = "1 1 1 1";
+};
+
+/// This material is used for generating shadow 
+/// materials for objects that do not have materials.
+new Material( AL_DefaultShadowMaterial )
+{
+   // We need something in the first pass else it 
+   // won't create a proper material instance.  
+   //
+   // We use color here because some objects may not
+   // have texture coords in their vertex format... 
+   // for example like terrain.
+   //
+   diffuseColor[0] = "1 1 1 1";
+               
+   // This is here mostly for terrain which uses
+   // this material to create its shadow material.
+   //
+   // At sunset/sunrise the sun is looking thru 
+   // backsides of the terrain which often are not
+   // closed.  By changing the material to be double
+   // sided we avoid holes in the shadowed geometry.
+   //
+   doubleSided = true;
+};
+
+// Particle System Point Light Material
+new ShaderData( AL_ParticlePointLightShader )
+{
+   DXVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/particlePointLightV.hlsl";
+   DXPixelShaderFile  = $Core::CommonShaderPath @ "/lighting/advanced/particlePointLightP.hlsl";
+
+   OGLVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/convexGeometryV.glsl";
+   OGLPixelShaderFile  = $Core::CommonShaderPath @ "/lighting/advanced/gl/pointLightP.glsl";
+   
+   samplerNames[0] = "$prePassBuffer";   
+      
+   pixVersion = 3.0;
+};
+
+new CustomMaterial( AL_ParticlePointLightMaterial )
+{
+   shader = AL_ParticlePointLightShader;
+   stateBlock = AL_ConvexLightState;
+   
+   sampler["prePassBuffer"] = "#prepass";
+   target = "lightinfo";
+   
+   pixVersion = 3.0;
+};

+ 92 - 0
Templates/BaseGame/game/core/lighting/basic/init.cs

@@ -0,0 +1,92 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+exec( "./shadowFilter.cs" );
+
+singleton GFXStateBlockData( BL_ProjectedShadowSBData )
+{
+   blendDefined = true;
+   blendEnable = true;
+   blendSrc = GFXBlendDestColor;
+   blendDest = GFXBlendZero;
+         
+   zDefined = true;
+   zEnable = true;
+   zWriteEnable = false;
+               
+   samplersDefined = true;
+   samplerStates[0] = SamplerClampLinear;   
+   vertexColorEnable = true;
+};
+
+singleton ShaderData( BL_ProjectedShadowShaderData )
+{
+   DXVertexShaderFile     = $Core::CommonShaderPath @ "/projectedShadowV.hlsl";
+   DXPixelShaderFile      = $Core::CommonShaderPath @ "/projectedShadowP.hlsl";   
+   
+   OGLVertexShaderFile     = $Core::CommonShaderPath @ "/gl/projectedShadowV.glsl";
+   OGLPixelShaderFile      = $Core::CommonShaderPath @ "/gl/projectedShadowP.glsl";   
+      
+   samplerNames[0] = "inputTex";
+   
+   pixVersion = 2.0;
+};
+
+singleton CustomMaterial( BL_ProjectedShadowMaterial )
+{
+   sampler["inputTex"] = "$miscbuff";
+ 
+   shader = BL_ProjectedShadowShaderData;
+   stateBlock = BL_ProjectedShadowSBData;
+   version = 2.0;
+   forwardLit = true;
+};
+
+function onActivateBasicLM()
+{
+   // If HDR is enabled... enable the special format token.
+   if ( $platform !$= "macos" && HDRPostFx.isEnabled )
+      AL_FormatToken.enable();
+      
+   // Create render pass for projected shadow.
+   new RenderPassManager( BL_ProjectedShadowRPM );
+
+   // Create the mesh bin and add it to the manager.
+   %meshBin = new RenderMeshMgr();
+   BL_ProjectedShadowRPM.addManager( %meshBin );
+   
+   // Add both to the root group so that it doesn't
+   // end up in the MissionCleanup instant group.
+   RootGroup.add( BL_ProjectedShadowRPM );
+   RootGroup.add( %meshBin );      
+}
+
+function onDeactivateBasicLM()
+{
+   // Delete the pass manager which also deletes the bin.
+   BL_ProjectedShadowRPM.delete();
+}
+
+function setBasicLighting()
+{
+   setLightManager( "Basic Lighting" );   
+}

+ 76 - 0
Templates/BaseGame/game/core/lighting/basic/shadowFilter.cs

@@ -0,0 +1,76 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+
+singleton ShaderData( BL_ShadowFilterShaderV )
+{   
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/lighting/basic/shadowFilterV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/lighting/basic/shadowFilterP.hlsl";
+   
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/lighting/basic/gl/shadowFilterV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/lighting/basic/gl/shadowFilterP.glsl";
+
+   samplerNames[0] = "$diffuseMap";
+
+   defines = "BLUR_DIR=float2(1.0,0.0)";
+
+   pixVersion = 2.0;     
+};
+
+singleton ShaderData( BL_ShadowFilterShaderH : BL_ShadowFilterShaderV )
+{
+    defines = "BLUR_DIR=float2(0.0,1.0)";
+};
+
+
+singleton GFXStateBlockData( BL_ShadowFilterSB : PFX_DefaultStateBlock )
+{
+   colorWriteDefined=true;
+   colorWriteRed=false;
+   colorWriteGreen=false;
+   colorWriteBlue=false;
+   blendDefined = true;
+   blendEnable = true;
+};
+
+// NOTE: This is ONLY used in Basic Lighting, and 
+// only directly by the ProjectedShadow.  It is not 
+// meant to be manually enabled like other PostEffects.
+singleton PostEffect( BL_ShadowFilterPostFx )
+{
+    // Blur vertically
+   shader = BL_ShadowFilterShaderV;
+   stateBlock = PFX_DefaultStateBlock;
+   targetClear = "PFXTargetClear_OnDraw";
+   targetClearColor = "0 0 0 0";
+   texture[0] = "$inTex";
+   target = "$outTex";   
+
+   // Blur horizontal
+   new PostEffect()
+   {
+      shader = BL_ShadowFilterShaderH;
+      stateBlock = PFX_DefaultStateBlock;
+      texture[0] = "$inTex";
+      target = "$outTex";
+   };
+};

+ 32 - 0
Templates/BaseGame/game/core/lighting/shadowMaps/init.cs

@@ -0,0 +1,32 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+
+new ShaderData(BlurDepthShader)
+{
+   DXVertexShaderFile = $Core::CommonShaderPath @ "/lighting/shadowMap/boxFilterV.hlsl";
+   DXPixelShaderFile  = $Core::CommonShaderPath @ "/lighting/shadowMap/boxFilterP.hlsl";
+   
+   OGLVertexShaderFile = $Core::CommonShaderPath @ "/lighting/shadowMap/gl/boxFilterV.glsl";
+   OGLPixelShaderFile = $Core::CommonShaderPath @ "/lighting/shadowMap/gl/boxFilterP.glsl";
+   pixVersion = 2.0;
+};

+ 90 - 0
Templates/BaseGame/game/core/main.cs

@@ -0,0 +1,90 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+// ----------------------------------------------------------------------------
+// Initialize core sub system functionality such as audio, the Canvas, PostFX,
+// rendermanager, light managers, etc.
+//
+// Note that not all of these need to be initialized before the client, although
+// the audio should and the canvas definitely needs to be.  I've put things here
+// to distinguish between the purpose and functionality of the various client
+// scripts.  Game specific script isn't needed until we reach the shell menus
+// and start a game or connect to a server. We get the various subsystems ready
+// to go, and then use initClient() to handle the rest of the startup sequence.
+//
+// If this is too convoluted we can reduce this complexity after futher testing
+// to find exactly which subsystems should be readied before kicking things off. 
+// ----------------------------------------------------------------------------
+
+//We need to hook the missing/warn material stuff early, so do it here
+$Core::MissingTexturePath = "core/images/missingTexture";
+$Core::UnAvailableTexturePath = "core/images/unavailable";
+$Core::WarningTexturePath = "core/images/warnMat";
+$Core::CommonShaderPath = "core/shaders";
+
+exec("./helperFunctions.cs");
+
+// We need some of the default GUI profiles in order to get the canvas and
+// other aspects of the GUI system ready.
+exec("./profiles.cs");
+
+//This is a bit of a shortcut, but we'll load the client's default settings to ensure all the prefs get initialized correctly
+%prefPath = getPrefpath();
+if ( isFile( %prefPath @ "/clientPrefs.cs" ) )
+   exec( %prefPath @ "/clientPrefs.cs" );
+else
+   exec("data/defaults.cs");
+   
+%der = $pref::Video::displayDevice;
+
+// Initialization of the various subsystems requires some of the preferences
+// to be loaded... so do that first.
+exec("./globals.cs");
+
+exec("./canvas.cs");
+exec("./cursor.cs");
+
+exec("./renderManager.cs");
+exec("./lighting.cs");
+
+exec("./audio.cs");
+exec("./sfx/audioAmbience.cs");
+exec("./sfx/audioData.cs");
+exec("./sfx/audioDescriptions.cs");
+exec("./sfx/audioEnvironments.cs");
+exec("./sfx/audioStates.cs");
+
+exec("./parseArgs.cs");
+
+// Materials and Shaders for rendering various object types
+exec("./gfxData/commonMaterialData.cs");
+exec("./gfxData/shaders.cs");
+exec("./gfxData/terrainBlock.cs");
+exec("./gfxData/water.cs");
+exec("./gfxData/scatterSky.cs");
+exec("./gfxData/clouds.cs");
+
+// Initialize all core post effects.   
+exec("./postFx.cs");
+
+// Seed the random number generator.
+setRandomSeed();

+ 392 - 0
Templates/BaseGame/game/core/parseArgs.cs

@@ -0,0 +1,392 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+//-----------------------------------------------------------------------------
+// Support functions used to manage the directory list
+function pushFront(%list, %token, %delim)
+{
+   if (%list !$= "")
+      return %token @ %delim @ %list;
+   return %token;
+}
+
+function pushBack(%list, %token, %delim)
+{
+   if (%list !$= "")
+      return %list @ %delim @ %token;
+   return %token;
+}
+
+function popFront(%list, %delim)
+{
+   return nextToken(%list, unused, %delim);
+}
+
+function parseArgs()
+{
+   for ($i = 1; $i < $Game::argc ; $i++)
+   {
+      $arg = $Game::argv[$i];
+      $nextArg = $Game::argv[$i+1];
+      $hasNextArg = $Game::argc - $i > 1;
+      $logModeSpecified = false;
+
+      // Check for dedicated run
+      /*if( stricmp($arg,"-dedicated") == 0  )
+      {
+         $userDirs = $defaultGame;
+         $dirCount = 1;
+         $isDedicated = true;
+      }*/
+
+      switch$ ($arg)
+      {
+         //--------------------
+         case "-dedicated":
+            $userDirs = $defaultGame;
+            $dirCount = 1;
+            $isDedicated = true;
+            $Server::Dedicated = true;
+            enableWinConsole(true);
+            $argUsed[%i]++;
+            
+                  //--------------------
+         case "-mission":
+            $argUsed[%i]++;
+            if ($hasNextArg) 
+            {
+               $missionArg = $nextArg;
+               $argUsed[%i+1]++;
+               %i++;
+            }
+            else
+               error("Error: Missing Command Line argument. Usage: -mission <filename>");
+
+         //--------------------
+         case "-connect":
+            $argUsed[%i]++;
+            if ($hasNextArg) 
+            {
+               $JoinGameAddress = $nextArg;
+               $argUsed[%i+1]++;
+               %i++;
+            }
+            else
+               error("Error: Missing Command Line argument. Usage: -connect <ip_address>");
+
+            
+         //--------------------
+         case "-log":
+            $argUsed[$i]++;
+            if ($hasNextArg)
+            {
+               // Turn on console logging
+               if ($nextArg != 0)
+               {
+                  // Dump existing console to logfile first.
+                  $nextArg += 4;
+               }
+               setLogMode($nextArg);
+               $logModeSpecified = true;
+               $argUsed[$i+1]++;
+               $i++;
+            }
+            else
+               error("Error: Missing Command Line argument. Usage: -log <Mode: 0,1,2>");
+
+         //--------------------
+         case "-dir":
+            $argUsed[$i]++;
+            if ($hasNextArg)
+            {
+               // Append the mod to the end of the current list
+               $userDirs = strreplace($userDirs, $nextArg, "");
+               $userDirs = pushFront($userDirs, $nextArg, ";");
+               $argUsed[$i+1]++;
+               $i++;
+               $dirCount++;
+            }
+            else
+               error("Error: Missing Command Line argument. Usage: -dir <dir_name>");
+
+         //--------------------
+         // changed the default behavior of this command line arg. It now
+         // defaults to ONLY loading the game, not tools 
+         // default auto-run already loads in tools --SRZ 11/29/07
+         case "-game":
+            $argUsed[$i]++;
+            if ($hasNextArg)
+            {
+               // Set the selected dir --NOTE: we no longer allow tools with this argument
+               /* 
+               if( $isDedicated )
+               {
+                  $userDirs = $nextArg;
+                  $dirCount = 1;
+               }
+               else
+               {
+                  $userDirs = "tools;" @ $nextArg;
+                  $dirCount = 2;
+               }
+               */
+               $userDirs = $nextArg;
+               $dirCount = 1;
+               $argUsed[$i+1]++;
+               $i++;
+               error($userDirs);
+            }
+            else
+               error("Error: Missing Command Line argument. Usage: -game <game_name>");
+
+         //--------------------
+         case "-console":
+            enableWinConsole(true);
+            $argUsed[$i]++;
+
+         //--------------------
+         case "-jSave":
+            $argUsed[$i]++;
+            if ($hasNextArg)
+            {
+               echo("Saving event log to journal: " @ $nextArg);
+               saveJournal($nextArg);
+               $argUsed[$i+1]++;
+               $i++;
+            }
+            else
+               error("Error: Missing Command Line argument. Usage: -jSave <journal_name>");
+
+         //--------------------
+         case "-jPlay":
+            $argUsed[$i]++;
+            if ($hasNextArg)
+            {
+               playJournal($nextArg);
+               $argUsed[$i+1]++;
+               $i++;
+            }
+            else
+               error("Error: Missing Command Line argument. Usage: -jPlay <journal_name>");
+               
+         //--------------------
+         case "-jPlayToVideo":
+            $argUsed[$i]++;
+            if ($hasNextArg)
+            {
+               $VideoCapture::journalName = $nextArg;
+               $VideoCapture::captureFromJournal = true;
+               $argUsed[$i+1]++;
+               $i++;
+            }
+            else
+               error("Error: Missing Command Line argument. Usage: -jPlayToVideo <journal_name>");
+               
+         //--------------------
+         case "-vidCapFile":
+            $argUsed[$i]++;
+            if ($hasNextArg)
+            {
+               $VideoCapture::fileName = $nextArg;
+               $argUsed[$i+1]++;
+               $i++;
+            }
+            else
+               error("Error: Missing Command Line argument. Usage: -vidCapFile <ouput_video_name>");
+               
+         //--------------------
+         case "-vidCapFPS":
+            $argUsed[$i]++;
+            if ($hasNextArg)
+            {
+               $VideoCapture::fps = $nextArg;
+               $argUsed[$i+1]++;
+               $i++;
+            }
+            else
+               error("Error: Missing Command Line argument. Usage: -vidCapFPS <ouput_video_framerate>");
+               
+         //--------------------
+         case "-vidCapEncoder":
+            $argUsed[$i]++;
+            if ($hasNextArg)
+            {
+               $VideoCapture::encoder = $nextArg;
+               $argUsed[$i+1]++;
+               $i++;
+            }
+            else
+               error("Error: Missing Command Line argument. Usage: -vidCapEncoder <ouput_video_encoder>");
+               
+         //--------------------
+         case "-vidCapWidth":
+            $argUsed[$i]++;
+            if ($hasNextArg)
+            {
+               $videoCapture::width = $nextArg;
+               $argUsed[$i+1]++;
+               $i++;
+            }
+            else
+               error("Error: Missing Command Line argument. Usage: -vidCapWidth <ouput_video_width>");
+               
+         //--------------------
+         case "-vidCapHeight":
+            $argUsed[$i]++;
+            if ($hasNextArg)
+            {
+               $videoCapture::height = $nextArg;
+               $argUsed[$i+1]++;
+               $i++;
+            }
+            else
+               error("Error: Missing Command Line argument. Usage: -vidCapHeight <ouput_video_height>");
+
+         //--------------------
+         case "-level":
+            $argUsed[$i]++;
+            if ($hasNextArg)
+            {
+               %hasExt = strpos($nextArg, ".mis");
+               if(%hasExt == -1)
+               {
+                  $levelToLoad = $nextArg @ " ";
+                  
+                  for(%i = $i + 2; %i < $Game::argc; %i++)
+                  {
+                     $arg = $Game::argv[%i];
+                     %hasExt = strpos($arg, ".mis");
+                     
+                     if(%hasExt == -1)
+                     {
+                        $levelToLoad = $levelToLoad @ $arg @ " ";
+                     } else
+                     {
+                        $levelToLoad = $levelToLoad @ $arg;
+                        break;
+                     }
+                  }
+               } 
+               else
+               {
+                  $levelToLoad = $nextArg;
+               }
+               
+               $argUsed[$i+1]++;
+               $i++;
+            }
+            else
+               error("Error: Missing Command Line argument. Usage: -level <level file name (no path), with or without extension>");
+
+         //-------------------
+         case "-worldeditor":
+            $startWorldEditor = true;
+            $argUsed[$i]++;
+
+         //-------------------
+         case "-guieditor":
+            $startGUIEditor = true;
+            $argUsed[$i]++;
+
+         //-------------------
+         case "-help":
+            $displayHelp = true;
+            $argUsed[$i]++;
+
+         //-------------------
+         case "-compileAll":
+            $compileAll = true;
+            $argUsed[$i]++;
+            
+         //-------------------
+         case "-compileTools":
+            $compileTools = true;
+            $argUsed[$i]++;
+
+         //-------------------
+         case "-genScript":
+            $genScript = true;
+            $argUsed[$i]++;
+            
+         case "-fullscreen":
+            $cliFullscreen = true;
+            $argUsed[%i]++;
+
+         case "-windowed":
+            $cliFullscreen = false;
+            $argUsed[%i]++;
+
+         case "-openGL":
+            $pref::Video::displayDevice = "OpenGL";
+            $argUsed[%i]++;
+
+         case "-directX":
+            $pref::Video::displayDevice = "D3D";
+            $argUsed[%i]++;
+
+         case "-autoVideo":
+            $pref::Video::displayDevice = "";
+            $argUsed[%i]++;
+
+         case "-prefs":
+            $argUsed[%i]++;
+            if ($hasNextArg) {
+               exec($nextArg, true, true);
+               $argUsed[%i+1]++;
+               %i++;
+            }
+            else
+               error("Error: Missing Command Line argument. Usage: -prefs <path/script.cs>");
+
+            
+         //-------------------
+         default:
+            $argUsed[$i]++;
+            if($userDirs $= "")
+               $userDirs = $arg;
+      }
+   }
+   
+   //-----------------------------------------------
+   // Play journal to video file?
+   if ($VideoCapture::captureFromJournal && $VideoCapture::journalName !$= "")
+   {         
+      if ($VideoCapture::fileName $= "")
+         $VideoCapture::fileName = $VideoCapture::journalName;     
+      
+      if ($VideoCapture::encoder $= "")
+         $VideoCapture::encoder = "THEORA";
+            
+      if ($VideoCapture::fps $= "")
+         $VideoCapture::fps = 30;
+               
+      if ($videoCapture::width $= "")
+         $videoCapture::width = 0;
+         
+      if ($videoCapture::height $= "")
+         $videoCapture::height = 0;
+         
+      playJournalToVideo(  $VideoCapture::journalName, $VideoCapture::fileName, 
+                           $VideoCapture::encoder, $VideoCapture::fps, 
+                           $videoCapture::width SPC $videoCapture::height );
+   }
+}

+ 74 - 0
Templates/BaseGame/game/core/postFX/GammaPostFX.cs

@@ -0,0 +1,74 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+singleton ShaderData( GammaShader )
+{
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/gammaP.hlsl";
+
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/gl/gammaP.glsl";
+   
+   samplerNames[0] = "$backBuffer";
+   samplerNames[1] = "$colorCorrectionTex";
+
+   pixVersion = 2.0;   
+};
+
+singleton GFXStateBlockData( GammaStateBlock : PFX_DefaultStateBlock )
+{
+   samplersDefined = true;
+   samplerStates[0] = SamplerClampLinear;
+   samplerStates[1] = SamplerClampLinear; 
+};
+
+singleton PostEffect( GammaPostFX )
+{
+   isEnabled = true;
+   allowReflectPass = true;
+   
+   renderTime = "PFXBeforeBin";
+   renderBin = "EditorBin";
+   renderPriority = 9999;
+      
+   shader = GammaShader;
+   stateBlock = GammaStateBlock;
+   
+   texture[0] = "$backBuffer";  
+   texture[1] = $HDRPostFX::colorCorrectionRamp;  
+   
+   targetFormat = getBestHDRFormat();
+};
+
+function GammaPostFX::preProcess( %this )
+{
+   if ( %this.texture[1] !$= $HDRPostFX::colorCorrectionRamp )
+      %this.setTexture( 1, $HDRPostFX::colorCorrectionRamp );         
+}
+
+function GammaPostFX::setShaderConsts( %this )
+{
+   %clampedGamma  = mClamp( $pref::Video::Gamma, 2.0, 2.5);
+   %this.setShaderConst( "$OneOverGamma", 1 / %clampedGamma );
+   %this.setShaderConst( "$Brightness", $pref::Video::Brightness );
+   %this.setShaderConst( "$Contrast", $pref::Video::Contrast );
+}

+ 186 - 0
Templates/BaseGame/game/core/postFX/MLAA.cs

@@ -0,0 +1,186 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+// An implementation of "Practical Morphological Anti-Aliasing" from 
+// GPU Pro 2 by Jorge Jimenez, Belen Masia, Jose I. Echevarria, 
+// Fernando Navarro, and Diego Gutierrez.
+//
+// http://www.iryoku.com/mlaa/
+
+// NOTE: This is currently disabled in favor of FXAA.  See 
+// core\scripts\client\canvas.cs if you want to re-enable it.
+
+singleton GFXStateBlockData( MLAA_EdgeDetectStateBlock : PFX_DefaultStateBlock )
+{   
+   // Mark the edge pixels in stencil.
+   stencilDefined = true;
+   stencilEnable = true;
+   stencilPassOp = GFXStencilOpReplace;
+   stencilFunc = GFXCmpAlways;
+   stencilRef = 1;
+
+   samplersDefined = true;   
+   samplerStates[0] = SamplerClampLinear;
+};
+
+singleton ShaderData( MLAA_EdgeDetectionShader )
+{   
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/mlaa/offsetV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/mlaa/edgeDetectionP.hlsl";
+
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/mlaa/gl/offsetV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/mlaa/gl/edgeDetectionP.glsl";
+
+   samplerNames[0] = "$colorMapG";
+   samplerNames[1] = "$prepassMap";
+
+   pixVersion = 3.0;
+};
+
+singleton GFXStateBlockData( MLAA_BlendWeightCalculationStateBlock : PFX_DefaultStateBlock )
+{   
+   // Here we want to process only marked pixels.
+   stencilDefined = true;
+   stencilEnable = true;
+   stencilPassOp = GFXStencilOpKeep;
+   stencilFunc = GFXCmpEqual;
+   stencilRef = 1;
+
+   samplersDefined = true;   
+   samplerStates[0] = SamplerClampPoint;
+   samplerStates[1] = SamplerClampLinear;
+   samplerStates[2] = SamplerClampPoint;
+};
+
+singleton ShaderData( MLAA_BlendWeightCalculationShader )
+{   
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/mlaa/passthruV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/mlaa/blendWeightCalculationP.hlsl";
+
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/mlaa/gl/passthruV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/mlaa/gl/blendWeightCalculationP.glsl";
+
+   samplerNames[0] = "$edgesMap";
+   samplerNames[1] = "$edgesMapL";
+   samplerNames[2] = "$areaMap";
+
+   pixVersion = 3.0;
+};
+
+singleton GFXStateBlockData( MLAA_NeighborhoodBlendingStateBlock : PFX_DefaultStateBlock )
+{   
+   // Here we want to process only marked pixels too.
+   stencilDefined = true;
+   stencilEnable = true;
+   stencilPassOp = GFXStencilOpKeep;
+   stencilFunc = GFXCmpEqual;
+   stencilRef = 1;
+
+   samplersDefined = true;   
+   samplerStates[0] = SamplerClampPoint;
+   samplerStates[1] = SamplerClampLinear;
+   samplerStates[2] = SamplerClampPoint;
+};
+
+singleton ShaderData( MLAA_NeighborhoodBlendingShader )
+{   
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/mlaa/offsetV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/mlaa/neighborhoodBlendingP.hlsl";
+   
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/mlaa/gl/offsetV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/mlaa/gl/neighborhoodBlendingP.glsl";
+
+   samplerNames[0] = "$blendMap";
+   samplerNames[1] = "$colorMapL";
+   samplerNames[2] = "$colorMap";
+
+   pixVersion = 3.0;
+};
+
+
+singleton PostEffect( MLAAFx )
+{
+   isEnabled = false;
+   
+   allowReflectPass = false;
+   renderTime = "PFXAfterDiffuse";
+
+   texture[0] = "$backBuffer"; //colorMapG      
+   texture[1] = "#prepass"; // Used for depth detection
+
+   target = "$outTex";
+   targetClear = PFXTargetClear_OnDraw;
+   targetClearColor = "0 0 0 0";
+
+   stateBlock = MLAA_EdgeDetectStateBlock;
+   shader = MLAA_EdgeDetectionShader;
+
+   // The luma calculation weights which can be user adjustable
+   // per-scene if nessasary.  The default value of...
+   //
+   //    0.2126 0.7152 0.0722 
+   //
+   // ... is the HDTV ITU-R Recommendation BT. 709.
+   lumaCoefficients = "0.2126 0.7152 0.0722";
+
+   // The tweakable color threshold used to select
+   // the range of edge pixels to blend.
+   threshold = 0.1;
+
+   // The depth delta threshold used to select
+   // the range of edge pixels to blend.
+   depthThreshold = 0.01;
+
+   new PostEffect()
+   {
+      internalName = "blendingWeightsCalculation";
+
+      target = "$outTex";
+      targetClear = PFXTargetClear_OnDraw;
+
+      shader = MLAA_BlendWeightCalculationShader;
+      stateBlock = MLAA_BlendWeightCalculationStateBlock;
+
+      texture[0] = "$inTex"; // Edges mask    
+      texture[1] = "$inTex"; // Edges mask 
+      texture[2] = "core/images/AreaMap33.dds";
+   };
+
+   new PostEffect()
+   {
+      internalName = "neighborhoodBlending";
+
+      shader = MLAA_NeighborhoodBlendingShader;
+      stateBlock = MLAA_NeighborhoodBlendingStateBlock;
+
+      texture[0] = "$inTex"; // Blend weights
+      texture[1] = "$backBuffer";      
+      texture[2] = "$backBuffer";      
+   };
+};
+
+function MLAAFx::setShaderConsts(%this)
+{
+   %this.setShaderConst("$lumaCoefficients", %this.lumaCoefficients);
+   %this.setShaderConst("$threshold", %this.threshold);
+   %this.setShaderConst("$depthThreshold", %this.depthThreshold);
+}

+ 53 - 0
Templates/BaseGame/game/core/postFX/MotionBlurFx.cs

@@ -0,0 +1,53 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+singleton ShaderData( PFX_MotionBlurShader )  
+{     
+   DXVertexShaderFile   = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";  //we use the bare-bones postFxV.hlsl
+   DXPixelShaderFile    = $Core::CommonShaderPath @ "/postFX/motionBlurP.hlsl";  //new pixel shader
+   
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile    = $Core::CommonShaderPath @ "/postFX/gl/motionBlurP.glsl";
+   
+   samplerNames[0] = "$backBuffer";
+   samplerNames[1] = "$prepassTex";
+   
+   pixVersion = 3.0;  
+};  
+
+singleton PostEffect(MotionBlurFX)  
+{
+   isEnabled = false;
+
+   renderTime = "PFXAfterDiffuse";  
+
+   shader = PFX_MotionBlurShader;  
+   stateBlock = PFX_DefaultStateBlock;  
+   texture[0] = "$backbuffer";
+   texture[1] = "#prepass";
+   target = "$backBuffer";
+};
+
+function MotionBlurFX::setShaderConsts(%this)
+{
+   %this.setShaderConst( "$velocityMultiplier", 3000 );
+}

+ 64 - 0
Templates/BaseGame/game/core/postFX/caustics.cs

@@ -0,0 +1,64 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+singleton GFXStateBlockData( PFX_CausticsStateBlock : PFX_DefaultStateBlock )
+{
+   blendDefined = true;
+   blendEnable = true; 
+   blendSrc = GFXBlendOne;
+   blendDest = GFXBlendOne;
+   
+   samplersDefined = true;
+   samplerStates[0] = SamplerClampLinear;
+   samplerStates[1] = SamplerWrapLinear;
+   samplerStates[2] = SamplerWrapLinear;
+};
+
+singleton ShaderData( PFX_CausticsShader )
+{   
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/caustics/causticsP.hlsl";
+         
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/caustics/gl/causticsP.glsl";
+      
+   samplerNames[0] = "$prepassTex";
+   samplerNames[1] = "$causticsTex0";
+   samplerNames[2] = "$causticsTex1";
+   
+   pixVersion = 3.0;
+};
+
+singleton PostEffect( CausticsPFX )
+{
+   isEnabled = false;
+   renderTime = "PFXAfterDiffuse";
+   renderBin = "ObjTranslucentBin";      
+   //renderPriority = 0.1;
+      
+   shader = PFX_CausticsShader;
+   stateBlock = PFX_CausticsStateBlock;
+   texture[0] = "#prepass";
+   texture[1] = "core/images/caustics_1";
+   texture[2] = "core/images/caustics_2";
+   target = "$backBuffer";
+};

+ 77 - 0
Templates/BaseGame/game/core/postFX/chromaticLens.cs

@@ -0,0 +1,77 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+/// 
+$CAPostFx::enabled = false;
+
+/// The lens distortion coefficient.
+$CAPostFx::distCoeffecient =  -0.05;
+
+/// The cubic distortion value.
+$CAPostFx::cubeDistortionFactor =  -0.1;
+
+/// The amount and direction of the maxium shift for
+/// the red, green, and blue channels.
+$CAPostFx::colorDistortionFactor = "0.005 -0.005 0.01";
+
+
+singleton GFXStateBlockData( PFX_DefaultChromaticLensStateBlock )
+{
+   zDefined = true;
+   zEnable = false;
+   zWriteEnable = false;   
+   samplersDefined = true;
+   samplerStates[0] = SamplerClampPoint;
+};
+
+singleton ShaderData( PFX_ChromaticLensShader )
+{   
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/chromaticLens.hlsl"; 
+   
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/gl/chromaticLens.glsl";
+   
+   samplerNames[0] = "$backBuffer";
+   
+   pixVersion = 3.0;
+};
+
+singleton PostEffect( ChromaticLensPostFX )
+{
+   renderTime = "PFXAfterDiffuse";
+   renderPriority = 0.2;
+   isEnabled = false;
+   allowReflectPass = false;
+
+   shader = PFX_ChromaticLensShader;
+   stateBlock = PFX_DefaultChromaticLensStateBlock;
+   texture[0] = "$backBuffer";
+   target = "$backBuffer";
+};
+
+function ChromaticLensPostFX::setShaderConsts( %this )
+{
+   %this.setShaderConst( "$distCoeff", $CAPostFx::distCoeffecient );   
+   %this.setShaderConst( "$cubeDistort", $CAPostFx::cubeDistortionFactor );    
+   %this.setShaderConst( "$colorDistort", $CAPostFx::colorDistortionFactor );   
+}

+ 72 - 0
Templates/BaseGame/game/core/postFX/default.postfxpreset.cs

@@ -0,0 +1,72 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+$PostFXManager::Settings::EnableVignette = "1";
+$PostFXManager::Settings::EnableDOF = "1";
+$PostFXManager::Settings::EnabledSSAO = "1";
+$PostFXManager::Settings::EnableHDR = "1";
+$PostFXManager::Settings::EnableLightRays = "1";
+$PostFXManager::Settings::EnablePostFX = "1";
+$PostFXManager::Settings::Vignette::VMax = "0.6";
+$PostFXManager::Settings::DOF::BlurCurveFar = "";
+$PostFXManager::Settings::DOF::BlurCurveNear = "";
+$PostFXManager::Settings::DOF::BlurMax = "";
+$PostFXManager::Settings::DOF::BlurMin = "";
+$PostFXManager::Settings::DOF::EnableAutoFocus = "";
+$PostFXManager::Settings::DOF::EnableDOF = "";
+$PostFXManager::Settings::DOF::FocusRangeMax = "";
+$PostFXManager::Settings::DOF::FocusRangeMin = "";
+$PostFXManager::Settings::HDR::adaptRate = "2";
+$PostFXManager::Settings::HDR::blueShiftColor = "1.05 0.97 1.27";
+$PostFXManager::Settings::HDR::brightPassThreshold = "1";
+$PostFXManager::Settings::HDR::enableBloom = "1";
+$PostFXManager::Settings::HDR::enableBlueShift = "0";
+$PostFXManager::Settings::HDR::enableToneMapping = "0.5";
+$PostFXManager::Settings::HDR::gaussMean = "0";
+$PostFXManager::Settings::HDR::gaussMultiplier = "0.3";
+$PostFXManager::Settings::HDR::gaussStdDev = "0.8";
+$PostFXManager::Settings::HDR::keyValue = "0.18";
+$PostFXManager::Settings::HDR::minLuminace = "0.001";
+$PostFXManager::Settings::HDR::whiteCutoff = "1";
+$PostFXManager::Settings::LightRays::brightScalar = "0.75";
+$PostFXManager::Settings::LightRays::decay = "1.0";
+$PostFXManager::Settings::LightRays::density = "0.94";
+$PostFXManager::Settings::LightRays::numSamples = "40";
+$PostFXManager::Settings::LightRays::weight = "5.65";
+$PostFXManager::Settings::SSAO::blurDepthTol = "0.001";
+$PostFXManager::Settings::SSAO::blurNormalTol = "0.95";
+$PostFXManager::Settings::SSAO::lDepthMax = "2";
+$PostFXManager::Settings::SSAO::lDepthMin = "0.2";
+$PostFXManager::Settings::SSAO::lDepthPow = "0.2";
+$PostFXManager::Settings::SSAO::lNormalPow = "2";
+$PostFXManager::Settings::SSAO::lNormalTol = "-0.5";
+$PostFXManager::Settings::SSAO::lRadius = "1";
+$PostFXManager::Settings::SSAO::lStrength = "10";
+$PostFXManager::Settings::SSAO::overallStrength = "2";
+$PostFXManager::Settings::SSAO::quality = "0";
+$PostFXManager::Settings::SSAO::sDepthMax = "1";
+$PostFXManager::Settings::SSAO::sDepthMin = "0.1";
+$PostFXManager::Settings::SSAO::sDepthPow = "1";
+$PostFXManager::Settings::SSAO::sNormalPow = "1";
+$PostFXManager::Settings::SSAO::sNormalTol = "0";
+$PostFXManager::Settings::SSAO::sRadius = "0.1";
+$PostFXManager::Settings::SSAO::sStrength = "6";
+$PostFXManager::Settings::ColorCorrectionRamp = "core/images/null_color_ramp.png";

+ 599 - 0
Templates/BaseGame/game/core/postFX/dof.cs

@@ -0,0 +1,599 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+/*
+
+================================================================================
+ The DOFPostEffect API
+================================================================================
+
+DOFPostEffect::setFocalDist( %dist )
+
+@summary
+This method is for manually controlling the focus distance. It will have no 
+effect if auto focus is currently enabled. Makes use of the parameters set by 
+setFocusParams.
+
+@param dist 
+float distance in meters
+
+--------------------------------------------------------------------------------
+
+DOFPostEffect::setAutoFocus( %enabled )
+
+@summary
+This method sets auto focus enabled or disabled. Makes use of the parameters set 
+by setFocusParams. When auto focus is enabled it determines the focal depth
+by performing a raycast at the screen-center.
+
+@param enabled
+bool
+
+--------------------------------------------------------------------------------
+
+DOFPostEffect::setFocusParams( %nearBlurMax, %farBlurMax, %minRange, %maxRange, %nearSlope, %farSlope )
+
+Set the parameters that control how the near and far equations are calculated
+from the focal distance. If you are not using auto focus you will need to call
+setFocusParams PRIOR to calling setFocalDist.
+
+@param nearBlurMax   
+float between 0.0 and 1.0
+The max allowed value of near blur.
+
+@param farBlurMax    
+float between 0.0 and 1.0
+The max allowed value of far blur.
+
+@param minRange/maxRange 
+float in meters
+The distance range around the focal distance that remains in focus is a lerp 
+between the min/maxRange using the normalized focal distance as the parameter. 
+The point is to allow the focal range to expand as you focus farther away since this is 
+visually appealing.
+
+Note: since min/maxRange are lerped by the "normalized" focal distance it is
+dependant on the visible distance set in your level.
+
+@param nearSlope
+float less than zero
+The slope of the near equation. A small number causes bluriness to increase gradually
+at distances closer than the focal distance. A large number causes bluriness to 
+increase quickly.
+
+@param farSlope
+float greater than zero
+The slope of the far equation. A small number causes bluriness to increase gradually
+at distances farther than the focal distance. A large number causes bluriness to
+increase quickly.
+
+Note: To rephrase, the min/maxRange parameters control how much area around the
+focal distance is completely in focus where the near/farSlope parameters control
+how quickly or slowly bluriness increases at distances outside of that range.
+
+================================================================================
+ Examples
+================================================================================
+
+Example1: Turn on DOF while zoomed in with a weapon.
+
+NOTE: These are not real callbacks! Hook these up to your code where appropriate!
+
+function onSniperZoom()
+{
+   // Parameterize how you want DOF to look.
+   DOFPostEffect.setFocusParams( 0.3, 0.3, 50, 500, -5, 5 );
+   
+   // Turn on auto focus
+   DOFPostEffect.setAutoFocus( true );
+   
+   // Turn on the PostEffect
+   DOFPostEffect.enable();
+}
+
+function onSniperUnzoom()
+{
+   // Turn off the PostEffect
+   DOFPostEffect.disable();
+}
+
+Example2: Manually control DOF with the mouse wheel.
+
+// Somewhere on startup...
+
+// Parameterize how you want DOF to look.
+DOFPostEffect.setFocusParams( 0.3, 0.3, 50, 500, -5, 5 );
+
+// Turn off auto focus
+DOFPostEffect.setAutoFocus( false );
+
+// Turn on the PostEffect
+DOFPostEffect.enable();
+
+
+NOTE: These are not real callbacks! Hook these up to your code where appropriate!
+
+function onMouseWheelUp()
+{
+   // Since setFocalDist is really just a wrapper to assign to the focalDist
+   // dynamic field we can shortcut and increment it directly.
+   DOFPostEffect.focalDist += 8;
+}
+
+function onMouseWheelDown()
+{
+   DOFPostEffect.focalDist -= 8;
+}
+*/
+
+/// This method is for manually controlling the focal distance. It will have no 
+/// effect if auto focus is currently enabled. Makes use of the parameters set by 
+/// setFocusParams.
+function DOFPostEffect::setFocalDist( %this, %dist )
+{    
+   %this.focalDist = %dist;
+}
+
+/// This method sets auto focus enabled or disabled. Makes use of the parameters set 
+/// by setFocusParams. When auto focus is enabled it determine the focal depth
+/// by performing a raycast at the screen-center.
+function DOFPostEffect::setAutoFocus( %this, %enabled )
+{
+   %this.autoFocusEnabled = %enabled;
+}
+
+/// Set the parameters that control how the near and far equations are calculated
+/// from the focal distance. If you are not using auto focus you will need to call
+/// setFocusParams PRIOR to calling setFocalDist.
+function DOFPostEffect::setFocusParams( %this, %nearBlurMax, %farBlurMax, %minRange, %maxRange, %nearSlope, %farSlope )
+{
+   %this.nearBlurMax = %nearBlurMax;
+   %this.farBlurMax = %farBlurMax;
+   %this.minRange = %minRange;
+   %this.maxRange = %maxRange;
+   %this.nearSlope = %nearSlope;
+   %this.farSlope = %farSlope;
+}
+
+/*
+
+More information...
+
+This DOF technique is based on this paper:
+http://http.developer.nvidia.com/GPUGems3/gpugems3_ch28.html
+
+================================================================================
+1. Overview of how we represent "Depth of Field"
+================================================================================
+
+DOF is expressed as an amount of bluriness per pixel according to its depth.
+We represented this by a piecewise linear curve depicted below.
+
+Note: we also refer to "bluriness" as CoC ( circle of confusion ) which is the term
+used in the basis paper and in photography.
+   
+
+X-axis (depth) 
+x = 0.0----------------------------------------------x = 1.0       
+
+Y-axis (bluriness)
+y = 1.0   
+  |
+  |   ____(x1,y1)                         (x4,y4)____
+  |       (ns,nb)\  <--Line1  line2--->  /(fe,fb)
+  |               \                     /
+  |                \(x2,y2)     (x3,y3)/
+  |                 (ne,0)------(fs,0)  
+y = 0.0
+                 
+
+I have labeled the "corners" of this graph with (Xn,Yn) to illustrate that
+this is in fact a collection of line segments where the x/y of each point
+corresponds to the key below.
+
+key:
+ns - (n)ear blur (s)tart distance
+nb - (n)ear (b)lur amount (max value)
+ne - (n)ear blur (e)nd distance
+fs - (f)ar blur (s)tart distance
+fe - (f)ar blur (e)nd distance
+fb - (f)ar (b)lur amount (max value)
+
+Of greatest importance in this graph is Line1 and Line2. Where...
+L1 { (x1,y1), (x2,y2) }
+L2 { (x3,y3), (x4,y4) }
+
+Line one represents the amount of "near" blur given a pixels depth and line two
+represents the amount of "far" blur at that depth.
+
+Both these equations are evaluated for each pixel and then the larger of the two
+is kept. Also the output blur (for each equation) is clamped between 0 and its
+maximum allowable value.
+
+Therefore, to specify a DOF "qualify" you need to specify the near-blur-line, 
+far-blur-line, and maximum near and far blur value.
+
+================================================================================
+2. Abstracting a "focal depth"
+================================================================================
+
+Although the shader(s) work in terms of a near and far equation it is more
+useful to express DOF as an adjustable focal depth and derive the other parameters
+"under the hood".
+
+Given a maximum near/far blur amount and a near/far slope we can calculate the
+near/far equations for any focal depth. We extend this to also support a range
+of depth around the focal depth that is also in focus and for that range to
+shrink or grow as the focal depth moves closer or farther.
+
+Keep in mind this is only one implementation and depending on the effect you
+desire you may which to express the relationship between focal depth and 
+the shader paramaters different. 
+
+*/
+
+//-----------------------------------------------------------------------------
+// GFXStateBlockData / ShaderData
+//-----------------------------------------------------------------------------
+
+singleton GFXStateBlockData( PFX_DefaultDOFStateBlock )
+{
+   zDefined = true;
+   zEnable = false;
+   zWriteEnable = false;
+      
+   samplersDefined = true;
+   samplerStates[0] = SamplerClampPoint;
+   samplerStates[1] = SamplerClampPoint;
+};
+
+singleton GFXStateBlockData( PFX_DOFCalcCoCStateBlock )
+{
+   zDefined = true;
+   zEnable = false;
+   zWriteEnable = false;
+      
+   samplersDefined = true;
+   samplerStates[0] = SamplerClampLinear;
+   samplerStates[1] = SamplerClampLinear;
+};
+
+singleton GFXStateBlockData( PFX_DOFDownSampleStateBlock )
+{
+   zDefined = true;
+   zEnable = false;
+   zWriteEnable = false;
+      
+   samplersDefined = true;
+   samplerStates[0] = SamplerClampLinear;
+   samplerStates[1] = SamplerClampPoint;
+};
+
+singleton GFXStateBlockData( PFX_DOFBlurStateBlock )
+{
+   zDefined = true;
+   zEnable = false;
+   zWriteEnable = false;
+      
+   samplersDefined = true;
+   samplerStates[0] = SamplerClampLinear;   
+};
+
+singleton GFXStateBlockData( PFX_DOFFinalStateBlock )
+{
+   zDefined = true;
+   zEnable = false;
+   zWriteEnable = false;
+      
+   samplersDefined = true;
+   samplerStates[0] = SamplerClampLinear;
+   samplerStates[1] = SamplerClampLinear;
+   samplerStates[2] = SamplerClampLinear;
+   samplerStates[3] = SamplerClampPoint;
+   
+   blendDefined = true;
+   blendEnable = true;
+   blendDest = GFXBlendInvSrcAlpha;
+   blendSrc = GFXBlendOne;
+};
+
+singleton ShaderData( PFX_DOFDownSampleShader )
+{      
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/dof/DOF_DownSample_V.hlsl";   
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/dof/DOF_DownSample_P.hlsl";            
+   
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_DownSample_V.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_DownSample_P.glsl";
+   
+   samplerNames[0] = "$colorSampler";
+   samplerNames[1] = "$depthSampler";
+   
+   pixVersion = 3.0;
+};
+
+singleton ShaderData( PFX_DOFBlurYShader )
+{
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/dof/DOF_Gausian_V.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/dof/DOF_Gausian_P.hlsl";
+   
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_Gausian_V.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_Gausian_P.glsl";
+   
+   samplerNames[0] = "$diffuseMap";
+   
+   pixVersion = 2.0;      
+   defines = "BLUR_DIR=float2(0.0,1.0)";         
+};
+
+singleton ShaderData( PFX_DOFBlurXShader : PFX_DOFBlurYShader )
+{
+   defines = "BLUR_DIR=float2(1.0,0.0)";
+};
+
+singleton ShaderData( PFX_DOFCalcCoCShader )
+{   
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/dof/DOF_CalcCoC_V.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/dof/DOF_CalcCoC_P.hlsl";         
+   
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_CalcCoC_V.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_CalcCoC_P.glsl"; 
+
+   samplerNames[0] = "$shrunkSampler";
+   samplerNames[1] = "$blurredSampler";
+   
+   pixVersion = 3.0;
+};
+
+singleton ShaderData( PFX_DOFSmallBlurShader )
+{   
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/dof/DOF_SmallBlur_V.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/dof/DOF_SmallBlur_P.hlsl";            
+   
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_SmallBlur_V.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_SmallBlur_P.glsl";
+
+   samplerNames[0] = "$colorSampler";
+   
+   pixVersion = 3.0;
+};
+
+singleton ShaderData( PFX_DOFFinalShader )
+{   
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/dof/DOF_Final_V.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/dof/DOF_Final_P.hlsl";
+   
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_Final_V.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_Final_P.glsl";
+   
+   samplerNames[0] = "$colorSampler";
+   samplerNames[1] = "$smallBlurSampler";
+   samplerNames[2] = "$largeBlurSampler";
+   samplerNames[3] = "$depthSampler";
+   
+   pixVersion = 3.0;
+};
+
+//-----------------------------------------------------------------------------
+// PostEffects
+//-----------------------------------------------------------------------------
+
+function DOFPostEffect::onAdd( %this )
+{
+   // The weighted distribution of CoC value to the three blur textures
+   // in the order small, medium, large. Most likely you will not need to
+   // change this value.
+   %this.setLerpDist( 0.2, 0.3, 0.5 );
+   
+   // Fill out some default values but DOF really should not be turned on
+   // without actually specifying your own parameters!
+   %this.autoFocusEnabled = false;
+   %this.focalDist = 0.0;
+   %this.nearBlurMax = 0.5;
+   %this.farBlurMax = 0.5;
+   %this.minRange = 50;
+   %this.maxRange = 500;
+   %this.nearSlope = -5.0;
+   %this.farSlope = 5.0;
+}
+
+function DOFPostEffect::setLerpDist( %this, %d0, %d1, %d2 )
+{
+   %this.lerpScale = -1.0 / %d0 SPC -1.0 / %d1 SPC -1.0 / %d2 SPC 1.0 / %d2;
+   %this.lerpBias = 1.0 SPC ( 1.0 - %d2 ) / %d1 SPC 1.0 / %d2 SPC ( %d2 - 1.0 ) / %d2;
+}
+
+singleton PostEffect( DOFPostEffect )
+{
+   renderTime = "PFXAfterBin";
+   renderBin = "GlowBin";      
+   renderPriority = 0.1;
+      
+   shader = PFX_DOFDownSampleShader;
+   stateBlock = PFX_DOFDownSampleStateBlock;
+   texture[0] = "$backBuffer";
+   texture[1] = "#prepass";
+   target = "#shrunk";
+   targetScale = "0.25 0.25";   
+   
+   isEnabled = false;
+};
+
+singleton PostEffect( DOFBlurY )
+{
+   shader = PFX_DOFBlurYShader;
+   stateBlock = PFX_DOFBlurStateBlock;
+   texture[0] = "#shrunk";
+   target = "$outTex";
+};
+
+DOFPostEffect.add( DOFBlurY );
+
+singleton PostEffect( DOFBlurX )
+{
+   shader = PFX_DOFBlurXShader;
+   stateBlock = PFX_DOFBlurStateBlock;
+   texture[0] = "$inTex";  
+   target = "#largeBlur";
+};
+
+DOFPostEffect.add( DOFBlurX );
+
+singleton PostEffect( DOFCalcCoC )
+{
+   shader = PFX_DOFCalcCoCShader;
+   stateBlock = PFX_DOFCalcCoCStateBlock;
+   texture[0] = "#shrunk";
+   texture[1] = "#largeBlur";
+   target = "$outTex";
+};
+
+DOFPostEffect.add( DOFCalcCoc );
+  
+singleton PostEffect( DOFSmallBlur )
+{
+   shader = PFX_DOFSmallBlurShader;
+   stateBlock = PFX_DefaultDOFStateBlock;
+   texture[0] = "$inTex";
+   target = "$outTex";
+};
+
+DOFPostEffect.add( DOFSmallBlur );
+   
+singleton PostEffect( DOFFinalPFX )
+{
+   shader = PFX_DOFFinalShader;
+   stateBlock = PFX_DOFFinalStateBlock;
+   texture[0] = "$backBuffer";
+   texture[1] = "$inTex";
+   texture[2] = "#largeBlur";   
+   texture[3] = "#prepass";   
+   target = "$backBuffer";
+};
+
+DOFPostEffect.add( DOFFinalPFX );
+
+
+//-----------------------------------------------------------------------------
+// Scripts
+//-----------------------------------------------------------------------------
+
+function DOFPostEffect::setShaderConsts( %this )
+{
+   if ( %this.autoFocusEnabled )
+      %this.autoFocus();
+   
+   %fd = %this.focalDist / $Param::FarDist;
+      
+   %range = mLerp( %this.minRange, %this.maxRange, %fd ) / $Param::FarDist * 0.5;  
+   
+   // We work in "depth" space rather than real-world units for the
+   // rest of this method...
+   
+   // Given the focal distance and the range around it we want in focus
+   // we can determine the near-end-distance and far-start-distance
+      
+   %ned = getMax( %fd - %range, 0.0 );   
+   %fsd = getMin( %fd + %range, 1.0 );         
+   
+   // near slope
+   %nsl = %this.nearSlope;
+   
+   // Given slope of near blur equation and the near end dist and amount (x2,y2)
+   // solve for the y-intercept
+   // y = mx + b
+   // so...
+   // y - mx = b
+   
+   %b = 0.0 - %nsl * %ned;
+   
+   %eqNear = %nsl SPC %b SPC 0.0;
+   
+   // Do the same for the far blur equation...
+   
+   %fsl = %this.farSlope;
+   
+   %b = 0.0 - %fsl * %fsd;
+   
+   %eqFar = %fsl SPC %b SPC 1.0;
+   
+   %this.setShaderConst( "$dofEqWorld", %eqNear );           
+   DOFFinalPFX.setShaderConst( "$dofEqFar", %eqFar );
+      
+   %this.setShaderConst( "$maxWorldCoC", %this.nearBlurMax );
+   DOFFinalPFX.setShaderConst( "$maxFarCoC", %this.farBlurMax );      
+
+   DOFFinalPFX.setShaderConst( "$dofLerpScale", %this.lerpScale );
+   DOFFinalPFX.setShaderConst( "$dofLerpBias", %this.lerpBias );  
+}
+
+function DOFPostEffect::autoFocus( %this )
+{      
+   if ( !isObject( ServerConnection ) ||   
+        !isObject( ServerConnection.getCameraObject() ) )
+   {      
+      return;
+   }
+   
+   %mask = $TypeMasks::StaticObjectType | $TypeMasks::TerrainObjectType;               
+   %control = ServerConnection.getCameraObject();
+
+   %fvec = %control.getEyeVector();      
+   %start = %control.getEyePoint();
+      
+   %end = VectorAdd( %start, VectorScale( %fvec, $Param::FarDist ) );
+      
+   // Use the client container for this ray cast.
+   %result = containerRayCast( %start, %end, %mask, %control, true );
+   
+   %hitPos = getWords( %result, 1, 3 );
+   
+   if ( %hitPos $= "" )
+      %focDist = $Param::FarDist;
+   else
+      %focDist = VectorDist( %hitPos, %start );  
+      
+   // For debuging   
+   //$DOF::debug_dist = %focDist;
+   //$DOF::debug_depth = %focDist / $Param::FarDist;      
+   //echo( "F: " @ %focDist SPC "D: " @ %delta );
+     
+   %this.focalDist = %focDist;
+}
+
+
+// For debugging
+/*
+function reloadDOF()
+{
+   exec( "./dof.cs" );
+   DOFPostEffect.reload();  
+   DOFPostEffect.disable();
+   DOFPostEffect.enable();
+}
+
+function dofMetricsCallback()
+{
+   return "  | DOF |" @
+          "  Dist: " @ $DOF::debug_dist @
+          "  Depth: " @ $DOF::debug_depth;               
+}
+*/

+ 113 - 0
Templates/BaseGame/game/core/postFX/edgeAA.cs

@@ -0,0 +1,113 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+
+singleton GFXStateBlockData( PFX_DefaultEdgeAAStateBlock )
+{
+   zDefined = true;
+   zEnable = false;
+   zWriteEnable = false;
+      
+   samplersDefined = true;
+   samplerStates[0] = SamplerClampPoint;
+   //samplerStates[1] = SamplerWrapPoint;
+};
+
+singleton ShaderData( PFX_EdgeAADetectShader )
+{   
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/edgeaa/edgeDetectP.hlsl";
+         
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/edgeaa/gl/edgeDetectP.glsl";
+      
+   samplerNames[0] = "$prepassBuffer";
+   
+   pixVersion = 3.0;
+};
+
+singleton ShaderData( PFX_EdgeAAShader )
+{   
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/edgeaa/edgeAAV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/edgeaa/edgeAAP.hlsl";
+         
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/edgeaa/gl/edgeAAV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/edgeaa/gl/edgeAAP.glsl";
+      
+   samplerNames[0] = "$edgeBuffer";
+   samplerNames[1] = "$backBuffer";
+   
+   pixVersion = 3.0;
+};
+
+singleton ShaderData( PFX_EdgeAADebugShader )
+{   
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/edgeaa/dbgEdgeDisplayP.hlsl";
+         
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/edgeaa/gl/dbgEdgeDisplayP.glsl";
+      
+   samplerNames[0] = "$edgeBuffer";
+   
+   pixVersion = 3.0;
+};
+
+singleton PostEffect( EdgeDetectPostEffect )
+{
+   renderTime = "PFXBeforeBin";
+   renderBin = "ObjTranslucentBin";      
+   //renderPriority = 0.1;
+   targetScale = "0.5 0.5";
+      
+   shader = PFX_EdgeAADetectShader;
+   stateBlock = PFX_DefaultEdgeAAStateBlock;
+   texture[0] = "#prepass";
+   target = "#edge";
+   
+   isEnabled = true;
+};
+
+singleton PostEffect( EdgeAAPostEffect )
+{
+   renderTime = "PFXAfterDiffuse";
+   //renderBin = "ObjTranslucentBin";      
+   //renderPriority = 0.1;
+   
+   shader = PFX_EdgeAAShader;
+   stateBlock = PFX_DefaultEdgeAAStateBlock;
+   texture[0] = "#edge"; 
+   texture[1] = "$backBuffer";
+   target = "$backBuffer";
+};
+   
+singleton PostEffect( Debug_EdgeAAPostEffect )
+{
+   renderTime = "PFXAfterDiffuse";
+   //renderBin = "ObjTranslucentBin";      
+   //renderPriority = 0.1;
+      
+   shader = PFX_EdgeAADebugShader;
+   stateBlock = PFX_DefaultEdgeAAStateBlock;
+   texture[0] = "#edge"; 
+   target = "$backBuffer";
+};

+ 63 - 0
Templates/BaseGame/game/core/postFX/flash.cs

@@ -0,0 +1,63 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+singleton ShaderData( PFX_FlashShader )
+{
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/flashP.hlsl";
+   
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/gl/flashP.glsl";
+   
+   samplerNames[0] = "$backBuffer";
+
+   defines = "WHITE_COLOR=float4(1.0,1.0,1.0,0.0);MUL_COLOR=float4(1.0,0.25,0.25,0.0)";
+
+   pixVersion = 2.0;
+};
+ 
+singleton PostEffect( FlashFx )
+{
+   isEnabled = false;    
+   allowReflectPass = false;  
+
+   renderTime = "PFXAfterDiffuse";  
+
+   shader = PFX_FlashShader;   
+   texture[0] = "$backBuffer";  
+   renderPriority = 10;
+   stateBlock = PFX_DefaultStateBlock;  
+};
+
+function FlashFx::setShaderConsts( %this )
+{
+   if ( isObject( ServerConnection ) )
+   {
+      %this.setShaderConst( "$damageFlash", ServerConnection.getDamageFlash() );
+      %this.setShaderConst( "$whiteOut", ServerConnection.getWhiteOut() );
+   }
+   else
+   {
+      %this.setShaderConst( "$damageFlash", 0 );
+      %this.setShaderConst( "$whiteOut", 0 );
+   }
+}

+ 135 - 0
Templates/BaseGame/game/core/postFX/fog.cs

@@ -0,0 +1,135 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+// Fog
+//------------------------------------------------------------------------------
+
+singleton ShaderData( FogPassShader )
+{   
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/fogP.hlsl";
+         
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/gl/fogP.glsl";
+            
+   samplerNames[0] = "$prepassTex";
+   
+   pixVersion = 2.0;
+};
+
+
+singleton GFXStateBlockData( FogPassStateBlock : PFX_DefaultStateBlock )
+{   
+   blendDefined = true;
+   blendEnable = true; 
+   blendSrc = GFXBlendSrcAlpha;
+   blendDest = GFXBlendInvSrcAlpha;
+};
+
+
+singleton PostEffect( FogPostFx )
+{   
+   // We forward render the reflection pass
+   // so it does its own fogging.
+   allowReflectPass = false;
+      
+   renderTime = "PFXBeforeBin";
+   renderBin = "ObjTranslucentBin";   
+   
+   shader = FogPassShader;
+   stateBlock = FogPassStateBlock;
+   texture[0] = "#prepass";
+   
+   renderPriority = 5;
+   
+   targetFormat = getBestHDRFormat();
+   isEnabled = true;
+};
+
+
+//------------------------------------------------------------------------------
+// UnderwaterFog
+//------------------------------------------------------------------------------
+
+singleton ShaderData( UnderwaterFogPassShader )
+{   
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/underwaterFogP.hlsl";
+         
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/gl/underwaterFogP.glsl";
+            
+   samplerNames[0] = "$prepassTex";
+   samplerNames[1] = "$backbuffer";
+   samplerNames[2] = "$waterDepthGradMap";
+   
+   pixVersion = 2.0;      
+};
+
+
+singleton GFXStateBlockData( UnderwaterFogPassStateBlock : PFX_DefaultStateBlock )
+{   
+   samplersDefined = true;
+   samplerStates[0] = SamplerClampPoint;
+   samplerStates[1] = SamplerClampPoint;   
+   samplerStates[2] = SamplerClampLinear;
+};
+
+
+singleton PostEffect( UnderwaterFogPostFx )
+{
+   oneFrameOnly = true;
+   onThisFrame = false;
+   
+   // Let the fog effect render during the 
+   // reflection pass.
+   allowReflectPass = true;
+      
+   renderTime = "PFXBeforeBin";
+   renderBin = "ObjTranslucentBin";   
+  
+   shader = UnderwaterFogPassShader;
+   stateBlock = UnderwaterFogPassStateBlock;
+   texture[0] = "#prepass";
+   texture[1] = "$backBuffer";
+   texture[2] = "#waterDepthGradMap";
+   
+   // Needs to happen after the FogPostFx
+   renderPriority = 4;
+   
+   isEnabled = true;
+};
+
+function UnderwaterFogPostFx::onEnabled( %this )
+{
+   TurbulenceFx.enable();
+   CausticsPFX.enable();
+   return true;
+}
+
+function UnderwaterFogPostFx::onDisabled( %this )
+{
+   TurbulenceFx.disable();
+   CausticsPFX.disable();
+   return false;
+}

+ 64 - 0
Templates/BaseGame/game/core/postFX/fxaa.cs

@@ -0,0 +1,64 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+// An implementation of "NVIDIA FXAA 3.11" by TIMOTHY LOTTES
+//
+// http://timothylottes.blogspot.com/
+//
+// The shader is tuned for the defaul quality and good performance.
+// See shaders\common\postFx\fxaa\fxaaP.hlsl to tweak the internal
+// quality and performance settings.
+
+singleton GFXStateBlockData( FXAA_StateBlock : PFX_DefaultStateBlock )
+{   
+   samplersDefined = true;   
+   samplerStates[0] = SamplerClampLinear;
+};
+
+singleton ShaderData( FXAA_ShaderData )
+{   
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/fxaa/fxaaV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/fxaa/fxaaP.hlsl";
+   
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/fxaa/gl/fxaaV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/fxaa/gl/fxaaP.glsl";
+   
+   samplerNames[0] = "$colorTex";
+
+   pixVersion = 3.0;
+};
+
+singleton PostEffect( FXAA_PostEffect )
+{
+   isEnabled = false;
+   
+   allowReflectPass = false;
+   renderTime = "PFXAfterDiffuse";
+
+   texture[0] = "$backBuffer";      
+
+   target = "$backBuffer";
+
+   stateBlock = FXAA_StateBlock;
+   shader = FXAA_ShaderData;
+};
+

+ 184 - 0
Templates/BaseGame/game/core/postFX/glow.cs

@@ -0,0 +1,184 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+
+singleton ShaderData( PFX_GlowBlurVertShader )
+{
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/glowBlurV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/glowBlurP.hlsl";
+   
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/glowBlurV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/gl/glowBlurP.glsl";
+      
+   defines = "BLUR_DIR=float2(0.0,1.0)";
+
+   samplerNames[0] = "$diffuseMap";
+         
+   pixVersion = 2.0;
+};
+
+
+singleton ShaderData( PFX_GlowBlurHorzShader : PFX_GlowBlurVertShader )
+{
+   defines = "BLUR_DIR=float2(1.0,0.0)";
+};
+
+
+singleton GFXStateBlockData( PFX_GlowCombineStateBlock : PFX_DefaultStateBlock )
+{
+   // Use alpha test to save some fillrate 
+   // on the non-glowing areas of the scene.
+   alphaDefined = true;
+   alphaTestEnable = true;
+   alphaTestRef = 1;
+   alphaTestFunc = GFXCmpGreaterEqual;
+         
+   // Do a one to one blend.
+   blendDefined = true;
+   blendEnable = true;
+   blendSrc = GFXBlendOne;
+   blendDest = GFXBlendOne;   
+};
+
+
+singleton PostEffect( GlowPostFx )
+{  
+   // Do not allow the glow effect to work in reflection 
+   // passes by default so we don't do the extra drawing.
+   allowReflectPass = false;
+                  
+   renderTime = "PFXAfterBin";
+   renderBin = "GlowBin";
+   renderPriority = 1;
+                    
+   // First we down sample the glow buffer.   
+   shader = PFX_PassthruShader;
+   stateBlock = PFX_DefaultStateBlock;
+   texture[0] = "#glowbuffer";
+   target = "$outTex";
+   targetScale = "0.5 0.5";
+   
+   isEnabled = true;
+               
+   // Blur vertically
+   new PostEffect()
+   {
+      shader = PFX_GlowBlurVertShader;
+      stateBlock = PFX_DefaultStateBlock;
+      texture[0] = "$inTex";
+      target = "$outTex";
+   };
+   
+   // Blur horizontally
+   new PostEffect()
+   {
+      shader = PFX_GlowBlurHorzShader;
+      stateBlock = PFX_DefaultStateBlock;
+      texture[0] = "$inTex";
+      target = "$outTex";
+   };
+            
+   // Upsample and combine with the back buffer.
+   new PostEffect()
+   {      
+      shader = PFX_PassthruShader;
+      stateBlock = PFX_GlowCombineStateBlock;
+      texture[0] = "$inTex";
+      target = "$backBuffer";
+   };
+};
+
+singleton ShaderData( PFX_VolFogGlowBlurVertShader )
+{
+	DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/glowBlurV.hlsl";
+	DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/VolFogGlowP.hlsl";
+	
+	OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/glowBlurV.glsl";
+	OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/VolFogGlowP.glsl";	
+	
+	defines = "BLUR_DIR=float2(0.0,1.0)";
+	samplerNames[0] = "$diffuseMap";
+	pixVersion = 2.0;
+};
+singleton ShaderData( PFX_VolFogGlowBlurHorzShader : PFX_VolFogGlowBlurVertShader )
+{
+	DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/glowBlurV.hlsl";
+	DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/VolFogGlowP.hlsl";
+	
+	OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/glowBlurV.glsl";
+	OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/VolFogGlowP.glsl";
+	
+	defines = "BLUR_DIR=float2(1.0,0.0)";
+};
+
+$VolFogGlowPostFx::glowStrength = 0.3;
+
+singleton PostEffect( VolFogGlowPostFx )
+{
+	// Do not allow the glow effect to work in reflection
+	// passes by default so we don't do the extra drawing.
+	allowReflectPass = false;
+	renderTime = "PFXAfterBin";
+	renderBin = "FogBin";
+	renderPriority = 1;
+	// First we down sample the glow buffer.
+	shader = PFX_PassthruShader;
+	stateBlock = PFX_DefaultStateBlock;
+	texture[0] = "$backbuffer";
+	target = "$outTex";
+	targetScale = "0.5 0.5";
+	isEnabled = true;
+	// Blur vertically
+	new PostEffect()
+	{
+		shader = PFX_VolFogGlowBlurVertShader;
+		stateBlock = PFX_DefaultStateBlock;
+		internalName = "vert";
+		texture[0] = "$inTex";
+		target = "$outTex";
+	};
+	// Blur horizontally
+	new PostEffect()
+	{
+		shader = PFX_VolFogGlowBlurHorzShader;
+		stateBlock = PFX_DefaultStateBlock;
+		internalName = "hor";
+		texture[0] = "$inTex";
+		target = "$outTex";
+	};
+	// Upsample and combine with the back buffer.
+	new PostEffect()
+	{
+		shader = PFX_PassthruShader;
+		stateBlock = PFX_GlowCombineStateBlock;
+		texture[0] = "$inTex";
+		target = "$backBuffer";
+	};
+};
+
+function VolFogGlowPostFx::setShaderConsts( %this )
+{
+	%vp=%this-->vert;
+	%vp.setShaderConst( "$strength", $VolFogGlowPostFx::glowStrength );
+	%vp=%this-->hor;
+	%vp.setShaderConst( "$strength", $VolFogGlowPostFx::glowStrength );
+}

+ 533 - 0
Templates/BaseGame/game/core/postFX/hdr.cs

@@ -0,0 +1,533 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+
+/// Blends between the scene and the tone mapped scene.
+$HDRPostFX::enableToneMapping = 0.5;
+
+/// The tone mapping middle grey or exposure value used
+/// to adjust the overall "balance" of the image.
+///
+/// 0.18 is fairly common value.
+///
+$HDRPostFX::keyValue = 0.18;
+
+/// The minimum luninace value to allow when tone mapping 
+/// the scene.  Is particularly useful if your scene very 
+/// dark or has a black ambient color in places.
+$HDRPostFX::minLuminace = 0.001;
+
+/// The lowest luminance value which is mapped to white.  This
+/// is usually set to the highest visible luminance in your 
+/// scene.  By setting this to smaller values you get a contrast
+/// enhancement.
+$HDRPostFX::whiteCutoff = 1.0;
+
+/// The rate of adaptation from the previous and new 
+/// average scene luminance. 
+$HDRPostFX::adaptRate = 2.0;
+
+/// Blends between the scene and the blue shifted version
+/// of the scene for a cinematic desaturated night effect.
+$HDRPostFX::enableBlueShift = 0.0;
+
+/// The blue shift color value.
+$HDRPostFX::blueShiftColor = "1.05 0.97 1.27";
+
+
+/// Blends between the scene and the bloomed scene.
+$HDRPostFX::enableBloom = 1.0;
+
+/// The threshold luminace value for pixels which are
+/// considered "bright" and need to be bloomed.
+$HDRPostFX::brightPassThreshold = 1.0;
+
+/// These are used in the gaussian blur of the
+/// bright pass for the bloom effect.
+$HDRPostFX::gaussMultiplier = 0.3;
+$HDRPostFX::gaussMean = 0.0;
+$HDRPostFX::gaussStdDev = 0.8;
+
+/// The 1x255 color correction ramp texture used
+/// by both the HDR shader and the GammaPostFx shader
+/// for doing full screen color correction. 
+$HDRPostFX::colorCorrectionRamp = "core/images/null_color_ramp.png";
+
+
+singleton ShaderData( HDR_BrightPassShader )
+{
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/hdr/brightPassFilterP.hlsl";   
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/hdr/gl/brightPassFilterP.glsl";
+   
+   samplerNames[0] = "$inputTex";
+   samplerNames[1] = "$luminanceTex";
+   
+   pixVersion = 3.0;
+};
+
+singleton ShaderData( HDR_DownScale4x4Shader )
+{
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/hdr/downScale4x4V.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/hdr/downScale4x4P.hlsl";
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/hdr/gl/downScale4x4V.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/hdr/gl/downScale4x4P.glsl";
+   
+   samplerNames[0] = "$inputTex";
+   
+   pixVersion = 2.0;
+};
+
+singleton ShaderData( HDR_BloomGaussBlurHShader )
+{
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/hdr/bloomGaussBlurHP.hlsl";
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/hdr/gl/bloomGaussBlurHP.glsl";
+   
+   samplerNames[0] = "$inputTex";
+   
+   pixVersion = 3.0;
+};
+
+singleton ShaderData( HDR_BloomGaussBlurVShader )
+{
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/hdr/bloomGaussBlurVP.hlsl";
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/hdr/gl/bloomGaussBlurVP.glsl";
+   
+   samplerNames[0] = "$inputTex";
+   
+   pixVersion = 3.0;
+};
+
+singleton ShaderData( HDR_SampleLumShader )
+{
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/hdr/sampleLumInitialP.hlsl";
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/hdr/gl/sampleLumInitialP.glsl";
+   
+   samplerNames[0] = "$inputTex";
+   
+   pixVersion = 3.0;
+};
+
+singleton ShaderData( HDR_DownSampleLumShader )
+{
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/hdr/sampleLumIterativeP.hlsl";
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/hdr/gl/sampleLumIterativeP.glsl";
+   
+   samplerNames[0] = "$inputTex";
+   
+   pixVersion = 3.0;
+};
+
+singleton ShaderData( HDR_CalcAdaptedLumShader )
+{
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/hdr/calculateAdaptedLumP.hlsl";
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/hdr/gl/calculateAdaptedLumP.glsl";
+   
+   samplerNames[0] = "$currLum";
+   samplerNames[1] = "$lastAdaptedLum";
+   
+   pixVersion = 3.0;
+};
+
+singleton ShaderData( HDR_CombineShader )
+{
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/hdr/finalPassCombineP.hlsl";
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/hdr/gl/finalPassCombineP.glsl";
+   
+   samplerNames[0] = "$sceneTex";
+   samplerNames[1] = "$luminanceTex";
+   samplerNames[2] = "$bloomTex";
+   samplerNames[3] = "$colorCorrectionTex";
+   samplerNames[4] = "prepassTex";
+   
+   pixVersion = 3.0;
+};
+
+
+singleton GFXStateBlockData( HDR_SampleStateBlock : PFX_DefaultStateBlock )
+{
+   samplersDefined = true;
+   samplerStates[0] = SamplerClampPoint;
+   samplerStates[1] = SamplerClampPoint;
+};
+
+singleton GFXStateBlockData( HDR_DownSampleStateBlock : PFX_DefaultStateBlock )
+{
+   samplersDefined = true;
+   samplerStates[0] = SamplerClampLinear;
+   samplerStates[1] = SamplerClampLinear;
+};
+
+singleton GFXStateBlockData( HDR_CombineStateBlock : PFX_DefaultStateBlock )
+{
+   samplersDefined = true;
+   samplerStates[0] = SamplerClampPoint;
+   samplerStates[1] = SamplerClampLinear;
+   samplerStates[2] = SamplerClampLinear;
+   samplerStates[3] = SamplerClampLinear;
+};
+
+singleton GFXStateBlockData( HDRStateBlock )
+{
+   samplersDefined = true;
+   samplerStates[0] = SamplerClampLinear;
+   samplerStates[1] = SamplerClampLinear;
+   samplerStates[2] = SamplerClampLinear;
+   samplerStates[3] = SamplerClampLinear;
+   
+   blendDefined = true;
+   blendDest = GFXBlendOne;
+   blendSrc = GFXBlendZero;
+   
+   zDefined = true;
+   zEnable = false;
+   zWriteEnable = false;
+   
+   cullDefined = true;
+   cullMode = GFXCullNone;
+};
+
+
+function HDRPostFX::setShaderConsts( %this )
+{
+   %this.setShaderConst( "$brightPassThreshold", $HDRPostFX::brightPassThreshold );
+   %this.setShaderConst( "$g_fMiddleGray", $HDRPostFX::keyValue );   
+         
+   %bloomH = %this-->bloomH;
+   %bloomH.setShaderConst( "$gaussMultiplier", $HDRPostFX::gaussMultiplier );
+   %bloomH.setShaderConst( "$gaussMean", $HDRPostFX::gaussMean );
+   %bloomH.setShaderConst( "$gaussStdDev", $HDRPostFX::gaussStdDev );   
+
+   %bloomV = %this-->bloomV;
+   %bloomV.setShaderConst( "$gaussMultiplier", $HDRPostFX::gaussMultiplier );
+   %bloomV.setShaderConst( "$gaussMean", $HDRPostFX::gaussMean );
+   %bloomV.setShaderConst( "$gaussStdDev", $HDRPostFX::gaussStdDev );   
+
+   %minLuminace = $HDRPostFX::minLuminace;
+   if ( %minLuminace <= 0.0 )
+   {
+      // The min should never be pure zero else the
+      // log() in the shader will generate INFs.      
+      %minLuminace = 0.00001;
+   }
+   %this-->adaptLum.setShaderConst( "$g_fMinLuminace", %minLuminace );
+        
+   %this-->finalLum.setShaderConst( "$adaptRate", $HDRPostFX::adaptRate );
+   
+   %combinePass = %this-->combinePass;   
+   %combinePass.setShaderConst( "$g_fEnableToneMapping", $HDRPostFX::enableToneMapping );
+   %combinePass.setShaderConst( "$g_fMiddleGray", $HDRPostFX::keyValue );
+   %combinePass.setShaderConst( "$g_fBloomScale", $HDRPostFX::enableBloom );      
+   %combinePass.setShaderConst( "$g_fEnableBlueShift", $HDRPostFX::enableBlueShift );   
+   %combinePass.setShaderConst( "$g_fBlueShiftColor", $HDRPostFX::blueShiftColor );   
+   
+   %clampedGamma  = mClamp( $pref::Video::Gamma, 2.0, 2.5);
+   %combinePass.setShaderConst( "$g_fOneOverGamma",  1 / %clampedGamma );       
+   %combinePass.setShaderConst( "$Brightness", $pref::Video::Brightness );
+   %combinePass.setShaderConst( "$Contrast", $pref::Video::Contrast );
+
+   %whiteCutoff = ( $HDRPostFX::whiteCutoff * $HDRPostFX::whiteCutoff ) *
+                  ( $HDRPostFX::whiteCutoff * $HDRPostFX::whiteCutoff );                  
+   %combinePass.setShaderConst( "$g_fWhiteCutoff", %whiteCutoff );
+}
+
+function HDRPostFX::preProcess( %this )
+{
+   %combinePass = %this-->combinePass;
+   
+   if ( %combinePass.texture[3] !$= $HDRPostFX::colorCorrectionRamp )
+      %combinePass.setTexture( 3, $HDRPostFX::colorCorrectionRamp );         
+}
+
+function HDRPostFX::onEnabled( %this )
+{
+   // We don't allow hdr on OSX yet.
+   if ( $platform $= "macos" )
+      return false;
+      
+   // See what HDR format would be best.
+   %format = getBestHDRFormat();
+   if ( %format $= "" || %format $= "GFXFormatR8G8B8A8" )
+   {
+      // We didn't get a valid HDR format... so fail.
+      return false;
+   }
+   
+   // HDR does it's own gamma calculation so 
+   // disable this postFx.
+   GammaPostFX.disable();
+   
+   // Set the right global shader define for HDR.
+   if ( %format $= "GFXFormatR10G10B10A2" )
+      addGlobalShaderMacro( "TORQUE_HDR_RGB10" );
+   else if ( %format $= "GFXFormatR16G16B16A16" )
+      addGlobalShaderMacro( "TORQUE_HDR_RGB16" );
+                        
+   echo( "HDR FORMAT: " @ %format );
+   
+   // Change the format of the offscreen surface
+   // to an HDR compatible format.
+   AL_FormatToken.format = %format;
+   setReflectFormat( %format );
+   
+   // Reset the light manager which will ensure the new
+   // hdr encoding takes effect in all the shaders and
+   // that the offscreen surface is enabled.
+   resetLightManager();
+         
+   return true;
+}
+
+function HDRPostFX::onDisabled( %this )
+{
+   // Enable a special GammaCorrection PostFX when this is disabled.
+   GammaPostFX.enable();
+   
+   // Restore the non-HDR offscreen surface format.
+   %format = getBestHDRFormat();
+   AL_FormatToken.format = %format;
+   setReflectFormat( %format );
+   
+   removeGlobalShaderMacro( "TORQUE_HDR_RGB10" );
+   removeGlobalShaderMacro( "TORQUE_HDR_RGB16" );
+            
+   // Reset the light manager which will ensure the new
+   // hdr encoding takes effect in all the shaders.
+   resetLightManager();
+}
+
+singleton PostEffect( HDRPostFX )
+{
+   isEnabled = false;
+   allowReflectPass = false;
+
+   // Resolve the HDR before we render any editor stuff
+   // and before we resolve the scene to the backbuffer.
+   renderTime = "PFXBeforeBin";
+   renderBin = "EditorBin";
+   renderPriority = 9999;
+      
+   // The bright pass generates a bloomed version of 
+   // the scene for pixels which are brighter than a 
+   // fixed threshold value.
+   //
+   // This is then used in the final HDR combine pass
+   // at the end of this post effect chain.
+   //
+                                
+      shader = HDR_BrightPassShader;
+      stateBlock = HDR_DownSampleStateBlock;
+      texture[0] = "$backBuffer";
+      texture[1] = "#adaptedLum";
+      target = "$outTex";
+      targetFormat = "GFXFormatR16G16B16A16F"; 
+      targetScale = "0.5 0.5";
+      
+      new PostEffect()
+      {
+         allowReflectPass = false;
+         shader = HDR_DownScale4x4Shader;
+         stateBlock = HDR_DownSampleStateBlock;
+         texture[0] = "$inTex";
+         target = "$outTex";
+         targetFormat = "GFXFormatR16G16B16A16F";
+         targetScale = "0.25 0.25";
+      };
+      
+      new PostEffect()
+      {
+         allowReflectPass = false;
+         internalName = "bloomH";
+         
+         shader = HDR_BloomGaussBlurHShader;
+         stateBlock = HDR_DownSampleStateBlock;
+         texture[0] = "$inTex";
+         target = "$outTex";
+         targetFormat = "GFXFormatR16G16B16A16F";   
+      };
+
+      new PostEffect()
+      {
+         allowReflectPass = false;
+         internalName = "bloomV";
+                  
+         shader = HDR_BloomGaussBlurVShader;
+         stateBlock = HDR_DownSampleStateBlock;
+         texture[0] = "$inTex";
+         target = "#bloomFinal";
+         targetFormat = "GFXFormatR16G16B16A16F";    
+      };
+
+   // BrightPass End
+   
+   // Now calculate the adapted luminance.
+   new PostEffect()
+   {
+      allowReflectPass = false;
+      internalName = "adaptLum";
+      
+      shader = HDR_SampleLumShader;
+      stateBlock = HDR_DownSampleStateBlock;
+      texture[0] = "$backBuffer";
+      target = "$outTex";
+      targetScale = "0.0625 0.0625"; // 1/16th
+      targetFormat = "GFXFormatR16F";
+      
+      new PostEffect()
+      {
+         allowReflectPass = false;
+         shader = HDR_DownSampleLumShader;
+         stateBlock = HDR_DownSampleStateBlock;
+         texture[0] = "$inTex";
+         target = "$outTex";
+         targetScale = "0.25 0.25"; // 1/4
+         targetFormat = "GFXFormatR16F";
+      };
+      
+      new PostEffect()
+      {
+         allowReflectPass = false;
+         shader = HDR_DownSampleLumShader;
+         stateBlock = HDR_DownSampleStateBlock;
+         texture[0] = "$inTex";
+         target = "$outTex";
+         targetScale = "0.25 0.25"; // 1/4
+         targetFormat = "GFXFormatR16F";
+      };
+      
+      new PostEffect()
+      {
+         allowReflectPass = false;
+         shader = HDR_DownSampleLumShader;
+         stateBlock = HDR_DownSampleStateBlock;
+         texture[0] = "$inTex";
+         target = "$outTex";
+         targetScale = "0.25 0.25"; // At this point the target should be 1x1.
+         targetFormat = "GFXFormatR16F";
+      };
+
+      // Note that we're reading the adapted luminance
+      // from the previous frame when generating this new
+      // one... PostEffect takes care to manage that.
+      new PostEffect()
+      {
+         allowReflectPass = false;
+         internalName = "finalLum";
+         shader = HDR_CalcAdaptedLumShader;
+         stateBlock = HDR_DownSampleStateBlock;
+         texture[0] = "$inTex";
+         texture[1] = "#adaptedLum";
+         target = "#adaptedLum";
+         targetFormat = "GFXFormatR16F";
+         targetClear = "PFXTargetClear_OnCreate";
+         targetClearColor = "1 1 1 1";
+      };
+   };
+   
+   // Output the combined bloom and toned mapped
+   // version of the scene.
+   new PostEffect()
+   {
+      allowReflectPass = false;
+      internalName = "combinePass";
+      
+      shader = HDR_CombineShader;
+      stateBlock = HDR_CombineStateBlock;
+      texture[0] = "$backBuffer";
+      texture[1] = "#adaptedLum";            
+      texture[2] = "#bloomFinal";
+      texture[3] = $HDRPostFX::colorCorrectionRamp;
+      target = "$backBuffer";
+   };
+};
+
+singleton ShaderData( LuminanceVisShader )
+{
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
+   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/hdr/luminanceVisP.hlsl";
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/hdr/gl/luminanceVisP.glsl";
+   
+   samplerNames[0] = "$inputTex";
+   
+   pixVersion = 3.0;
+};
+
+singleton GFXStateBlockData( LuminanceVisStateBlock : PFX_DefaultStateBlock )
+{
+   samplersDefined = true;
+   samplerStates[0] = SamplerClampLinear;   
+};
+
+function LuminanceVisPostFX::setShaderConsts( %this )
+{
+   %this.setShaderConst( "$brightPassThreshold", $HDRPostFX::brightPassThreshold );
+}
+
+singleton PostEffect( LuminanceVisPostFX )
+{
+   isEnabled = false;
+   allowReflectPass = false;
+      
+   // Render before we do any editor rendering.  
+   renderTime = "PFXBeforeBin";
+   renderBin = "EditorBin";
+   renderPriority = 9999;
+   
+   shader = LuminanceVisShader;
+   stateBlock = LuminanceVisStateBlock;
+   texture[0] = "$backBuffer";
+   target = "$backBuffer";
+   //targetScale = "0.0625 0.0625"; // 1/16th
+   //targetFormat = "GFXFormatR16F";
+};
+
+function LuminanceVisPostFX::onEnabled( %this )
+{
+   if ( !HDRPostFX.isEnabled() )
+   {
+      HDRPostFX.enable();
+   }
+   
+   HDRPostFX.skip = true;
+   
+   return true;
+}
+
+function LuminanceVisPostFX::onDisabled( %this )
+{      
+   HDRPostFX.skip = false; 
+}
+

Some files were not shown because too many files changed in this diff