瀏覽代碼

Re-submission of the Volumetric Fog PR, with cleanup.

Areloch 9 年之前
父節點
當前提交
a90eb9762b
共有 62 個文件被更改,包括 2035 次插入6 次删除
  1. 3 0
      Engine/source/gui/core/guiCanvas.cpp
  2. 10 0
      Engine/source/gui/core/guiCanvas.h
  3. 1 0
      Engine/source/renderInstance/renderPassManager.cpp
  4. 1 0
      Engine/source/renderInstance/renderPassManager.h
  5. 10 0
      Engine/source/renderInstance/renderTranslucentMgr.cpp
  6. 6 1
      Engine/source/windowManager/platformWindow.cpp
  7. 8 3
      Engine/source/windowManager/platformWindow.h
  8. 2 0
      Engine/source/windowManager/win32/win32Window.cpp
  9. 二進制
      Templates/Empty/game/art/environment/FogMod_heavy.dds
  10. 二進制
      Templates/Empty/game/art/environment/FogMod_light.dds
  11. 二進制
      Templates/Empty/game/art/environment/FogMod_med.dds
  12. 97 0
      Templates/Empty/game/art/environment/Fog_Cube.DAE
  13. 8 0
      Templates/Empty/game/art/environment/Fog_Cube.cs
  14. 76 0
      Templates/Empty/game/core/scripts/client/postFx/glow.cs
  15. 1 0
      Templates/Empty/game/core/scripts/client/postFx/postFxManager.gui.settings.cs
  16. 2 0
      Templates/Empty/game/core/scripts/client/renderManager.cs
  17. 106 0
      Templates/Empty/game/scripts/server/VolumetricFog.cs
  18. 1 0
      Templates/Empty/game/scripts/server/scriptExec.cs
  19. 87 0
      Templates/Empty/game/shaders/common/VolumetricFog/VFogP.hlsl
  20. 39 0
      Templates/Empty/game/shaders/common/VolumetricFog/VFogPreP.hlsl
  21. 46 0
      Templates/Empty/game/shaders/common/VolumetricFog/VFogPreV.hlsl
  22. 36 0
      Templates/Empty/game/shaders/common/VolumetricFog/VFogRefl.hlsl
  23. 45 0
      Templates/Empty/game/shaders/common/VolumetricFog/VFogV.hlsl
  24. 87 0
      Templates/Empty/game/shaders/common/VolumetricFog/gl/VFogP.glsl
  25. 37 0
      Templates/Empty/game/shaders/common/VolumetricFog/gl/VFogPreP.glsl
  26. 42 0
      Templates/Empty/game/shaders/common/VolumetricFog/gl/VFogPreV.glsl
  27. 33 0
      Templates/Empty/game/shaders/common/VolumetricFog/gl/VFogRefl.glsl
  28. 38 0
      Templates/Empty/game/shaders/common/VolumetricFog/gl/VFogV.glsl
  29. 74 0
      Templates/Empty/game/shaders/common/postFx/VolFogGlowP.hlsl
  30. 67 0
      Templates/Empty/game/shaders/common/postFx/gl/VolFogGlowP.glsl
  31. 二進制
      Templates/Empty/game/tools/classIcons/VolumetricFog.png
  32. 13 1
      Templates/Empty/game/tools/worldEditor/gui/objectBuilderGui.ed.gui
  33. 1 0
      Templates/Empty/game/tools/worldEditor/scripts/editors/creator.ed.cs
  34. 二進制
      Templates/Full/game/art/environment/FogMod_heavy.dds
  35. 二進制
      Templates/Full/game/art/environment/FogMod_light.dds
  36. 二進制
      Templates/Full/game/art/environment/FogMod_med.dds
  37. 97 0
      Templates/Full/game/art/environment/Fog_Cube.DAE
  38. 8 0
      Templates/Full/game/art/environment/Fog_Cube.cs
  39. 77 0
      Templates/Full/game/art/environment/LightVolume_Sphere.DAE
  40. 8 0
      Templates/Full/game/art/environment/LightVolume_Sphere.cs
  41. 二進制
      Templates/Full/game/art/environment/LightVolume_Sphere.dts
  42. 76 0
      Templates/Full/game/core/scripts/client/postFx/glow.cs
  43. 1 0
      Templates/Full/game/core/scripts/client/postFx/postFxManager.gui.settings.cs
  44. 2 0
      Templates/Full/game/core/scripts/client/renderManager.cs
  45. 36 0
      Templates/Full/game/core/scripts/client/shaders.cs
  46. 106 0
      Templates/Full/game/scripts/server/VolumetricFog.cs
  47. 1 0
      Templates/Full/game/scripts/server/scriptExec.cs
  48. 87 0
      Templates/Full/game/shaders/common/VolumetricFog/VFogP.hlsl
  49. 39 0
      Templates/Full/game/shaders/common/VolumetricFog/VFogPreP.hlsl
  50. 46 0
      Templates/Full/game/shaders/common/VolumetricFog/VFogPreV.hlsl
  51. 37 0
      Templates/Full/game/shaders/common/VolumetricFog/VFogRefl.hlsl
  52. 45 0
      Templates/Full/game/shaders/common/VolumetricFog/VFogV.hlsl
  53. 87 0
      Templates/Full/game/shaders/common/VolumetricFog/gl/VFogP.glsl
  54. 37 0
      Templates/Full/game/shaders/common/VolumetricFog/gl/VFogPreP.glsl
  55. 42 0
      Templates/Full/game/shaders/common/VolumetricFog/gl/VFogPreV.glsl
  56. 33 0
      Templates/Full/game/shaders/common/VolumetricFog/gl/VFogRefl.glsl
  57. 38 0
      Templates/Full/game/shaders/common/VolumetricFog/gl/VFogV.glsl
  58. 74 0
      Templates/Full/game/shaders/common/postFx/VolFogGlowP.hlsl
  59. 67 0
      Templates/Full/game/shaders/common/postFx/gl/VolFogGlowP.glsl
  60. 二進制
      Templates/Full/game/tools/classIcons/VolumetricFog.png
  61. 13 1
      Templates/Full/game/tools/worldEditor/gui/objectBuilderGui.ed.gui
  62. 1 0
      Templates/Full/game/tools/worldEditor/scripts/editors/creator.ed.cs

+ 3 - 0
Engine/source/gui/core/guiCanvas.cpp

@@ -321,8 +321,11 @@ void GuiCanvas::setWindowTitle(const char *newTitle)
       mPlatformWindow->setCaption(newTitle);
 }
 
