Author Topic: Float Positioning Blit Images  (Read 7971 times)

Offline Jamiro

  • byte
  • *
  • Posts: 36
    • View Profile
Float Positioning Blit Images
« on: April 24, 2018, 09:53:24 am »
Hello,

I've been using blit function to emulate a HUD, but it seems it only use integer-based coordinates which can lead to an aliased animation while positionining when the values are decimal, so for example if I have a point in screen that has a coordinate of 1,5x; 10,8y, it would need to be round or truc to its integer value thus leading to rough representation when these values tend to change.

So my question is, is it possible to have a blit with decimal based coordinates? The only solution I've came up so far is using an object in space coordinates and constantly project its coordinates onto a parallel plane to the screen using Interact2D which could reduce performace exponentially much more than using blit. Is there any other good and correct way to do this?

thanks

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Float Positioning Blit Images
« Reply #1 on: April 24, 2018, 10:25:31 am »
Well...that the blit() methods take integers only is caused by the software renderer. It can't do subpixel-blitting and the methods reflect that. It's not as easy as it might look at first glance to change this now. To make me understand this better: What kind of HUD is that? Why exactly do you need floats to blit it?

Offline Jamiro

  • byte
  • *
  • Posts: 36
    • View Profile
Re: Float Positioning Blit Images
« Reply #2 on: April 25, 2018, 04:50:45 am »
Ok, so there's a reason why it can't, but...

Couldn't it be done using a simple condition inside the blit method that checks if it's using Software or Hardware and depending on which context is being used it switched to either an integer blit or float blit (while changing only the outside parameters to be of Float type thus keeping retrocompatibility)?

I'm currently making progress bars and 2D-point indicators. When the progress bar increases or decreases the effect is too sharp when its changing by small units, so it its not as smooth as if I were to use a space sprite. It also happens when using dots on a grid, if I change a dot a very small increment in position it will not have a smooth change, it will be moving as if it were painted like a bitmap raster, instead of a smooth raster.

like the example below illustrates a change of position of a sprite's pixel:

1- integer positioning mode:


2- float positioning mode:


is it possible to update the blit method to satisfy both rendering modes while keeping it's legacy?
If so it would give a more accurate way of making smoother animated UI components.

Offline Jamiro

  • byte
  • *
  • Posts: 36
    • View Profile
Re: Float Positioning Blit Images
« Reply #3 on: April 26, 2018, 11:27:08 am »
Do you think it is possible to add this change or is there any other way I can obtain this result?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Float Positioning Blit Images
« Reply #4 on: April 26, 2018, 12:39:59 pm »
I'll have a look...

Offline Jamiro

  • byte
  • *
  • Posts: 36
    • View Profile
Re: Float Positioning Blit Images
« Reply #5 on: May 03, 2018, 10:07:48 am »
Is it also possible ATM to rotate any blit image? If I wanted to add any HUD element that uses rotation around any given pivot, like a 2D sprite, is there any way to do it? If not so, is it possible to add it in a near future?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Float Positioning Blit Images
« Reply #6 on: May 03, 2018, 11:26:25 am »
No, it's not possible but you could use an Overlay instead.

Offline Jamiro

  • byte
  • *
  • Posts: 36
    • View Profile
Re: Float Positioning Blit Images
« Reply #7 on: July 09, 2018, 07:13:20 pm »
Hello, any news about this possibility to add a decimal coordinate system for blitting?

thanks

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Float Positioning Blit Images
« Reply #8 on: July 09, 2018, 11:52:46 pm »
Sorry, seems like I've forgot about it. I remember looking at it, but I can't remember the outcome. I'm on holidays ATM, but I'll look at it again once I'm back.

Offline Jamiro

  • byte
  • *
  • Posts: 36
    • View Profile
Re: Float Positioning Blit Images
« Reply #9 on: July 09, 2018, 11:58:33 pm »
Sure, no worries, take your time

Offline Jamiro

  • byte
  • *
  • Posts: 36
    • View Profile
Re: Float Positioning Blit Images
« Reply #10 on: September 01, 2018, 07:56:08 pm »
Hello,

getting back again on this matter, the outcome was because on Hardware Renderer we can blit with a floating coordinate system, whereas in the softwre renderer we can't, but we could use floating type for both and then just use the float point for hardware and cast to int on the software renderer, thus having the legacy code running well keeping compatibilty. I think that was the feasable idea behind this whole conversation.

lemme know if its possible to do or not,

many thanks,

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Float Positioning Blit Images
« Reply #11 on: September 04, 2018, 08:58:29 pm »
Yes, that should work. I'll try to add it in the next few days.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Float Positioning Blit Images
« Reply #12 on: September 04, 2018, 11:45:20 pm »
And software-rendered Polylines, please?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Float Positioning Blit Images
« Reply #13 on: September 05, 2018, 08:10:24 am »
That's a whole different beast. Would it be sufficient to have them without depth buffering?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Float Positioning Blit Images
« Reply #14 on: September 06, 2018, 10:43:06 pm »
Hello,

getting back again on this matter, the outcome was because on Hardware Renderer we can blit with a floating coordinate system, whereas in the softwre renderer we can't, but we could use floating type for both and then just use the float point for hardware and cast to int on the software renderer, thus having the legacy code running well keeping compatibilty. I think that was the feasable idea behind this whole conversation.

lemme know if its possible to do or not,

many thanks,

Ok...as always, even simple things are not as simple as they seem at first glance, but this might do the trick:

https://jpct.de/download/beta/jpct.jar

and for jPCT-AE

https://jpct.de/download/beta/jpct_ae.jar

I've simply replaced the int types in the blit methods by floats. It worked fine on my tests albeit I didn't test the actual sub-pixel stuff.