Author Topic: Tasharen Fog of War - Anti Aliasing breaks effect  (Read 5136 times)

Anselm

  • Guest
Tasharen Fog of War - Anti Aliasing breaks effect
« on: October 31, 2013, 04:21:30 PM »
I just purchased Tasharen Fog Of War for my RTS game a few minutes ago. I went to test it out, and immediately noticed that having anti aliasing on causes some very odd breaks in the effect. Essentially the clear area in the fog moves with the camera rather than the units.

I figure this must have been encountered at some point, and I was wondering how I could fix this. If it hasn't been encountered, I can provide images and more details on the break.

Replies ASAP would be appreciated, I bought this because I'm on a tight deadline and thought I would be able to just drop it in to my game.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tasharen Fog of War - Anti Aliasing breaks effect
« Reply #1 on: November 01, 2013, 11:11:08 AM »
Seems to work fine here. I switched the quality settings in the TNet's base project to have 4xMSAA and it works as expected. Are you sure it's not some other setting?

Anselm

  • Guest
Re: Tasharen Fog of War - Anti Aliasing breaks effect
« Reply #2 on: November 01, 2013, 11:13:33 AM »
I'm positive it's anti aliasing, I made two identical quality levels, except one had anti aliasing disabled and the other had it at 2x.

I played around with it, disabling it on the one, enabling it, etc. And the break always happened when it was enabled.

Here's a picture of the break:


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tasharen Fog of War - Anti Aliasing breaks effect
« Reply #3 on: November 01, 2013, 11:18:58 AM »
Here's a picture of 4xMSAA running just fine. As I said, it has to be something else. Check other post-processing effects.

Anselm

  • Guest
Re: Tasharen Fog of War - Anti Aliasing breaks effect
« Reply #4 on: November 01, 2013, 11:27:21 AM »
Hmm okay I just tested it again, the problem is caused when BOTH Deferred Rendering and Anti Aliasing are turned on at the same time. If just one is on it runs fine.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tasharen Fog of War - Anti Aliasing breaks effect
« Reply #5 on: November 01, 2013, 11:37:26 AM »
I vaguely remember adding some check for the water that handled this. Basically having post process effects like deferred rendering makes the screen coordinates get flipped on the Y for some oddball Unity-known reason. Flip it in the shader.

In your case open up the FOW shader and remove the part after:
  1. #if SHADER_API_D3D9
like so... before:
  1. #if SHADER_API_D3D9
  2.         float2 depthUV = i.uv;
  3.         depthUV.y = lerp(depthUV.y, 1.0 - depthUV.y, _CamPos.w);
  4.         float depth = UNITY_SAMPLE_DEPTH(tex2D(_CameraDepthTexture, depthUV));
  5.         float3 pos = CamToWorld(depthUV, depth);
  6. #else
  7.         float depth = UNITY_SAMPLE_DEPTH(tex2D(_CameraDepthTexture, i.uv));
  8.         float3 pos = CamToWorld(i.uv, depth);
  9. #endif
after:
  1.         float depth = UNITY_SAMPLE_DEPTH(tex2D(_CameraDepthTexture, i.uv));
  2.         float3 pos = CamToWorld(i.uv, depth);

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tasharen Fog of War - Anti Aliasing breaks effect
« Reply #6 on: November 01, 2013, 11:42:44 AM »
P.S. Normally what Unity suggests doing is use UNITY_UV_STARTS_AT_TOP macro, but unfortunately it also fails in this case, and the MSAA + Deferred combo breaks it.

Anselm

  • Guest
Re: Tasharen Fog of War - Anti Aliasing breaks effect
« Reply #7 on: November 01, 2013, 11:50:18 AM »
Ahh, yeah Unity does a lot of weird stuff with it's post processing effects. That's worked like a charm, thanks a bundle!