strange blitting artefacts with software renderer

Started by gabriel.wurzer, September 20, 2014, 04:23:05 PM

Previous topic - Next topic

gabriel.wurzer

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


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


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?

gabriel.wurzer

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!

EgonOlsen

#2
'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.

gabriel.wurzer

#3
Sorry for the "doesn't work", would have been more polite to say "the preferred way is..." :-) I've tried your suggestion
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.

EgonOlsen

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.