Author Topic: strange blitting artefacts with software renderer  (Read 2408 times)

Offline gabriel.wurzer

  • byte
  • *
  • Posts: 3
    • View Profile
strange blitting artefacts with software renderer
« on: September 20, 2014, 04:23:05 pm »
dear all,
I get strange artifacts when blitting, as seen in the attached image, which shows that this happens both with billboards as well with text rendered through glFont.blit which uses Framebuffer.blit().



Details: I am using the software renderer in java, established through

Code: [Select]
FrameBuffer buffer = new FrameBuffer(width, height, FrameBuffer.SAMPLINGMODE_NORMAL);
buffer.enableRenderer(IRenderer.RENDERER_SOFTWARE);
buffer.disableRenderer(IRenderer.RENDERER_OPENGL);
...
World world = new World();
world.addObject(...billboarded object...)

Adjusting framebuffer size by a few pixels plus or minus does not help (this is, the assumption that it could be an issue with the passed-in size or of size being odd or even [as given in this post: http://www.jpct.net/forum2/index.php/topic,3158.msg23122.html#msg23122], does not hold).

I render using

Code: [Select]
public void paintComponent(Graphics g) {
  buffer.clear(java.awt.Color.DARK_GRAY);
  world.renderScene(buffer);
  world.draw(buffer);
  buffer.update();
  glFont.blitString(buffer, "this is a blitted text", 200, 100, 0, Color.ORANGE);
  buffer.display(g);
  repaint();
}

any suggestions?

Offline gabriel.wurzer

  • byte
  • *
  • Posts: 3
    • View Profile
Re: strange blitting artefacts with software renderer
« Reply #1 on: September 20, 2014, 05:02:48 pm »
Sorry, I just found the solution in the following thread http://www.jpct.net/forum2/index.php/topic,1074.msg14528/topicseen.html#msg14528. Summary: blitting of text doesn't work in software mode, revert to Java2D. Thank you!

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: strange blitting artefacts with software renderer
« Reply #2 on: September 20, 2014, 05:42:42 pm »
'Doesn't work' is a bit harsh... ;)...It just applies the same filter as it does in normal rendering. You can try to disable it before blitting by doing Config.texelFilter=false.
« Last Edit: September 20, 2014, 10:06:20 pm by EgonOlsen »

Offline gabriel.wurzer

  • byte
  • *
  • Posts: 3
    • View Profile
Re: strange blitting artefacts with software renderer
« Reply #3 on: September 21, 2014, 09:22:45 am »
Sorry for the "doesn't work", would have been more polite to say "the preferred way is..." :-) I've tried your suggestion
Code: [Select]
Config.texelFilter = false;
and while this did not change the blitting artifacts concerning the text, I noticed an improvement in billboarded text (see attached image). Now I can either
  • print text to a BufferedImage and assign this as a billboard texture, as given in the image. this has the advantage that the labels are treated as normal object within the scene that move with their hosting objects (I figure I shall addChild() the labels). the disadvantage I can imagine is that this uses a lot of texture memory - even more so if I want to display high-res text.
  • use Interact2D.projectCenter3D2D() and inverse camera transform on all wasVisible() objects of the scene, then see if that coordinate lies within the screen, then draw "over" the rendered jpct image with java2D which gives the qualitatively best results at the tradeoff of performance (since I have to go through every object once more)
still figuring what I'll do for best performance/visual quality; egon, if you have a gut feeling, then please let me know.
« Last Edit: September 21, 2014, 10:23:36 am by gabriel.wurzer »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: strange blitting artefacts with software renderer
« Reply #4 on: September 22, 2014, 08:11:20 am »
You are using scaled blits...do you have to? Because that's what causes the filtering artifacts. The software renderer does it's scaling by internally using an Overlay, which is why setting Config.texelFilter=true before calling the blit method has no effect (because the actual rendering happens later in the pipeline in this case). If possible, try to avoid using scaled blits in software mode and it should look fine.