www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: gabriel.wurzer on September 20, 2014, 04:23:05 pm

Title: strange blitting artefacts with software renderer
Post by: gabriel.wurzer 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().

(http://question-jpct-blitting.png)

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 (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?
Title: Re: strange blitting artefacts with software renderer
Post by: gabriel.wurzer 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 (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!
Title: Re: strange blitting artefacts with software renderer
Post by: EgonOlsen 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.
Title: Re: strange blitting artefacts with software renderer
Post by: gabriel.wurzer 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
still figuring what I'll do for best performance/visual quality; egon, if you have a gut feeling, then please let me know.
Title: Re: strange blitting artefacts with software renderer
Post by: EgonOlsen 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.