+CanvasSizeChangeSignal GuiCanvas::smCanvasSizeChangeSignal;
+
 void GuiCanvas::handleResize( WindowId did, S32 width, S32 height )
 {
+   getCanvasSizeChangeSignal().trigger(this);
 	if (Journal::IsPlaying() && mPlatformWindow)
 	{
 		mPlatformWindow->lockSize(false);

+ 10 - 0
Engine/source/gui/core/guiCanvas.h

@@ -33,6 +33,10 @@
 #include "platform/platformInput.h"
 #endif
 
+#ifndef _SIGNAL_H_
+#include "core/util/tSignal.h"
+#endif
+
 #include "component/interfaces/IProcessInput.h"
 #include "windowManager/platformWindowMgr.h"
 #include "gfx/gfxFence.h"
@@ -74,6 +78,8 @@
 /// screen will be painted normally. If you are making an animated GuiControl
 /// you need to add your control to the dirty areas of the canvas.
 ///
+class guiCanvas;
+typedef Signal<void(GuiCanvas* canvas)> CanvasSizeChangeSignal;
 class GuiCanvas : public GuiControl, public IProcessInput
 {
 
@@ -183,6 +189,8 @@ protected:
    virtual void setupFences();
    
    void checkLockMouseMove( const GuiEvent& event );
+   //Signal used to let others know this canvas has changed size.
+	static CanvasSizeChangeSignal smCanvasSizeChangeSignal;
 
    GuiControl *mMenuBarCtrl;
 
@@ -200,6 +208,8 @@ public:
 
    static void initPersistFields();
 
+   static CanvasSizeChangeSignal& getCanvasSizeChangeSignal() { return smCanvasSizeChangeSignal; }
+
    /// @name Rendering methods
    ///
    /// @{

+ 1 - 0
Engine/source/renderInstance/renderPassManager.cpp

@@ -53,6 +53,7 @@ const RenderInstType RenderPassManager::RIT_ObjectTranslucent("ObjectTranslucent
 const RenderInstType RenderPassManager::RIT_Decal("Decal");
 const RenderInstType RenderPassManager::RIT_Water("Water");
 const RenderInstType RenderPassManager::RIT_Foliage("Foliage");
+const RenderInstType RenderPassManager::RIT_VolumetricFog("ObjectVolumetricFog");
 const RenderInstType RenderPassManager::RIT_Translucent("Translucent");
 const RenderInstType RenderPassManager::RIT_Begin("Begin");
 const RenderInstType RenderPassManager::RIT_Custom("Custom");

+ 1 - 0
Engine/source/renderInstance/renderPassManager.h

@@ -110,6 +110,7 @@ public:
    static const RenderInstType RIT_Decal;
    static const RenderInstType RIT_Water;
    static const RenderInstType RIT_Foliage;
+   static const RenderInstType RIT_VolumetricFog;
    static const RenderInstType RIT_Translucent;
    static const RenderInstType RIT_Begin;
    static const RenderInstType RIT_Custom;

+ 10 - 0
Engine/source/renderInstance/renderTranslucentMgr.cpp

@@ -51,6 +51,7 @@ RenderTranslucentMgr::RenderTranslucentMgr()
 {
    notifyType( RenderPassManager::RIT_ObjectTranslucent );
    notifyType( RenderPassManager::RIT_Particle );
+   notifyType( RenderPassManager::RIT_VolumetricFog);
 }
 
 RenderTranslucentMgr::~RenderTranslucentMgr()
@@ -187,6 +188,15 @@ void RenderTranslucentMgr::render( SceneRenderState *state )
          j++;
          continue;
       }
+      else if (baseRI->type == RenderPassManager::RIT_VolumetricFog)
+	   {
+	      ObjectRenderInst* objRI = static_cast<ObjectRenderInst*>(baseRI);
+	      objRI->renderDelegate(objRI, state, NULL);
+	      lastVB = NULL;
+	      lastPB = NULL;
+	      j++;
+	      continue;
+	   }
       else if ( baseRI->type == RenderPassManager::RIT_Particle )
       {
          ParticleRenderInst *ri = static_cast<ParticleRenderInst*>(baseRI);

+ 6 - 1
Engine/source/windowManager/platformWindow.cpp

@@ -22,7 +22,7 @@
 
 #include "windowManager/platformWindow.h"
 
-
+ScreenResChangeSignal PlatformWindow::smScreenResChangeSignal;
 //-----------------------------------------------------------------------------
 
 void PlatformWindow::setFullscreen( const bool fullscreen )
@@ -48,3 +48,8 @@ bool PlatformWindow::shouldNotTranslate( U32 modifiers, U32 keyCode ) const
    else
       return false;
 }
+void PlatformWindow::setVideoMode(const GFXVideoMode &mode)
+{
+   _setVideoMode(mode);
+	getScreenResChangeSignal().trigger(this, true);
+}

+ 8 - 3
Engine/source/windowManager/platformWindow.h

@@ -28,6 +28,9 @@
 #include "core/util/safeDelete.h"
 #include "windowManager/platformCursorController.h"
 #include "windowManager/windowInputGenerator.h"
+#ifndef _SIGNAL_H_ //Volumetric Fog
+#include "core/util/tSignal.h"
+#endif
 
 //forward decl's
 class PlatformWindowManager;
@@ -35,7 +38,7 @@ class GFXDevice;
 struct GFXVideoMode;
 class GFXWindowTarget;
 class IProcessInput;
-
+typedef Signal<void(PlatformWindow *PlatformWindow, bool resize)> ScreenResChangeSignal;
 /// Abstract representation of a native OS window.
 ///
 /// Every windowing system has its own representations and conventions as
@@ -110,7 +113,7 @@ protected:
       // This controller maps window input (Mouse/Keyboard) to a generic input consumer
       mWindowInputGenerator = new WindowInputGenerator( this );
    }
-
+   static ScreenResChangeSignal smScreenResChangeSignal;
 public:
 
    /// To get rid of a window, just delete it. Make sure the GFXDevice is
@@ -158,7 +161,7 @@ public:
    virtual GFXWindowTarget *getGFXTarget()=0;
 
    /// Set the video mode for this window.
-   virtual void setVideoMode(const GFXVideoMode &mode)=0;
+   virtual void setVideoMode(const GFXVideoMode &mode);
 
    /// Get our current video mode - if the window has been resized, it will
    /// reflect this.
@@ -497,6 +500,7 @@ public:
    IdleEvent         idleEvent;
 
    /// @}
+   static ScreenResChangeSignal& getScreenResChangeSignal() { return smScreenResChangeSignal; }
    
    /// Get the platform specific object needed to create or attach an accelerated
    /// graohics drawing context on or to the window
@@ -507,6 +511,7 @@ public:
    virtual void* getPlatformDrawable() const = 0;
 protected:
    virtual void _setFullscreen(const bool fullScreen) {};
+   virtual void _setVideoMode(const GFXVideoMode &mode) {};
 };
 
 #endif

+ 2 - 0
Engine/source/windowManager/win32/win32Window.cpp

@@ -287,6 +287,8 @@ void Win32Window::setVideoMode( const GFXVideoMode &mode )
 		mOwningManager->raiseCurtain();
 
 	SetForegroundWindow(getHWND());
+
+   getScreenResChangeSignal().trigger(this, true);
 }
 
 bool Win32Window::clearFullscreen()

二進制
Templates/Empty/game/art/environment/FogMod_heavy.dds


二進制
Templates/Empty/game/art/environment/FogMod_light.dds


二進制
Templates/Empty/game/art/environment/FogMod_med.dds


File diff suppressed because it is too large
+ 97 - 0
Templates/Empty/game/art/environment/Fog_Cube.DAE


+ 8 - 0
Templates/Empty/game/art/environment/Fog_Cube.cs

@@ -0,0 +1,8 @@
+
+singleton TSShapeConstructor(Fog_CubeDAE)
+{
+   baseShape = "./Fog_Cube.DAE";
+   lodType = "TrailingNumber";
+   neverImport = "env*";
+   loadLights = "0";
+};

+ 76 - 0
Templates/Empty/game/core/scripts/client/postFx/glow.cs

@@ -106,3 +106,79 @@ singleton PostEffect( GlowPostFx )
       target = "$backBuffer";
    };
 };
+
+singleton ShaderData( PFX_VolFogGlowBlurVertShader )
+{
+	DXVertexShaderFile = "shaders/common/postFx/glowBlurV.hlsl";
+	DXPixelShaderFile = "shaders/common/postFx/VolFogGlowP.hlsl";
+	
+	OGLVertexShaderFile = "shaders/common/postFx/gl/glowBlurV.glsl";
+	OGLPixelShaderFile = "shaders/common/postFx/gl/VolFogGlowP.glsl";	
+	
+	defines = "BLUR_DIR=float2(0.0,1.0)";
+	samplerNames[0] = "$diffuseMap";
+	pixVersion = 2.0;
+};
+singleton ShaderData( PFX_VolFogGlowBlurHorzShader : PFX_VolFogGlowBlurVertShader )
+{
+	DXVertexShaderFile = "shaders/common/postFx/glowBlurV.hlsl";
+	DXPixelShaderFile = "shaders/common/postFx/VolFogGlowP.hlsl";
+	
+	OGLVertexShaderFile = "shaders/common/postFx/gl/glowBlurV.glsl";
+	OGLPixelShaderFile = "shaders/common/postFx/gl/VolFogGlowP.glsl";
+	
+	defines = "BLUR_DIR=float2(1.0,0.0)";
+};
+
+$VolFogGlowPostFx::glowStrength = 0.3;
+
+singleton PostEffect( VolFogGlowPostFx )
+{
+	// Do not allow the glow effect to work in reflection
+	// passes by default so we don't do the extra drawing.
+	allowReflectPass = false;
+	renderTime = "PFXAfterBin";
+	renderBin = "FogBin";
+	renderPriority = 1;
+	// First we down sample the glow buffer.
+	shader = PFX_PassthruShader;
+	stateBlock = PFX_DefaultStateBlock;
+	texture[0] = "$backbuffer";
+	target = "$outTex";
+	targetScale = "0.5 0.5";
+	isEnabled = true;
+	// Blur vertically
+	new PostEffect()
+	{
+		shader = PFX_VolFogGlowBlurVertShader;
+		stateBlock = PFX_DefaultStateBlock;
+		internalName = "vert";
+		texture[0] = "$inTex";
+		target = "$outTex";
+	};
+	// Blur horizontally
+	new PostEffect()
+	{
+		shader = PFX_VolFogGlowBlurHorzShader;
+		stateBlock = PFX_DefaultStateBlock;
+		internalName = "hor";
+		texture[0] = "$inTex";
+		target = "$outTex";
+	};
+	// Upsample and combine with the back buffer.
+	new PostEffect()
+	{
+		shader = PFX_PassthruShader;
+		stateBlock = PFX_GlowCombineStateBlock;
+		texture[0] = "$inTex";
+		target = "$backBuffer";
+	};
+};
+
+function VolFogGlowPostFx::setShaderConsts( %this )
+{
+	%vp=%this-->vert;
+	%vp.setShaderConst( "$strength", $VolFogGlowPostFx::glowStrength );
+	%vp=%this-->hor;
+	%vp.setShaderConst( "$strength", $VolFogGlowPostFx::glowStrength );
+}

