2D Toolkit Forum
2D Toolkit => Support => Topic started by: pedrohbalmeida on December 02, 2014, 10:13:10 pm
-
Hi,
I'm new to 2dtoolkit usage and I'm having some problems with some sprites being clipped at camera edges when they should be visible. I'm using a tk2d perspective camera
I'm attaching two images:
- one illustrates the gap at the edge;
- the other shows that the sprites are tied together. It's the same setup as the first one, only the camera is translated a little bit.
Can you please help me?
Best,
-
Do they both have the same Z values?
-
Yep! They both have the same Z values.
Best,
-
Up!
Any news about this problem? If you can't reproduce it, I can send a project sample!
Best regards,
-
I wrote a long reply about why this could potentially happen, but I'm not sure why it isn't there, perhaps I forgot to post before closing the window...
You can reduce chance of this happening by keeping the anchor in the same position, and making sure your camera is snapped to a pixel if not. Its much harder to do the latter with a perspective camera, so you could potentially also do it with a shader (eg. use the unity2d sprite shader) with pixel snapping.
-
Hi Unikron,
thanks very much for your reply. I've tried using the shader with pixel snap (since it was the easier option) and the problem persists. If it's not asking too much, can you please elaborate about the problem cause?
Best regards,
-
Hi Unikron,
can you please elaborate a little bit on the possibles causes for this problem? At the moment I haven't found a way to fix it :-(
Best regards,
-
The likely cause is floating point precision. If the origins are at different positions, 2 identical vertices transformed as 2 different source objects may end up at different locations. This is far more likely to happen with perspective because of the floating point divide in there. Either use an ortho camera, or add one more pixel to your source art (and let it overhang outside the viewport) to solve it.