It seems that the coords in the Rect of every GUI.* function are rounded to nearest integer before rendering.
So, for example, a sprite wouldn’t move smoothly across the screen?
How do you do it? Move it using the GUI.matrix?
It seems that the coords in the Rect of every GUI.* function are rounded to nearest integer before rendering.
So, for example, a sprite wouldn’t move smoothly across the screen?
How do you do it? Move it using the GUI.matrix?
It would, since a pixel is the smallest unit that can be displayed anyway. If you have problems with smoothness, make sure vsync is on, so the display updating is synced to the monitor.
–Eric
Yeah, but I think that internally the graphics API accepts floating point numbers, and in fact there is a difference in the way the graphics card treats 40 vs 40.5322.
This is an explanation I have found:
So, the difference is in the graphics cards doing a filtering when fetches the texture color.
That’s why you have to sum 0.5 when passing the UV coords to DirectX, because it takes the pixel origin at its center and if you dont do that your texture gets filtered.
This filtering of course is desirable when you want your sprite appear to move smoother around your screen.
He’s right, Eric.
I did it like this-
take this code
Window (i,Rect (theX,theY,100,28), titleWin,"");
replace it with this.
var pos = new Vector3(theX,theY,0);
var q = new Quaternion(0,0,0,1);
var s = new Vector3(1,1,1);
var tMatrix : Matrix4x4 = Matrix4x4.TRS(pos, q, s);
GUI.matrix = tMatrix;
Window (i,Rect (0,0,100,28), titleWin,"");
perfect sub-pixeling…
Cool, thanks Brian. Note that you can create the matrix like this too …
var tMatrix : Matrix4x4 = Matrix4x4.identity;
tMatrix[0,3] = theX;
tMatrix[1,3] = theY;