New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phaser doesn't take PixiJS resolution texture into account #1707

Closed
alamboley opened this Issue Mar 31, 2015 · 8 comments

Comments

4 participants
@alamboley

alamboley commented Mar 31, 2015

Hey there,

In PixiJS we have a resolution argument in its constructor so we can handle several assets size see the Resolution and Retina! part.
The Phaser.Game object doesn't offer this kind of functionality, so how could we handle multiple assets size without fighting on our side on different assets size / scale factor multiplication and so on... ?

The long story is on the forum.

Thanks.

@alamboley

This comment has been minimized.

Show comment
Hide comment
@alamboley

alamboley Mar 31, 2015

Ok, got it from there: #1621 You should update the book ;)

It rises me an other issue, PixiJS only manages 1 and @2x ; so how could I manage many assets scales from [0.25,0.375,0.5,0.75,1] ; from iPhone 3GS, iPhone retina, iPhone 6(+), iPad retina... Obviously, I will put android devices resolutions close to the iOS one corresponding.

Any ideas guys? @GoodBoyDigital @englercj

Maybe we should add into Texture a scale. If Pixi's texture have a scale, it enables us to have the same image size no matter the image resolution used.

Example : I designed my image for the iPad retina, it's 100 x 100. I defined it as a 4x.
Now on an iPhone 3GS, I load the 1x, but I want it to be reported as a 100 x 100 so I won't fight with positionning...

Does that make sense? At that time we're fighting fiercely with our more than 2 assets resolutions.

alamboley commented Mar 31, 2015

Ok, got it from there: #1621 You should update the book ;)

It rises me an other issue, PixiJS only manages 1 and @2x ; so how could I manage many assets scales from [0.25,0.375,0.5,0.75,1] ; from iPhone 3GS, iPhone retina, iPhone 6(+), iPad retina... Obviously, I will put android devices resolutions close to the iOS one corresponding.

Any ideas guys? @GoodBoyDigital @englercj

Maybe we should add into Texture a scale. If Pixi's texture have a scale, it enables us to have the same image size no matter the image resolution used.

Example : I designed my image for the iPad retina, it's 100 x 100. I defined it as a 4x.
Now on an iPhone 3GS, I load the 1x, but I want it to be reported as a 100 x 100 so I won't fight with positionning...

Does that make sense? At that time we're fighting fiercely with our more than 2 assets resolutions.

@gsynuh

This comment has been minimized.

Show comment
Hide comment
@gsynuh

gsynuh Mar 31, 2015

-> Maybe a Texture could have a scale property (as well as resolution).

if my source image represents a half scale asset, (low resolution texture) , I could tell Texture it has a scale of .5 .
The source's width/height would be multiplied by 2 (1/.5) when calculating its uv...
Essentially having a low res version of that asset - but that would also let us load any arbtirary scale of textures, and still work with the same units and never have to change our code (only the texture scales when its fit to load higher quality textures).

gsynuh commented Mar 31, 2015

-> Maybe a Texture could have a scale property (as well as resolution).

if my source image represents a half scale asset, (low resolution texture) , I could tell Texture it has a scale of .5 .
The source's width/height would be multiplied by 2 (1/.5) when calculating its uv...
Essentially having a low res version of that asset - but that would also let us load any arbtirary scale of textures, and still work with the same units and never have to change our code (only the texture scales when its fit to load higher quality textures).

@GoodBoyDigital

This comment has been minimized.

Show comment
Hide comment
@GoodBoyDigital

GoodBoyDigital Mar 31, 2015

Hey there this has been addressed in v3

bg_zone_1@0.5x.png <- that would be a resolution of 0.5;

GoodBoyDigital commented Mar 31, 2015

Hey there this has been addressed in v3

bg_zone_1@0.5x.png <- that would be a resolution of 0.5;

@gsynuh

This comment has been minimized.

Show comment
Hide comment
@gsynuh

gsynuh Apr 1, 2015

Hi @GoodBoyDigital ,