+ 1 - 0
Templates/Empty/game/core/scripts/client/postFx/postFxManager.gui.settings.cs

@@ -70,6 +70,7 @@ function PostFXManager::settingsSetEnabled(%this, %bEnablePostFX)
       
       postVerbose("% - PostFX Manager - PostFX disabled");
    }
+   VolFogGlowPostFx.disable();
 }
 
 function PostFXManager::settingsEffectSetEnabled(%this, %sName, %bEnable)

+ 2 - 0
Templates/Empty/game/core/scripts/client/renderManager.cs

@@ -75,6 +75,8 @@ function initRenderManager()
 	DiffuseRenderPassManager.addManager( new RenderParticleMgr()            { renderOrder = 1.35; processAddOrder = 1.35; } );
    DiffuseRenderPassManager.addManager( new RenderTranslucentMgr()         { renderOrder = 1.4; processAddOrder = 1.4; } );
    
+   DiffuseRenderPassManager.addManager(new RenderObjectMgr(FogBin){ bintype = "ObjectVolumetricFog"; renderOrder = 1.45; processAddOrder = 1.45; } );
+   
    // Note that the GlowPostFx is triggered after this bin.
    DiffuseRenderPassManager.addManager( new RenderGlowMgr(GlowBin) { renderOrder = 1.5; processAddOrder = 1.5; } );
    

+ 106 - 0
Templates/Empty/game/scripts/server/VolumetricFog.cs

@@ -0,0 +1,106 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+function VolumetricFog::onEnterFog(%this,%obj)
+{
+   // This method is called whenever the control object (Camera or Player)
+   // %obj enters the fog area.
+   
+   // echo("Control Object " @ %obj @ " enters fog " @ %this);
+}
+
+function VolumetricFog::onLeaveFog(%this,%obj)
+{
+   // This method is called whenever the control object (Camera or Player)
+   // %obj leaves the fog area.
+   
+   // echo("Control Object " @ %obj @ " left fog " @ %this);
+}
+
+function VolumetricFog::Dissolve(%this,%speed,%delete)
+{
+   // This method dissolves the fog at speed milliseconds
+   %this.isBuilding = true;
+   if (%this.FogDensity > 0)
+   {
+      %this.setFogDensity(%this.FogDensity - 0.005);
+      %this.schedule(%speed,Dissolve,%speed,%delete);
+   }
+   else
+   {
+      %this.isBuilding = false;
+      %this.SetFogDensity(0.0);
+      if (%delete !$= "" && %delete !$="0" && %delete !$="false")
+         %this.schedule(250,delete);
+   }
+}
+
+function VolumetricFog::Thicken(%this,%speed, %end_density)
+{
+   // This method thickens the fog at speed milliseconds to a density of %end_density
+
+   %this.isBuilding = true;
+   if (%this.FogDensity + 0.005 < %end_density)
+   {
+      %this.setFogDensity(%this.FogDensity + 0.005);
+      %this.schedule(%speed,Thicken,%speed, %end_density);
+   }
+   else
+   {
+      %this.setFogDensity(%end_density);
+      %this.isBuilding = false;
+   }
+}
+ 
+function GenerateFog(%pos,%scale,%color,%density)
+{
+   // This function can be used to generate some fog caused by massive gunfire etc.
+   // Change shape and modulation data to your likings.
+   
+   %fog=new VolumetricFog() {
+      shapeName = "art/environment/Fog_Sphere.dts";
+      fogColor = %color;
+      fogDensity = "0.0";
+      ignoreWater = "0";
+      MinSize = "250";
+      FadeSize = "750";
+      texture = "art/environment/FogMod_heavy.dds";
+      tiles = "1";
+      modStrength = "0.2";
+      PrimSpeed = "-0.01 0.04";
+      SecSpeed = "0.02 0.02";
+      position = %pos;
+      rotation = "0 0 1 20.354";
+      scale = %scale;
+      canSave = "1";
+      canSaveDynamicFields = "1";
+   };
+   
+   if (isObject(%fog))
+   {
+      MissionCleanup.add(%fog);
+      
+      %fog.Thicken(500,%density);
+   }
+   
+   return %fog;
+}

+ 1 - 0
Templates/Empty/game/scripts/server/scriptExec.cs

@@ -22,3 +22,4 @@
 
 // Load up all scripts.  This function is called when
 // a server is constructed.
+exec("./VolumetricFog.cs");

+ 87 - 0
Templates/Empty/game/shaders/common/VolumetricFog/VFogP.hlsl

@@ -0,0 +1,87 @@
+//-----------------------------------------------------------------------------
+// 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.
+//-----------------------------------------------------------------------------
+
+// Volumetric Fog final pixel shader V2.00
+
+#include "shadergen:/autogenConditioners.h"
+#include "../torque.hlsl"
+
+uniform sampler2D prepassTex : register(S0);
+uniform sampler2D depthBuffer : register(S1);
+uniform sampler2D frontBuffer : register(S2);
+uniform sampler2D density : register(S3);
+  
+uniform float accumTime;
+uniform float4 fogColor;
+uniform float fogDensity;
+uniform float preBias;
+uniform float textured;
+uniform float modstrength;
+uniform float4 modspeed;//xy speed layer 1, zw speed layer 2
+uniform float2 viewpoint;
+uniform float2 texscale;
+uniform float3 ambientColor;
+uniform float numtiles;
+uniform float fadesize;
+uniform float2 PixelSize;
+
+struct ConnectData
+{
+   float4 hpos : POSITION;
+   float4 htpos : TEXCOORD0;
+   float2 uv0 : TEXCOORD1;
+};
+
+float4 main( ConnectData IN ) : COLOR0
+{
+	float2 uvscreen=((IN.htpos.xy/IN.htpos.w) + 1.0 ) / 2.0;
+	uvscreen.y = 1.0 - uvscreen.y;
+	
+	float obj_test = prepassUncondition( prepassTex, uvscreen).w * preBias;
+	float depth = tex2D(depthBuffer,uvscreen).r;
+	float front = tex2D(frontBuffer,uvscreen).r;
+
+	if (depth <= front)
+		return float4(0,0,0,0);
+	else if ( obj_test < depth )
+		depth = obj_test;
+	if ( front >= 0.0)
+		depth -= front;
+
+	float diff = 1.0;
+	float3 col = fogColor.rgb;
+	if (textured != 0.0)
+	{
+		float2 offset = viewpoint + ((-0.5 + (texscale * uvscreen)) * numtiles);
+
+		float2 mod1 = tex2D(density,(offset + (modspeed.xy*accumTime))).rg;
+		float2 mod2= tex2D(density,(offset + (modspeed.zw*accumTime))).rg;
+		diff = (mod2.r + mod1.r) * modstrength;
+		col *= (2.0 - ((mod1.g + mod2.g) * fadesize))/2.0;
+	}
+
+	col *= ambientColor;
+
+	float4 resultColor = float4(col, 1.0 - saturate(exp(-fogDensity  * depth * diff * fadesize)));
+
+	return hdrEncode(resultColor);
+}

+ 39 - 0
Templates/Empty/game/shaders/common/VolumetricFog/VFogPreP.hlsl

@@ -0,0 +1,39 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+// Volumetric Fog prepass pixel shader V1.00
+
+struct ConnectData
+{
+   float4 hpos : POSITION;
+   float4 pos : TEXCOORD0;
+};
+
+float4 main( ConnectData IN ) : COLOR0
+{
+   float OUT;
+   
+   clip( IN.pos.w );
+   OUT = IN.pos.w;
+
+   return float4(OUT,0,0,1);
+}

