• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

[SOLVED] 3d Camera in 2d world is off by 1/1000 of a pixel? (Pics)

RujiK

Member
I'm using a custom 3d camera in a 2d looking game. The camera works fine UNLESS I move beyond 1000 pixels to the right, and then I get a weird seam in the ground and everything is raised by one pixel:



I'm guessing every tile is slowly building up a fraction as I go to the right until it adds up to more than 1. I've tried using a custom view matrix as well as matrix_build_lookat, but both give these seams (although in different x positions.)
Code:
          [1.0    0.0     0.0     0.0]
_matrix = [0.0    0.707  -0.707   0.0]
          [0.0    0.707   0.707   0.0]
          [x      y       z       1.0]
0.707 = cos(45), sin(45)

...or like this:

_matrix = matrix_build_lookat(cam_x,cam_y     ,cam_z     ,
                              cam_x,cam_y - 16,cam_z + 16, 0, 1, 0)

///Draw event
matrix_set( matrix_view, _matrix );
I've tried randomly adding +/- 0.01 to each value in the matrix but it just seams to move the seam around, nothing can eliminate it.

Can anyone help? This has me stumped. (Generous upvotes for your time if that is any incentive.) Thanks!
 
I've got a couple questions.

Are you drawing sprites, tiles, or vertex buffers, or something else?

What are the values of cam_x, cam_y, and cam_z? Knowing these values will help making testing easier.

When you attempted to make a custom matrix, how did you attempt it?

Finally, is the effect that you are attempting here just a rotation around the x axis? If so, for what purpose?
 

RujiK

Member
Vertex_buffers. The custom matrix is actually based on your code from your "2D Billboard Example" :D

Fortunately, this was just a case of me being an idiot and having tunnel vision for the matrix. I went to bed very frustrated after two hours of no progress and guessing floating points must be to blame.

While getting ready for work and in the shower, I had a "Eureka!" moment. I forgot I had this code for vertex positions to prevent z fighting:
Code:
xpos = (xx + offset_x);
ypos = (yy + offset_y) + (xpos*0.01)/16; <- OOPS.
zpos = (zz + offset_z);
Oops. I'm dumb. Thanks for the help though! And also your 2d billboard example has helped me tremendously so thanks for that too. Solved.
 
Top