www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: Jamiro on April 24, 2018, 09:53:24 am

Title: Float Positioning Blit Images
Post by: Jamiro 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
Title: Re: Float Positioning Blit Images
Post by: EgonOlsen 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?
Title: Re: Float Positioning Blit Images
Post by: Jamiro 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:
(https://i.imgur.com/tVIzLUy.png)

2- float positioning mode:
(https://i.imgur.com/2qUKFVv.png)

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.
Title: Re: Float Positioning Blit Images
Post by: Jamiro 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?
Title: Re: Float Positioning Blit Images
Post by: EgonOlsen on April 26, 2018, 12:39:59 pm
I'll have a look...
Title: Re: Float Positioning Blit Images
Post by: Jamiro 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?
Title: Re: Float Positioning Blit Images
Post by: EgonOlsen on May 03, 2018, 11:26:25 am
No, it's not possible but you could use an Overlay instead.
Title: Re: Float Positioning Blit Images
Post by: Jamiro on July 09, 2018, 07:13:20 pm
Hello, any news about this possibility to add a decimal coordinate system for blitting?

thanks
Title: Re: Float Positioning Blit Images
Post by: EgonOlsen 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.
Title: Re: Float Positioning Blit Images
Post by: Jamiro on July 09, 2018, 11:58:33 pm
Sure, no worries, take your time
Title: Re: Float Positioning Blit Images
Post by: Jamiro 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,
Title: Re: Float Positioning Blit Images
Post by: EgonOlsen on September 04, 2018, 08:58:29 pm
Yes, that should work. I'll try to add it in the next few days.
Title: Re: Float Positioning Blit Images
Post by: AGP on September 04, 2018, 11:45:20 pm
And software-rendered Polylines, please?
Title: Re: Float Positioning Blit Images
Post by: EgonOlsen on September 05, 2018, 08:10:24 am
That's a whole different beast. Would it be sufficient to have them without depth buffering?
Title: Re: Float Positioning Blit Images
Post by: EgonOlsen 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 (https://jpct.de/download/beta/jpct.jar)

and for jPCT-AE

https://jpct.de/download/beta/jpct_ae.jar (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.
Title: Re: Float Positioning Blit Images
Post by: AGP on September 07, 2018, 08:05:44 pm
Quote
That's a whole different beast. Would it be sufficient to have them without depth buffering?

Is that like that one I did by extending Polylines? If so, no. ; )

I still haven't solved that displacement issue with AWTGLCanvas, by the way. I don't mean to be pushy but I dream of a day when you update the lwjgl version.
Title: Re: Float Positioning Blit Images
Post by: Jamiro on September 22, 2018, 03:20:25 am
Great, many thanks,

I'll do a quick check on it an let you know,

Regards