+ 46 - 0
Templates/Empty/game/shaders/common/VolumetricFog/VFogPreV.hlsl

@@ -0,0 +1,46 @@
+//-----------------------------------------------------------------------------
+// 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.
+//-----------------------------------------------------------------------------
+
+// Volumetric Fog prepass vertex shader V1.00
+
+#include "shaders/common/hlslstructs.h"
+
+struct ConnectData
+{
+   float4 hpos : POSITION;
+   float4 pos : TEXCOORD0;
+};
+
+uniform float4x4 modelView;
+
+ConnectData main( VertexIn_P IN)    
+{
+	ConnectData OUT;
+	
+	float4 inPos = IN.pos;
+	inPos.w = 1.0;
+ 
+	OUT.hpos = mul( modelView, inPos );
+    OUT.pos = OUT.hpos;
+
+    return OUT;  
+}

+ 36 - 0
Templates/Empty/game/shaders/common/VolumetricFog/VFogRefl.hlsl

@@ -0,0 +1,36 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+uniform float4 fogColor;
+uniform float fogDensity;
+uniform float reflStrength;
+
+struct ConnectData
+{
+   float4 hpos : POSITION;
+   float4 pos : TEXCOORD0;
+};
+
+float4 main( ConnectData IN ) : COLOR0
+{
+   return float4(fogColor.rgb,saturate(fogDensity*reflStrength));
+}

+ 45 - 0
Templates/Empty/game/shaders/common/VolumetricFog/VFogV.hlsl

@@ -0,0 +1,45 @@
+//-----------------------------------------------------------------------------
+// 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.
+//-----------------------------------------------------------------------------
+
+// Volumetric Fog final vertex shader V1.00
+
+#include "shaders/common/hlslstructs.h"
+
+struct ConnectData
+{
+   float4 hpos : POSITION;
+   float4 htpos : TEXCOORD0;
+   float2 uv0 : TEXCOORD1;
+};
+
+uniform float4x4 modelView;
+
+ConnectData main( VertexIn_PNT IN)    
+{  
+    ConnectData OUT;
+	
+	OUT.hpos = mul(modelView, IN.pos);
+	OUT.htpos = OUT.hpos;
+	OUT.uv0 = IN.uv0;
+	
+    return OUT;  
+}

+ 87 - 0
Templates/Empty/game/shaders/common/VolumetricFog/gl/VFogP.glsl

@@ -0,0 +1,87 @@
+//-----------------------------------------------------------------------------
+// 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.
+//-----------------------------------------------------------------------------
+
+#include "../../gl/hlslCompat.glsl"
+#include "shadergen:/autogenConditioners.h"
+#include "../../gl/torque.glsl"
+
+uniform sampler2D prepassTex;
+uniform sampler2D depthBuffer;
+uniform sampler2D frontBuffer;
+uniform sampler2D density;
+  
+uniform float accumTime;
+uniform vec4 fogColor;
+uniform float fogDensity;
+uniform float preBias;
+uniform float textured;
+uniform float modstrength;
+uniform vec4 modspeed;//xy speed layer 1, zw speed layer 2
+uniform vec2 viewpoint;
+uniform vec2 texscale;
+uniform vec3 ambientColor;
+uniform float numtiles;
+uniform float fadesize;
+uniform vec2 PixelSize;
+
+in vec4 _hpos;
+#define IN_hpos _hpos
+out vec4 OUT_col;
+
+void main()
+{
+	vec2 uvscreen=((IN_hpos.xy/IN_hpos.w) + 1.0 ) / 2.0;
+	uvscreen.y = 1.0 - uvscreen.y;
+	
+	float obj_test = prepassUncondition( prepassTex, uvscreen).w * preBias;
+	float depth = tex2D(depthBuffer,uvscreen).r;
+	float front = tex2D(frontBuffer,uvscreen).r;
+
+	if (depth <= front)
+	{
+		OUT_col = vec4(0,0,0,0);
+		return;
+	}
+	
+	else if ( obj_test < depth )
+		depth = obj_test;
+	if ( front >= 0.0)
+		depth -= front;
+
+	float diff = 1.0;
+	vec3 col = fogColor.rgb;
+	if (textured != 0.0)
+	{
+		vec2 offset = viewpoint + ((-0.5 + (texscale * uvscreen)) * numtiles);
+
+		vec2 mod1 = tex2D(density,(offset + (modspeed.xy*accumTime))).rg;
+		vec2 mod2= tex2D(density,(offset + (modspeed.zw*accumTime))).rg;
+		diff = (mod2.r + mod1.r) * modstrength;
+		col *= (2.0 - ((mod1.g + mod2.g) * fadesize))/2.0;
+	}
+
+   col *= ambientColor;
+
+   vec4 returnColor = vec4(col, 1.0 - saturate(exp(-fogDensity  * depth * diff * fadesize)));
+
+	OUT_col = hdrEncode(returnColor);
+}

+ 37 - 0
Templates/Empty/game/shaders/common/VolumetricFog/gl/VFogPreP.glsl

@@ -0,0 +1,37 @@
+//-----------------------------------------------------------------------------
+// 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.
+//-----------------------------------------------------------------------------
+
+#include "../../gl/hlslCompat.glsl"
+
+in vec4 _hpos;
+#define IN_hpos _hpos
+
+out vec4 OUT_col;
+
+void main()
+{
+   float OUT;
+   clip( IN_hpos.w );
+   OUT = IN_hpos.w;
+
+   OUT_col = vec4(OUT,0,0,1);
+}

+ 42 - 0
Templates/Empty/game/shaders/common/VolumetricFog/gl/VFogPreV.glsl

@@ -0,0 +1,42 @@
+//-----------------------------------------------------------------------------
+// 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.
+//-----------------------------------------------------------------------------
+
+#include "../../gl/hlslCompat.glsl"
+
+in vec4 vPosition;
+#define IN_position vPosition
+
+out vec4 _hpos;
+#define OUT_hpos _hpos
+
+uniform mat4 modelView;
+
+void main()
+{
+	vec4 inPos = IN_position;
+	inPos.w = 1.0;
+ 
+	OUT_hpos = tMul( modelView, inPos );
+
+	gl_Position = OUT_hpos;
+	correctSSP(gl_Position);
+}

+ 33 - 0
Templates/Empty/game/shaders/common/VolumetricFog/gl/VFogRefl.glsl

@@ -0,0 +1,33 @@
+//-----------------------------------------------------------------------------
+// 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.
+//-----------------------------------------------------------------------------
+
+#include "../../gl/hlslCompat.glsl"
+
+uniform vec4 fogColor;
+uniform float fogDensity;
+uniform float reflStrength;
+out vec4 OUT_col;
+
+void main()
+{
+   OUT_col = vec4(fogColor.rgb,saturate(fogDensity*reflStrength));
+}

+ 38 - 0
Templates/Empty/game/shaders/common/VolumetricFog/gl/VFogV.glsl

@@ -0,0 +1,38 @@
+//-----------------------------------------------------------------------------
+// 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.
+//-----------------------------------------------------------------------------
+
+#include "../../gl/hlslCompat.glsl"
+
+in vec4 vPosition;
+#define IN_position vPosition
+
+out vec4 _hpos;
+#define OUT_hpos _hpos
+
+uniform mat4 modelView;
+
+void main()    
+{  
+	OUT_hpos = tMul(modelView, IN_position);
+	gl_Position = OUT_hpos;
+	correctSSP(gl_Position);
+}

+ 74 - 0
Templates/Empty/game/shaders/common/postFx/VolFogGlowP.hlsl

