Fixed ratio without losing quality?

Hi, I have an issue about fixed ratio. I am working on pixel game and when the screen size changes it zoom out or in to keep safe the ratio. However, it makes quality looks bad. How can I fix it?

Could you describe what you mean by the quality looks bad? Does it look “blurry”? It might help if we could see a screenshot. :slight_smile:

Actually, It is a project so I should not share screenshots. Yeah, it looks blurry. Actually I didn’t get the idea of “vmath.matrix4_orthographic’s paramaters”. Documentation says it is left, right, bottom, top but i cant get the idea :confused:

One thing that might help would be to change the game.project setting default_texture_mag_filter to nearest instead of linear under the graphics category.

(Essentially this means that when rendering a “magnified” texture/sprite, the filtering will use “nearest neighbour sampling” instead of interpolating linearly, some detailed information here, and in our own documentation here.)

4 Likes

vmath.matrix4_orthographic basically just defines a box. The left, right, bottom, and top parameters are just positions in the game world on each axis. So if you wanted to draw an 800x800px square area centered on the origin, you would use

vmath.matrix4_orthographic(-400, 400, -400, 400, -1, 1)
-- the last -1 and 1 are the near and far z positions. 

If you wanted to offset that view 200px to the right, you would do:

vmath.matrix4_orthographic(-200, 600, -400, 400, -1, 1)

Okay, I handled the situation. However there is another problem. When the screen size is changed the render handles the zooming part. So game does not have bigger or smaller view sprites. However, when the screen size is changed the center position changes there is an example :

How can i fix this situation? I tried viewport but the result was not satisfying. It scales the circle and it looks like ellipse because of the wrong ratio. Any idea about this problem?

While it’s good to understand the ins and outs of the render script I would suggest that to save yourself some headache to look into one of the camera extensions in our Asset Portal. The camera extension will allow you to scale, stretch, fit and zoom your view. The camera extensions typically also help with following a game object, doing camera effects such as shake and recoil etc,

2 Likes