浏览代码

Reorgs the editing of postFX so the editor settings edits the default config, and Scene > edit postFX to edit scene
Changes the saving of postfx from saving via the editor to instead save on level save
Reorganizes the core postfx folder to subfolders for better organization, as well as moving the shaders to group with the respective postFX
Changes the postfx editor so it only edits postFXs that are actively enabled in the scene, and only saves out similarly.
Adjusts the level download logic to pass asset id for both data compactness compared to the full level filename, as well as easier lookup reference for associated files like the postFX preset file or decal files from the asset def.
Updated the PostFXAsset template to provide an up-to-date starting point/template.

Areloch 5 年之前
父节点
当前提交
3c0c106051
共有 100 个文件被更改,包括 1026 次插入442 次删除
  1. 17 0
      Engine/source/T3D/Scene.cpp
  2. 4 0
      Engine/source/T3D/Scene.h
  3. 15 1
      Engine/source/T3D/assets/LevelAsset.cpp
  4. 23 18
      Templates/BaseGame/game/core/clientServer/scripts/client/levelDownload.cs
  5. 5 5
      Templates/BaseGame/game/core/clientServer/scripts/server/levelDownload.cs
  6. 1 1
      Templates/BaseGame/game/core/clientServer/scripts/server/levelLoad.cs
  7. 1 1
      Templates/BaseGame/game/core/gameObjects/datablocks/defaultDatablocks.cs
  8. 8 0
      Templates/BaseGame/game/core/postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFX.asset.taml
  9. 124 0
      Templates/BaseGame/game/core/postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFX.cs
  10. 3 3
      Templates/BaseGame/game/core/postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFXP.glsl
  11. 3 3
      Templates/BaseGame/game/core/postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFXP.hlsl
  12. 2 2
      Templates/BaseGame/game/core/postFX/scripts/Caustics/CausticsPostFX.asset.taml
  13. 2 2
      Templates/BaseGame/game/core/postFX/scripts/Caustics/CausticsPostFX.cs
  14. 2 2
      Templates/BaseGame/game/core/postFX/scripts/Caustics/CausticsPostFXP.glsl
  15. 2 2
      Templates/BaseGame/game/core/postFX/scripts/Caustics/CausticsPostFXP.hlsl
  16. 8 0
      Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFX.asset.taml
  17. 156 0
      Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFX.cs
  18. 13 0
      Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFXP.glsl
  19. 35 0
      Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFXP.hlsl
  20. 2 2
      Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_CalcCoC_P.glsl
  21. 1 1
      Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_CalcCoC_P.hlsl
  22. 3 3
      Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_CalcCoC_V.glsl
  23. 2 2
      Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_CalcCoC_V.hlsl
  24. 1 1
      Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_DownSample_P.glsl
  25. 2 2
      Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_DownSample_P.hlsl
  26. 2 2
      Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_DownSample_V.glsl
  27. 2 2
      Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_DownSample_V.hlsl
  28. 2 2
      Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Final_P.glsl
  29. 2 2
      Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Final_P.hlsl
  30. 3 3
      Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Final_V.glsl
  31. 2 2
      Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Final_V.hlsl
  32. 1 1
      Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Gausian_P.glsl
  33. 1 1
      Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Gausian_P.hlsl
  34. 2 2
      Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Gausian_V.glsl
  35. 2 2
      Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Gausian_V.hlsl
  36. 3 3
      Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Passthrough_V.glsl
  37. 2 2
      Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Passthrough_V.hlsl
  38. 1 1
      Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_SmallBlur_P.glsl
  39. 1 1
      Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_SmallBlur_P.hlsl
  40. 2 2
      Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_SmallBlur_V.glsl
  41. 2 2
      Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_SmallBlur_V.hlsl
  42. 6 0
      Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DepthOfFieldPostFX.asset.taml
  43. 111 122
      Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DepthOfFieldPostFX.cs
  44. 1 1
      Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/dbgEdgeDisplayP.glsl
  45. 1 1
      Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/dbgEdgeDisplayP.hlsl
  46. 2 2
      Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAP.glsl
  47. 1 1
      Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAP.hlsl
  48. 6 0
      Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAPostFX.asset.taml
  49. 8 8
      Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAPostFX.cs
  50. 3 3
      Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAV.glsl
  51. 2 2
      Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAV.hlsl
  52. 1 1
      Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeDetectP.glsl
  53. 2 2
      Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeDetectP.hlsl
  54. 0 0
      Templates/BaseGame/game/core/postFX/scripts/FXAA/FXAAPostFX.asset.taml
  55. 4 4
      Templates/BaseGame/game/core/postFX/scripts/FXAA/FXAAPostFX.cs
  56. 0 0
      Templates/BaseGame/game/core/postFX/scripts/FXAA/Fxaa3_11.h
  57. 2 2
      Templates/BaseGame/game/core/postFX/scripts/FXAA/fxaaP.glsl
  58. 1 1
      Templates/BaseGame/game/core/postFX/scripts/FXAA/fxaaP.hlsl
  59. 2 2
      Templates/BaseGame/game/core/postFX/scripts/FXAA/fxaaV.glsl
  60. 2 2
      Templates/BaseGame/game/core/postFX/scripts/FXAA/fxaaV.hlsl
  61. 0 0
      Templates/BaseGame/game/core/postFX/scripts/Flash/flashP.glsl
  62. 0 0
      Templates/BaseGame/game/core/postFX/scripts/Flash/flashP.hlsl
  63. 6 0
      Templates/BaseGame/game/core/postFX/scripts/Flash/flashPostFX.asset.taml
  64. 2 2
      Templates/BaseGame/game/core/postFX/scripts/Flash/flashPostFX.cs
  65. 2 2
      Templates/BaseGame/game/core/postFX/scripts/Fog/fogP.glsl
  66. 3 3
      Templates/BaseGame/game/core/postFX/scripts/Fog/fogP.hlsl
  67. 0 0
      Templates/BaseGame/game/core/postFX/scripts/Fog/fogPostFX.asset.taml
  68. 2 2
      Templates/BaseGame/game/core/postFX/scripts/Fog/fogPostFX.cs
  69. 8 0
      Templates/BaseGame/game/core/postFX/scripts/Gamma/GammaPostFX.asset.taml
  70. 59 6
      Templates/BaseGame/game/core/postFX/scripts/Gamma/GammaPostFX.cs
  71. 2 8
      Templates/BaseGame/game/core/postFX/scripts/Gamma/gammaP.glsl
  72. 2 8
      Templates/BaseGame/game/core/postFX/scripts/Gamma/gammaP.hlsl
  73. 0 0
      Templates/BaseGame/game/core/postFX/scripts/Glow/GlowPostFX.asset.taml
  74. 12 12
      Templates/BaseGame/game/core/postFX/scripts/Glow/GlowPostFX.cs
  75. 0 0
      Templates/BaseGame/game/core/postFX/scripts/Glow/VolFogGlowP.glsl
  76. 0 0
      Templates/BaseGame/game/core/postFX/scripts/Glow/VolFogGlowP.hlsl
  77. 0 0
      Templates/BaseGame/game/core/postFX/scripts/Glow/glowBlurP.glsl
  78. 0 0
      Templates/BaseGame/game/core/postFX/scripts/Glow/glowBlurP.hlsl
  79. 0 0
      Templates/BaseGame/game/core/postFX/scripts/Glow/glowBlurV.glsl
  80. 0 0
      Templates/BaseGame/game/core/postFX/scripts/Glow/glowBlurV.hlsl
  81. 0 0
      Templates/BaseGame/game/core/postFX/scripts/HDR/HDRPostFX.asset.taml
  82. 115 99
      Templates/BaseGame/game/core/postFX/scripts/HDR/HDRPostFX.cs
  83. 2 2
      Templates/BaseGame/game/core/postFX/scripts/HDR/bloomGaussBlurHP.glsl
  84. 44 1
      Templates/BaseGame/game/core/postFX/scripts/HDR/bloomGaussBlurHP.hlsl
  85. 2 2
      Templates/BaseGame/game/core/postFX/scripts/HDR/bloomGaussBlurVP.glsl
  86. 42 1
      Templates/BaseGame/game/core/postFX/scripts/HDR/bloomGaussBlurVP.hlsl
  87. 3 3
      Templates/BaseGame/game/core/postFX/scripts/HDR/brightPassFilterP.glsl
  88. 2 2
      Templates/BaseGame/game/core/postFX/scripts/HDR/brightPassFilterP.hlsl
  89. 2 2
      Templates/BaseGame/game/core/postFX/scripts/HDR/calculateAdaptedLumP.glsl
  90. 1 1
      Templates/BaseGame/game/core/postFX/scripts/HDR/calculateAdaptedLumP.hlsl
  91. 2 2
      Templates/BaseGame/game/core/postFX/scripts/HDR/downScale4x4P.glsl
  92. 2 2
      Templates/BaseGame/game/core/postFX/scripts/HDR/downScale4x4P.hlsl
  93. 2 2
      Templates/BaseGame/game/core/postFX/scripts/HDR/downScale4x4V.glsl
  94. 2 2
      Templates/BaseGame/game/core/postFX/scripts/HDR/downScale4x4V.hlsl
  95. 42 17
      Templates/BaseGame/game/core/postFX/scripts/HDR/finalPassCombineP.glsl
  96. 35 16
      Templates/BaseGame/game/core/postFX/scripts/HDR/finalPassCombineP.hlsl
  97. 3 3
      Templates/BaseGame/game/core/postFX/scripts/HDR/luminanceVisP.glsl
  98. 2 2
      Templates/BaseGame/game/core/postFX/scripts/HDR/luminanceVisP.hlsl
  99. 3 3
      Templates/BaseGame/game/core/postFX/scripts/HDR/sampleLumInitialP.glsl
  100. 2 2
      Templates/BaseGame/game/core/postFX/scripts/HDR/sampleLumInitialP.hlsl

+ 17 - 0
Engine/source/T3D/Scene.cpp

@@ -34,6 +34,11 @@ void Scene::initPersistFields()
    addGroup("Gameplay");
    addField("gameModeName", TypeString, Offset(mGameModeName, Scene), "The name of the gamemode that this scene utilizes");
    endGroup("Gameplay");
+
+   addGroup("PostFX");
+   addProtectedField("EditPostEffects", TypeBool, Offset(mEditPostFX, Scene),
+      &Scene::_editPostEffects, &defaultProtectedGetFn, "Edit Scene's default Post Effects", AbstractClassRep::FieldFlags::FIELD_ComponentInspectors);
+   endGroup("PostFX");
 }
 
 bool Scene::onAdd()
@@ -88,6 +93,18 @@ void Scene::onPostAdd()
       Con::executef(this, "onPostAdd");
 }
 
+bool Scene::_editPostEffects(void* object, const char* index, const char* data)
+{
+   Scene* scene = static_cast<Scene*>(object);
+
+#ifdef TORQUE_TOOLS
+   if(Con::isFunction("editScenePostEffects"))
+      Con::executef("editScenePostEffects", scene);
+#endif
+
+   return false;
+}
+
 void Scene::addObject(SimObject* object)
 {
    //Child scene

+ 4 - 0
Engine/source/T3D/Scene.h

@@ -35,6 +35,8 @@ class Scene : public NetObject, public virtual ITickable
 
    bool mIsDirty;
 
+   bool mEditPostFX;
+
    StringTableEntry mGameModeName;
 
 protected:
@@ -48,6 +50,8 @@ public:
 
    static void initPersistFields();
 
+   static bool _editPostEffects(void* object, const char* index, const char* data);
+
    virtual bool onAdd();
    virtual void onRemove();
    virtual void onPostAdd();

+ 15 - 1
Engine/source/T3D/assets/LevelAsset.cpp

@@ -361,13 +361,27 @@ void LevelAsset::unloadDependencies()
    }
 }
 
-DefineEngineMethod(LevelAsset, getLevelFile, const char*, (),,
+DefineEngineMethod(LevelAsset, getLevelPath, const char*, (),,
    "Creates a new script asset using the targetFilePath.\n"
    "@return The bool result of calling exec")
 {
    return object->getLevelPath();
 }
 
+DefineEngineMethod(LevelAsset, getPostFXPresetPath, const char*, (), ,
+   "Creates a new script asset using the targetFilePath.\n"
+   "@return The bool result of calling exec")
+{
+   return object->getPostFXPresetPath();
+}
+
+DefineEngineMethod(LevelAsset, getDecalsPath, const char*, (), ,
+   "Creates a new script asset using the targetFilePath.\n"
+   "@return The bool result of calling exec")
+{
+   return object->getDecalsPath();
+}
+
 DefineEngineMethod(LevelAsset, loadDependencies, void, (), ,
    "Initiates the loading of asset dependencies for this level.")
 {

+ 23 - 18
Templates/BaseGame/game/core/clientServer/scripts/client/levelDownload.cs

@@ -41,7 +41,7 @@
 $pref::Client::EnableDatablockCache = true;
 $pref::Client::DatablockCacheFilename = "data/cache/client/datablock_cache_c.dbc";
 
-function clientCmdMissionStartPhase1_LoadCache(%seq, %missionName)
+function clientCmdMissionStartPhase1_LoadCache(%seq, %levelAsset)
 {
   if ($pref::Client::EnableDatablockCache && $loadFromDatablockCache)
   {
@@ -57,16 +57,16 @@ function clientCmdMissionStartPhase1_LoadCache(%seq, %missionName)
     echo("<<<< Loading Datablocks From Cache >>>>");
     if (ServerConnection.loadDatablockCache_Begin())
     {
-      schedule(10, 0, "updateLoadDatablockCacheProgress", %seq, %missionName);
+      schedule(10, 0, "updateLoadDatablockCacheProgress", %seq, %levelAsset);
     }
   }
 }
 
-function updateLoadDatablockCacheProgress(%seq, %missionName)
+function updateLoadDatablockCacheProgress(%seq, %levelAsset)
 {
    if (ServerConnection.loadDatablockCache_Continue())
    {
-      $loadDatablockCacheProgressThread = schedule(10, 0, "updateLoadDatablockCacheProgress", %seq, %missionName);
+      $loadDatablockCacheProgressThread = schedule(10, 0, "updateLoadDatablockCacheProgress", %seq, %levelAsset);
       return;
    }
  
@@ -80,14 +80,14 @@ function updateLoadDatablockCacheProgress(%seq, %missionName)
    }
 
    echo("<<<< Finished Loading Datablocks From Cache >>>>");
-   clientCmdMissionStartPhase2(%seq,%missionName);
+   clientCmdMissionStartPhase2(%seq, %levelAsset);
 }
 
-function updateLoadDatablockCacheProgress(%seq, %missionName)
+function updateLoadDatablockCacheProgress(%seq, %levelAsset)
 {
    if (ServerConnection.loadDatablockCache_Continue())
    {
-      $loadDatablockCacheProgressThread = schedule(10, 0, "updateLoadDatablockCacheProgress", %seq, %missionName);
+      $loadDatablockCacheProgressThread = schedule(10, 0, "updateLoadDatablockCacheProgress", %seq, %levelAsset);
       return;
    }
  
@@ -101,21 +101,24 @@ function updateLoadDatablockCacheProgress(%seq, %missionName)
    }
 
    echo("<<<< Finished Loading Datablocks From Cache >>>>");
-   clientCmdMissionStartPhase2(%seq,%missionName);
+   clientCmdMissionStartPhase2(%seq, %levelAsset);
 }
 
