R
Robzoid
Guest
I've been trying to learn about subpixel rendering in Gamemaker and I'm confused on where it actually draws objects to the screen for decimal values of x and y. I saw this thread on "How to avoid subpixel rending"
https://forum.yoyogames.com/index.php?threads/how-do-i-avoid-subpixel-rendering.49651/
which lead me to believe that subpixel rendering exists in gamemaker. From what I researched, there are 3 subpixels in a pixel. So, when I tested things, I expected something like x position of 0.0 - 0.3 to look the same, 0.4 - 0.6 to look the same and 0.7 to 0.9 to look the same. I got something much different upon testing.
I made two identical objects with two identically sized sprites - one red, one green for contrast. I set their x values to 480 plus some decimal value. I wanted to see when the red object was visible behind the green object based on the two objects' x values. Pics are below. I added the text in MS Paint. The yellow line at the bottom is one pixel thick for reference.
When the red and green objects' x values are both between 480.0 and 480.5, the two objects are in the same position (i.e. red object is invisible. See pics 3 and 4). I didn't include this in a pic, but when both objects are between 480.6 and 480.9, they are in the same position (i.e. red is invisible behind green). It is only when one is 480.0 - 480.5 and the other is 480.6 - 480.9 that they are in different positions (see pics 1 and 2). Also, see pic 5. The amount the red object sticks out is equal to the 1 pixel-thick reference sprite/object.
This tells me the following: if the decimal value of an x or y value is between 0.0 and 0.5, GM rounds it down (i.e. x = 480). If the decimal value of an x or y value is between 0.6 and 0.9, GM rounds it up (i.e. x = 481). The amount moved is never less than 1 pixel (pic 5).
This, to me, suggests that subpixel rendering does not exist in Gamemaker and that it simply rounds x and y values up or down at the end of each step. Maybe this is a hardware thing? I bought my monitor 2 years ago and my computer is about 4 years old.
Could you guys tell me if I'm off here? If i'm not, I don't understand why people bother with coding collision code that rounds decimal values, like floor(x), floor(y). Maybe it's because they don't like the way Gamemaker rounds? I really don't get it. In my game, I have decimal values all over. My x and y values are rarely integers and I haven't had any problems. Why create separate code to handle decimal values when Gamemaker, at least to my understanding, handle it for you?
https://forum.yoyogames.com/index.php?threads/how-do-i-avoid-subpixel-rendering.49651/
which lead me to believe that subpixel rendering exists in gamemaker. From what I researched, there are 3 subpixels in a pixel. So, when I tested things, I expected something like x position of 0.0 - 0.3 to look the same, 0.4 - 0.6 to look the same and 0.7 to 0.9 to look the same. I got something much different upon testing.
I made two identical objects with two identically sized sprites - one red, one green for contrast. I set their x values to 480 plus some decimal value. I wanted to see when the red object was visible behind the green object based on the two objects' x values. Pics are below. I added the text in MS Paint. The yellow line at the bottom is one pixel thick for reference.
When the red and green objects' x values are both between 480.0 and 480.5, the two objects are in the same position (i.e. red object is invisible. See pics 3 and 4). I didn't include this in a pic, but when both objects are between 480.6 and 480.9, they are in the same position (i.e. red is invisible behind green). It is only when one is 480.0 - 480.5 and the other is 480.6 - 480.9 that they are in different positions (see pics 1 and 2). Also, see pic 5. The amount the red object sticks out is equal to the 1 pixel-thick reference sprite/object.
This tells me the following: if the decimal value of an x or y value is between 0.0 and 0.5, GM rounds it down (i.e. x = 480). If the decimal value of an x or y value is between 0.6 and 0.9, GM rounds it up (i.e. x = 481). The amount moved is never less than 1 pixel (pic 5).
This, to me, suggests that subpixel rendering does not exist in Gamemaker and that it simply rounds x and y values up or down at the end of each step. Maybe this is a hardware thing? I bought my monitor 2 years ago and my computer is about 4 years old.
Could you guys tell me if I'm off here? If i'm not, I don't understand why people bother with coding collision code that rounds decimal values, like floor(x), floor(y). Maybe it's because they don't like the way Gamemaker rounds? I really don't get it. In my game, I have decimal values all over. My x and y values are rarely integers and I haven't had any problems. Why create separate code to handle decimal values when Gamemaker, at least to my understanding, handle it for you?