GLBasic forum

Main forum => GLBasic - en => Topic started by: bigtunacan on 2011-Nov-02

Title: Jaggies with POLYVECTORs ?
Post by: bigtunacan on 2011-Nov-02
I'm using polyvectors to create my sprites as I'm loading my images from TexturePacker and targeting iPhone.

I'm now noticing major jaggies.  My images are all PNG format.  When I open my texture atlas PNG file it looks find, no aliasing problems on it's own.  Once I load the images into my game, the aliasing is super bad.

I've attached a sample image where you can clearly see what is happening.

Code (glbasic) Select

STARTPOLY 0,0 // Bitmap = No.0
  POLYVECTOR  x,    y,  txt_spr.tx1,  txt_spr.ty1, RGB(255, 255, 255)
  POLYVECTOR  x, y+height, txt_spr.tx1, txt_spr.ty2, RGB (255, 255, 255)
  POLYVECTOR  x+width, y+height, txt_spr.tx2, txt_spr.ty2, RGB(255, 255, 255)
  POLYVECTOR  x+width, y, txt_spr.tx2, txt_spr.ty1, RGB(255, 255, 255)
ENDPOLY




[attachment deleted by admin]
Title: Re: Jaggies with POLYVECTORs ?
Post by: erico on 2011-Nov-02
Do you have
smoothshading true going on?
Title: Re: Jaggies with POLYVECTORs ?
Post by: Wampus on 2011-Nov-02
Alpha channel issues perhaps? Check ALPHAMODE?

Is this something that started happening that previously was working OK?
Title: Re: Jaggies with POLYVECTORs ?
Post by: bigtunacan on 2011-Nov-02
I'm not setting anything for SMOOTHSHADING or ALPHAMODE currently.  The images are not being scaled.  I think this has been a problem since I started the project, but it just wasn't as noticeable until I started adding in my menus where it really jumps out.
Title: Re: Jaggies with POLYVECTORs ?
Post by: erico on 2011-Nov-02
Using pngs with alpha and alphamode -1 was a solution for similar problems we had before, give a go.
But your PNG must have antialiase going on on the likes of photoshop.

Where are you drawing your gfx?(what program)
Title: Re: Jaggies with POLYVECTORs ?
Post by: Qube on 2011-Nov-02
Could you be experiencing the same issue as I am? http://www.glbasic.com/forum/index.php?topic=6671.msg59044#msg59044

If possible can you roll back you GLBasic Version to at least 10.118 and see if it's still the same?
Title: Re: Jaggies with POLYVECTORs ?
Post by: spacefractal on 2011-Nov-02
I mind have seen that issue in my game too. My artist say it's a multiply and need a demultiply first.

I think the image have designed with "White" as background, not black.

So I think it's depend how you draw to the back buffer (example from a offscreen).

To test, try to fill the screen with White instead of black and see the alpha issue is gone and eventuelly with transperancy set to -1
Title: Re: Jaggies with POLYVECTORs ?
Post by: bigtunacan on 2011-Nov-02
My images are all png files that were created on a transparent/no background.
Title: Re: Jaggies with POLYVECTORs ?
Post by: spacefractal on 2011-Nov-02
I guess its the same issue you have as I have in the attachement (the box behind the toy mouse is darker than floor rather than lighter)? so you can see I have seen that issue myself and guess that is what it happens to you.

For testing for your self, try to create a 25% as well 75% alpha on the png picture and draw it and see what it happens. So its somewhere wrong blend mode you use.

Here I remember I fixed when I in started used OFFSCREEN, I just filled a WHITE background insterad of a black CLEARSCREEN. Alternativt dont use OFFSCREEN, which I dont think you use it here?

Here is more reading about the issue I think you have:
http://www.quasimondo.com/archives/000665.php


PS. Filename is in danish and read something like this: "This look completly wrong that one".

[attachment deleted by admin]
Title: Re: Jaggies with POLYVECTORs ?
Post by: bigtunacan on 2011-Nov-03
I'm using a premultiplied alpha channel in a png file like Ocean said.  The link regarding the related floating point issues are related to Flash are you saying this is also a problem in GLBasic? I thought that png with alpha was preferred in GLBasic...
Title: Re: Jaggies with POLYVECTORs ?
Post by: spacefractal on 2011-Nov-03
Its was not direcly that, but more you got idea what it happens
Title: Re: Jaggies with POLYVECTORs ?
Post by: Slydog on 2011-Nov-03
Have you got this working yet? 
Isn't your problem the jagged edges, and that there's no blending?

Three things need to be in place:
1. PNGs with a transparent background (gray checkered effect in most graphic tools)
2. PNGs need to be blended at the edges (if you sample the border pixels, the alpha value shouldn't just be 0% and 100%, but variable between 0 and 100, try a 'Blur' filter/command to make sure)
3. Use the 'ALPHAMODE -1' command to enable alpha blending (this MAY need to be called every frame, not sure)
Title: Re: Jaggies with POLYVECTORs ?
Post by: Crivens on 2011-Nov-03
QuoteUse the 'ALPHAMODE -1' command to enable alpha blending (this MAY need to be called every frame, not sure
Various things reset it even before doing a SHOWSCREEN. Just incase do it every time you want to draw something.

Cheers
Title: Re: Jaggies with POLYVECTORs ?
Post by: Wampus on 2011-Nov-03
Just a side note. So far I've been using:-

STARTPOLY [textureatlassprite], 1
ALPHAMODE -0.99


to start off my draw routines. I then end with:-

ALPHAMODE -0.99
ENDPOLY
SHOWSCREEEN


If I don't do it this way, i.e. use ALPHAMODE -0.99 instead of ALPHAMODE -1.0 then ALPHAMODE settings get stuck on -1.0 even if I try to change the setting while drawing new sprites from the chosen texture atlas.