Game Development Community

Anyone have a clue? This code will only run in specific folder..

by Vince Gee · in Torque 3D Professional · 05/23/2012 (6:46 pm) · 5 replies

In FPS Example\game\core\scripts\client\postFx their is a file called hdr.cs.

You can move all of the code in that file to another folder anywhere in the game EXCEPT...

singleton PostEffect( HDRPostFX )
{
   isEnabled = false;
   allowReflectPass = false;
   renderTime = "PFXBeforeBin";
   renderBin = "EditorBin";
   renderPriority = 9999;
   shader = HDR_BrightPassShader;
   stateBlock = HDR_DownSampleStateBlock;
   texture[0] = "$backBuffer";
   texture[1] = "#adaptedLum";
   target = "$outTex";
   targetFormat = "GFXFormatR16G16B16A16F"; 
   targetScale = "0.5 0.5";
   new PostEffect()
      {
         shader = HDR_DownScale4x4Shader;
         stateBlock = HDR_DownSampleStateBlock;
         texture[0] = "$inTex";
         target = "$outTex";
         targetFormat = "GFXFormatR16G16B16A16F";
         targetScale = "0.25 0.25";
      };
   new PostEffect()
      {
         internalName = "bloomH";
         shader = HDR_BloomGaussBlurHShader;
         stateBlock = HDR_DownSampleStateBlock;
         texture[0] = "$inTex";
         target = "$outTex";
         targetFormat = "GFXFormatR16G16B16A16F";   
      };
   new PostEffect()
      {
         internalName = "bloomV";
         shader = HDR_BloomGaussBlurVShader;
         stateBlock = HDR_DownSampleStateBlock;
         texture[0] = "$inTex";
         target = "#bloomFinal";
         targetFormat = "GFXFormatR16G16B16A16F";    
      };
   new PostEffect()
      {
      internalName = "adaptLum";
      shader = HDR_SampleLumShader;
      stateBlock = HDR_DownSampleStateBlock;
      texture[0] = "$backBuffer";
      target = "$outTex";
      targetScale = "0.0625 0.0625";
      targetFormat = "GFXFormatR16F";
      new PostEffect()
         {
         shader = HDR_DownSampleLumShader;
         stateBlock = HDR_DownSampleStateBlock;
         texture[0] = "$inTex";
         target = "$outTex";
         targetScale = "0.25 0.25";
         targetFormat = "GFXFormatR16F";
         };
      new PostEffect()
         {
         shader = HDR_DownSampleLumShader;
         stateBlock = HDR_DownSampleStateBlock;
         texture[0] = "$inTex";
         target = "$outTex";
         targetScale = "0.25 0.25";
         targetFormat = "GFXFormatR16F";
         };
      new PostEffect()
         {
         shader = HDR_DownSampleLumShader;
         stateBlock = HDR_DownSampleStateBlock;
         texture[0] = "$inTex";
         target = "$outTex";
         targetScale = "0.25 0.25";
         targetFormat = "GFXFormatR16F";
         };
      new PostEffect()
         {
         internalName = "finalLum";         
         shader = HDR_CalcAdaptedLumShader;
         stateBlock = HDR_DownSampleStateBlock;
         texture[0] = "$inTex";
         texture[1] = "#adaptedLum";
         target = "#adaptedLum";
         targetFormat = "GFXFormatR16F";
         targetClear = "PFXTargetClear_OnCreate";
         targetClearColor = "1 1 1 1";
         };
   };
   new PostEffect()
   {
      internalName = "combinePass";
      shader = HDR_CombineShader;
      stateBlock = HDR_CombineStateBlock;
      texture[0] = "$backBuffer";
      texture[1] = "#adaptedLum";            
      texture[2] = "#bloomFinal";
      texture[3] = $HDRPostFX::colorCorrectionRamp;
      target = "$backBuffer";
   };
};

If you move that code, the HDR won't work...

If you put the code into an eval statement, the HDR won't work.

What in Thor's Thundering Butthole is sooo special about this location?

grumble... grumble... sigh....


Seriously,
If anyone knows, I would really like to be enlightened...

Vince

#1
05/23/2012 (7:09 pm)
Personally, i have a directory structure completely different from templates provided by GG. I deleted the folder core, separed the client from the server, and added some code that dynamically loads the scripts without define one for one.

So i suggest you review the references to that postfx.
#2
05/23/2012 (10:47 pm)
I would hazard a guess that it has to do with directories containing textures or reference info used in the PostEffect object. Are $inTex and $outTex set to a relative location?
#3
05/24/2012 (10:44 am)
Are the shaders being found when this PostEffect is initialized? I'd step through the PostEffect C++ code for the HDR effect and see whether it's actually creating the object successfully.
#4
05/24/2012 (11:03 am)
When that datablock is moved I get a high contrast as in real bright pixalation of the world which is different than when the shader is turned off.
#5
05/24/2012 (11:26 am)
You've probably missed some small reference somewhere. Location of anything in the project directory should be irrelevant as long as you tweak the various hard-coded references sprinkled here and there. Like Alfio, my project base has been completely rewritten and restructured compared to the standard Templates and the described issue is not one I've experienced.