Antialiasing/framebuffer shader

Hiya,

What about something to perform custom full scene antialiasing? I mean something to control the FSAA/MSAA sampling grid, coverage, rotating kernels, etc… I think I saw something about this before ( in a DX10 GDC presentation perhaps? can’t remember )
That could be like a weighted image kernel.

Also something to allow to use FSAA/MSAA with deferred rendering… But I know this is near impossible…

We could name this “antialiasing shaders”. What do you think? Any ideas?

Nah, FSAA/MSAA/CSAA(or whatever) are to “unstable” of a technology to warrant a new shader or something like that besides the usual stuff.
the thing is that antialiasing is not needed equally as much when you increase resolution (i regularly play games at 2048x1536 and i rarely need antialising).

In the future i think simple 2x2 and 4x4 super sampling will be the dominant AA system when the GPU processing power moves from the current slightly ridiculous to overwhelmingly ludicrous.
Besides super sampling is even today pretty simple to implement compared to MSAA/FSAA.

Found it
http://www.elitebastards.com/cms/index.p…=1&limitstart=2

Notice the

One of the main improvements touted by Microsoft in DirectX 10.1 is improved access to shader resources - In particular, this involves better control when reading back samples from multi-sample anti-aliasing. In conjunction with this, the ability to create customised downsampling filters will be available in DirectX 10.1.

What about something to perform custom full scene antialiasing? I mean something to control the FSAA/MSAA sampling grid, coverage, rotating kernels
Why would you need a shader (ie: program) for that? Why not simply a few configuration options?

Maybe I misunderstand the way antialiasing works, but wouldn’t it be sufficient to smooth only the polygon edges (as they are actually one being juggy)? This could be done by some sort of edge detection + local blurring. Has someone tried something similar?

I have seen some things out there, but because they need some serious processing all of them are more or less failures, besides edges does not look antialiased, they look blurry.
And because FSAA is supported by hardware it is something that most developers prefer.

And BTW most FSAA schemes only comes into effect only when a polygon intersects a pixel, so it sort of works like that anyway

Originally posted by Zengar:
Maybe I misunderstand the way antialiasing works, but wouldn’t it be sufficient to smooth only the polygon edges (as they are actually one being juggy)? This could be done by some sort of edge detection + local blurring. Has someone tried something similar?
FSAA and MSAA work by rendering to a larger sized frame and then downsample in some way. So the whole thing needs to be processed.
What you are talking about is edge smoothing and it has issues : the programmer needs to sort poly and set some blending mode.

>> So the whole thing needs to be processed.
Not quite. Texture sampling, lighting, fragment shader execution, and other interpolations only happen once for all the fragments contributing to a single screen pixel.

Not quite. Texture sampling, lighting, fragment shader execution, and other interpolations only happen once for all the fragments contributing to a single screen pixel.
Not for multisampling. Multiple executions can contribute to the same pixel, but not in the way it happens for supersampling. Two adjacent triangles run fragment shaders in the pixels that they share, but they fill in different coverage information.

It is a performance hit, but not nearly as severe as the one for supersampling.

Originally posted by zeoverlordl:
In the future i think simple 2x2 and 4x4 super sampling will be the dominant AA system when the GPU processing

But is not multisample AA faster? I think supersampling is really expensive! The point of multisample is that only processes the pixels in the borders and supersampling processes simply all the pixels.

Originally posted by Korval:
Why would you need a shader (ie: program) for that? Why not simply a few configuration options?
Well perhaps you’re right, but I think a small program for that could be more flexible and to be prepared for future things.

Let’s concrete a few more. See this:

      [http://www.xbitlabs.com/articles/video/display/nv40_12.html](http://www.xbitlabs.com/articles/video/display/nv40_12.html)          

You could be able to touch the sampling weights and to rotate the grid.

Also you should able to control how is done the trasparency antialiasing.

So the shader could be something like:

float4 main ( uniform int2 pixelXY )
{
   //Perform an average of 4 samples near and multiply it using the pixel depth ( I know, it's stupid but is only a small example )
   float4 topLeft = getPixel(pixelXY+int2(-1,-1));
   float topLeftD = getDepth(pixelXY+int2(-1,-1));

   float4 topRight = getPixel(pixelXY+int2(-1,1));
   float4 topRightD = getDepth(pixelXY+int2(-1,1));

   float4 botLeft = getPixel(pixelXY+int2(1,-1));
   float4 botLeftD = getDepth(pixelXY+int2(1,-1));

   float4 botRight = getPixel(pixelXY+int2(1,1));
   float4 botRightD = getDepth(pixelXY+int2(1,1));

   return (topRight*topRightD+botLeft*botLeftD*botRight*botRightD+topLeft*topLeftD)/4;
}

So with this you will have access to stencil, depth and pixels for antialasing ( or other things ). Basically it could have three instructions:

getPixel -> Retrieves the color of the pixel XY in the framebuffer

getDepth -> Retrieves the depth of the pixel XY in the framebuffer

getStencil -> Retrieves the stencil value of the pixelXY in the framebuffer

Using an option the GPU will fire our AA shader only for triangle borders ( multisampling ) or for ALL pixels ( for supersampling or post-pass effects, etc )

Well, I think more control over AA will be always welcome.

I think a future blend shader is a better place to put some of that.

Besides grid rotation and sample patterns has to be set up in advance since the GPU has to allocate the memory in which to store it in.
And once that is set, changing it mid rendering will just mess things up.

Multisample resolve shaders is one of the ideas that will be interesting in DX10 timeframe. There are plenty of ways to improve over current fixed function resolves. For instance with HDR you’d want to tonemap all samples and blend manually to ensure you get gamma correction after tonemapping. With fixed function resolve you’d have the hardware gamma correct the linear values, which after tonemapping may not at all be optimal for the human visual system, especially in very bright or dark areas of the scene.

Other ideas are things like artificially increase the number of samples by blending in some samples from neighbor pixels. Sort of like Quincunx, but with perhaps 8 samples in the current pixels and perhaps the 3 or 4 closest samples in each of the neighbor pixels.

Found other article about the DX10.1 improved antialiasing control:

http://www.behardware.com/articles/631-2/directx-10-and-gpus.html