Hello Guest

Author Topic: clipping problem on camera edges  (Read 5899 times)

pedrohbalmeida

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 7
    • View Profile
clipping problem on camera edges
« 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,

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: clipping problem on camera edges
« Reply #1 on: December 04, 2014, 10:01:36 am »
Do they both have the same Z values?

pedrohbalmeida

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: clipping problem on camera edges
« Reply #2 on: December 04, 2014, 01:04:05 pm »
Yep! They both have the same Z values.

Best,

pedrohbalmeida

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: clipping problem on camera edges
« Reply #3 on: December 17, 2014, 05:51:16 pm »
Up!

Any news about this problem? If you can't reproduce it, I can send a project sample!

Best regards,

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: clipping problem on camera edges
« Reply #4 on: December 18, 2014, 12:31:50 am »
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.

pedrohbalmeida

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: clipping problem on camera edges
« Reply #5 on: December 18, 2014, 12:49:07 am »
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,

pedrohbalmeida

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: clipping problem on camera edges
« Reply #6 on: December 22, 2014, 04:47:55 pm »
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,

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: clipping problem on camera edges
« Reply #7 on: December 22, 2014, 04:50:18 pm »
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.