-function clientCmdMissionStartPhase1(%seq, %missionName, %cache_crc)
+function clientCmdMissionStartPhase1(%seq, %levelAsset, %cache_crc)
 {
+   %levelAssetDef = AssetDatabase.acquireAsset(%levelAsset);
+   
    // These need to come after the cls.
-   echo ("*** New Mission: " @ %missionName);
+   echo ("*** New Mission: " @ %levelAssetDef.levelName);
    echo ("*** Phase 1: Download Datablocks & Targets");
    
-   $Client::MissionFile = %missionName;
+   $Client::LevelAsset = %levelAssetDef;
+   $Client::MissionFile = %levelAssetDef.getLevelPath();
    $pref::ReflectionProbes::CurrentLevelPath = filePath($Client::MissionFile) @ "/" @ fileBase($Client::MissionFile) @ "/probes/";
    
    //Prep the postFX stuff
    // Load the post effect presets for this mission.
-   %path = filePath( %missionName ) @ "/" @ fileBase( %missionName ) @ $PostFXManager::fileExtension;
+   %path = %levelAssetDef.getPostFXPresetPath();
 
    if ( isScriptFile( %path ) )
    {
@@ -190,7 +193,7 @@ function onDataBlockObjectReceived(%index, %total)
 //----------------------------------------------------------------------------
 // Phase 2
 //----------------------------------------------------------------------------
-function clientCmdMissionStartPhase2(%seq,%missionName)
+function clientCmdMissionStartPhase2(%seq, %levelAsset)
 {
    onPhaseComplete();
    echo ("*** Phase 2: Download Ghost Objects");
@@ -215,19 +218,21 @@ function onGhostAlwaysObjectReceived()
 //----------------------------------------------------------------------------
 // Phase 3
 //----------------------------------------------------------------------------
-function clientCmdMissionStartPhase3(%seq,%missionName)
+function clientCmdMissionStartPhase3(%seq, %levelAsset)
 {
    onPhaseComplete();
    StartClientReplication();
-   StartFoliageReplication();
+   
+   %levelAssetDef = AssetDatabase.acquireAsset(%levelAsset);
    
    // Load the static mission decals.
-   if(isFile(%missionName @ ".decals"))
-      decalManagerLoad( %missionName @ ".decals" );
+   if(isFile(%levelAssetDef.getDecalsPath()))
+      decalManagerLoad( %levelAssetDef.getDecalsPath() );
    
    echo ("*** Phase 3: Mission Lighting");
    $MSeq = %seq;
-   $Client::MissionFile = %missionName;
+   $Client::LevelAsset = %levelAssetDef;
+   $Client::MissionFile = %levelAssetDef.getLevelPath();
 
    // Need to light the mission before we are ready.
    // The sceneLightingComplete function will complete the handshake 

+ 5 - 5
Templates/BaseGame/game/core/clientServer/scripts/server/levelDownload.cs

@@ -68,9 +68,9 @@ function GameConnection::loadMission(%this)
    }
    else
    {
-      commandToClient(%this, 'MissionStartPhase1', $missionSequence, $Server::MissionFile, %cache_crc);
+      commandToClient(%this, 'MissionStartPhase1', $missionSequence, $Server::LevelAsset.getAssetId(), %cache_crc);
          
-      echo("*** Sending mission load to client: " @ $Server::MissionFile);
+      echo("*** Sending mission load to client: " @ $Server::LevelAsset.getAssetId());
    }
 }
 
@@ -100,7 +100,7 @@ function GameConnection::onBeginDatablockCacheLoad( %this, %missionSequence )
    if (%this.currentPhase != 1)
       return;
    %this.currentPhase = 1.5;
-   commandToClient(%this, 'MissionStartPhase1_LoadCache', $missionSequence, $Server::MissionFile);
+   commandToClient(%this, 'MissionStartPhase1_LoadCache', $missionSequence, $Server::LevelAsset.getAssetId());
 }
 
 function serverCmdMissionStartPhase1Ack(%client, %seq)
@@ -129,7 +129,7 @@ function GameConnection::onDataBlocksDone( %this, %missionSequence )
    %this.currentPhase = 1.5;
 
    // On to the next phase
-   commandToClient(%this, 'MissionStartPhase2', $missionSequence, $Server::MissionFile);
+   commandToClient(%this, 'MissionStartPhase2', $missionSequence, $Server::LevelAsset.getAssetId());
 }
 
 //----------------------------------------------------------------------------
@@ -163,7 +163,7 @@ function GameConnection::onGhostAlwaysFailed(%client)
 function GameConnection::onGhostAlwaysObjectsReceived(%client)
 {
    // Ready for next phase.
-   commandToClient(%client, 'MissionStartPhase3', $missionSequence, $Server::MissionFile);
+   commandToClient(%client, 'MissionStartPhase3', $missionSequence, $Server::LevelAsset.getAssetId());
 }
 
 //----------------------------------------------------------------------------

+ 1 - 1
Templates/BaseGame/game/core/clientServer/scripts/server/levelLoad.cs

@@ -44,7 +44,7 @@ function loadMission( %levelAsset, %isFirstMission )
    // increment the mission sequence (used for ghost sequencing)
    $missionSequence++;
    $missionRunning = false;
-   $Server::MissionFile = $Server::LevelAsset.getLevelFile();
+   $Server::MissionFile = $Server::LevelAsset.getLevelPath();
    $Server::LoadFailMsg = "";
    
    $Server::LevelAsset.loadDependencies();

+ 1 - 1
Templates/BaseGame/game/core/gameObjects/datablocks/defaultDatablocks.cs