@@ -0,0 +1,74 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2014 R.G.S. - Richards Game Studio, the Netherlands
+//					  http://www.richardsgamestudio.com/
+//
+// If you find this code useful or you are feeling particularly generous I
+// would ask that you please go to http://www.richardsgamestudio.com/ then
+// choose Donations from the menu on the left side and make a donation to
+// Richards Game Studio. It will be highly appreciated.
+//
+// The MIT License:
+//
+// 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.
+//-----------------------------------------------------------------------------
+
+// Volumetric Fog Glow postFx pixel shader V1.00
+
+#include "./postFx.hlsl"
+
+uniform sampler2D diffuseMap : register(S0);
+uniform float strength;
+
+struct VertToPix
+{
+   float4 hpos       : POSITION;
+
+   float2 uv0        : TEXCOORD0;
+   float2 uv1        : TEXCOORD1;
+   float2 uv2        : TEXCOORD2;
+   float2 uv3        : TEXCOORD3;
+
+   float2 uv4        : TEXCOORD4;
+   float2 uv5        : TEXCOORD5;
+   float2 uv6        : TEXCOORD6;
+   float2 uv7        : TEXCOORD7;
+};
+
+float4 main( VertToPix IN ) : COLOR
+{
+   float4 kernel = float4( 0.175, 0.275, 0.375, 0.475 ) * strength;
+
+   float4 OUT = 0;
+   OUT += tex2D( diffuseMap, IN.uv0 ) * kernel.x;
+   OUT += tex2D( diffuseMap, IN.uv1 ) * kernel.y;
+   OUT += tex2D( diffuseMap, IN.uv2 ) * kernel.z;
+   OUT += tex2D( diffuseMap, IN.uv3 ) * kernel.w;
+
+   OUT += tex2D( diffuseMap, IN.uv4 ) * kernel.x;
+   OUT += tex2D( diffuseMap, IN.uv5 ) * kernel.y;
+   OUT += tex2D( diffuseMap, IN.uv6 ) * kernel.z;
+   OUT += tex2D( diffuseMap, IN.uv7 ) * kernel.w;
+
+   // Calculate a lumenance value in the alpha so we
+   // can use alpha test to save fillrate.
+   float3 rgb2lum = float3( 0.30, 0.59, 0.11 );
+   OUT.a = dot( OUT.rgb, rgb2lum );
+
+   return OUT;
+}

+ 67 - 0
Templates/Empty/game/shaders/common/postFx/gl/VolFogGlowP.glsl

@@ -0,0 +1,67 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2014 R.G.S. - Richards Game Studio, the Netherlands
+//					  http://www.richardsgamestudio.com/
+//
+// If you find this code useful or you are feeling particularly generous I
+// would ask that you please go to http://www.richardsgamestudio.com/ then
+// choose Donations from the menu on the left side and make a donation to
+// Richards Game Studio. It will be highly appreciated.
+//
+// The MIT License:
+//
+// 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.
+//-----------------------------------------------------------------------------
+
+// Volumetric Fog Glow postFx pixel shader V1.00
+
+uniform sampler2D diffuseMap;
+uniform float strength;
+
+out vec4 OUT_col;
+
+in vec2 uv0;
+in vec2 uv1;
+in vec2 uv2;
+in vec2 uv3;
+
+in vec2 uv4;
+in vec2 uv5;
+in vec2 uv6;
+in vec2 uv7;
+
+void main()
+{
+   vec4 kernel = vec4( 0.175, 0.275, 0.375, 0.475 ) * strength;
+
+   OUT_col = vec4(0);
+   OUT_col += texture( diffuseMap, uv0 ) * kernel.x;
+   OUT_col += texture( diffuseMap, uv1 ) * kernel.y;
+   OUT_col += texture( diffuseMap, uv2 ) * kernel.z;
+   OUT_col += texture( diffuseMap, uv3 ) * kernel.w;
+
+   OUT_col += texture( diffuseMap, uv4 ) * kernel.x;
+   OUT_col += texture( diffuseMap, uv5 ) * kernel.y;
+   OUT_col += texture( diffuseMap, uv6 ) * kernel.z;
+   OUT_col += texture( diffuseMap, uv7 ) * kernel.w;
+
+   // Calculate a lumenance value in the alpha so we
+   // can use alpha test to save fillrate.
+   vec3 rgb2lum = vec3( 0.30, 0.59, 0.11 );
+   OUT_col.a = dot( OUT_col.rgb, rgb2lum );
+}

二進制
Templates/Empty/game/tools/classIcons/VolumetricFog.png


+ 13 - 1
Templates/Empty/game/tools/worldEditor/gui/objectBuilderGui.ed.gui

@@ -980,7 +980,19 @@ function ObjectBuilderGui::buildObserverDropPoint(%this)
 //------------------------------------------------------------------------------
 // System
 //------------------------------------------------------------------------------
-
+function ObjectBuilderGui::buildVolumetricFog(%this)
+{
+	// Change this if you want to default to another Folder
+	// Otherwise every time you want to add a Fog you will go this.
+	%defShape = "/art/environment/Fog_Cube.dts";
+	%this.lastPath=getMainDotCsDir() @ %defShape;
+	OBObjectName.setValue( "" );
+	%this.objectClassName = "VolumetricFog";
+	%this.addField( "shapeName", "TypeFile", "Shape (Fog volume)", "", "*.dts;*.dae");
+	%this.addField("Scale", "TypePoint3", "Scale", "1 1 1");
+	%this.addField("FogColor", "TypeColorI", "FogColor", "200 200 200 255");
+	%this.process();
+}
 function ObjectBuilderGui::buildPhysicsEntity(%this)
 {
    %this.objectClassName = "PhysicsEntity";

+ 1 - 0
Templates/Empty/game/tools/worldEditor/scripts/editors/creator.ed.cs

@@ -46,6 +46,7 @@ function EWCreatorWindow::init( %this )
       %this.registerMissionObject( "SFXEmitter",          "Sound Emitter" );
       %this.registerMissionObject( "Precipitation" );
       %this.registerMissionObject( "ParticleEmitterNode", "Particle Emitter" );
+      %this.registerMissionObject( "VolumetricFog",       "Volumetric Fog" );
       %this.registerMissionObject( "RibbonNode", "Ribbon" );
       
       // Legacy features. Users should use Ground Cover and the Forest Editor.   

二進制
Templates/Full/game/art/environment/FogMod_heavy.dds


二進制
Templates/Full/game/art/environment/FogMod_light.dds


二進制
Templates/Full/game/art/environment/FogMod_med.dds


File diff suppressed because it is too large
+ 97 - 0
Templates/Full/game/art/environment/Fog_Cube.DAE


+ 8 - 0
Templates/Full/game/art/environment/Fog_Cube.cs

@@ -0,0 +1,8 @@
+
+singleton TSShapeConstructor(Fog_CubeDAE)
+{
+   baseShape = "./Fog_Cube.DAE";
+   lodType = "TrailingNumber";
+   neverImport = "env*";
+   loadLights = "0";
+};

File diff suppressed because it is too large
+ 77 - 0
Templates/Full/game/art/environment/LightVolume_Sphere.DAE


+ 8 - 0
Templates/Full/game/art/environment/LightVolume_Sphere.cs

@@ -0,0 +1,8 @@
+
+singleton TSShapeConstructor(LightVolume_SphereDAE)
+{
+   baseShape = "./LightVolume_Sphere.DAE";
+   lodType = "TrailingNumber";
+   neverImport = "env*";
+   loadLights = "0";
+};

二進制
Templates/Full/game/art/environment/LightVolume_Sphere.dts


+ 76 - 0
Templates/Full/game/core/scripts/client/postFx/glow.cs

@@ -106,3 +106,79 @@ singleton PostEffect( GlowPostFx )
       target = "$backBuffer";
    };
 };
