Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
anti alias on Sprite? — Gideros Forum

anti alias on Sprite?

piepie Member
edited June 2015 in General questions
Hi,
I know that we currently can load Texture and TexturePacks with antialiasing filter, but I was wondering if in the light of the new improvements could be possible to apply antialias "later" on a sprite composed of many not-antialiased textures.

I try to explain: I am doing an isometric game, so I use isometricTileMap and isometric tile images.

I can't use antialiased tiles, since it would affect their borders and they would show their contact lines in the tilemap as a "grid".
I don't think I can apply gideros antialias filter on the texture used to build the tilemap for the same reason. [Edit: I did it, and it didn't help, see below].

What I would need is to apply antialias on the "drawn tilemap" (a Sprite) - after it has been "composed".
Is there any chance to do this?

Thank you very much

Comments

  • you could render all the stuff together with rendertarget and that basically creates a texture that you can use for anything, and you can turn on filtering for this texture i think.
  • piepie Member
    @keszegh thanks, I thought about this:
    isn't it going to be really heavy? I mean, I already have a tileset loaded, won't renderTarget create a texture as big as the rendered area?
    In my game it should be at least 1280x640 on a 10x10 map. I fear that this would "double" the texture memory usage.
  • it would surely double the texture memory, but you should try how fast it is and let us know. in any case i don't think that there is any other solution currently for "What I would need is to apply antialias on the "drawn tilemap" (a Sprite) - after it has been"composed"".

    btw did you test this in practice?:
    "I can't use antialiased tiles, since it would affect their borders and they would show their contact lines in the tilemap as a "grid". "
    as i'm not sure if it behaves like this.
  • piepie Member
    I am sure (I tried :) ) that if I export the tileset with antialias flagged from illustrator it will try to antialias the tile borders too, interpolating the tile border color with the transparent background color - which leads to a visible grid between tiles. (My tile borders are "diagonal" since I am doing this isometric, so I have a series of "pixel stairs" that need to be kept as they are to fit seamlessly)

    I succedeed in filtering the tile textures with gideros (sometimes I miss the obvious) and the result is the same as importing them already anti aliased, see attachment: antialias on left image - you can see the "grid".

    I will try with renderTarget, but I already have almost 30Mb of texture ram busy, and much more on @2x images, i fear the worst.

    Thanks
    antialias.png
    630 x 317 - 332K
  • 30mb*2 is not that outrageous on todays devices.

    i think if you draw a big shape with texture set to "wrap = Texture.REPEAT" and filtering on should be filtered, only the border of the shape won't be filtered, but that's perhaps not so visible if next to it there is a shape with different texture (and not the same).

    but i never did tiling so i just guess around.
  • piepie Member
    unfortunately the border problem occurs on every element on my tileset, on the grass texture is more evident though.

    For the records, on my tablet (which loads @2x images) ram texture counts almost 90mb, if that is going to double I feel it may be too much.
    I just hoped that openGL 2 could have some more "filter" to play with :)
    However I will try with renderTarget on some layers of the tilemap to see what's coming out.

    thank you
  • SinisterSoftSinisterSoft Maintainer
    @pie It would be useful if you could turn it off for specific sprites (and their children). You should suggest this via github.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • piepie Member
    I applied an antialiased renderTarget to my tilemap, but memory consumption as expected increase a lot, and I don't think it's worth the visual improvement.

    for the records:
    54mb with base images on 480x800 resolution
    412mb with @2x on 1600x2560 resolution
  • hgy29hgy29 Maintainer
    @pie, some things that are in preparation for a next release may be able to solve this: user settable shaders.

    If I understand correctly, the problem is that your textures include alpha parts (because they are isometric), hence when filtering edges get mixed with nearby alpha.
    So if you could render them with an appropriate shader, the per-pixel program could check for partial alpha final values and depending on alpha threshold, either revert back the filtering assuming you know if the transparent value color (transparent black or transparent white :P), or completely discard the pixel.

    You could then have texture filtering while keeping sharp edges.
    Theroretically... :D
  • did you try btw using meshes? so your 'grass texture' would be e.g. a square-shape texture and only the mesh would be in this 2.5 shape. this way there wouldn't be a gap between tiles.

    another trick would be if you want simple tiles, no trick with meshes to make the tiles a little bigger then needed and then they overlap slightly, this way you don't see the gaps.
  • piepie Member
    @hgy29 these shaders look very promising! thank you!
    I'm looking forward to seeing them in action! :D

    I think that you understood perfectly what happens, however anyone can see it clearly in the attachments with a bit of zoom in.



    antialias2.png
    256 x 192 - 35K
    antialias2_alpha.png
    256 x 192 - 48K
  • piepie Member
    edited June 2015
    @keszegh isometricTilemap already use meshes to place textures down, it seems that it is doing well (except this anti aliasing side effect). And using 2.5 tiles I can build my maps with Tiled. :)

    I tried also cheating, "extending" the meshes which compose the tilemap by 1 pixel on each vertex, but unfortunately it doesn't come out as perfect as "sharp textures" with the correct values.

    thanks for your thoughts

    Likes: rodri

    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.