I’m having a problem when rendering the same image many times over each other using drawTiles.
Some time ago, I ported flambe’s Particle API to my own rendering engine on top of OpenFL. I use Tilesheet rendering on Native and software rendering on Flash.
The problem I have is the following:
This is how it looks on Flash:
This is how it looked on Neko / Windows:
It became a bit better after I rounded all coordinates using Std.int, but it is still there:
So, I thought it might have to do with scaling. I am using a matrix to scale my images and when I tried some of the scaling values, I experienced the same result for some values like 1.21875 and 1.4, but some others like 1.1 or 0.5 seemed to work correctly.
Could someone please tell me how I can avoid this?
Thanks in advance,
I posted a related question just now myself, and it looks like you are further ahead of me on particles (one of my topics in related questions in my post). For my own education, is each of your particles a different tile right now?
And sorry I can’t actually help with your question.
Well, in other tile drawing with awkward scaling, I’ve found that I sometimes need a 1-pixel margin on each tile in the original BitmapData that replicates the outer edge of each tile’s pixels. Otherwise, neighboring unrelated pixels can get pulled in. But again, I suspect you are already ahead of me on these things.
Actually, your post was very helpful. Thank you.
It looks like the neighboring was a problem: My engine automatically creates a spritesheet of all Images that are loaded, so that it can batch nearly all draw calls into one single drawTiles call at the end of every frame. I actually did not know about neighboring, so I left the background of the BitmapData I use as texture atlas black. This seems to have caused these black borders. At least, I cannot see them anymore after changing it to transparent.
So, thank you for that hint.
Actually I do not know that much about Particle engines. As I said, I just ported flambe’s part. It was quite straight-forward.
To answer your question: Yes every Particle is a single Tile, at least in my implementation. I do not know if there is a faster way to do this, but from my tests, I can say, this works pretty well as long as you put as many tiles into every drawTiles call as possible.
I wanted to upload the engine to github as open source when it is in a more finished state, but if you are interested, I could upload it as-is.
Thanks much for the reply, and I’m glad my info was helpful! I think I still had gaps sometimes with the transparency route, but maybe I’d done it wrong. No need to rush on the code. Sometimes I like hacking things myself anyway, but you’ve given me reason to believe I know a sane path.