+
+singleton ShaderData( PFX_VolFogGlowBlurVertShader )
+{
+	DXVertexShaderFile = "shaders/common/postFx/glowBlurV.hlsl";
+	DXPixelShaderFile = "shaders/common/postFx/VolFogGlowP.hlsl";
+	
+	OGLVertexShaderFile = "shaders/common/postFx/gl/glowBlurV.glsl";
+	OGLPixelShaderFile = "shaders/common/postFx/gl/VolFogGlowP.glsl";	
+	
+	defines = "BLUR_DIR=float2(0.0,1.0)";
+	samplerNames[0] = "$diffuseMap";
+	pixVersion = 2.0;
+};
+singleton ShaderData( PFX_VolFogGlowBlurHorzShader : PFX_VolFogGlowBlurVertShader )
+{
+	DXVertexShaderFile = "shaders/common/postFx/glowBlurV.hlsl";
+	DXPixelShaderFile = "shaders/common/postFx/VolFogGlowP.hlsl";
+	
+	OGLVertexShaderFile = "shaders/common/postFx/gl/glowBlurV.glsl";
+	OGLPixelShaderFile = "shaders/common/postFx/gl/VolFogGlowP.glsl";
+	
+	defines = "BLUR_DIR=float2(1.0,0.0)";
+};
+
+$VolFogGlowPostFx::glowStrength = 0.3;
+
+singleton PostEffect( VolFogGlowPostFx )
+{
+	// Do not allow the glow effect to work in reflection
+	// passes by default so we don't do the extra drawing.
+	allowReflectPass = false;
+	renderTime = "PFXAfterBin";
+	renderBin = "FogBin";
+	renderPriority = 1;
+	// First we down sample the glow buffer.
+	shader = PFX_PassthruShader;
+	stateBlock = PFX_DefaultStateBlock;
+	texture[0] = "$backbuffer";
+	target = "$outTex";
+	targetScale = "0.5 0.5";
+	isEnabled = true;
+	// Blur vertically
+	new PostEffect()
+	{
+		shader = PFX_VolFogGlowBlurVertShader;
+		stateBlock = PFX_DefaultStateBlock;
+		internalName = "vert";
+		texture[0] = "$inTex";
+		target = "$outTex";
+	};
+	// Blur horizontally
+	new PostEffect()
+	{
+		shader = PFX_VolFogGlowBlurHorzShader;
+		stateBlock = PFX_DefaultStateBlock;
+		internalName = "hor";
+		texture[0] = "$inTex";
+		target = "$outTex";
+	};
+	// Upsample and combine with the back buffer.
+	new PostEffect()
+	{
+		shader = PFX_PassthruShader;
+		stateBlock = PFX_GlowCombineStateBlock;
+		texture[0] = "$inTex";
+		target = "$backBuffer";
+	};
+};
+
+function VolFogGlowPostFx::setShaderConsts( %this )
+{
+	%vp=%this-->vert;
+	%vp.setShaderConst( "$strength", $VolFogGlowPostFx::glowStrength );
+	%vp=%this-->hor;
+	%vp.setShaderConst( "$strength", $VolFogGlowPostFx::glowStrength );
+}

+ 1 - 0
Templates/Full/game/core/scripts/client/postFx/postFxManager.gui.settings.cs

@@ -70,6 +70,7 @@ function PostFXManager::settingsSetEnabled(%this, %bEnablePostFX)
       
       postVerbose("% - PostFX Manager - PostFX disabled");
    }
+   VolFogGlowPostFx.disable();
 }
 
 function PostFXManager::settingsEffectSetEnabled(%this, %sName, %bEnable)

+ 2 - 0
Templates/Full/game/core/scripts/client/renderManager.cs

@@ -75,6 +75,8 @@ function initRenderManager()
 	DiffuseRenderPassManager.addManager( new RenderParticleMgr()            { renderOrder = 1.35; processAddOrder = 1.35; } );
    DiffuseRenderPassManager.addManager( new RenderTranslucentMgr()         { renderOrder = 1.4; processAddOrder = 1.4; } );
    
+   DiffuseRenderPassManager.addManager(new RenderObjectMgr(FogBin){ bintype = "ObjectVolumetricFog"; renderOrder = 1.45; processAddOrder = 1.45; } );
+   
    // Note that the GlowPostFx is triggered after this bin.
    DiffuseRenderPassManager.addManager( new RenderGlowMgr(GlowBin) { renderOrder = 1.5; processAddOrder = 1.5; } );
    

+ 36 - 0
Templates/Full/game/core/scripts/client/shaders.cs

@@ -101,4 +101,40 @@ new ShaderData( fxFoliageReplicatorShader )
    samplerNames[1] = "$alphaMap";
    
    pixVersion = 1.4;
+};
+
+singleton ShaderData( VolumetricFogPrePassShader )
+{
+   DXVertexShaderFile = "shaders/common/VolumetricFog/VFogPreV.hlsl";
+   DXPixelShaderFile = "shaders/common/VolumetricFog/VFogPreP.hlsl";
+	
+   OGLVertexShaderFile  = "shaders/common/VolumetricFog/gl/VFogPreV.glsl";
+   OGLPixelShaderFile   = "shaders/common/VolumetricFog/gl/VFogPreP.glsl";
+   
+   pixVersion = 3.0;
+};
+singleton ShaderData( VolumetricFogShader )
+{
+   DXVertexShaderFile = "shaders/common/VolumetricFog/VFogV.hlsl";
+   DXPixelShaderFile = "shaders/common/VolumetricFog/VFogP.hlsl";
+	
+   OGLVertexShaderFile  = "shaders/common/VolumetricFog/gl/VFogV.glsl";
+   OGLPixelShaderFile   = "shaders/common/VolumetricFog/gl/VFogP.glsl";	
+	
+   samplerNames[0] = "$prepassTex";
+   samplerNames[1] = "$depthBuffer";
+   samplerNames[2] = "$frontBuffer";
+   samplerNames[3] = "$density";
+   
+   pixVersion = 3.0;
+};
+singleton ShaderData( VolumetricFogReflectionShader )
+{
+   DXVertexShaderFile = "shaders/common/VolumetricFog/VFogPreV.hlsl";
+   DXPixelShaderFile = "shaders/common/VolumetricFog/VFogRefl.hlsl";
+	
+   OGLVertexShaderFile  = "shaders/common/VolumetricFog/gl/VFogPreV.glsl";
+   OGLPixelShaderFile   = "shaders/common/VolumetricFog/gl/VFogRefl.glsl";
+	
+   pixVersion = 3.0;
 };

+ 106 - 0
Templates/Full/game/scripts/server/VolumetricFog.cs

@@ -0,0 +1,106 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+function VolumetricFog::onEnterFog(%this,%obj)
+{
+   // This method is called whenever the control object (Camera or Player)
+   // %obj enters the fog area.
+   
+   // echo("Control Object " @ %obj @ " enters fog " @ %this);
+}
+
+function VolumetricFog::onLeaveFog(%this,%obj)
+{
+   // This method is called whenever the control object (Camera or Player)
+   // %obj leaves the fog area.
+   
+   // echo("Control Object " @ %obj @ " left fog " @ %this);
+}
+
+function VolumetricFog::Dissolve(%this,%speed,%delete)
+{
+   // This method dissolves the fog at speed milliseconds
+   %this.isBuilding = true;
+   if (%this.FogDensity > 0)
+   {
+      %this.setFogDensity(%this.FogDensity - 0.005);
+      %this.schedule(%speed,Dissolve,%speed,%delete);
+   }
+   else
+   {
+      %this.isBuilding = false;
+      %this.SetFogDensity(0.0);
+      if (%delete !$= "" && %delete !$="0" && %delete !$="false")
+         %this.schedule(250,delete);
+   }
+}
+
+function VolumetricFog::Thicken(%this,%speed, %end_density)
+{
+   // This method thickens the fog at speed milliseconds to a density of %end_density
+
+   %this.isBuilding = true;
+   if (%this.FogDensity + 0.005 < %end_density)
+   {
+      %this.setFogDensity(%this.FogDensity + 0.005);
+      %this.schedule(%speed,Thicken,%speed, %end_density);
+   }
+   else
+   {
+      %this.setFogDensity(%end_density);
+      %this.isBuilding = false;
+   }
+}
+ 
+function GenerateFog(%pos,%scale,%color,%density)
+{
+   // This function can be used to generate some fog caused by massive gunfire etc.
+   // Change shape and modulation data to your likings.
+   
+   %fog=new VolumetricFog() {
+      shapeName = "art/environment/Fog_Sphere.dts";
+      fogColor = %color;
+      fogDensity = "0.0";
+      ignoreWater = "0";
+      MinSize = "250";
+      FadeSize = "750";
+      texture = "art/environment/FogMod_heavy.dds";
+      tiles = "1";
+      modStrength = "0.2";
+      PrimSpeed = "-0.01 0.04";
+      SecSpeed = "0.02 0.02";
+      position = %pos;
+      rotation = "0 0 1 20.354";
+      scale = %scale;
+      canSave = "1";
+      canSaveDynamicFields = "1";
+   };
+   
+   if (isObject(%fog))
+   {
+      MissionCleanup.add(%fog);
+      
+      %fog.Thicken(500,%density);
+   }
+   
+   return %fog;
+}

+ 1 - 0
Templates/Full/game/scripts/server/scriptExec.cs

@@ -24,6 +24,7 @@
 // a server is constructed.
 exec("./camera.cs");
 exec("./triggers.cs");
+exec("./VolumetricFog.cs");
 exec("./inventory.cs");
 exec("./shapeBase.cs");
 exec("./item.cs");

+ 87 - 0
Templates/Full/game/shaders/common/VolumetricFog/VFogP.hlsl

