Outerra forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Outerra Tech Demo download. Help with graphics driver issues

Author Topic: Log-depth buffer (gl_FragDepth writes) vs. MSAA  (Read 5534 times)

anatolij

  • Newbie
  • Posts: 1
  • newbie
Log-depth buffer (gl_FragDepth writes) vs. MSAA
« on: May 12, 2014, 04:51:58 am »

Hi, I'd like to ask how did you solve the "MSAA vs. gl_FragDepth writes" problem. If that not a secret  :)

I'm trying to implement log depth buffer using knowledge from your great articles, thanks a lot for them. The logaritmic depth works fine, but since I need to have some large triangles in the scene, I have to write the modified depth in fragment shader using gl_FragDepth. Doing it just in vertex shader and letting interpolators to do the job lead into inprecise depth values for large triangles on the screen.

I haven't come that far with my code yet, but I presume that assigning to gl_FragDepth will break the logic of MSAA, where the fragment shader is executed once per pixel of the rasterized element. It means that in this case it outputs the same depth value for all MSAA pixel samples, which is not what we want - it disables the antialiasing.


I would be thankful if you can give me at least a hint, how did you solve this problem in Outerra. I see that in Anteworld demo, there is no Z-fighting (thus the log depth is turned on) and MSAA works as a dream - edges are smooth both for terrain and nearby 3D objects. Sorry it it is already answered elsewhere, I was searching for it, but without any success.


Thanks and have a nice day.
Logged

cameni

  • Brano Kemen
  • Outerra Administrator
  • Hero Member
  • *****
  • Posts: 6721
  • No sense of urgency.
    • outerra.com
Re: Log-depth buffer (gl_FragDepth writes) vs. MSAA
« Reply #1 on: May 12, 2014, 05:09:32 am »

We haven't actually done anything with it. The differences would be miniscule - it's equivalent to outputting sub-pixel triangles, in which case you would not have to write gl_FragDepth. On that small range the depth values are almost linear, you probably would not be able to spot any difference, only in some very extreme cases.

However, if you have recent Nvidia or AMD(>13.12) drivers, Outerra is actually using reverse mapped floating point depth buffer via NV_depth_buffer_float extension, as described in the blog. Only if the extension isn't available it falls back to the logarithmic buffer.
Logged