"temporal reprojection" anti-aliasing

jReality backends
Post Reply
benjamin.kutschan
Posts: 48
Joined: Mon 16. May 2011, 16:29

"temporal reprojection" anti-aliasing

Post by benjamin.kutschan » Fri 8. Mar 2013, 12:52

I was playing around with an idea how one could implement "temporal reprojection" (i think it's called that, and I heard of it as being implemented in the cry engine) anti-aliasing. Basically one has to jitter the camera slightly from frame to frame. Then the resulting pixel would be the average of the last n frames. The downside is, that this would of introduce some kind of motion-blur.

My idea was to render to an FBO twice the size of the window and discard 3 out of 4 pixels. but discard different pixels every frame. then take the average of 4 frames. Unfortunately it seams that the following code decreases the performance rather than increasing. Either the if statements or more likely the casting to integer has such a performance hit that it is outweighs the 75% discarded pixels.

Code: Select all

if(int(gl_FragCoord.s)%2 == 1 || int(gl_FragCoord.t)%2 == 1) discard;
Also replacing the cast by

Code: Select all

 if(fract(gl_FragCoord.s/2) > 0.5 || fract(gl_FragCoord.t/2) > 0.5)
gives the same result.
Final performance with this is about half as slow instead of 4 times as fast.

Now I'll try to actually jitter the geometry. Calculate the neccessary displacement of every vertex from its z-Coordinate. Advantage: we don't waste FBO space like in the first method.

benjamin.kutschan
Posts: 48
Joined: Mon 16. May 2011, 16:29

Re: "temporal reprojection" anti-aliasing

Post by benjamin.kutschan » Fri 8. Mar 2013, 21:25

Ok, I managed to do what I intended. The average of the last 4 frames, all jittered slightly is taken as pixel. This gives anti-aliasing when image is still and unfortunately motion-blur when the image is moving.
Note, that despite being unintentional the motion-blur does look quite cool. And it comes quasi for free as does this anti-aliasing.
Note that currently only tubes are anti-aliased using this technique for evaluating purpose. It's very easy ported to the other geometry types.
Image

Edit: I found the crytek's paper on anti-aliasing in cry engine 3:
http://www.crytek.com/cryengine/present ... ryengine-3
It describes this method I have tried under the name A-Buffer SSAA (screen space anti-aliasing). On slide 11 they discover the "noticable image ghosting", and for the rest of the paper try to eliminate it using rather complicated fixes and not yielding a very good result.

I think for jReality the best method is simply supersampling, rendering at twice the resolution and then downsizing the image with multisampling enabled. This is trivial to implement, can easily be switched off and should scale well with newer graphics cards that have more processing cores.

benjamin.kutschan
Posts: 48
Joined: Mon 16. May 2011, 16:29

Re: "temporal reprojection" anti-aliasing

Post by benjamin.kutschan » Sat 9. Mar 2013, 12:53

Here's a comparison of no anti-aliasing:
Image

... and 16xMultisample with 2 times supersampling (4 times more pixel)
Image

I think the second picture is quite accaptable. In this size it runs smoothly (~50FPS) on my Geforce 410M. If the whole screen is covered with (this) geometry frame rate drops here to about 10 FPS.
So on high end graphics cards (i.e. in the cave) with 10-20 times more shader processors and roughly 8 times more texture mapping units it should run well.

User avatar
steffen
Posts: 186
Joined: Fri 16. Jun 2006, 13:30
Location: TU Berlin
Contact:

Re: "temporal reprojection" anti-aliasing

Post by steffen » Sun 10. Mar 2013, 18:08

How is antialiasing different compared to the old jogl backend?

benjamin.kutschan
Posts: 48
Joined: Mon 16. May 2011, 16:29

Re: "temporal reprojection" anti-aliasing

Post by benjamin.kutschan » Sun 10. Mar 2013, 18:23

I don't know how it is exactly done in the old backend. I suspect it renders into the back framebuffer with multisampling (MS).
In the new backend we have to render to frame buffer objects (FBO) to be able to do order-independent transparency and maybe other things.
I could not find a way to make rendering to the FBO use multisampling.
Therefore I just render with twice the resolution to the FBO. When copying from FBO to back frame buffer it then uses MS.

Post Reply