@@ -0,0 +1,87 @@
+//-----------------------------------------------------------------------------
+// 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.
+//-----------------------------------------------------------------------------
+
+// Volumetric Fog final pixel shader V2.00
+
+#include "shadergen:/autogenConditioners.h"
+#include "../torque.hlsl"
+
+uniform sampler2D prepassTex : register(S0);
+uniform sampler2D depthBuffer : register(S1);
+uniform sampler2D frontBuffer : register(S2);
+uniform sampler2D density : register(S3);
+  
+uniform float accumTime;
+uniform float4 fogColor;
+uniform float fogDensity;
+uniform float preBias;
+uniform float textured;
+uniform float modstrength;
+uniform float4 modspeed;//xy speed layer 1, zw speed layer 2
+uniform float2 viewpoint;
+uniform float2 texscale;
+uniform float3 ambientColor;
+uniform float numtiles;
+uniform float fadesize;
+uniform float2 PixelSize;
+
+struct ConnectData
+{
+   float4 hpos : POSITION;
+   float4 htpos : TEXCOORD0;
+   float2 uv0 : TEXCOORD1;
+};
+
+float4 main( ConnectData IN ) : COLOR0
+{
+	float2 uvscreen=((IN.htpos.xy/IN.htpos.w) + 1.0 ) / 2.0;
+	uvscreen.y = 1.0 - uvscreen.y;
+	
+	float obj_test = prepassUncondition( prepassTex, uvscreen).w * preBias;
+	float depth = tex2D(depthBuffer,uvscreen).r;
+	float front = tex2D(frontBuffer,uvscreen).r;
+
+	if (depth <= front)
+		return float4(0,0,0,0);
+	else if ( obj_test < depth )
+		depth = obj_test;
+	if ( front >= 0.0)
+		depth -= front;
+
+	float diff = 1.0;
+	float3 col = fogColor.rgb;
+	if (textured != 0.0)
+	{
+		float2 offset = viewpoint + ((-0.5 + (texscale * uvscreen)) * numtiles);
+
+		float2 mod1 = tex2D(density,(offset + (modspeed.xy*accumTime))).rg;
+		float2 mod2= tex2D(density,(offset + (modspeed.zw*accumTime))).rg;
+		diff = (mod2.r + mod1.r) * modstrength;
+		col *= (2.0 - ((mod1.g + mod2.g) * fadesize))/2.0;
+	}
+
+	col *= ambientColor;
+
+	float4 resultColor = float4(col, 1.0 - saturate(exp(-fogDensity  * depth * diff * fadesize)));
+
+	return hdrEncode(resultColor);
+}

+ 39 - 0
Templates/Full/game/shaders/common/VolumetricFog/VFogPreP.hlsl

@@ -0,0 +1,39 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+// Volumetric Fog prepass pixel shader V1.00
+
+struct ConnectData
+{
+   float4 hpos : POSITION;
+   float4 pos : TEXCOORD0;
+};
+
+float4 main( ConnectData IN ) : COLOR0
+{
+   float OUT;
+   
+   clip( IN.pos.w );
+   OUT = IN.pos.w;
+
+   return float4(OUT,0,0,1);
+}

+ 46 - 0
Templates/Full/game/shaders/common/VolumetricFog/VFogPreV.hlsl

@@ -0,0 +1,46 @@
+//-----------------------------------------------------------------------------
+// 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.
+//-----------------------------------------------------------------------------
+
+// Volumetric Fog prepass vertex shader V1.00
+
+#include "shaders/common/hlslstructs.h"
+
+struct ConnectData
+{
+   float4 hpos : POSITION;
+   float4 pos : TEXCOORD0;
+};
+
+uniform float4x4 modelView;
+
+ConnectData main( VertexIn_P IN)    
+{
+	ConnectData OUT;
+	
+	float4 inPos = IN.pos;
+	inPos.w = 1.0;
+ 
+	OUT.hpos = mul( modelView, inPos );
+    OUT.pos = OUT.hpos;
+
+    return OUT;  
+}

+ 37 - 0
Templates/Full/game/shaders/common/VolumetricFog/VFogRefl.hlsl

@@ -0,0 +1,37 @@
+//-----------------------------------------------------------------------------
+// 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.
+//-----------------------------------------------------------------------------
+
+// Volumetric Fog Reflection pixel shader V1.00
+uniform float4 fogColor;
+uniform float fogDensity;
+uniform float reflStrength;
+
+struct ConnectData
+{
+   float4 hpos : POSITION;
+   float4 pos : TEXCOORD0;
+};
+
+float4 main( ConnectData IN ) : COLOR0
+{
+   return float4(fogColor.rgb,saturate(fogDensity*reflStrength));
+}

+ 45 - 0
Templates/Full/game/shaders/common/VolumetricFog/VFogV.hlsl

@@ -0,0 +1,45 @@
+//-----------------------------------------------------------------------------
+// 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.
+//-----------------------------------------------------------------------------
+
+// Volumetric Fog final vertex shader V1.00
+
+#include "shaders/common/hlslstructs.h"
+
+struct ConnectData
+{
+   float4 hpos : POSITION;
+   float4 htpos : TEXCOORD0;
+   float2 uv0 : TEXCOORD1;
+};
+
+uniform float4x4 modelView;
+
+ConnectData main( VertexIn_PNT IN)    
+{  
+    ConnectData OUT;
+	
+	OUT.hpos = mul(modelView, IN.pos);
+	OUT.htpos = OUT.hpos;
+	OUT.uv0 = IN.uv0;
+	
+    return OUT;  
+}

+ 87 - 0
Templates/Full/game/shaders/common/VolumetricFog/gl/VFogP.glsl

@@ -0,0 +1,87 @@
+//-----------------------------------------------------------------------------
+// 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.
+//-----------------------------------------------------------------------------
+
+#include "../../gl/hlslCompat.glsl"
+#include "shadergen:/autogenConditioners.h"
+#include "../../gl/torque.glsl"
+
+uniform sampler2D prepassTex;
+uniform sampler2D depthBuffer;
+uniform sampler2D frontBuffer;
+uniform sampler2D density;
+  
+uniform float accumTime;
+uniform vec4 fogColor;
+uniform float fogDensity;
+uniform float preBias;
+uniform float textured;
+uniform float modstrength;
+uniform vec4 modspeed;//xy speed layer 1, zw speed layer 2
+uniform vec2 viewpoint;
+uniform vec2 texscale;
+uniform vec3 ambientColor;
+uniform float numtiles;
+uniform float fadesize;
+uniform vec2 PixelSize;
+
+in vec4 _hpos;
+#define IN_hpos _hpos
+out vec4 OUT_col;
+
+void main()
+{
+	vec2 uvscreen=((IN_hpos.xy/IN_hpos.w) + 1.0 ) / 2.0;
+	uvscreen.y = 1.0 - uvscreen.y;
+	
+	float obj_test = prepassUncondition( prepassTex, uvscreen).w * preBias;
+	float depth = tex2D(depthBuffer,uvscreen).r;
+	float front = tex2D(frontBuffer,uvscreen).r;
+
+	if (depth <= front)
+	{
+		OUT_col = vec4(0,0,0,0);
+		return;
+	}
+	
+	else if ( obj_test < depth )
+		depth = obj_test;
+	if ( front >= 0.0)
+		depth -= front;
+
+	float diff = 1.0;
+	vec3 col = fogColor.rgb;
+	if (textured != 0.0)
+	{
+		vec2 offset = viewpoint + ((-0.5 + (texscale * uvscreen)) * numtiles);
+
+		vec2 mod1 = tex2D(density,(offset + (modspeed.xy*accumTime))).rg;
+		vec2 mod2= tex2D(density,(offset + (modspeed.zw*accumTime))).rg;
+		diff = (mod2.r + mod1.r) * modstrength;
+		col *= (2.0 - ((mod1.g + mod2.g) * fadesize))/2.0;
+	}
+
+   col *= ambientColor;
+
+   vec4 returnColor = vec4(col, 1.0 - saturate(exp(-fogDensity  * depth * diff * fadesize)));
+
+	OUT_col = hdrEncode(returnColor);
+}

+ 37 - 0
Templates/Full/game/shaders/common/VolumetricFog/gl/VFogPreP.glsl

@@ -0,0 +1,37 @@
+//-----------------------------------------------------------------------------
+// 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.
+//-----------------------------------------------------------------------------
+
+#include "../../gl/hlslCompat.glsl"
+
+in vec4 _hpos;
+#define IN_hpos _hpos
+
+out vec4 OUT_col;
+
+void main()
+{
+   float OUT;
+   clip( IN_hpos.w );
+   OUT = IN_hpos.w;
+
+   OUT_col = vec4(OUT,0,0,1);
+}