Thanks for the reply, this is great news.
Am I correct to assume that whatever the resolution of a texture, its representation in the form of a Sprite for example, if no transformation is done on the stage, itself, and any parent in between, said sprite would appear at exactly the same size (and report the same width/height) as if its texture was at resolution 1 ? (just need a confirmation sorry if I'm repetitive)

if so this is amazingly helpful for multi-resolution/multi-device/multi-screen whatever we want to call it, as well as not having to just use letterbox mode or just scale everything with the game's resolution.

my only wish would be to have resolution specifically aimed at using different assets for different screen pixel 'densities' if you will, and having a different factor with a different name , like "scale" which in that case is really about different screen or window or browser size and a scale for textures. It's the same in the end really (in fact they would be mulitplied together I guess) but the word "resolution" I find can be confusing when using this property for different purposes as it was designed for.


So now I'd like to hear about Phaser and its position on this, as in my project as far as I can tell, this is not yet working (Phaser 2.3) I do see the pixi package having the right code for @2x for example (so older than v3) , in PIXI.BaseTexture.fromImage however this specific function is never called in my project - looking at Phaser.Loader/Phaser.Cache, it seems Phaser creates its BaseTextures/Texture in its own way - and just apparently not taking resolution of textures (into account. Please do correct me if I'm wrong, I've spent time looking at the source of master and dev branch as well but this must already be clear to frequent contributors.

Confirming that it isn't available yet at least would let me know I'm not doing anything wrong - appart from reading the source code clearly wrong then which is very very likely.

Anyway thank you very much for your time, have a nice day !


cc @photonstorm ,

gsynuh commented Apr 1, 2015

Hi @GoodBoyDigital ,

Thanks for the reply, this is great news.
Am I correct to assume that whatever the resolution of a texture, its representation in the form of a Sprite for example, if no transformation is done on the stage, itself, and any parent in between, said sprite would appear at exactly the same size (and report the same width/height) as if its texture was at resolution 1 ? (just need a confirmation sorry if I'm repetitive)

if so this is amazingly helpful for multi-resolution/multi-device/multi-screen whatever we want to call it, as well as not having to just use letterbox mode or just scale everything with the game's resolution.

my only wish would be to have resolution specifically aimed at using different assets for different screen pixel 'densities' if you will, and having a different factor with a different name , like "scale" which in that case is really about different screen or window or browser size and a scale for textures. It's the same in the end really (in fact they would be mulitplied together I guess) but the word "resolution" I find can be confusing when using this property for different purposes as it was designed for.


So now I'd like to hear about Phaser and its position on this, as in my project as far as I can tell, this is not yet working (Phaser 2.3) I do see the pixi package having the right code for @2x for example (so older than v3) , in PIXI.BaseTexture.fromImage however this specific function is never called in my project - looking at Phaser.Loader/Phaser.Cache, it seems Phaser creates its BaseTextures/Texture in its own way - and just apparently not taking resolution of textures (into account. Please do correct me if I'm wrong, I've spent time looking at the source of master and dev branch as well but this must already be clear to frequent contributors.

Confirming that it isn't available yet at least would let me know I'm not doing anything wrong - appart from reading the source code clearly wrong then which is very very likely.

Anyway thank you very much for your time, have a nice day !


cc @photonstorm ,

@GoodBoyDigital

This comment has been minimized.

Show comment
Hide comment
@GoodBoyDigital

GoodBoyDigital Apr 1, 2015

Am I correct to assume that whatever the resolution of a texture, its representation in the form of a Sprite for example, if no transformation is done on the stage, itself, and any parent in between, said sprite would appear at exactly the same size (and report the same width/height) as if its texture was at resolution 1 ? (just need a confirmation sorry if I'm repetitive)

yes, this is now how it now works :) different resolutions will always have the same width/ height once in pixi.

GoodBoyDigital commented Apr 1, 2015

Am I correct to assume that whatever the resolution of a texture, its representation in the form of a Sprite for example, if no transformation is done on the stage, itself, and any parent in between, said sprite would appear at exactly the same size (and report the same width/height) as if its texture was at resolution 1 ? (just need a confirmation sorry if I'm repetitive)

yes, this is now how it now works :) different resolutions will always have the same width/ height once in pixi.

@alamboley alamboley changed the title from Phaser.Game doesn't have resolution argument. to Phaser doesn't take PixiJS resolution texture into account Apr 1, 2015

@photonstorm

This comment has been minimized.

Show comment
Hide comment
@photonstorm

photonstorm Apr 1, 2015

Owner

I have no plans on addressing this in Phaser 2.x, sorry. It's too much of an internal change. If that means you need to build your game natively in Pixi 3 when it's released and stop using Phaser then I can fully understand that. Equally if someone wants to add the feature and submit a PR I'd be up for that too.

Owner

photonstorm commented Apr 1, 2015

I have no plans on addressing this in Phaser 2.x, sorry. It's too much of an internal change. If that means you need to build your game natively in Pixi 3 when it's released and stop using Phaser then I can fully understand that. Equally if someone wants to add the feature and submit a PR I'd be up for that too.

@alamboley

This comment has been minimized.

Show comment
Hide comment
@alamboley

alamboley Apr 2, 2015

Thanks for the clarification. We started looking into the Phaser core but it sounded complicated since we don't master yet the Phaser internal architecture.
You confirmed that it would be complicated to include due to the many internal change involved.

Unfortunately, we already spent lot of time on this multi scale assets subject. So we'll just use a scale factor everywhere for the moment, but I hope you plan to add this in Phaser 3. I think it's really important for :

  • a UI framework, it will be way cleaner if there isn't a scale factor involved in each line of code (off topic, but I'd pay bucks for a simple UI framework : layout group, scroll container, list etc. I'm surprised that there isn't yet an UI framework for Pixijs/Phaser).
  • physics, at the moment if my scaled assets don't report the same size, it means that my simulation won't be the same. And I'll probably fight with gravity, force... multiplied again by this scale factor...

Thanks again to both of you for your hard work.

alamboley commented Apr 2, 2015

Thanks for the clarification. We started looking into the Phaser core but it sounded complicated since we don't master yet the Phaser internal architecture.
You confirmed that it would be complicated to include due to the many internal change involved.

Unfortunately, we already spent lot of time on this multi scale assets subject. So we'll just use a scale factor everywhere for the moment, but I hope you plan to add this in Phaser 3. I think it's really important for :

  • a UI framework, it will be way cleaner if there isn't a scale factor involved in each line of code (off topic, but I'd pay bucks for a simple UI framework : layout group, scroll container, list etc. I'm surprised that there isn't yet an UI framework for Pixijs/Phaser).
  • physics, at the moment if my scaled assets don't report the same size, it means that my simulation won't be the same. And I'll probably fight with gravity, force... multiplied again by this scale factor...

Thanks again to both of you for your hard work.

@photonstorm

This comment has been minimized.

Show comment
Hide comment
@photonstorm

photonstorm Jul 7, 2015

Owner

In order to keep the Github issues clear this feature request has been moved to the Phaser 3 wishlist.

Owner

photonstorm commented Jul 7, 2015

In order to keep the Github issues clear this feature request has been moved to the Phaser 3 wishlist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment