Author Topic: edges  (Read 9256 times)

Offline acorn98

  • byte
  • *
  • Posts: 46
    • View Profile
edges
« on: January 28, 2004, 04:49:34 pm »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: edges
« Reply #1 on: January 28, 2004, 05:06:38 pm »
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.... :?:

Offline acorn98

  • byte
  • *
  • Posts: 46
    • View Profile
edges
« Reply #2 on: January 28, 2004, 10:34:19 pm »
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  :)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
edges
« Reply #3 on: January 29, 2004, 12:52:39 am »
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.

Offline acorn98

  • byte
  • *
  • Posts: 46
    • View Profile
edges
« Reply #4 on: January 29, 2004, 10:37:07 pm »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
edges
« Reply #5 on: January 30, 2004, 12:26:29 am »
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.

Offline acorn98

  • byte
  • *
  • Posts: 46
    • View Profile
edges
« Reply #6 on: January 30, 2004, 01:22:54 am »
Thanks - if you get a chance to look into it, anything you can add to that effect would be really useful.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
edges
« Reply #7 on: February 03, 2004, 01:06:58 am »
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.

Offline acorn98

  • byte
  • *
  • Posts: 46
    • View Profile
edges
« Reply #8 on: February 03, 2004, 01:49:05 pm »
Fantastic - Thanks Helge, really appreciate this. I'll give it a go tonight.

Offline acorn98

  • byte
  • *
  • Posts: 46
    • View Profile
edges
« Reply #9 on: February 05, 2004, 04:57:02 pm »
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:

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
edges
« Reply #10 on: February 13, 2004, 12:29:43 am »
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.