+ 42 - 0
Templates/Full/game/shaders/common/VolumetricFog/gl/VFogPreV.glsl

@@ -0,0 +1,42 @@
+//-----------------------------------------------------------------------------
+// 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.
+//-----------------------------------------------------------------------------
+
+#include "../../gl/hlslCompat.glsl"
+
+in vec4 vPosition;
+#define IN_position vPosition
+
+out vec4 _hpos;
+#define OUT_hpos _hpos
+
+uniform mat4 modelView;
+
+void main()
+{
+	vec4 inPos = IN_position;
+	inPos.w = 1.0;
+ 
+	OUT_hpos = tMul( modelView, inPos );
+
+	gl_Position = OUT_hpos;
+	correctSSP(gl_Position);
+}

+ 33 - 0
Templates/Full/game/shaders/common/VolumetricFog/gl/VFogRefl.glsl

@@ -0,0 +1,33 @@
+//-----------------------------------------------------------------------------
+// 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.
+//-----------------------------------------------------------------------------
+
+#include "../../gl/hlslCompat.glsl"
+
+uniform vec4 fogColor;
+uniform float fogDensity;
+uniform float reflStrength;
+out vec4 OUT_col;
+
+void main()
+{
+   OUT_col = vec4(fogColor.rgb,saturate(fogDensity*reflStrength));
+}

+ 38 - 0
Templates/Full/game/shaders/common/VolumetricFog/gl/VFogV.glsl

@@ -0,0 +1,38 @@
+//-----------------------------------------------------------------------------
+// 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.
+//-----------------------------------------------------------------------------
+
+#include "../../gl/hlslCompat.glsl"
+
+in vec4 vPosition;
+#define IN_position vPosition
+
+out vec4 _hpos;
+#define OUT_hpos _hpos
+
+uniform mat4 modelView;
+
+void main()    
+{  
+	OUT_hpos = tMul(modelView, IN_position);
+	gl_Position = OUT_hpos;
+	correctSSP(gl_Position);
+}

+ 74 - 0
Templates/Full/game/shaders/common/postFx/VolFogGlowP.hlsl

@@ -0,0 +1,74 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2014 R.G.S. - Richards Game Studio, the Netherlands
+//					  http://www.richardsgamestudio.com/
+//
+// If you find this code useful or you are feeling particularly generous I
+// would ask that you please go to http://www.richardsgamestudio.com/ then
+// choose Donations from the menu on the left side and make a donation to
+// Richards Game Studio. It will be highly appreciated.
+//
+// The MIT License:
+//
+// 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.
+//-----------------------------------------------------------------------------
+
+// Volumetric Fog Glow postFx pixel shader V1.00
+
+#include "./postFx.hlsl"
+
+uniform sampler2D diffuseMap : register(S0);
+uniform float strength;
+
+struct VertToPix
+{
+   float4 hpos       : POSITION;
+
+   float2 uv0        : TEXCOORD0;
+   float2 uv1        : TEXCOORD1;
+   float2 uv2        : TEXCOORD2;
+   float2 uv3        : TEXCOORD3;
+
+   float2 uv4        : TEXCOORD4;
+   float2 uv5        : TEXCOORD5;
+   float2 uv6        : TEXCOORD6;
+   float2 uv7        : TEXCOORD7;
+};
+
+float4 main( VertToPix IN ) : COLOR
+{
+   float4 kernel = float4( 0.175, 0.275, 0.375, 0.475 ) * strength;
+
+   float4 OUT = 0;
+   OUT += tex2D( diffuseMap, IN.uv0 ) * kernel.x;
+   OUT += tex2D( diffuseMap, IN.uv1 ) * kernel.y;
+   OUT += tex2D( diffuseMap, IN.uv2 ) * kernel.z;
+   OUT += tex2D( diffuseMap, IN.uv3 ) * kernel.w;
+
+   OUT += tex2D( diffuseMap, IN.uv4 ) * kernel.x;
+   OUT += tex2D( diffuseMap, IN.uv5 ) * kernel.y;
+   OUT += tex2D( diffuseMap, IN.uv6 ) * kernel.z;
+   OUT += tex2D( diffuseMap, IN.uv7 ) * kernel.w;
+
+   // Calculate a lumenance value in the alpha so we
+   // can use alpha test to save fillrate.
+   float3 rgb2lum = float3( 0.30, 0.59, 0.11 );
+   OUT.a = dot( OUT.rgb, rgb2lum );
+
+   return OUT;
+}

+ 67 - 0
Templates/Full/game/shaders/common/postFx/gl/VolFogGlowP.glsl

@@ -0,0 +1,67 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2014 R.G.S. - Richards Game Studio, the Netherlands
+//					  http://www.richardsgamestudio.com/
+//
+// If you find this code useful or you are feeling particularly generous I
+// would ask that you please go to http://www.richardsgamestudio.com/ then
+// choose Donations from the menu on the left side and make a donation to
+// Richards Game Studio. It will be highly appreciated.
+//
+// The MIT License:
+//
+// 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.
+//-----------------------------------------------------------------------------
+
+// Volumetric Fog Glow postFx pixel shader V1.00
+
+uniform sampler2D diffuseMap;
+uniform float strength;
+
+out vec4 OUT_col;
+
+in vec2 uv0;
+in vec2 uv1;
+in vec2 uv2;
+in vec2 uv3;
+
+in vec2 uv4;
+in vec2 uv5;
+in vec2 uv6;
+in vec2 uv7;
+
+void main()
+{
+   vec4 kernel = vec4( 0.175, 0.275, 0.375, 0.475 ) * strength;
+
+   OUT_col = vec4(0);
+   OUT_col += texture( diffuseMap, uv0 ) * kernel.x;
+   OUT_col += texture( diffuseMap, uv1 ) * kernel.y;
+   OUT_col += texture( diffuseMap, uv2 ) * kernel.z;
+   OUT_col += texture( diffuseMap, uv3 ) * kernel.w;
+
+   OUT_col += texture( diffuseMap, uv4 ) * kernel.x;
+   OUT_col += texture( diffuseMap, uv5 ) * kernel.y;
+   OUT_col += texture( diffuseMap, uv6 ) * kernel.z;
+   OUT_col += texture( diffuseMap, uv7 ) * kernel.w;
+
+   // Calculate a lumenance value in the alpha so we
+   // can use alpha test to save fillrate.
+   vec3 rgb2lum = vec3( 0.30, 0.59, 0.11 );
+   OUT_col.a = dot( OUT_col.rgb, rgb2lum );
+}

二進制
Templates/Full/game/tools/classIcons/VolumetricFog.png


+ 13 - 1
Templates/Full/game/tools/worldEditor/gui/objectBuilderGui.ed.gui

@@ -980,7 +980,19 @@ function ObjectBuilderGui::buildObserverDropPoint(%this)
 //------------------------------------------------------------------------------
 // System
 //------------------------------------------------------------------------------
-
+function ObjectBuilderGui::buildVolumetricFog(%this)
+{
+	// Change this if you want to default to another Folder
+	// Otherwise every time you want to add a Fog you will go this.
+	%defShape = "/art/environment/Fog_Cube.dts";
+	%this.lastPath=getMainDotCsDir() @ %defShape;
+	OBObjectName.setValue( "" );
+	%this.objectClassName = "VolumetricFog";
+	%this.addField( "shapeName", "TypeFile", "Shape (Fog volume)", "", "*.dts;*.dae");
+	%this.addField("Scale", "TypePoint3", "Scale", "1 1 1");
+	%this.addField("FogColor", "TypeColorI", "FogColor", "200 200 200 255");
+	%this.process();
+}
 function ObjectBuilderGui::buildPhysicsEntity(%this)
 {
    %this.objectClassName = "PhysicsEntity";

+ 1 - 0
Templates/Full/game/tools/worldEditor/scripts/editors/creator.ed.cs

@@ -46,6 +46,7 @@ function EWCreatorWindow::init( %this )
       %this.registerMissionObject( "SFXEmitter",          "Sound Emitter" );
       %this.registerMissionObject( "Precipitation" );
       %this.registerMissionObject( "ParticleEmitterNode", "Particle Emitter" );
+      %this.registerMissionObject( "VolumetricFog", "Volumetric Fog" );
       %this.registerMissionObject( "RibbonNode", "Ribbon" );
       
       // Legacy features. Users should use Ground Cover and the Forest Editor.   

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