Jump to content

[Solved]: weird PostFX and Ryder incompability


irei1as

Recommended Posts

I'm having an issue with a particular kind of PostEffect, first person view and some particular equipments of weapons.

I have absolutely no idea why this is happening so I would want to ask for a confirmation that this is common or if it's just happening with my old computer.

Note: Using DirectX.


First create a .cs with this (and then exec it somewhere, of course):

function createRend()
{
  if(!isObject(RendViewUpdater))
  {
     %tickObj = new ScriptTickObject(RendViewUpdater);
     %tickObj.setProcessTicks(true);
     %tickObj.tNT = "PreBin1";
     PreBin1.enable();
     MissionCleanup.add(%tickObj);

     %playGuiRendWindow = new GuiBitmapCtrl() {
        position = "100 100";
        extent = "150 150";
     };
     PlayGui.add(%playGuiRendWindow);

     %tickObj.miniWindow = %playGuiRendWindow;

  }
}

function RendViewUpdater::onInterpolateTick(%this, %delta)
{
  (%this.miniWindow).setNamedTexture(%this.tNT);
}

function RendViewUpdater::onRemove(%this)
{
  (%this.miniWindow).delete();
}


singleton ShaderData( TestCopy_Shader )
{   
  DXVertexShaderFile 	= "./xintexV.hlsl";
  DXPixelShaderFile 	= "./xintexP.hlsl";

  samplerNames[0] = "$inputTex";

  pixVersion = 2.0;
};

singleton GFXStateBlockData( TestCopy_stateblock )
{
  zDefined = true;
  zEnable = false;
  zWriteEnable = false;

  samplersDefined = true;
  samplerStates[0] = SamplerClampPoint;
};

singleton PostEffect( PreBin1 )
{
  isEnabled = false;
  renderTime = "PFXAfterBin";
  renderBin = "SkyBin";      

  shader = TestCopy_Shader;
  stateBlock = TestCopy_stateblock;

  texture[0] = "$backbuffer";
  target = "#PreBin1";
};

 

In the same folder as the .cs add these two files:

xintexV.hlsl

struct VertToPix
{
  float4 hpos       : POSITION;
  float2 uv        : TEXCOORD0;
};

VertToPix main( VertToPix In )
{
  return In;
}

 

xintexP.hlsl

struct ConnectData
{
  float2 texCoord : TEXCOORD0;
};

uniform sampler2D inputTex : register(S0);

//--------------------------------------------------------------
//Main
//--------------------------------------------------------------

float4 main( ConnectData IN ) :COLOR
{
  float4 color1 = tex2D(inputTex, IN.texCoord);
  return color1;
} 

 


Run the desert level of a full project and in the console type:

createRend()

 

Then the scene isn't correctly rendered in first person (render first person must be disabled in the Player datablock for the error to show) and with a particular weaponImage equipment.


It will render incorrectly if:

-You have the Ryder Pistol equipped.

-You have no image equipped ( in the console: LocalClientConnection.player.unmountImage(0); )

-You have the vehicle turret equpped ( in the console: LocalClientConnection.player.mountImage(TurretImage,0); Note: funny in third person.)

http://i.imgur.com/MIcw5FH.png


It will be alright otherwise (another weapon equipped, like the Lurker Rifle):

http://i.imgur.com/x3YGHKD.png



I really need to know if it's just my version of Torque 3d (not up to date) or if the issue it's still around.

And, um, do you know why it may be happening? Why it happens for some weapons but not for others?

Thanks a lot for your help.

Edited by irei1as
Link to comment
Share on other sites

Might be that the Ryder has no muzzle point set, since this is what it would have in common with no image equipped.

In my game I noticed that the Ryder muzzle point is wrong.

No idea if this helps, those are just things I noticed, may be related or not.

Link to comment
Share on other sites

Thanks a lot for both your insight. I was able to locate the issue from the hints.

It's related to the backbuffer not being cleared (or something like that) and GammaPostFX being picky with it.


Let me share the kind of hack for the fix.

In postEffect.cpp locate:

   if ( mTargetTex || mTargetDepthStencil )
  {
     mTarget->resolve();
     GFX->popActiveRenderTarget();
  }
  else
  {
     // We wrote to the active back buffer, so release
     // the current texture copy held by the manager.
     //
     // This ensures a new copy is made.
     PFXMGR->releaseBackBufferTex();
  }

And make it:

   if ( mTargetTex || mTargetDepthStencil )
  {
     mTarget->resolve();
     GFX->popActiveRenderTarget();
     PFXMGR->releaseBackBufferTex();
  }
  else
  {
     // We wrote to the active back buffer, so release
     // the current texture copy held by the manager.
     //
     // This ensures a new copy is made.
     PFXMGR->releaseBackBufferTex();
  }

 

But I don't think this change is very efficient. But, well, it works for what I want to test.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...