Main Menu

edges

Started by acorn98, January 28, 2004, 04:49:34 PM

Previous topic - Next topic

acorn98

A question for Helge..

I'm trying to soften (anti-alias) the edges of my on-screen objects. I've  used frameBuffer.getPixels and blurred the image array. This produces a good result but it's a bit slow. I also tried SAMPLINGMODE_OGSS_FAST, but the result wasn't quite what I was after.

Any suggestions/ideas gratefully received.

EgonOlsen

Quote from: "acorn98"I also tried SAMPLINGMODE_OGSS_FAST, but the result wasn't quite what I was after.
In which way? OGSS_FAST does a simple 1.5*1.5 oversampling and rescales the rendered image. That's basically like AA worked on the older GeForce2 cards. OGSS does the same using a 2*2 pattern. Because it's supersampling and not multisampling (like newer hardware does it) not only edges but also textures are anti-aliased. Blurring on the other hand can't be seen as anti-aliasing IMHO even if NVidia offered something similar with their Quincunx-AA (a combination of MSAA and an adaptive blur filter).
I'm not sure what exactly do you have in mind, i.e. which result do you want to get from AA-ing the scene.... :?:

acorn98

On reflection, I think anti-alias was a bad choice of phrase - I think what I really want to do is blur the entire scene, so it looks slightly out of focus.

So far, the best result has been to process each pixel and mix in an average of the neighbouring pixels, but it eats CPU like nothing else. Having said that, the blur code I wrote was quick and dirty, so maybe I'll try optimising it - unless you can think of a way to blur the scene using jPCT?

By the way, I like the new feature that dynamically creates textures for diffuse colours  :)

EgonOlsen

Ok, i understand the problem better now. I once had a similar bluring for a depth of field effect implemented and its performance was ok...but it looked horrible and i never went public with it. I also had a postfiltering implemented (like the Voodoo2 did it) but i decided to remove it in one of the latest versions. Performance for this filter was ok too. So it's definitly possible to do this in reasonable time.
The problem is, that working with the pixels-Array on the application side works only if Java2 (i.e. a BufferedImage) is used. In Java 1.1, a MemoryImageSource will be used and that's "blind" for changes you may apply to the pixels-arrays. That's why the docs for this method suggest to blit the pixels-array back into the framebuffer....but that's even slower.
If you don't care for Java 1.1 support, just optimize your bluring routine and you are done. If support for 1.1 is important, adding the bluring into the engine's core would be the better solution. In this case, just send me your bluring routine and i'll add it somehow.

acorn98

Thanks for the info. I had overlooked the fact that under 1.1 the engine doesn't pick up pix-array changes, and ideally I'd like to maintain compatibility with 1.1. My browser uses 2.0 so I hadn't even noticed there was a problem.

Rather than pollute your engine with a one-off blur effect, is there another way to retrieve an array using MemoryImageSource that causes the engine to reflect changes made to that array? It would be handy for all kinds of image post-processing.

Thanks for your help.

EgonOlsen

Quote from: "acorn98"Rather than pollute your engine with a one-off blur effect, is there another way to retrieve an array using MemoryImageSource that causes the engine to reflect changes made to that array? It would be handy for all kinds of image post-processing.
I'll have a look at it after the weekend. It's a bit dirty to manipulate the pixels-array behind the framebuffer's back IMO but i also think that it could usefull in cases. I'll add something that makes it possible in one way or another.

acorn98

Thanks - if you get a chance to look into it, anything you can add to that effect would be really useful.

EgonOlsen

Quote from: "acorn98"Thanks - if you get a chance to look into it, anything you can add to that effect would be really useful.
I've added a refresh()-method to FrameBuffer that can be called after modifying the pixels-array to make it represent your code's changes to it. It's not an "official" release, so i uploaded the jar-file only:

Edit: *Link removed*

Please let me know if it works for you.

acorn98

Fantastic - Thanks Helge, really appreciate this. I'll give it a go tonight.

acorn98

I've tried the new build in an applet. It works well, and doesn't seem to have slowed down noticeably.

I want to add a few post-render effects and some 2D overlaysto my project, so this just what I needed. Thanks again, Helge  :wink:

EgonOlsen

0.98 is out and therefor i've removed the beta-jar. Now you can use the official version of it...it includes the refresh()-method as well as some other stuff.