12/15/2023 0 Comments Unity pixel perfect![]() I guess that might have something to do with me using floating point coords for sprite positioning, but I also tried it with integer coordinates - and you know, floating point numbers have some trouble accurately representing exact integer values. So one vertex was getting shifted to the left, while the other wasn't, or vice versa. I believe it's somewhat to do with the inaccuracy of floating point math, whereby the result of `rounding` pixel coordinates on one vertex may produce a number that isn't quite rounded in the same way for the other vertices. This was noticeable because I was using a special shader which made it really obvious. ![]() I had a spaceship sprite which, as it moved, it would `wiggle` in a slight and strange way, as if the width of the sprite were alternating between +- 1 pixel width difference. What can happen, and what I have literally seen happen, is that vertices on the left and right edges of a sprite can be 'fixed' differently, and independently. It doesn't have any awareness of the other vertices, and the positions of the other vertices are not affected by this instance of the 'fix'. ![]() In the shader, the code which applies the pixel snap (if I understand it right), applies an adjustment to the position of the current vertex. One thing that bothered me about pixel snap is that it functions on a PER-VERTEX basis. Maybe a tip, a tutorial or any other stuff. It'd be great if you guys could throw some light on this topic. After trying all this with no results, I'm about to quit, is very frustrating.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |