• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Pixel Perfect Surfaces

T

ThunkGames

Guest
Hey,

I am having some trouble with surfaces and the precision to which they are drawn. What I am trying to do is draw "darkness" over every block in my game (at whole number coordinates). A light surface is subtracted from this surface and then it is drawn so that it lines up with the blocks.

Except it doesn't. It does this. Jitteryness in the x and y direction

Blocks are at integer coordinates within the room and the surface is being drawn not scaled and at an integer coordinate in the room.

I am aware that this system is kind of slow, however I first tried drawing everything that could be affected by darkness to a surface (blocks, player, pickups, etc. Not things like the background or the moon), drawing that surface and then drawing it again except passing it though a darkening shader. This resulted in everything appearing jittery, as seen in the above clip.

I'm hoping this has a solution, and I know if it does you all will be able to show me the light. I am turning here because I have exhausted all other outlets.

Thanks!!

-David
 
What is the size of the surface? It shouldn't matter but try making the surface rounded up to nearest POW2. So if your surface size is (640,480), (width,height), make it (1024,512). I know at least with android, this is important with shaders. Windows usually doesn't have issues with this but shaders are tricky.
 

RangerX

Member
And just double checking that its not a scaling issue.... what's your:

- View and port size?
- Application surface size?
- Monitor resolution from which you took that video?
 
T

ThunkGames

Guest
Apologies for the late replies. The alerts didn't appear for me.

What is the size of the surface? It shouldn't matter but try making the surface rounded up to nearest POW2. So if your surface size is (640,480), (width,height), make it (1024,512). I know at least with android, this is important with shaders. Windows usually doesn't have issues with this but shaders are tricky.
I saw this in the manual but didn't think it applied. I suppose I could change the size of the surface from 1024 to 1024 when I get home.

What is the size of the surface? It shouldn't matter but try making the surface rounded up to nearest POW2. So if your surface size is (640,480), (width,height), make it (1024,512). I know at least with android, this is important with shaders. Windows usually doesn't have issues with this but shaders are tricky.
And just double checking that its not a scaling issue.... what's your:

- View and port size?
- Application surface size?
- Monitor resolution from which you took that video?
-Width view: 341.33
-Height view: 192
-Width port: 1600
-Height port: 900
-Application surface width: 1024
-Application surface height: 768

Is the fact that the width is not an integer the problem? I don't see how this could be though because the problem also occurs in the y direction.

Anyways, thank you both for your help. I'll edit the post with the results of making the surface dimensions powers of 2.

-David

EDIT:
Nope, the powers of 2 thing didn't help. Thanks anyways for the suggestion.
 
Last edited by a moderator:

Zerb Games

Member
Sorry not sure what to say on this issue... The stuff I woulda said is already suggested, however on the off chance you didn't change the interpolate between colors, turn it off that helps with blurriness. Also, draw things at floor(x), and floor(y). -Width view: 341.33 is the only thing I can see that would be a problem here. Other than that idk, sorry.
 
S

seanm

Guest
your view has to be an integer, and you lose the guarantee of accurate rendering if you stretch the view ports.


But, are you drawing the surface in the GUI event?
 
A

anomalous

Guest
Can you clarify in your original post, that this is correct:
When you did not use a shader it was OK.
When you switched to using a shader it was misaligned?
 

RangerX

Member
So here's where the jitter comes from:

-Width view: 341.33
-Height view: 192
-Width port: 1600
-Height port: 900
-Application surface width: 1024
-Application surface height: 768

GameMaker takes a rectangle of 341.33 by 192 from your room and renders it. Then oops, it need to resize it to 1600 by 900. At this point your game is scaled up by a fraction value intead of an integer so graphical damage already occurs. Then GameMaker puts your game on the application surface. But it needs to squish it into 1024x768. Any scaling down damages the graphic. Its not good. At this point I even wonder how your game can still look like something.

What you should do is having one view size (integer values) and give the same size for the port on screen. Then you scale up your game with the application surface -- which would also have the same size as the view and port in a case where you don't scale (like if the screen is the same resolution as your view size)
 
T

ThunkGames

Guest
So here's where the jitter comes from:

-Width view: 341.33
-Height view: 192
-Width port: 1600
-Height port: 900
-Application surface width: 1024
-Application surface height: 768

GameMaker takes a rectangle of 341.33 by 192 from your room and renders it. Then oops, it need to resize it to 1600 by 900. At this point your game is scaled up by a fraction value intead of an integer so graphical damage already occurs. Then GameMaker puts your game on the application surface. But it needs to squish it into 1024x768. Any scaling down damages the graphic. Its not good. At this point I even wonder how your game can still look like something.

What you should do is having one view size (integer values) and give the same size for the port on screen. Then you scale up your game with the application surface -- which would also have the same size as the view and port in a case where you don't scale (like if the screen is the same resolution as your view size)
Ok I THINK that coupled with limiting view coordinates to integers has done the trick. Now I have a painful amount of finding, replacing and reworking to do (all of my UI drawing/handling was based on view_wport and view_hport).

Thank you for your help!

-David
 
Top