@@ -1,6 +1,6 @@
 datablock ReflectorDesc( DefaultCubeDesc )
 {  
-   texSize = 256;
+   texSize = 64;
    nearDist = 0.1;
    farDist = 1000.0;
    objectTypeMask = 0xFFFFFFFF;

+ 8 - 0
Templates/BaseGame/game/core/postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFX.asset.taml

@@ -0,0 +1,8 @@
+<PostEffectAsset
+    canSave="true"
+    canSaveDynamicFields="true"
+    AssetName="CameraMotionBlurPostFX"
+    scriptFile="@assetFile=CameraMotionBlurPostFX.cs"
+    hlslShader="@assetFile=CameraMotionBlurPostFXP.hlsl"
+    glslShader="@assetFile=CameraMotionBlurPostFXP.glsl"
+    VersionId="1" />

+ 124 - 0
Templates/BaseGame/game/core/postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFX.cs

@@ -0,0 +1,124 @@
+//-----------------------------------------------------------------------------
+// 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.
+//-----------------------------------------------------------------------------
+
+$PostFX::CameraMotionBlurPostFX::samples = 5;
+$PostFX::CameraMotionBlurPostFX::velocityMultiplier = 3000;
+
+singleton ShaderData( CameraMotionBlurPostFX_Shader )
+{
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
+   DXPixelShaderFile 	= "./CameraMotionBlurPostFXP.hlsl";   
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile   = "./CameraMotionBlurPostFXP.glsl";
+   
+   samplerNames[0] = "$backBuffer";
+   samplerNames[1] = "$deferredTex";
+   
+   pixVersion = 3.0;
+};
+
+singleton GFXStateBlockData( CameraMotionBlurPostFX_StateBlock )
+{
+   zDefined = true;
+   zEnable = false;
+   zWriteEnable = false;
+      
+   samplersDefined = true;
+   samplerStates[0] = SamplerClampLinear;
+};
+
+
+function CameraMotionBlurPostFX::setShaderConsts( %this )
+{
+   %this.setShaderConst( "$velocityMultiplier", $PostFX::CameraMotionBlurPostFX::velocityMultiplier );
+   %this.setShaderConst( "$samples", $PostFX::CameraMotionBlurPostFX::samples );
+}
+
+function CameraMotionBlurPostFX::preProcess( %this )
+{
+}
+
+function CameraMotionBlurPostFX::onAdd(%this)
+{
+   //Register the postFX with the manager
+   PostFXManager.registerPostEffect(%this);
+}
+
+function CameraMotionBlurPostFX::onEnabled( %this )
+{
+   return true;
+}
+
+function CameraMotionBlurPostFX::onDisabled( %this )
+{
+   return true;
+}
+
+//This is used to populate the PostFXEditor's settings so the post FX can be edited
+//This is automatically polled for any postFX that has been registered(in our onAdd) and the settings
+//are thus exposed for editing
+function CameraMotionBlurPostFX::populatePostFXSettings(%this)
+{
+   PostEffectEditorInspector.startGroup("CameraMotionBlurPostFX - General");
+   PostEffectEditorInspector.addCallbackField("$PostFX::CameraMotionBlurPostFX::Enabled", "Enabled", "bool", "", $PostFX::CameraMotionBlurPostFX::Enabled, "", "toggleCameraMotionBlurPostFX");
+   PostEffectEditorInspector.addField("$PostFX::CameraMotionBlurPostFX::velocityMultiplier", "Velocity Multiplier", "float", "", $PostFX::CameraMotionBlurPostFX::velocityMultiplier, "");
+   PostEffectEditorInspector.addField("$PostFX::CameraMotionBlurPostFX::samples", "Sample Count", "float", "", $PostFX::CameraMotionBlurPostFX::samples, "");
+   PostEffectEditorInspector.endGroup();
+}
+
+//This is called back from our callbackField defined in populatePostFXSettings to
+//Allow us to easily toggle the postFX and have it respond immediately
+function PostEffectEditorInspector::toggleCameraMotionBlurPostFX(%this)
+{
+   if($PostFX::CameraMotionBlurPostFX::Enabled)
+      CameraMotionBlurPostFX.enable();
+   else
+      CameraMotionBlurPostFX.disable();
+}
+
+function CameraMotionBlurPostFX::applyFromPreset(%this)
+{
+   if($PostFX::CameraMotionBlurPostFX::Enabled)
+      %this.enable();
+   else
+      %this.disable();
+}
+
+function CameraMotionBlurPostFX::savePresetSettings(%this)
+{
+   PostFXManager::savePresetSetting("$PostFX::CameraMotionBlurPostFX::Enabled");
+   PostFXManager::savePresetSetting("$PostFX::CameraMotionBlurPostFX::velocityMultiplier");
+   PostFXManager::savePresetSetting("$PostFX::CameraMotionBlurPostFX::samples");
+}
+
+//Our actual postFX
+singleton PostEffect( CameraMotionBlurPostFX )
+{
+   isEnabled = false;
+   renderTime = "PFXAfterDiffuse"; 
+
+   shader = CameraMotionBlurPostFX_Shader;
+   stateBlock = CameraMotionBlurPostFX_StateBlock;
+   texture[0] = "$backbuffer";
+   texture[1] = "#deferred";
+   target = "$backBuffer";
+};

+ 3 - 3
Templates/BaseGame/game/core/rendering/shaders/postFX/gl/motionBlurP.glsl → Templates/BaseGame/game/core/postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFXP.glsl

@@ -20,10 +20,10 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../gl/hlslCompat.glsl"
-#include "../../gl/torque.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
+#include "core/rendering/shaders/gl/torque.glsl"
 #include "shadergen:/autogenConditioners.h"
-#include "postFx.glsl"
+#include "core/rendering/shaders/postFX/gl/postFx.glsl"
 
 #undef IN_uv0
 #define _IN_uv0 uv0

+ 3 - 3
Templates/BaseGame/game/core/rendering/shaders/postFX/motionBlurP.hlsl → Templates/BaseGame/game/core/postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFXP.hlsl

@@ -20,9 +20,9 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "./postFx.hlsl"
-#include "../torque.hlsl"
-#include "../shaderModelAutoGen.hlsl"
+#include "core/rendering/shaders/postFX/postFx.hlsl"
+#include "core/rendering/shaders/torque.hlsl"
+#include "core/rendering/shaders/shaderModelAutoGen.hlsl"
 
 uniform float4x4 matPrevScreenToWorld;
 uniform float4x4 matWorldToScreen;

+ 2 - 2
Templates/BaseGame/game/core/postFX/scripts/vignettePostFX.asset.taml → Templates/BaseGame/game/core/postFX/scripts/Caustics/CausticsPostFX.asset.taml

@@ -1,6 +1,6 @@
 <PostEffectAsset
     canSave="true"
     canSaveDynamicFields="true"
-    AssetName="vignettePostFX"
-    scriptFile="@assetFile=vignettePostFX.cs"
+    AssetName="CausticsPostFX"
+    scriptFile="@assetFile=CausticsPostFX.cs"
     VersionId="1" />

+ 2 - 2
Templates/BaseGame/game/core/postFX/scripts/caustics.cs → Templates/BaseGame/game/core/postFX/scripts/Caustics/CausticsPostFX.cs

@@ -36,10 +36,10 @@ singleton GFXStateBlockData( PFX_CausticsStateBlock : PFX_DefaultStateBlock )
 singleton ShaderData( PFX_CausticsShader )
 {   
    DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
-   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/caustics/causticsP.hlsl";
+   DXPixelShaderFile 	= "./causticsP.hlsl";
          
    OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
-   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/caustics/gl/causticsP.glsl";
+   OGLPixelShaderFile   = "./causticsP.glsl";
       
    samplerNames[0] = "$deferredTex";
    samplerNames[1] = "$causticsTex0";

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/caustics/gl/causticsP.glsl → Templates/BaseGame/game/core/postFX/scripts/Caustics/CausticsPostFXP.glsl

@@ -20,8 +20,8 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../../gl/hlslCompat.glsl"
-#include "../../gl/postFx.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
+#include "core/rendering/shaders/postFX/gl/postFx.glsl"
 #include "shadergen:/autogenConditioners.h"
 
 uniform vec3    eyePosWorld;

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/caustics/causticsP.hlsl → Templates/BaseGame/game/core/postFX/scripts/Caustics/CausticsPostFXP.hlsl

@@ -20,8 +20,8 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../postFx.hlsl"
-#include "../../shaderModelAutoGen.hlsl"
+#include "core/rendering/shaders/postFx.hlsl"
+#include "core/rendering/shaders/shaderModelAutoGen.hlsl"
 
 uniform float     accumTime;
 uniform float3    eyePosWorld;

+ 8 - 0
Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFX.asset.taml

@@ -0,0 +1,8 @@
+<PostEffectAsset
+    canSave="true"
+    canSaveDynamicFields="true"
+    AssetName="ChromaticAberrationPostFX"
+    scriptFile="@assetFile=ChromaticAberrationPostFX.cs"
+    hlslShader="@assetFile=ChromaticAberrationPostFXP.hlsl"
+    glslShader="@assetFile=ChromaticAberrationPostFXP.glsl"
+    VersionId="1" />

+ 156 - 0
Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFX.cs

@@ -0,0 +1,156 @@
+//-----------------------------------------------------------------------------
+// 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 lens distortion coefficient.
+$PostFX::EnableChromaticAberrationPostFX::DistCoefficient =  -0.05;
+
+/// The cubic distortion value.
+$PostFX::EnableChromaticAberrationPostFX::CubeDistortionFactor =  -0.1;
+
+/// The amount and direction of the maxium shift for
+/// the red, green, and blue channels.
+$PostFX::EnableChromaticAberrationPostFX::ColorDistFactor = "0.005 -0.005 0.01";
+
+singleton ShaderData( ChromaticAberrationPostFX_Shader )
+{
+   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
+   DXPixelShaderFile 	= "./ChromaticAberrationPostFXP.hlsl";   
+   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile   = "./ChromaticAberrationPostFXP.glsl";
+   
+   samplerNames[0] = "$inputTex";
+   
+   pixVersion = 2.0;
+};
+
+singleton GFXStateBlockData( ChromaticAberrationPostFX_StateBlock )
+{
+   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 ChromaticAberrationPostFX::setShaderConsts( %this )
+{
+   %this.setShaderConst( "$distCoeff", $PostFX::EnableChromaticAberrationPostFX::DistCoefficient );   
+   %this.setShaderConst( "$cubeDistort", $PostFX::EnableChromaticAberrationPostFX::CubeDistortionFactor );    
+   %this.setShaderConst( "$colorDistort", $PostFX::EnableChromaticAberrationPostFX::ColorDistFactor ); 
+}
+
+function ChromaticAberrationPostFX::preProcess( %this )
+{
+}
+
+function ChromaticAberrationPostFX::onAdd(%this)
+{
+   //Register the postFX with the manager
+   PostFXManager.registerPostEffect(%this);
+}
+
+function ChromaticAberrationPostFX::onEnabled( %this )
+{
+   return true;
+}
+
+function ChromaticAberrationPostFX::onDisabled( %this )
+{
+}
+
+//This is used to populate the PostFXEditor's settings so the post FX can be edited
+//This is automatically polled for any postFX that has been registered(in our onAdd) and the settings
+//are thus exposed for editing
+function ChromaticAberrationPostFX::populatePostFXSettings(%this)
+{
+   PostEffectEditorInspector.startGroup("ChromaticAberrationPostFX - General");
+   PostEffectEditorInspector.addCallbackField("$PostFX::EnableChromaticAberrationPostFX::Enabled", "Enabled", "bool", "", $PostFX::EnableChromaticAberrationPostFX::Enabled, "", "toggleChromaticAberrationPostFX");
+   PostEffectEditorInspector.addField("$PostFX::EnableChromaticAberrationPostFX::DistCoefficient", "Dist Coefficient", "float", "", $PostFX::EnableChromaticAberrationPostFX::DistCoefficient, "");
+   PostEffectEditorInspector.addField("$PostFX::EnableChromaticAberrationPostFX::CubeDistortionFactor", "Cube Distortion Factor", "float", "", $PostFX::EnableChromaticAberrationPostFX::CubeDistortionFactor, "");
+   PostEffectEditorInspector.addField("$PostFX::EnableChromaticAberrationPostFX::ColorDistFactor", "Color Distortion Factor", "string", "", $PostFX::EnableChromaticAberrationPostFX::ColorDistFactor, "");
+   PostEffectEditorInspector.endGroup();
+}
+
+function PostEffectEditorInspector::toggleChromaticAberrationPostFX(%this)
+{
+   if($PostFX::EnableChromaticAberrationPostFX::Enabled)
+      ChromaticAberrationPostFX.enable();
+   else
+      ChromaticAberrationPostFX.disable();
+}
+
+//This function pair(applyFromPreset and settingsApply) are done the way they are, with the separated variables
+//so that we can effectively store the 'settings' away from the live variables that the postFX's actually utilize
+//when rendering. This allows us to modify things but still leave room for reverting or temporarily applying them
+function ChromaticAberrationPostFX::applyFromPreset(%this)
+{
+   if($PostFX::EnableChromaticAberrationPostFX::Enabled)
+      %this.enable();
+   else
+      %this.disable();
+}
+
+function ChromaticAberrationPostFX::savePresetSettings(%this)
+{
+   PostFXManager::savePresetSetting("$PostFX::EnableChromaticAberrationPostFX::Enabled");
+   PostFXManager::savePresetSetting("$PostFX::EnableChromaticAberrationPostFX::DistCoefficient");
+   PostFXManager::savePresetSetting("$PostFX::EnableChromaticAberrationPostFX::CubeDistortionFactor");
+   PostFXManager::savePresetSetting("$PostFX::EnableChromaticAberrationPostFX::ColorDistFactor");
+}
+
+//Our actual postFX
+singleton PostEffect( ChromaticAberrationPostFX )
+{
+   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 = ChromaticAberrationPostFX_Shader;
+   stateBlock = PFX_DefaultStateBlock;
+   texture[0] = "$backBuffer";
+   target = "$backBuffer";
+   targetFormat = "GFXFormatR16G16B16A16F"; 
+   targetScale = "1 1";
+};

+ 13 - 0
Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFXP.glsl

@@ -0,0 +1,13 @@
+#include "core/rendering/shaders/gl/torque.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
+#include "shadergen:/autogenConditioners.h"
+#include "core/rendering/shaders/postFX/gl/postFX.glsl"
+
+uniform sampler2D inputTex;
+
+out vec4 OUT_col;
+
+void main()
+{
+   OUT_col = hdrEncode( vec4(1,1,1,1) );
+}

+ 35 - 0
Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFXP.hlsl

@@ -0,0 +1,35 @@
+#include "core/rendering/shaders/postFX/postFx.hlsl"
+#include "core/rendering/shaders/torque.hlsl"
+
+TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
+uniform float distCoeff;
+uniform float cubeDistort;
+uniform float3 colorDistort;
+
+float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
+{
+   float2 tex = IN.uv0;
+
+    float f = 0;
+    float r2 = (tex.x - 0.5) * (tex.x - 0.5) + (tex.y - 0.5) * (tex.y - 0.5);       
+
+    // Only compute the cubic distortion if necessary.
+    if ( cubeDistort == 0.0 )
+        f = 1 + r2 * distCoeff;
+    else
+        f = 1 + r2 * (distCoeff + cubeDistort * sqrt(r2));
+
+    // Distort each color channel seperately to get a chromatic distortion effect.
+    float3 outColor;
+    float3 distort = f.xxx + colorDistort;
+
+   [unroll]
+    for ( int i=0; i < 3; i++ )
+    {
+        float x = distort[i] * ( tex.x - 0.5 ) + 0.5;
+        float y = distort[i] * ( tex.y - 0.5 ) + 0.5;
+        outColor[i] = TORQUE_TEX2DLOD( inputTex, float4(x,y,0,0) )[i];
+    }
+
+    return float4( outColor.rgb, 1 );
+}

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_CalcCoC_P.glsl → Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_CalcCoC_P.glsl

@@ -20,8 +20,8 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../../gl/hlslCompat.glsl"
-#include "../../gl/postFx.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
+#include "core/rendering/shaders/postFX/gl/postFx.glsl"
 
 // These are set by the game engine.  
 uniform sampler2D shrunkSampler;  // Output of DofDownsample()  

+ 1 - 1
Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_CalcCoC_P.hlsl → Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_CalcCoC_P.hlsl

@@ -20,7 +20,7 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "./../postFx.hlsl"
+#include "core/rendering/shaders/postFX/postFx.hlsl"
 
 // These are set by the game engine.  
 TORQUE_UNIFORM_SAMPLER2D(shrunkSampler, 0);  // Output of DofDownsample()

+ 3 - 3
Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_CalcCoC_V.glsl → Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_CalcCoC_V.glsl

@@ -20,9 +20,9 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../../gl/hlslCompat.glsl"
-#include "../../../gl/torque.glsl"
-#include "../../gl/postFx.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
+#include "core/rendering/shaders/gl/torque.glsl"
+#include "core/rendering/shaders/postFX/gl/postFx.glsl"
 
 uniform vec4 rtParams0;
 uniform vec4 rtParams1;

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_CalcCoC_V.hlsl → Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_CalcCoC_V.hlsl

@@ -20,8 +20,8 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "./../postFx.hlsl"
-#include "./../../torque.hlsl"
+#include "core/rendering/shaders/postFX/postFx.hlsl"
+#include "core/rendering/shaders/torque.hlsl"
 
 uniform float4 rtParams0;
 uniform float4 rtParams1;

+ 1 - 1
Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_DownSample_P.glsl → Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_DownSample_P.glsl

@@ -20,7 +20,7 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../../gl/hlslCompat.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
 #include "shadergen:/autogenConditioners.h"
 
 // These are set by the game engine.  

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_DownSample_P.hlsl → Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_DownSample_P.hlsl

@@ -20,8 +20,8 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../shaderModel.hlsl"
-#include "../../shaderModelAutoGen.hlsl"
+#include "core/rendering/shaders/shaderModel.hlsl"
+#include "core/rendering/shaders/shaderModelAutoGen.hlsl"
 
 // These are set by the game engine.  
 // The render target size is one-quarter the scene rendering size.  

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_DownSample_V.glsl → Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_DownSample_V.glsl

@@ -20,8 +20,8 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../../gl/hlslCompat.glsl"
-#include "../../../gl/torque.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
+#include "core/rendering/shaders/gl/torque.glsl"
 
 in vec4 vPosition;
 in vec2 vTexCoord0;

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_DownSample_V.hlsl → Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_DownSample_V.hlsl

@@ -20,8 +20,8 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "./../postFx.hlsl"
-#include "./../../torque.hlsl"
+#include "core/rendering/shaders/postFX/postFx.hlsl"
+#include "core/rendering/shaders/torque.hlsl"
 
 struct Vert
 {

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_Final_P.glsl → Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Final_P.glsl

@@ -20,9 +20,9 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../../gl/hlslCompat.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
 #include "shadergen:/autogenConditioners.h"
-#include "../../gl/postFx.glsl"
+#include "core/rendering/shaders/postFX/gl/postFx.glsl"
 
 uniform sampler2D colorSampler; // Original source image  
 uniform sampler2D smallBlurSampler; // Output of SmallBlurPS()  

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_Final_P.hlsl → Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Final_P.hlsl

@@ -20,8 +20,8 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../shaderModelAutoGen.hlsl"
-#include "./../postFx.hlsl"
+#include "core/rendering/shaders/shaderModelAutoGen.hlsl"
+#include "core/rendering/shaders/postFX/postFx.hlsl"
 
 TORQUE_UNIFORM_SAMPLER2D(colorSampler,0); // Original source image 
 TORQUE_UNIFORM_SAMPLER2D(smallBlurSampler,1); // Output of SmallBlurPS()  

+ 3 - 3
Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_Final_V.glsl → Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Final_V.glsl

@@ -20,9 +20,9 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../../gl/hlslCompat.glsl"
-#include "../../../gl/torque.glsl"
-#include "../../gl/postFx.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
+#include "core/rendering/shaders/gl/torque.glsl"
+#include "core/rendering/shaders/postFX/gl/postFx.glsl"
 
 uniform vec4 rtParams0;
 uniform vec4 rtParams1;

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_Final_V.hlsl → Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Final_V.hlsl

@@ -20,8 +20,8 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "./../postFx.hlsl"
-#include "./../../torque.hlsl"
+#include "core/rendering/shaders/postFX/postFx.hlsl"
+#include "core/rendering/shaders/torque.hlsl"
 
 uniform float4 rtParams0;
 uniform float4 rtParams1;

+ 1 - 1
Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_Gausian_P.glsl → Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Gausian_P.glsl

@@ -20,7 +20,7 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../../gl/hlslCompat.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
 #include "shadergen:/autogenConditioners.h"
 
 in vec3 wsEyeRay;

+ 1 - 1
Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_Gausian_P.hlsl → Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Gausian_P.hlsl

@@ -20,7 +20,7 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "./../postFx.hlsl"
+#include "core/rendering/shaders/postFX/postFx.hlsl"
 
 TORQUE_UNIFORM_SAMPLER2D(diffuseMap, 0);
 

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_Gausian_V.glsl → Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Gausian_V.glsl

@@ -20,8 +20,8 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../../gl/hlslCompat.glsl"
-#include "../../../gl/torque.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
+#include "core/rendering/shaders/gl/torque.glsl"
 
 in vec4 vPosition;
 in vec2 vTexCoord0;

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_Gausian_V.hlsl → Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Gausian_V.hlsl

@@ -20,8 +20,8 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "./../postFx.hlsl"
-#include "./../../torque.hlsl"
+#include "core/rendering/shaders/postFX/postFx.hlsl"
+#include "core/rendering/shaders/torque.hlsl"
 
 
 uniform float4 rtParams0;

+ 3 - 3
Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_Passthrough_V.glsl → Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Passthrough_V.glsl

@@ -20,9 +20,9 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../../gl/hlslCompat.glsl"
-#include "../../../gl/torque.glsl"
-#include "../../gl/postFx.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
+#include "core/rendering/shaders/gl/torque.glsl"
+#include "core/rendering/shaders/postFX/gl/postFx.glsl"
 
 uniform vec4 rtParams0;
 uniform vec4 rtParams1;

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_Passthrough_V.hlsl → Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_Passthrough_V.hlsl

@@ -20,8 +20,8 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "./../postFx.hlsl"
-#include "./../../torque.hlsl"
+#include "core/rendering/shaders/postFX/postFx.hlsl"
+#include "core/rendering/shaders/torque.hlsl"
 
 uniform float4 rtParams0;
 uniform float4 rtParams1;

+ 1 - 1
Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_SmallBlur_P.glsl → Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_SmallBlur_P.glsl

@@ -25,7 +25,7 @@
 // The sample weights are 1/16 in the corners, 2/16 on the edges,  
 // and 4/16 in the center.
 
-#include "../../../gl/hlslCompat.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
 
 uniform sampler2D colorSampler;  // Output of DofNearCoc()  
 

+ 1 - 1
Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_SmallBlur_P.hlsl → Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_SmallBlur_P.hlsl

@@ -24,7 +24,7 @@
 // colorMapSampler, which is the same size as the render target.  
 // The sample weights are 1/16 in the corners, 2/16 on the edges,  
 // and 4/16 in the center.  
-#include "../../shaderModel.hlsl"
+#include "core/rendering/shaders/shaderModel.hlsl"
 
 TORQUE_UNIFORM_SAMPLER2D(colorSampler, 0); // Output of DofNearCoc()
 

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/dof/gl/DOF_SmallBlur_V.glsl → Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_SmallBlur_V.glsl

@@ -25,8 +25,8 @@
 // The sample weights are 1/16 in the corners, 2/16 on the edges,  
 // and 4/16 in the center.  
 
-#include "../../../gl/hlslCompat.glsl"
-#include "../../../gl/torque.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
+#include "core/rendering/shaders/gl/torque.glsl"
 
 in vec4 vPosition;
 in vec2 vTexCoord0;

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/dof/DOF_SmallBlur_V.hlsl → Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DOF_SmallBlur_V.hlsl

@@ -25,8 +25,8 @@
 // The sample weights are 1/16 in the corners, 2/16 on the edges,  
 // and 4/16 in the center.  
 
-#include "./../postFx.hlsl"
-#include "./../../torque.hlsl"
+#include "core/rendering/shaders/postFX/postFx.hlsl"
+#include "core/rendering/shaders/torque.hlsl"
 
 struct Vert
 {

+ 6 - 0
Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DepthOfFieldPostFX.asset.taml

@@ -0,0 +1,6 @@
+<PostEffectAsset
+    canSave="true"
+    canSaveDynamicFields="true"
+    AssetName="DepthOfFieldPostFX"
+    scriptFile="@assetFile=DepthOfFieldPostFX.cs"
+    VersionId="1" />

+ 111 - 122
Templates/BaseGame/game/core/postFX/scripts/dof.cs → Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DepthOfFieldPostFX.cs

@@ -1,32 +1,11 @@
-//-----------------------------------------------------------------------------
-// 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
+ The DepthOfFieldPostFX API
 ================================================================================
 
-DOFPostEffect::setFocalDist( %dist )
+DepthOfFieldPostFX::setFocalDist( %dist )
 
 @summary
 This method is for manually controlling the focus distance. It will have no 
@@ -38,7 +17,7 @@ float distance in meters
 
 --------------------------------------------------------------------------------
 
-DOFPostEffect::setAutoFocus( %enabled )
+DepthOfFieldPostFX::setAutoFocus( %enabled )
 
 @summary
 This method sets auto focus enabled or disabled. Makes use of the parameters set 
@@ -50,7 +29,7 @@ bool
 
 --------------------------------------------------------------------------------
 
-DOFPostEffect::setFocusParams( %nearBlurMax, %farBlurMax, %minRange, %maxRange, %nearSlope, %farSlope )
+DepthOfFieldPostFX::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
@@ -101,19 +80,19 @@ 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 );
+   DepthOfFieldPostFX.setFocusParams( 0.3, 0.3, 50, 500, -5, 5 );
    
    // Turn on auto focus
-   DOFPostEffect.setAutoFocus( true );
+   DepthOfFieldPostFX.setAutoFocus( true );
    
    // Turn on the PostEffect
-   DOFPostEffect.enable();
+   DepthOfFieldPostFX.enable();
 }
 
 function onSniperUnzoom()
 {
    // Turn off the PostEffect
-   DOFPostEffect.disable();
+   DepthOfFieldPostFX.disable();
 }
 
 Example2: Manually control DOF with the mouse wheel.
@@ -121,13 +100,13 @@ 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 );
+DepthOfFieldPostFX.setFocusParams( 0.3, 0.3, 50, 500, -5, 5 );
 
 // Turn off auto focus
-DOFPostEffect.setAutoFocus( false );
+DepthOfFieldPostFX.setAutoFocus( false );
 
 // Turn on the PostEffect
-DOFPostEffect.enable();
+DepthOfFieldPostFX.enable();
 
 
 NOTE: These are not real callbacks! Hook these up to your code where appropriate!
@@ -136,19 +115,19 @@ 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;
+   DepthOfFieldPostFX.focalDist += 8;
 }
 
 function onMouseWheelDown()
 {
-   DOFPostEffect.focalDist -= 8;
+   DepthOfFieldPostFX.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 )
+function DepthOfFieldPostFX::setFocalDist( %this, %dist )
 {    
    %this.focalDist = %dist;
 }
@@ -156,7 +135,7 @@ function DOFPostEffect::setFocalDist( %this, %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 )
+function DepthOfFieldPostFX::setAutoFocus( %this, %enabled )
 {
    %this.autoFocusEnabled = %enabled;
 }
@@ -164,7 +143,7 @@ function DOFPostEffect::setAutoFocus( %this, %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 )
+function DepthOfFieldPostFX::setFocusParams( %this, %nearBlurMax, %farBlurMax, %minRange, %maxRange, %nearSlope, %farSlope )
 {
    %this.nearBlurMax = %nearBlurMax;
    %this.farBlurMax = %farBlurMax;
@@ -318,11 +297,11 @@ singleton GFXStateBlockData( PFX_DOFFinalStateBlock )
 
 singleton ShaderData( PFX_DOFDownSampleShader )
 {      
-   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/dof/DOF_DownSample_V.hlsl";   
-   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/dof/DOF_DownSample_P.hlsl";            
+   DXVertexShaderFile 	= "./DOF_DownSample_V.hlsl";   
+   DXPixelShaderFile 	= "./DOF_DownSample_P.hlsl";            
    
-   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_DownSample_V.glsl";
-   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_DownSample_P.glsl";
+   OGLVertexShaderFile  = "./DOF_DownSample_V.glsl";
+   OGLPixelShaderFile   = "./DOF_DownSample_P.glsl";
    
    samplerNames[0] = "$colorSampler";
    samplerNames[1] = "$depthSampler";
@@ -332,11 +311,11 @@ singleton ShaderData( PFX_DOFDownSampleShader )
 
 singleton ShaderData( PFX_DOFBlurYShader )
 {
-   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/dof/DOF_Gausian_V.hlsl";
-   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/dof/DOF_Gausian_P.hlsl";
+   DXVertexShaderFile 	= "./DOF_Gausian_V.hlsl";
+   DXPixelShaderFile 	= "./DOF_Gausian_P.hlsl";
    
-   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_Gausian_V.glsl";
-   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_Gausian_P.glsl";
+   OGLVertexShaderFile  = "./DOF_Gausian_V.glsl";
+   OGLPixelShaderFile   = "./DOF_Gausian_P.glsl";
    
    samplerNames[0] = "$diffuseMap";
    
@@ -351,11 +330,11 @@ singleton ShaderData( PFX_DOFBlurXShader : PFX_DOFBlurYShader )
 
 singleton ShaderData( PFX_DOFCalcCoCShader )
 {   
-   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/dof/DOF_CalcCoC_V.hlsl";
-   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/dof/DOF_CalcCoC_P.hlsl";         
+   DXVertexShaderFile 	= "./DOF_CalcCoC_V.hlsl";
+   DXPixelShaderFile 	= "./DOF_CalcCoC_P.hlsl";         
    
-   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_CalcCoC_V.glsl";
-   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_CalcCoC_P.glsl"; 
+   OGLVertexShaderFile  = "./DOF_CalcCoC_V.glsl";
+   OGLPixelShaderFile   = "./DOF_CalcCoC_P.glsl"; 
 
    samplerNames[0] = "$shrunkSampler";
    samplerNames[1] = "$blurredSampler";
@@ -365,11 +344,11 @@ singleton ShaderData( PFX_DOFCalcCoCShader )
 
 singleton ShaderData( PFX_DOFSmallBlurShader )
 {   
-   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/dof/DOF_SmallBlur_V.hlsl";
-   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/dof/DOF_SmallBlur_P.hlsl";            
+   DXVertexShaderFile 	= "./DOF_SmallBlur_V.hlsl";
+   DXPixelShaderFile 	= "./DOF_SmallBlur_P.hlsl";            
    
-   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_SmallBlur_V.glsl";
-   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_SmallBlur_P.glsl";
+   OGLVertexShaderFile  = "./DOF_SmallBlur_V.glsl";
+   OGLPixelShaderFile   = "./DOF_SmallBlur_P.glsl";
 
    samplerNames[0] = "$colorSampler";
    
@@ -378,11 +357,11 @@ singleton ShaderData( PFX_DOFSmallBlurShader )
 
 singleton ShaderData( PFX_DOFFinalShader )
 {   
-   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/dof/DOF_Final_V.hlsl";
-   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/dof/DOF_Final_P.hlsl";
+   DXVertexShaderFile 	= "./DOF_Final_V.hlsl";
+   DXPixelShaderFile 	= "./DOF_Final_P.hlsl";
    
-   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_Final_V.glsl";
-   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_Final_P.glsl";
+   OGLVertexShaderFile  = "./DOF_Final_V.glsl";
+   OGLPixelShaderFile   = "./DOF_Final_P.glsl";
    
    samplerNames[0] = "$colorSampler";
    samplerNames[1] = "$smallBlurSampler";
@@ -396,7 +375,7 @@ singleton ShaderData( PFX_DOFFinalShader )
 // PostEffects
 //-----------------------------------------------------------------------------
 
-function DOFPostEffect::onAdd( %this )
+function DepthOfFieldPostFX::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
@@ -417,14 +396,16 @@ function DOFPostEffect::onAdd( %this )
    PostFXManager.registerPostEffect(%this);
 }
 
-function DOFPostEffect::setLerpDist( %this, %d0, %d1, %d2 )
+function DepthOfFieldPostFX::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 )
+singleton PostEffect( DepthOfFieldPostFX )
 {
+   isEnabled = false;
+   
    renderTime = "PFXAfterBin";
    renderBin = "GlowBin";      
    renderPriority = 0.1;
@@ -436,75 +417,83 @@ singleton PostEffect( DOFPostEffect )
    target = "#shrunk";
    targetScale = "0.25 0.25";   
    
-   isEnabled = false;
+   singleton PostEffect( DOFBlurY )
+   {
+      shader = PFX_DOFBlurYShader;
+      stateBlock = PFX_DOFBlurStateBlock;
+      texture[0] = "#shrunk";
+      target = "$outTex";
+   };
+   
+   singleton PostEffect( DOFBlurX )
+   {
+      shader = PFX_DOFBlurXShader;
+      stateBlock = PFX_DOFBlurStateBlock;
+      texture[0] = "$inTex";  
+      target = "#largeBlur";
+   };
+   
+   singleton PostEffect( DOFCalcCoC )
+   {
+      shader = PFX_DOFCalcCoCShader;
+      stateBlock = PFX_DOFCalcCoCStateBlock;
+      texture[0] = "#shrunk";
+      texture[1] = "#largeBlur";
+      target = "$outTex";
+   };
+   
+   singleton PostEffect( DOFSmallBlur )
+   {
+      shader = PFX_DOFSmallBlurShader;
+      stateBlock = PFX_DefaultDOFStateBlock;
+      texture[0] = "$inTex";
+      target = "$outTex";
+   };
+   
+   singleton PostEffect( DOFFinalPFX )
+   {
+      shader = PFX_DOFFinalShader;
+      stateBlock = PFX_DOFFinalStateBlock;
+      texture[0] = "$backBuffer";
+      texture[1] = "$inTex";
+      texture[2] = "#largeBlur";   
+      texture[3] = "#deferred";   
+      target = "$backBuffer";
+   };
 };
 
-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 )
+//-----------------------------------------------------------------------------
+// Scripts
+//-----------------------------------------------------------------------------
+function DepthOfFieldPostFX::populatePostFXSettings(%this)
 {
-   shader = PFX_DOFCalcCoCShader;
-   stateBlock = PFX_DOFCalcCoCStateBlock;
-   texture[0] = "#shrunk";
-   texture[1] = "#largeBlur";
-   target = "$outTex";
-};
+   PostEffectEditorInspector.startGroup("Depth of Field - General");
+   PostEffectEditorInspector.addCallbackField("$PostFX::DepthOfFieldPostFX::Enabled", "Enabled", "bool", "", $PostFX::DepthOfFieldPostFX::Enabled, "", "toggleDepthOfFieldPostFX");
+   PostEffectEditorInspector.endGroup();
+}
 
-DOFPostEffect.add( DOFCalcCoc );
-  
-singleton PostEffect( DOFSmallBlur )
+function PostEffectEditorInspector::toggleDepthOfFieldPostFX(%this)
 {
-   shader = PFX_DOFSmallBlurShader;
-   stateBlock = PFX_DefaultDOFStateBlock;
-   texture[0] = "$inTex";
-   target = "$outTex";
-};
+   if($PostFX::DepthOfFieldPostFX::Enabled)
+      DepthOfFieldPostFX.enable();
+   else
+      DepthOfFieldPostFX.disable();
+}
 
-DOFPostEffect.add( DOFSmallBlur );
-   
-singleton PostEffect( DOFFinalPFX )
+function DepthOfFieldPostFX::applyFromPreset(%this)
 {
-   shader = PFX_DOFFinalShader;
-   stateBlock = PFX_DOFFinalStateBlock;
-   texture[0] = "$backBuffer";
-   texture[1] = "$inTex";
-   texture[2] = "#largeBlur";   
-   texture[3] = "#deferred";   
-   target = "$backBuffer";
-};
-
-DOFPostEffect.add( DOFFinalPFX );
-
+   if($PostFX::DepthOfFieldPostFX::Enabled)
+      DepthOfFieldPostFX.enable();
+   else
+      DepthOfFieldPostFX.disable();
+}
 
-//-----------------------------------------------------------------------------
-// Scripts
-//-----------------------------------------------------------------------------
-function DOFPostEffect::populatePostFXSettings(%this)
+function DepthOfFieldPostFX::savePresetSettings(%this)
 {
-   PostEffectEditorInspector.startGroup("Depth of Field");
-   PostEffectEditorInspector.addField("isEnabled", "Enabled", "bool", "", DOFPostEffect.isEnabled, "", DOFPostEffect);
-   PostEffectEditorInspector.endGroup();
+   PostFXManager::savePresetSetting("$PostFX::DepthOfFieldPostFX::Enabled");
 }
 
-function DOFPostEffect::setShaderConsts( %this )
+function DepthOfFieldPostFX::setShaderConsts( %this )
 {
    if ( %this.autoFocusEnabled )
       %this.autoFocus();
@@ -553,7 +542,7 @@ function DOFPostEffect::setShaderConsts( %this )
    DOFFinalPFX.setShaderConst( "$dofLerpBias", %this.lerpBias );  
 }
 
-function DOFPostEffect::autoFocus( %this )
+function DepthOfFieldPostFX::autoFocus( %this )
 {      
    if ( !isObject( ServerConnection ) ||   
         !isObject( ServerConnection.getCameraObject() ) )
@@ -593,9 +582,9 @@ function DOFPostEffect::autoFocus( %this )
 function reloadDOF()
 {
    exec( "./dof.cs" );
-   DOFPostEffect.reload();  
-   DOFPostEffect.disable();
-   DOFPostEffect.enable();
+   DepthOfFieldPostFX.reload();  
+   DepthOfFieldPostFX.disable();
+   DepthOfFieldPostFX.enable();
 }
 
 function dofMetricsCallback()

+ 1 - 1
Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/gl/dbgEdgeDisplayP.glsl → Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/dbgEdgeDisplayP.glsl

@@ -20,7 +20,7 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../../gl/hlslCompat.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
 #include "shadergen:/autogenConditioners.h"
 
 in vec2 uv0;

+ 1 - 1
Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/dbgEdgeDisplayP.hlsl → Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/dbgEdgeDisplayP.hlsl

@@ -20,7 +20,7 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../postFx.hlsl"
+#include "core/rendering/shaders/postFX/postFx.hlsl"
 
 TORQUE_UNIFORM_SAMPLER2D(edgeBuffer);
 

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/gl/edgeAAP.glsl → Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAP.glsl

@@ -20,9 +20,9 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../../gl/hlslCompat.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
 #include "shadergen:/autogenConditioners.h"
-#include "../../gl/postFx.glsl"
+#include "core/rendering/shaders/postFX/gl/postFx.glsl"
 
 uniform sampler2D edgeBuffer;
 uniform sampler2D backBuffer;

+ 1 - 1
Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/edgeAAP.hlsl → Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAP.hlsl

@@ -20,7 +20,7 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../postFx.hlsl"
+#include "core/rendering/shaders/postFX/postFx.hlsl"
 
 TORQUE_UNIFORM_SAMPLER2D(edgeBuffer,0);
 TORQUE_UNIFORM_SAMPLER2D(backBuffer, 1);

+ 6 - 0
Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAPostFX.asset.taml

@@ -0,0 +1,6 @@
+<PostEffectAsset
+    canSave="true"
+    canSaveDynamicFields="true"
+    AssetName="edgeAAPostFX"
+    scriptFile="@assetFile=edgeAAPostFX.cs"
+    VersionId="1" />

+ 8 - 8
Templates/BaseGame/game/core/postFX/scripts/edgeAA.cs → Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAPostFX.cs

@@ -35,10 +35,10 @@ singleton GFXStateBlockData( PFX_DefaultEdgeAAStateBlock )
 singleton ShaderData( PFX_EdgeAADetectShader )
 {   
    DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
-   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/edgeaa/edgeDetectP.hlsl";
+   DXPixelShaderFile 	= "./edgeDetectP.hlsl";
          
    OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
-   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/edgeaa/gl/edgeDetectP.glsl";
+   OGLPixelShaderFile   = "./edgeDetectP.glsl";
       
    samplerNames[0] = "$deferredBuffer";
    
@@ -47,11 +47,11 @@ singleton ShaderData( PFX_EdgeAADetectShader )
 
 singleton ShaderData( PFX_EdgeAAShader )
 {   
-   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/edgeaa/edgeAAV.hlsl";
-   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/edgeaa/edgeAAP.hlsl";
+   DXVertexShaderFile 	= "./edgeAAV.hlsl";
+   DXPixelShaderFile 	= "./edgeAAP.hlsl";
          
-   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/edgeaa/gl/edgeAAV.glsl";
-   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/edgeaa/gl/edgeAAP.glsl";
+   OGLVertexShaderFile  = "./edgeAAV.glsl";
+   OGLPixelShaderFile   = "./edgeAAP.glsl";
       
    samplerNames[0] = "$edgeBuffer";
    samplerNames[1] = "$backBuffer";
@@ -62,10 +62,10 @@ singleton ShaderData( PFX_EdgeAAShader )
 singleton ShaderData( PFX_EdgeAADebugShader )
 {   
    DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
-   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/edgeaa/dbgEdgeDisplayP.hlsl";
+   DXPixelShaderFile 	= "./dbgEdgeDisplayP.hlsl";
          
    OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
-   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/edgeaa/gl/dbgEdgeDisplayP.glsl";
+   OGLPixelShaderFile   = "./dbgEdgeDisplayP.glsl";
       
    samplerNames[0] = "$edgeBuffer";
    

+ 3 - 3
Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/gl/edgeAAV.glsl → Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAV.glsl

@@ -20,9 +20,9 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../../gl/hlslCompat.glsl"
-#include "../../../gl/torque.glsl"
-#include "../../gl/postFx.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
+#include "core/rendering/shaders/gl/torque.glsl"
+#include "core/rendering/shaders/postFX/gl/postFx.glsl"
 
 uniform vec4 rtParams0;
 uniform vec4 rtParams1;

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/edgeAAV.hlsl → Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAV.hlsl

@@ -20,8 +20,8 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "./../postFx.hlsl"
-#include "./../../torque.hlsl"
+#include "core/rendering/shaders/postFX/postFx.hlsl"
+#include "core/rendering/shaders/torque.hlsl"
 
 
 uniform float4 rtParams0;

+ 1 - 1
Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/gl/edgeDetectP.glsl → Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeDetectP.glsl

@@ -20,7 +20,7 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../../gl/hlslCompat.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
 #include "shadergen:/autogenConditioners.h"
 
 // GPU Gems 3, pg 443-444

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/edgeaa/edgeDetectP.hlsl → Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeDetectP.hlsl

@@ -20,8 +20,8 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../postFx.hlsl"
-#include "../../shaderModelAutoGen.hlsl"
+#include "core/rendering/shaders/postFX/postFx.hlsl"
+#include "core/rendering/shaders/shaderModelAutoGen.hlsl"
 
 TORQUE_UNIFORM_SAMPLER2D(deferredBuffer,0);
 

+ 0 - 0
Templates/BaseGame/game/core/postFX/scripts/FXAAPostFX.asset.taml → Templates/BaseGame/game/core/postFX/scripts/FXAA/FXAAPostFX.asset.taml


+ 4 - 4
Templates/BaseGame/game/core/postFX/scripts/FXAAPostFX.cs → Templates/BaseGame/game/core/postFX/scripts/FXAA/FXAAPostFX.cs

@@ -36,11 +36,11 @@ singleton GFXStateBlockData( FXAA_StateBlock : PFX_DefaultStateBlock )
 
 singleton ShaderData( FXAA_ShaderData )
 {   
-   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/fxaa/fxaaV.hlsl";
-   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/fxaa/fxaaP.hlsl";
+   DXVertexShaderFile 	= "./fxaaV.hlsl";
+   DXPixelShaderFile 	= "./fxaaP.hlsl";
    
-   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/fxaa/gl/fxaaV.glsl";
-   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/fxaa/gl/fxaaP.glsl";
+   OGLVertexShaderFile  = "./fxaaV.glsl";
+   OGLPixelShaderFile   = "./fxaaP.glsl";
    
    samplerNames[0] = "$colorTex";
 

+ 0 - 0
Templates/BaseGame/game/core/rendering/shaders/postFX/fxaa/Fxaa3_11.h → Templates/BaseGame/game/core/postFX/scripts/FXAA/Fxaa3_11.h


+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/fxaa/gl/fxaaP.glsl → Templates/BaseGame/game/core/postFX/scripts/FXAA/fxaaP.glsl

@@ -25,8 +25,8 @@
 #define FXAA_QUALITY__PRESET 12
 #define FXAA_GREEN_AS_LUMA 1
 
-#include "../Fxaa3_11.h"
-#include "../../../gl/hlslCompat.glsl"
+#include "Fxaa3_11.h"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
 
 uniform sampler2D colorTex ;
 uniform vec2 oneOverTargetSize;

+ 1 - 1
Templates/BaseGame/game/core/rendering/shaders/postFX/fxaa/fxaaP.hlsl → Templates/BaseGame/game/core/postFX/scripts/FXAA/fxaaP.hlsl

@@ -20,7 +20,7 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../shaderModel.hlsl"
+#include "core/rendering/shaders/shaderModel.hlsl"
 
 #define FXAA_PC 1
 #if TORQUE_SM == 40

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/fxaa/gl/fxaaV.glsl → Templates/BaseGame/game/core/postFX/scripts/FXAA/fxaaV.glsl

@@ -19,8 +19,8 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
-#include "../../../gl/hlslCompat.glsl"
-#include "../../../gl/torque.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
+#include "core/rendering/shaders/gl/torque.glsl"
 
 in vec4 vPosition;
 in vec2 vTexCoord0;

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/fxaa/fxaaV.hlsl → Templates/BaseGame/game/core/postFX/scripts/FXAA/fxaaV.hlsl

@@ -20,8 +20,8 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "./../../torque.hlsl"
-#include "./../postFx.hlsl"
+#include "core/rendering/shaders/torque.hlsl"
+#include "core/rendering/shaders/postFX/postFx.hlsl"
 
 struct VertToPix
 {

+ 0 - 0
Templates/BaseGame/game/core/rendering/shaders/postFX/gl/flashP.glsl → Templates/BaseGame/game/core/postFX/scripts/Flash/flashP.glsl


+ 0 - 0
Templates/BaseGame/game/core/rendering/shaders/postFX/flashP.hlsl → Templates/BaseGame/game/core/postFX/scripts/Flash/flashP.hlsl


+ 6 - 0
Templates/BaseGame/game/core/postFX/scripts/Flash/flashPostFX.asset.taml

@@ -0,0 +1,6 @@
+<PostEffectAsset
+    canSave="true"
+    canSaveDynamicFields="true"
+    AssetName="flashPostFX"
+    scriptFile="@assetFile=flashPostFX.cs"
+    VersionId="1" />

+ 2 - 2
Templates/BaseGame/game/core/postFX/scripts/flash.cs → Templates/BaseGame/game/core/postFX/scripts/Flash/flashPostFX.cs

@@ -23,10 +23,10 @@
 singleton ShaderData( PFX_FlashShader )
 {
    DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
-   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/flashP.hlsl";
+   DXPixelShaderFile 	= "./flashP.hlsl";
    
    OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
-   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/gl/flashP.glsl";
+   OGLPixelShaderFile   = "./flashP.glsl";
    
    samplerNames[0] = "$backBuffer";
 

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/gl/fogP.glsl → Templates/BaseGame/game/core/postFX/scripts/Fog/fogP.glsl

@@ -20,10 +20,10 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../gl/hlslCompat.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
 
 #include "shadergen:/autogenConditioners.h"
-#include "../../gl/torque.glsl"
+#include "core/rendering/shaders/gl/torque.glsl"
 
 uniform sampler2D deferredTex ;
 uniform vec3    eyePosWorld;

+ 3 - 3
Templates/BaseGame/game/core/rendering/shaders/postFX/fogP.hlsl → Templates/BaseGame/game/core/postFX/scripts/Fog/fogP.hlsl

@@ -21,9 +21,9 @@
 //-----------------------------------------------------------------------------
 
 
-#include "./postFx.hlsl"
-#include "./../torque.hlsl"
-#include "./../shaderModelAutoGen.hlsl"
+#include "core/rendering/shaders/postFX/postFx.hlsl"
+#include "core/rendering/shaders/torque.hlsl"
+#include "core/rendering/shaders/shaderModelAutoGen.hlsl"
 
 TORQUE_UNIFORM_SAMPLER2D(deferredTex, 0);
 uniform float3    eyePosWorld;

+ 0 - 0
Templates/BaseGame/game/core/postFX/scripts/fogPostFX.asset.taml → Templates/BaseGame/game/core/postFX/scripts/Fog/fogPostFX.asset.taml


+ 2 - 2
Templates/BaseGame/game/core/postFX/scripts/fogPostFX.cs → Templates/BaseGame/game/core/postFX/scripts/Fog/fogPostFX.cs

@@ -27,10 +27,10 @@
 singleton ShaderData( FogPassShader )
 {   
    DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
-   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/fogP.hlsl";
+   DXPixelShaderFile 	= "./fogP.hlsl";
          
    OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
-   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/gl/fogP.glsl";
+   OGLPixelShaderFile   = "./fogP.glsl";
             
    samplerNames[0] = "$deferredTex";
    

+ 8 - 0
Templates/BaseGame/game/core/postFX/scripts/Gamma/GammaPostFX.asset.taml

@@ -0,0 +1,8 @@
+<PostEffectAsset
+    canSave="true"
+    canSaveDynamicFields="true"
+    AssetName="GammaPostFX"
+    scriptFile="@assetFile=GammaPostFX.cs"
+    hlslShader="@assetFile=gammaP.hlsl"
+    glslShader="@assetFile=gammaP.glsl"
+    VersionId="1" />

+ 59 - 6
Templates/BaseGame/game/core/postFX/scripts/GammaPostFX.cs → Templates/BaseGame/game/core/postFX/scripts/Gamma/GammaPostFX.cs

@@ -23,10 +23,10 @@
 singleton ShaderData( GammaShader )
 {
    DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
-   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/gammaP.hlsl";
+   DXPixelShaderFile 	= "./gammaP.hlsl";
 
    OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
-   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/gl/gammaP.glsl";
+   OGLPixelShaderFile   = "./gammaP.glsl";
    
    samplerNames[0] = "$backBuffer";
    samplerNames[1] = "$colorCorrectionTex";
@@ -54,14 +54,11 @@ singleton PostEffect( GammaPostFX )
    stateBlock = GammaStateBlock;
    
    texture[0] = "$backBuffer";  
-   texture[1] = $HDRPostFX::colorCorrectionRamp;  
    textureSRGB[1] = true;
 };
 
 function GammaPostFX::preProcess( %this )
 {
-   if ( %this.texture[1] !$= $HDRPostFX::colorCorrectionRamp )
-      %this.setTexture( 1, $HDRPostFX::colorCorrectionRamp );         
 }
 
 function GammaPostFX::setShaderConsts( %this )
@@ -70,4 +67,60 @@ function GammaPostFX::setShaderConsts( %this )
    %this.setShaderConst( "$OneOverGamma", 1 / %clampedGamma );
    %this.setShaderConst( "$Brightness", $pref::Video::Brightness );
    %this.setShaderConst( "$Contrast", $pref::Video::Contrast );
-}
+}
+
+function GammaPostFX::onAdd(%this)
+{
+   //Register the postFX with the manager
+   PostFXManager.registerPostEffect(%this);
+}
+
+function GammaPostFX::onEnabled( %this )
+{
+   return true;
+}
+
+function GammaPostFX::onDisabled( %this )
+{
+}
+
+//This is used to populate the PostFXEditor's settings so the post FX can be edited
+//This is automatically polled for any postFX that has been registered(in our onAdd) and the settings
+//are thus exposed for editing
+function GammaPostFX::populatePostFXSettings(%this)
+{
+   PostEffectEditorInspector.startGroup("GammaPostFX - General");
+   PostEffectEditorInspector.addCallbackField("$PostFX::GammaPostFX::Enabled", "Enable", "bool", "", $PostFX::GammaPostFX::Enabled, "", "toggleGammaPostFX");
+   PostEffectEditorInspector.endGroup();
+}
+
+function PostEffectEditorInspector::toggleGammaPostFX(%this)
+{
+   //If we're toggling between gamma then we're also toggling HDR the opposite way
+   if($PostFX::GammaPostFX::Enabled)
+   {
+      HDRPostFX.disable();
+   }
+   else
+   {
+      HDRPostFX.enable();
+   }
+}
+
+function GammaPostFX::applyFromPreset(%this)
+{
+   if($PostFX::GammaPostFX::Enabled)
+   {
+      HDRPostFX.disable();
+   }
+   else
+   {
+      HDRPostFX.enable();
+   }
+}
+
+function GammaPostFX::savePresetSettings(%this)
+{
+   PostFXManager::savePresetSetting("$PostFX::GammaPostFX::Enabled");
+}
+

+ 2 - 8
Templates/BaseGame/game/core/rendering/shaders/postFX/gl/gammaP.glsl → Templates/BaseGame/game/core/postFX/scripts/Gamma/gammaP.glsl

@@ -20,12 +20,11 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../gl/hlslCompat.glsl"
-#include "../../gl/torque.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
+#include "core/rendering/shaders/gl/torque.glsl"
 #include "shadergen:/autogenConditioners.h"
 
 uniform sampler2D backBuffer;
-uniform sampler1D colorCorrectionTex;
 
 uniform float OneOverGamma;
 uniform float Brightness;
@@ -39,11 +38,6 @@ void main()
 {
     vec4 color = texture(backBuffer, uv0.xy);
 
-   // Apply the color correction.
-   color.r = texture( colorCorrectionTex, color.r ).r;
-   color.g = texture( colorCorrectionTex, color.g ).g;
-   color.b = texture( colorCorrectionTex, color.b ).b;
-
    // Apply contrast
    color.rgb = ((color.rgb - 0.5f) * Contrast) + 0.5f;
  

+ 2 - 8
Templates/BaseGame/game/core/rendering/shaders/postFX/gammaP.hlsl → Templates/BaseGame/game/core/postFX/scripts/Gamma/gammaP.hlsl

@@ -21,11 +21,10 @@
 //-----------------------------------------------------------------------------
 
 #include "shadergen:/autogenConditioners.h"  
-#include "./postFx.hlsl"  
-#include "../torque.hlsl"
+#include "core/rendering/shaders/postFX/postFx.hlsl"  
+#include "core/rendering/shaders/torque.hlsl"
 
 TORQUE_UNIFORM_SAMPLER2D(backBuffer, 0);
-TORQUE_UNIFORM_SAMPLER1D(colorCorrectionTex, 1);
 
 uniform float OneOverGamma;
 uniform float Brightness;
@@ -35,11 +34,6 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
 {
     float4 color = TORQUE_TEX2D(backBuffer, IN.uv0.xy);
 
-   // Apply the color correction.
-   color.r = TORQUE_TEX1D( colorCorrectionTex, color.r ).r;
-   color.g = TORQUE_TEX1D( colorCorrectionTex, color.g ).g;
-   color.b = TORQUE_TEX1D( colorCorrectionTex, color.b ).b;
-
    // Apply contrast
    color.rgb = ((color.rgb - 0.5f) * Contrast) + 0.5f;
  

+ 0 - 0
Templates/BaseGame/game/core/postFX/scripts/GlowPostFX.asset.taml → Templates/BaseGame/game/core/postFX/scripts/Glow/GlowPostFX.asset.taml


+ 12 - 12
Templates/BaseGame/game/core/postFX/scripts/GlowPostFX.cs → Templates/BaseGame/game/core/postFX/scripts/Glow/GlowPostFX.cs

@@ -23,11 +23,11 @@
 
 singleton ShaderData( PFX_GlowBlurVertShader )
 {
-   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/glowBlurV.hlsl";
-   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/glowBlurP.hlsl";
+   DXVertexShaderFile 	= "./glowBlurV.hlsl";
+   DXPixelShaderFile 	= "./glowBlurP.hlsl";
    
-   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/glowBlurV.glsl";
-   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/gl/glowBlurP.glsl";
+   OGLVertexShaderFile  = "./glowBlurV.glsl";
+   OGLPixelShaderFile   = "./glowBlurP.glsl";
       
    defines = "BLUR_DIR=float2(0.0,1.0)";
 
@@ -109,11 +109,11 @@ singleton PostEffect( GlowPostFX )
 
 singleton ShaderData( PFX_VolFogGlowBlurVertShader )
 {
-	DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/glowBlurV.hlsl";
-	DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/VolFogGlowP.hlsl";
+	DXVertexShaderFile = "./glowBlurV.hlsl";
+	DXPixelShaderFile = "./VolFogGlowP.hlsl";
 	
-	OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/glowBlurV.glsl";
-	OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/VolFogGlowP.glsl";	
+	OGLVertexShaderFile = "./glowBlurV.glsl";
+	OGLPixelShaderFile = "./VolFogGlowP.glsl";	
 	
 	defines = "BLUR_DIR=float2(0.0,1.0)";
 	samplerNames[0] = "$diffuseMap";
@@ -121,11 +121,11 @@ singleton ShaderData( PFX_VolFogGlowBlurVertShader )
 };
 singleton ShaderData( PFX_VolFogGlowBlurHorzShader : PFX_VolFogGlowBlurVertShader )
 {
-	DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/glowBlurV.hlsl";
-	DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/VolFogGlowP.hlsl";
+	DXVertexShaderFile = "./glowBlurV.hlsl";
+	DXPixelShaderFile = "./VolFogGlowP.hlsl";
 	
-	OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/glowBlurV.glsl";
-	OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/VolFogGlowP.glsl";
+	OGLVertexShaderFile = "./glowBlurV.glsl";
+	OGLPixelShaderFile = "./VolFogGlowP.glsl";
 	
 	defines = "BLUR_DIR=float2(1.0,0.0)";
 };

+ 0 - 0
Templates/BaseGame/game/core/rendering/shaders/postFX/gl/VolFogGlowP.glsl → Templates/BaseGame/game/core/postFX/scripts/Glow/VolFogGlowP.glsl


+ 0 - 0
Templates/BaseGame/game/core/rendering/shaders/postFX/VolFogGlowP.hlsl → Templates/BaseGame/game/core/postFX/scripts/Glow/VolFogGlowP.hlsl


+ 0 - 0
Templates/BaseGame/game/core/rendering/shaders/postFX/gl/glowBlurP.glsl → Templates/BaseGame/game/core/postFX/scripts/Glow/glowBlurP.glsl


+ 0 - 0
Templates/BaseGame/game/core/rendering/shaders/postFX/glowBlurP.hlsl → Templates/BaseGame/game/core/postFX/scripts/Glow/glowBlurP.hlsl


+ 0 - 0
Templates/BaseGame/game/core/rendering/shaders/postFX/gl/glowBlurV.glsl → Templates/BaseGame/game/core/postFX/scripts/Glow/glowBlurV.glsl


+ 0 - 0
Templates/BaseGame/game/core/rendering/shaders/postFX/glowBlurV.hlsl → Templates/BaseGame/game/core/postFX/scripts/Glow/glowBlurV.hlsl


+ 0 - 0
Templates/BaseGame/game/core/postFX/scripts/HDRPostFX.asset.taml → Templates/BaseGame/game/core/postFX/scripts/HDR/HDRPostFX.asset.taml


+ 115 - 99
Templates/BaseGame/game/core/postFX/scripts/HDRPostFX.cs → Templates/BaseGame/game/core/postFX/scripts/HDR/HDRPostFX.cs

@@ -22,63 +22,63 @@
 
 
 /// Blends between the scene and the tone mapped scene.
-$HDRPostFX::enableToneMapping = 0.5;
+$PostFX::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;
+$PostFX::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;
+$PostFX::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;
+$PostFX::HDRPostFX::whiteCutoff = 1.0;
 
 /// The rate of adaptation from the previous and new 
 /// average scene luminance. 
-$HDRPostFX::adaptRate = 2.0;
+$PostFX::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;
+$PostFX::HDRPostFX::enableBlueShift = 0.0;
 
 /// The blue shift color value.
-$HDRPostFX::blueShiftColor = "1.05 0.97 1.27";
+$PostFX::HDRPostFX::blueShiftColor = "1.05 0.97 1.27";
 
 
 /// Blends between the scene and the bloomed scene.
-$HDRPostFX::enableBloom = 1.0;
+$PostFX::HDRPostFX::enableBloom = 1.0;
 
 /// The threshold luminace value for pixels which are
 /// considered "bright" and need to be bloomed.
-$HDRPostFX::brightPassThreshold = 1.0;
+$PostFX::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;
+$PostFX::HDRPostFX::gaussMultiplier = 0.3;
+$PostFX::HDRPostFX::gaussMean = 0.0;
+$PostFX::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/postFX/images/null_color_ramp.png";
+// The tonemapping algo to use
+$PostFX::HDRPostFX::tonemapMode = "Filmic";
+
+$PostFX::HDRPostFX::enableAutoExposure = true;
 
 
 singleton ShaderData( HDR_BrightPassShader )
 {
    DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
-   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/hdr/brightPassFilterP.hlsl";   
+   DXPixelShaderFile 	= "./brightPassFilterP.hlsl";   
    OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
-   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/hdr/gl/brightPassFilterP.glsl";
+   OGLPixelShaderFile   = "./brightPassFilterP.glsl";
    
    samplerNames[0] = "$inputTex";
    samplerNames[1] = "$luminanceTex";
@@ -88,10 +88,10 @@ singleton ShaderData( HDR_BrightPassShader )
 
 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";
+   DXVertexShaderFile 	= "./downScale4x4V.hlsl";
+   DXPixelShaderFile 	= "./downScale4x4P.hlsl";
+   OGLVertexShaderFile  = "./downScale4x4V.glsl";
+   OGLPixelShaderFile   = "./downScale4x4P.glsl";
    
    samplerNames[0] = "$inputTex";
    
@@ -101,9 +101,9 @@ singleton ShaderData( HDR_DownScale4x4Shader )
 singleton ShaderData( HDR_BloomGaussBlurHShader )
 {
    DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
-   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/hdr/bloomGaussBlurHP.hlsl";
+   DXPixelShaderFile 	= "./bloomGaussBlurHP.hlsl";
    OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
-   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/hdr/gl/bloomGaussBlurHP.glsl";
+   OGLPixelShaderFile   = "./bloomGaussBlurHP.glsl";
    
    samplerNames[0] = "$inputTex";
    
@@ -113,9 +113,9 @@ singleton ShaderData( HDR_BloomGaussBlurHShader )
 singleton ShaderData( HDR_BloomGaussBlurVShader )
 {
    DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
-   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/hdr/bloomGaussBlurVP.hlsl";
+   DXPixelShaderFile 	= "./bloomGaussBlurVP.hlsl";
    OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
-   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/hdr/gl/bloomGaussBlurVP.glsl";
+   OGLPixelShaderFile   = "./bloomGaussBlurVP.glsl";
    
    samplerNames[0] = "$inputTex";
    
@@ -125,9 +125,9 @@ singleton ShaderData( HDR_BloomGaussBlurVShader )
 singleton ShaderData( HDR_SampleLumShader )
 {
    DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
-   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/hdr/sampleLumInitialP.hlsl";
+   DXPixelShaderFile 	= "./sampleLumInitialP.hlsl";
    OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
-   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/hdr/gl/sampleLumInitialP.glsl";
+   OGLPixelShaderFile   = "./sampleLumInitialP.glsl";
    
    samplerNames[0] = "$inputTex";
    
@@ -137,9 +137,9 @@ singleton ShaderData( HDR_SampleLumShader )
 singleton ShaderData( HDR_DownSampleLumShader )
 {
    DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
-   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/hdr/sampleLumIterativeP.hlsl";
+   DXPixelShaderFile 	= "./sampleLumIterativeP.hlsl";
    OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
-   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/hdr/gl/sampleLumIterativeP.glsl";
+   OGLPixelShaderFile   = "./sampleLumIterativeP.glsl";
    
    samplerNames[0] = "$inputTex";
    
@@ -149,9 +149,9 @@ singleton ShaderData( HDR_DownSampleLumShader )
 singleton ShaderData( HDR_CalcAdaptedLumShader )
 {
    DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
-   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/hdr/calculateAdaptedLumP.hlsl";
+   DXPixelShaderFile 	= "./calculateAdaptedLumP.hlsl";
    OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
-   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/hdr/gl/calculateAdaptedLumP.glsl";
+   OGLPixelShaderFile   = "./calculateAdaptedLumP.glsl";
    
    samplerNames[0] = "$currLum";
    samplerNames[1] = "$lastAdaptedLum";
@@ -162,9 +162,9 @@ singleton ShaderData( HDR_CalcAdaptedLumShader )
 singleton ShaderData( HDR_CombineShader )
 {
    DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
-   DXPixelShaderFile 	= $Core::CommonShaderPath @ "/postFX/hdr/finalPassCombineP.hlsl";
+   DXPixelShaderFile 	= "./finalPassCombineP.hlsl";
    OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
-   OGLPixelShaderFile   = $Core::CommonShaderPath @ "/postFX/hdr/gl/finalPassCombineP.glsl";
+   OGLPixelShaderFile   = "./finalPassCombineP.glsl";
    
    samplerNames[0] = "$sceneTex";
    samplerNames[1] = "$luminanceTex";
@@ -221,20 +221,20 @@ singleton GFXStateBlockData( HDRStateBlock )
 
 function HDRPostFX::setShaderConsts( %this )
 {
-   %this.setShaderConst( "$brightPassThreshold", $HDRPostFX::brightPassThreshold );
-   %this.setShaderConst( "$g_fMiddleGray", $HDRPostFX::keyValue );   
+   %this.setShaderConst( "$brightPassThreshold", $PostFX::HDRPostFX::brightPassThreshold );
+   %this.setShaderConst( "$g_fMiddleGray", $PostFX::HDRPostFX::keyValue );   
          
    %bloomH = %this-->bloomH;
-   %bloomH.setShaderConst( "$gaussMultiplier", $HDRPostFX::gaussMultiplier );
-   %bloomH.setShaderConst( "$gaussMean", $HDRPostFX::gaussMean );
-   %bloomH.setShaderConst( "$gaussStdDev", $HDRPostFX::gaussStdDev );   
+   %bloomH.setShaderConst( "$gaussMultiplier", $PostFX::HDRPostFX::gaussMultiplier );
+   %bloomH.setShaderConst( "$gaussMean", $PostFX::HDRPostFX::gaussMean );
+   %bloomH.setShaderConst( "$gaussStdDev", $PostFX::HDRPostFX::gaussStdDev );   
 
    %bloomV = %this-->bloomV;
-   %bloomV.setShaderConst( "$gaussMultiplier", $HDRPostFX::gaussMultiplier );
-   %bloomV.setShaderConst( "$gaussMean", $HDRPostFX::gaussMean );
-   %bloomV.setShaderConst( "$gaussStdDev", $HDRPostFX::gaussStdDev );   
+   %bloomV.setShaderConst( "$gaussMultiplier", $PostFX::HDRPostFX::gaussMultiplier );
+   %bloomV.setShaderConst( "$gaussMean", $PostFX::HDRPostFX::gaussMean );
+   %bloomV.setShaderConst( "$gaussStdDev", $PostFX::HDRPostFX::gaussStdDev );   
 
-   %minLuminace = $HDRPostFX::minLuminace;
+   %minLuminace = $PostFX::HDRPostFX::minLuminace;
    if ( %minLuminace <= 0.0 )
    {
       // The min should never be pure zero else the
@@ -243,22 +243,32 @@ function HDRPostFX::setShaderConsts( %this )
    }
    %this-->adaptLum.setShaderConst( "$g_fMinLuminace", %minLuminace );
         
-   %this-->finalLum.setShaderConst( "$adaptRate", $HDRPostFX::adaptRate );
+   %this-->finalLum.setShaderConst( "$adaptRate", $PostFX::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 );   
+   %combinePass.setShaderConst( "$g_fEnableToneMapping", $PostFX::HDRPostFX::enableToneMapping );
+   %combinePass.setShaderConst( "$g_fMiddleGray", $PostFX::HDRPostFX::keyValue );
+   %combinePass.setShaderConst( "$g_fBloomScale", $PostFX::HDRPostFX::enableBloom );      
+   %combinePass.setShaderConst( "$g_fEnableBlueShift", $PostFX::HDRPostFX::enableBlueShift );   
+   %combinePass.setShaderConst( "$g_fBlueShiftColor", $PostFX::HDRPostFX::blueShiftColor );   
+   
+   %combinePass.setShaderConst( "$g_fEnableAutoExposure", $PostFX::HDRPostFX::enableAutoExposure );
+   
+   %tonemapMode = 1;
+   if($PostFX::HDRPostFX::tonemapMode $= "Filmic")
+      %tonemapMode = 1;
+   else if($PostFX::HDRPostFX::tonemapMode $= "ACES")
+      %tonemapMode = 2;
+      
+   %combinePass.setShaderConst( "$g_fTonemapMode", %tonemapMode );
    
    %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 );                  
+   %whiteCutoff = ( $PostFX::HDRPostFX::whiteCutoff * $PostFX::HDRPostFX::whiteCutoff ) *
+                  ( $PostFX::HDRPostFX::whiteCutoff * $PostFX::HDRPostFX::whiteCutoff );                  
    %combinePass.setShaderConst( "$g_fWhiteCutoff", %whiteCutoff );
 }
 
@@ -266,8 +276,8 @@ function HDRPostFX::preProcess( %this )
 {
    %combinePass = %this-->combinePass;
    
-   if ( %combinePass.texture[3] !$= $HDRPostFX::colorCorrectionRamp )
-      %combinePass.setTexture( 3, $HDRPostFX::colorCorrectionRamp );         
+   if ( %combinePass.texture[3] !$= $PostFX::HDRPostFX::colorCorrectionRamp )
+      %combinePass.setTexture( 3, $PostFX::HDRPostFX::colorCorrectionRamp );         
 }
 
 function HDRPostFX::onEnabled( %this )
@@ -301,12 +311,16 @@ function HDRPostFX::onEnabled( %this )
    // hdr encoding takes effect in all the shaders and
    // that the offscreen surface is enabled.
    resetLightManager();
+   
+   $PostFX::HDRPostFX::Enabled = true;
          
    return true;
 }
 
 function HDRPostFX::onDisabled( %this )
 {
+   $PostFX::HDRPostFX::Enabled = false;
+   
    // Enable a special GammaCorrection PostFX when this is disabled.
    GammaPostFX.enable();
    
@@ -330,7 +344,7 @@ function HDRPostFX::onAdd( %this )
    //HDR should really be on at all times
    //%this.enable();
    
-   $HDRPostFX::enableToneMapping = 1;
+   $PostFX::HDRPostFX::enableToneMapping = 1;
 }
 
 //This is used to populate the PostFXEditor's settings so the post FX can be edited
@@ -339,62 +353,64 @@ function HDRPostFX::onAdd( %this )
 function HDRPostFX::populatePostFXSettings(%this)
 {
    PostEffectEditorInspector.startGroup("HDR - General");
-   PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::keyValue", "Key Value", "range", "", $HDRPostFX::keyValue, "0 1 10");
-   PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::minLuminace", "Minimum Luminance", "range", "", $HDRPostFX::minLuminace, "0 1 10");
-   PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::whiteCutoff", "White Cutoff", "range", "", $HDRPostFX::whiteCutoff, "0 1 10");
-   PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::adaptRate", "Brightness Adapt Rate", "range", "", $HDRPostFX::adaptRate, "0 1 10");
+   PostEffectEditorInspector.addCallbackField("$PostFX::HDRPostFX::Enabled", "Enabled", "bool", "", $PostFX::HDRPostFX::Enabled, "", "toggleHDRPostFX");
+   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::minLuminace", "Minimum Luminance", "range", "", $PostFX::HDRPostFX::minLuminace, "0 1 100");
+   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::whiteCutoff", "White Cutoff", "range", "", $PostFX::HDRPostFX::whiteCutoff, "0 10 20");
+   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::adaptRate", "Brightness Adapt Rate", "range", "", $PostFX::HDRPostFX::adaptRate, "0 1 10");
+   PostEffectEditorInspector.endGroup();
+   
+   PostEffectEditorInspector.startGroup("HDR - Tonemapping");
+   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::tonemapMode", "Tonemapping Mode", "list", "", $PostFX::HDRPostFX::tonemapMode, "Filmic,ACES");
    PostEffectEditorInspector.endGroup();
    
    PostEffectEditorInspector.startGroup("HDR - Bloom");
-   PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::enableBloom", "Enable Bloom", "bool", "", $HDRPostFX::enableBloom, "");
-   PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::brightPassThreshold", "Bright Pass Threshold", "float", "", $HDRPostFX::brightPassThreshold, "");
-   PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::gaussMultiplier", "Blur Multiplier", "float", "", $HDRPostFX::gaussMultiplier, "");
-   PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::gaussMean", "Blur \"Mean\" Value", "float", "", $HDRPostFX::gaussMean, "");
-   PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::gaussStdDev", "Blur \"Std. Dev\" Value", "float", "", $HDRPostFX::gaussStdDev, "");
+   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::enableBloom", "Enable Bloom", "bool", "", $PostFX::HDRPostFX::enableBloom, "");
+   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::brightPassThreshold", "Bright Pass Threshold", "float", "", $PostFX::HDRPostFX::brightPassThreshold, "");
+   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::gaussMultiplier", "Blur Multiplier", "range", "", $PostFX::HDRPostFX::gaussMultiplier, "0 1 10");
+   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::gaussMean", "Blur Mean Value", "range", "", $PostFX::HDRPostFX::gaussMean, "0 1 10");
+   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::gaussStdDev", "Blur Std. Dev Value", "range", "", $PostFX::HDRPostFX::gaussStdDev, "0 1 10");
    PostEffectEditorInspector.endGroup();
    
-   PostEffectEditorInspector.startGroup("HDR - Effects");
-   PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::enableBlueShift", "Enable Blue Shift", "bool", "", $HDRPostFX::enableBlueShift, "");
-   PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::blueShiftColor", "Blue Shift Color", "colorF", "", $HDRPostFX::blueShiftColor, "");
+   PostEffectEditorInspector.startGroup("HDR - Adaptation");
+   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::enableAutoExposure", "Enable Auto Exposure", "bool", "", $PostFX::HDRPostFX::enableAutoExposure, "");
+   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::keyValue", "Key Value", "range", "", $PostFX::HDRPostFX::keyValue, "0 1 10");
+   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::enableBlueShift", "Enable Blue Shift", "bool", "", $PostFX::HDRPostFX::enableBlueShift, "");
+   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::blueShiftColor", "Blue Shift Color", "colorF", "", $PostFX::HDRPostFX::blueShiftColor, "");
    PostEffectEditorInspector.endGroup();
 }
 
-//This function pair(applyFromPreset and settingsApply) are done the way they are, with the separated variables
-//so that we can effectively store the 'settings' away from the live variables that the postFX's actually utilize
-//when rendering. This allows us to modify things but still leave room for reverting or temporarily applying them
+function PostEffectEditorInspector::toggleHDRPostFX(%this)
+{
+   if($PostFX::HDRPostFX::Enabled)
+      HDRPostFX.enable();
+   else
+      HDRPostFX.disable();
+}
+
 function HDRPostFX::applyFromPreset(%this)
 {
-   //HDRPostFX Settings
-   $HDRPostFX::adaptRate               = $PostFXManager::Settings::HDR::adaptRate;
-   $HDRPostFX::blueShiftColor          = $PostFXManager::Settings::HDR::blueShiftColor;
-   $HDRPostFX::brightPassThreshold     = $PostFXManager::Settings::HDR::brightPassThreshold; 
-   $HDRPostFX::enableBloom             = $PostFXManager::Settings::HDR::enableBloom;
-   $HDRPostFX::enableBlueShift         = $PostFXManager::Settings::HDR::enableBlueShift;
-   $HDRPostFX::enableToneMapping       = $PostFXManager::Settings::HDR::enableToneMapping;
-   $HDRPostFX::gaussMean               = $PostFXManager::Settings::HDR::gaussMean;
-   $HDRPostFX::gaussMultiplier         = $PostFXManager::Settings::HDR::gaussMultiplier;
-   $HDRPostFX::gaussStdDev             = $PostFXManager::Settings::HDR::gaussStdDev;
-   $HDRPostFX::keyValue                = $PostFXManager::Settings::HDR::keyValue;
-   $HDRPostFX::minLuminace             = $PostFXManager::Settings::HDR::minLuminace;
-   $HDRPostFX::whiteCutoff             = $PostFXManager::Settings::HDR::whiteCutoff;
-   $HDRPostFX::colorCorrectionRamp     = $PostFXManager::Settings::ColorCorrectionRamp;
+   if($PostFX::HDRPostFX::Enabled)
+      HDRPostFX.enable();
+   else
+      HDRPostFX.disable();
 }
 
-function HDRPostFX::settingsApply(%this)
+function HDRPostFX::savePresetSettings(%this)
 {
-   $PostFXManager::Settings::HDR::adaptRate                 = $HDRPostFX::adaptRate;
-   $PostFXManager::Settings::HDR::blueShiftColor            = $HDRPostFX::blueShiftColor;
-   $PostFXManager::Settings::HDR::brightPassThreshold       = $HDRPostFX::brightPassThreshold;
-   $PostFXManager::Settings::HDR::enableBloom               = $HDRPostFX::enableBloom;
-   $PostFXManager::Settings::HDR::enableBlueShift           = $HDRPostFX::enableBlueShift;
-   $PostFXManager::Settings::HDR::enableToneMapping         = $HDRPostFX::enableToneMapping;
-   $PostFXManager::Settings::HDR::gaussMean                 = $HDRPostFX::gaussMean;
-   $PostFXManager::Settings::HDR::gaussMultiplier           = $HDRPostFX::gaussMultiplier;
-   $PostFXManager::Settings::HDR::gaussStdDev               = $HDRPostFX::gaussStdDev;
-   $PostFXManager::Settings::HDR::keyValue                  = $HDRPostFX::keyValue;
-   $PostFXManager::Settings::HDR::minLuminace               = $HDRPostFX::minLuminace;
-   $PostFXManager::Settings::HDR::whiteCutoff               = $HDRPostFX::whiteCutoff;
-   $PostFXManager::Settings::ColorCorrectionRamp            = $HDRPostFX::colorCorrectionRamp;
+   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::Enabled");
+   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::minLuminace");
+   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::whiteCutoff");
+   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::adaptRate");
+   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::tonemapMode");
+   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::enableBloom");
+   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::brightPassThreshold");
+   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::gaussMultiplier");
+   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::gaussMean");
+   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::gaussStdDev");
+   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::enableAutoExposure");
+   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::keyValue");
+   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::enableBlueShift");
+   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::blueShiftColor");
 }
 
 singleton PostEffect( HDRPostFX )
@@ -537,7 +553,7 @@ singleton PostEffect( HDRPostFX )
       texture[0] = "$backBuffer";
       texture[1] = "#adaptedLum";            
       texture[2] = "#bloomFinal";
-      texture[3] = $HDRPostFX::colorCorrectionRamp;
+      texture[3] = $PostFX::HDRPostFX::colorCorrectionRamp;
       target = "$backBuffer";
    };
 };
@@ -562,7 +578,7 @@ singleton GFXStateBlockData( LuminanceVisStateBlock : PFX_DefaultStateBlock )
 
 function LuminanceVisPostFX::setShaderConsts( %this )
 {
-   %this.setShaderConst( "$brightPassThreshold", $HDRPostFX::brightPassThreshold );
+   %this.setShaderConst( "$brightPassThreshold", $PostFX::HDRPostFX::brightPassThreshold );
 }
 
 singleton PostEffect( LuminanceVisPostFX )

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/bloomGaussBlurHP.glsl → Templates/BaseGame/game/core/postFX/scripts/HDR/bloomGaussBlurHP.glsl

@@ -20,9 +20,9 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../../gl/hlslCompat.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
 #include "shadergen:/autogenConditioners.h"
-#include "../../gl/postFx.glsl"
+#include "core/rendering/shaders/postFX/gl/postFx.glsl"
 
 uniform sampler2D inputTex ;
 uniform vec2 oneOverTargetSize;

+ 44 - 1
Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/bloomGaussBlurHP.hlsl → Templates/BaseGame/game/core/postFX/scripts/HDR/bloomGaussBlurHP.hlsl

@@ -20,7 +20,7 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../postFx.hlsl"
+#include "core/rendering/shaders/postFX/postFx.hlsl"
 
 TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
 uniform float2 oneOverTargetSize;
@@ -47,6 +47,46 @@ float computeGaussianValue( float x, float mean, float std_deviation )
     return tmp * tmp2;
 }
 
+float SCurve (float x) 
+{
+		x = x * 2.0 - 1.0;
+		return -x * abs(x) * 0.5 + x + 0.5;
+}
+
+float4 BlurH (TORQUE_SAMPLER2D(source), float2 size, float2 uv, float radius) 
+{
+	if (radius >= 1.0)
+	{
+		float4 A = float4(0.0,0.0,0.0,0.0); 
+		float4 C = float4(0.0,0.0,0.0,0.0); 
+
+		float width = 1.0 / size.x;
+
+      float divisor = 0.0; 
+      float weight = 0.0;
+
+      float radiusMultiplier = 1.0 / radius;
+
+      // Hardcoded for radius 20 (normally we input the radius
+      // in there), needs to be literal here
+
+      for (float x = -20.0; x <= 20.0; x++)
+      {
+         A = TORQUE_TEX2D(source, uv + float2(x * width, 0.0));
+
+         weight = SCurve(1.0 - (abs(x) * radiusMultiplier)); 
+
+         C += A * weight; 
+
+         divisor += weight; 
+      }
+
+		return float4(C.r / divisor, C.g / divisor, C.b / divisor, 1.0);
+	}
+
+	return TORQUE_TEX2D(source, uv);
+}
+
 float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
 {
    float4 color = { 0.0f, 0.0f, 0.0f, 0.0f };
@@ -63,6 +103,9 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
       weight = gaussMultiplier * computeGaussianValue( x, gaussMean, gaussStdDev );
       color += (TORQUE_TEX2D( inputTex, IN.uv0 + float2( offset, 0.0f ) ) * weight );
    }
+
+   //float2 targetSize = 1/oneOverTargetSize;
+   //float4 color = BlurH(TORQUE_SAMPLER2D_MAKEARG(inputTex), targetSize, IN.uv0, 20.0);
    
    return float4( color.rgb, 1.0f );
 }

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/bloomGaussBlurVP.glsl → Templates/BaseGame/game/core/postFX/scripts/HDR/bloomGaussBlurVP.glsl

@@ -20,9 +20,9 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../../gl/hlslCompat.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
 #include "shadergen:/autogenConditioners.h"
-#include "../../gl/postFx.glsl"
+#include "core/rendering/shaders/postFX/gl/postFx.glsl"
 
 uniform sampler2D inputTex ;
 uniform vec2 oneOverTargetSize;

+ 42 - 1
Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/bloomGaussBlurVP.hlsl → Templates/BaseGame/game/core/postFX/scripts/HDR/bloomGaussBlurVP.hlsl

@@ -20,7 +20,7 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../postFx.hlsl"
+#include "core/rendering/shaders/postFX/postFx.hlsl"
 
 TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
 uniform float2 oneOverTargetSize;
@@ -46,6 +46,44 @@ float computeGaussianValue( float x, float mean, float std_deviation )
     return tmp * tmp2;
 }
 
+float SCurve (float x) 
+{
+		x = x * 2.0 - 1.0;
+		return -x * abs(x) * 0.5 + x + 0.5;
+}
+
+float4 BlurV (TORQUE_SAMPLER2D(source), float2 size, float2 uv, float radius) 
+{
+	if (radius >= 1.0)
+	{
+		float4 A = float4(0.0,0.0,0.0,0.0); 
+		float4 C = float4(0.0,0.0,0.0,0.0); 
+
+		float height = 1.0 / size.y;
+
+		float divisor = 0.0; 
+      float weight = 0.0;
+
+      float radiusMultiplier = 1.0 / radius;
+
+      for (float y = -20.0; y <= 20.0; y++)
+      {
+         A = TORQUE_TEX2D(source, uv + float2(0.0, y * height));
+
+         weight = SCurve(1.0 - (abs(y) * radiusMultiplier)); 
+
+         C += A * weight; 
+
+         divisor += weight; 
+      }
+
+		return float4(C.r / divisor, C.g / divisor, C.b / divisor, 1.0);
+	}
+
+	return TORQUE_TEX2D(source, uv);
+}
+
+
 float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
 {
    float4 color = { 0.0f, 0.0f, 0.0f, 0.0f };
@@ -63,5 +101,8 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
       color += (TORQUE_TEX2D( inputTex, IN.uv0 + float2( 0.0f, offset ) ) * weight );
    }
 
+   //float2 targetSize = 1/oneOverTargetSize;
+   //float4 color = BlurV(TORQUE_SAMPLER2D_MAKEARG(inputTex), targetSize, IN.uv0, 20.0);
+
    return float4( color.rgb, 1.0f );
 }

+ 3 - 3
Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/brightPassFilterP.glsl → Templates/BaseGame/game/core/postFX/scripts/HDR/brightPassFilterP.glsl

@@ -20,10 +20,10 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../../gl/torque.glsl"
-#include "../../../gl/hlslCompat.glsl"
+#include "core/rendering/shaders/gl/torque.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
 #include "shadergen:/autogenConditioners.h"
-#include "../../gl/postFx.glsl"
+#include "core/rendering/shaders/postFX/gl/postFx.glsl"
 
 uniform sampler2D inputTex ;
 uniform sampler2D luminanceTex  ;

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/brightPassFilterP.hlsl → Templates/BaseGame/game/core/postFX/scripts/HDR/brightPassFilterP.hlsl

@@ -20,8 +20,8 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../postFx.hlsl"
-#include "../../torque.hlsl"
+#include "core/rendering/shaders/postFX/postFx.hlsl"
+#include "core/rendering/shaders/torque.hlsl"
 
 
 TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/calculateAdaptedLumP.glsl → Templates/BaseGame/game/core/postFX/scripts/HDR/calculateAdaptedLumP.glsl

@@ -20,9 +20,9 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../../gl/hlslCompat.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
 #include "shadergen:/autogenConditioners.h"
-#include "../../gl/postFx.glsl"
+#include "core/rendering/shaders/postFX/gl/postFx.glsl"
 
 uniform sampler2D currLum;
 uniform sampler2D lastAdaptedLum;

+ 1 - 1
Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/calculateAdaptedLumP.hlsl → Templates/BaseGame/game/core/postFX/scripts/HDR/calculateAdaptedLumP.hlsl

@@ -20,7 +20,7 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../postFx.hlsl"
+#include "core/rendering/shaders/postFX/postFx.hlsl"
 
 TORQUE_UNIFORM_SAMPLER2D(currLum, 0);
 TORQUE_UNIFORM_SAMPLER2D(lastAdaptedLum, 1);

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/downScale4x4P.glsl → Templates/BaseGame/game/core/postFX/scripts/HDR/downScale4x4P.glsl

@@ -21,8 +21,8 @@
 //-----------------------------------------------------------------------------
 
 #define IN_GLSL
-#include "../../../shdrConsts.h"
-#include "../../../gl/hlslCompat.glsl"
+#include "core/rendering/shaders/shdrConsts.h"
+#include ".core/rendering/shaders/gl/hlslCompat.glsl"
 #include "shadergen:/autogenConditioners.h"
 
 in vec4 texCoords[8];

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/downScale4x4P.hlsl → Templates/BaseGame/game/core/postFX/scripts/HDR/downScale4x4P.hlsl

@@ -21,8 +21,8 @@
 //-----------------------------------------------------------------------------
 
 #define IN_HLSL
-#include "../../shdrConsts.h"
-#include "../postFx.hlsl"
+#include "core/rendering/shaders/shdrConsts.h"
+#include "core/rendering/shaders/postFX/postFx.hlsl"
 
 //-----------------------------------------------------------------------------
 // Data 

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/downScale4x4V.glsl → Templates/BaseGame/game/core/postFX/scripts/HDR/downScale4x4V.glsl

@@ -21,8 +21,8 @@
 //-----------------------------------------------------------------------------
 
 #define IN_GLSL
-#include "../../../shdrConsts.h"
-#include "../../../gl/hlslCompat.glsl"
+#include "core/rendering/shaders/shdrConsts.h"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
 
 in vec4 vPosition;
 in vec2 vTexCoord0;

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/downScale4x4V.hlsl → Templates/BaseGame/game/core/postFX/scripts/HDR/downScale4x4V.hlsl

@@ -21,8 +21,8 @@
 //-----------------------------------------------------------------------------
 
 #define IN_HLSL
-#include "../../shdrConsts.h"
-#include "../postFx.hlsl"
+#include "core/rendering/shaders/shdrConsts.h"
+#include "core/rendering/shaders/postFX/postFx.hlsl"
 //-----------------------------------------------------------------------------
 // Constants
 //-----------------------------------------------------------------------------

+ 42 - 17
Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/finalPassCombineP.glsl → Templates/BaseGame/game/core/postFX/scripts/HDR/finalPassCombineP.glsl

@@ -20,15 +20,14 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../../gl/torque.glsl"
-#include "../../../gl/hlslCompat.glsl"
-#include "../../gl/postFx.glsl"
+#include "core/rendering/shaders/gl/torque.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
+#include "core/rendering/shaders/postFX/gl/postFx.glsl"
 #include "shadergen:/autogenConditioners.h"
 
 uniform sampler2D sceneTex;
 uniform sampler2D luminanceTex;
 uniform sampler2D bloomTex;
-uniform sampler1D colorCorrectionTex;
 
 uniform vec2 texSize0;
 uniform vec2 texSize2;
@@ -37,6 +36,9 @@ uniform float g_fEnableToneMapping;
 uniform float g_fMiddleGray;
 uniform float g_fWhiteCutoff;
 
+uniform float g_fEnableAutoExposure;
+uniform float g_fTonemapMode;
+
 uniform float g_fEnableBlueShift;
 uniform vec3 g_fBlueShiftColor; 
 
@@ -60,15 +62,38 @@ vec3 Uncharted2Tonemap(vec3 x)
    return ((x*(A*x + C*B) + D*E) / (x*(A*x + B) + D*F)) - E / F;
 }
 
+float3 ACESFilm( float3 x )
+{
+    const float a = 2.51;
+    const float b = 0.03;
+    const float c = 2.43;
+    const float d = 0.59;
+    const float e = 0.14;
+    return sat((x*(a*x+b))/(x*(c*x+d)+e));
+}
+
 vec3 tonemap(vec3 c)
 {
-   const float W = 11.2;
-   float ExposureBias = 2.0f;
-   float ExposureAdjust = 1.5f;
-   c *= ExposureAdjust;
-   vec3 curr = Uncharted2Tonemap(ExposureBias*c);
-   vec3 whiteScale = 1.0f / Uncharted2Tonemap(vec3(W,W,W));
-   return curr*whiteScale;
+   vec3 colorOut = c;
+
+   if(g_fTonemapMode == 1.0)
+   {
+      const float W = 11.2;
+      float ExposureBias = 2.0f;
+      float ExposureAdjust = 1.5f;
+      c *= ExposureAdjust;
+      vec3 curr = Uncharted2Tonemap(ExposureBias*c);
+      vec3 whiteScale = 1.0f / Uncharted2Tonemap(vec3(W,W,W));
+
+      colorOut = curr*whiteScale;
+   }
+   }
+   else if(g_fTonemapMode == 2.0)
+   {
+      colorOut = ACESFilm(c);
+   }
+
+   return colorOut;
 }
 
 void main()
@@ -100,11 +125,6 @@ void main()
    // Add the bloom effect.
    _sample += g_fBloomScale * bloom;
 
-   // Apply the color correction.
-   _sample.r = texture( colorCorrectionTex, _sample.r ).r;
-   _sample.g = texture( colorCorrectionTex, _sample.g ).g;
-   _sample.b = texture( colorCorrectionTex, _sample.b ).b;
-
    // Apply contrast
    _sample.rgb = ((_sample.rgb - 0.5f) * Contrast) + 0.5f;
 
@@ -114,7 +134,12 @@ void main()
    //tonemapping - TODO fix up eye adaptation
    if ( g_fEnableToneMapping > 0.0f )
    {
-      _sample.rgb = tonemap(_sample.rgb);
+      float adapation = 1;
+
+      if ( g_fEnableAutoExposure > 0.0f )
+         adapation = (g_fMiddleGray / (adaptedLum + 0.0001)) * hdrLuminance( _sample.rgb );
+
+      _sample.rgb = tonemap(_sample.rgb * adapation);
    }
 
    OUT_col = _sample;

+ 35 - 16
Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/finalPassCombineP.hlsl → Templates/BaseGame/game/core/postFX/scripts/HDR/finalPassCombineP.hlsl

@@ -20,14 +20,13 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../torque.hlsl"
-#include "../postFx.hlsl"
-#include "../../shaderModelAutoGen.hlsl"
+#include "core/rendering/shaders/torque.hlsl"
+#include "core/rendering/shaders/postFX/postFx.hlsl"
+#include "core/rendering/shaders/shaderModelAutoGen.hlsl"
 
 TORQUE_UNIFORM_SAMPLER2D(sceneTex, 0);
 TORQUE_UNIFORM_SAMPLER2D(luminanceTex, 1);
 TORQUE_UNIFORM_SAMPLER2D(bloomTex, 2);
-TORQUE_UNIFORM_SAMPLER1D(colorCorrectionTex, 3);
 
 uniform float2 texSize0;
 uniform float2 texSize2;
@@ -37,6 +36,9 @@ uniform float g_fMiddleGray;
 uniform float g_fWhiteCutoff;
 uniform float g_fEnableBlueShift;
 
+uniform float g_fEnableAutoExposure;
+uniform float g_fTonemapMode;
+
 uniform float3 g_fBlueShiftColor;
 uniform float g_fBloomScale;
 uniform float g_fOneOverGamma;
@@ -55,14 +57,31 @@ float3 Uncharted2Tonemap(const float3 x)
    return ((x*(A*x + C*B) + D*E) / (x*(A*x + B) + D*F)) - E / F;
 }
 
+float3 ACESFilm( float3 x )
+{
+    const float a = 2.51;
+    const float b = 0.03;
+    const float c = 2.43;
+    const float d = 0.59;
+    const float e = 0.14;
+    return saturate((x*(a*x+b))/(x*(c*x+d)+e));
+}
+
 float3 tonemap(float3 color)
 {
-   const float W = 11.2;
-   float ExposureBias = 2.0f;
-   //float ExposureAdjust = 1.5f;
-   //c *= ExposureAdjust;
-   color = Uncharted2Tonemap(ExposureBias*color);
-   color = color * (1.0f / Uncharted2Tonemap(W));
+   if(g_fTonemapMode == 1.0)
+   {
+      const float W = 11.2;
+      float ExposureBias = 2.0f;
+      //float ExposureAdjust = 1.5f;
+      //c *= ExposureAdjust;
+      color = Uncharted2Tonemap(ExposureBias*color);
+      color = color * (1.0f / Uncharted2Tonemap(W));
+   }
+   else if(g_fTonemapMode == 2.0)
+   {
+      color = ACESFilm(color);
+   }
 
    return color;
 }
@@ -96,11 +115,6 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
    // Add the bloom effect.
    sample += g_fBloomScale * bloom;
 
-   // Apply the color correction.
-   sample.r = TORQUE_TEX1D( colorCorrectionTex, sample.r ).r;
-   sample.g = TORQUE_TEX1D( colorCorrectionTex, sample.g ).g;
-   sample.b = TORQUE_TEX1D( colorCorrectionTex, sample.b ).b;
-
    // Apply contrast
    sample.rgb = ((sample.rgb - 0.5f) * Contrast) + 0.5f;
 
@@ -110,7 +124,12 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
    //tonemapping - TODO fix up eye adaptation
    if ( g_fEnableToneMapping > 0.0f )
    {
-      sample.rgb = tonemap(sample.rgb);
+      float adapation = 1;
+
+      if( g_fEnableAutoExposure > 0.0f )
+         adapation = (g_fMiddleGray / (adaptedLum + 0.0001)) * hdrLuminance( sample.rgb );
+
+      sample.rgb = tonemap(sample.rgb * adapation);
    }
 
    return sample;

+ 3 - 3
Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/luminanceVisP.glsl → Templates/BaseGame/game/core/postFX/scripts/HDR/luminanceVisP.glsl

@@ -20,10 +20,10 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../../gl/torque.glsl"
-#include "../../../gl/hlslCompat.glsl"
+#include "core/rendering/shaders/gl/torque.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
 #include "shadergen:/autogenConditioners.h"
-#include "../../gl/postFx.glsl"
+#include "core/rendering/shaders/postFX/gl/postFx.glsl"
 
 uniform sampler2D inputTex;
 uniform float brightPassThreshold;

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/luminanceVisP.hlsl → Templates/BaseGame/game/core/postFX/scripts/HDR/luminanceVisP.hlsl

@@ -20,8 +20,8 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../postFx.hlsl"
-#include "../../torque.hlsl"
+#include "core/rendering/shaders/postFX/postFx.hlsl"
+#include "core/rendering/shaders/torque.hlsl"
 
 
 TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);

+ 3 - 3
Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/gl/sampleLumInitialP.glsl → Templates/BaseGame/game/core/postFX/scripts/HDR/sampleLumInitialP.glsl

@@ -20,9 +20,9 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../../gl/torque.glsl"
-#include "../../../gl/hlslCompat.glsl"
-#include "../../gl/postFx.glsl"
+#include "core/rendering/shaders/gl/torque.glsl"
+#include "core/rendering/shaders/gl/hlslCompat.glsl"
+#include "core/rendering/shaders/postFX/gl/postFx.glsl"
 
 uniform sampler2D inputTex;
 uniform vec2 texSize0;

+ 2 - 2
Templates/BaseGame/game/core/rendering/shaders/postFX/hdr/sampleLumInitialP.hlsl → Templates/BaseGame/game/core/postFX/scripts/HDR/sampleLumInitialP.hlsl

@@ -20,8 +20,8 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "../../torque.hlsl"
-#include "../postFx.hlsl"
+#include "core/rendering/shaders/torque.hlsl"
+#include "core/rendering/shaders/postFX/postFx.hlsl"
 
 TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
 uniform float2 texSize0;

部分文件因为文件数量过多而无法显示