1
\$\begingroup\$

I have created a textured plane in blender of size 2×2 and I am using that as a tile. This is the screenshot of what I have done in blender. Nothing special, the default plane on origin, I just added a texture.

enter image description here

I exported this plane to iPhone as POD file. And using below code, I created my tile map.

//getting the tile
CC3MeshNode * greenSlate  = (CC3MeshNode*)[self getNodeNamed:@"GreenSlate"];

CC3Vector greenSize       = [self returnSizeOfNode:greenSlate];

//This one printed as 2.0, 0.0, 2.0 .     
NSLog(@"greenSlate : %f  %f %f", greenSize.x, greenSize.y, greenSize.z);

float xOffset           =   -3;
float zOffset           =   -3;

for (int column = 0; column < 3; column++) {
    for (int row = 0; row < 3; row++) {
        CC3MeshNode * mesh  =   nil;

        float xStart        =   xOffset;
        float zStart        =   zOffset;

        mesh            =   [greenSlate copy];

        xStart          =   xOffset + column * greenSize.x;
        zStart          =   zOffset + row * greenSize.z;

        mesh.location   =   cc3v(xStart , 0  , zStart);
        mesh.visible    =   YES;

        //add to scene
        [self addChild:mesh];
    }
}

And when I run on simulator, I am getting this.

enter image description here

The tiles are at correct position, but there is a black line between each tile. How can I remove these lines?

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

Guess this is a rounding issue. Have you tried rounding your vertex coordinates?

\$\endgroup\$
4
  • \$\begingroup\$ I thought of that too.. The size of one tile is 2 x 2.. And the xStart and yStart in the above code takes values : -3.0, -1.0, 1.0 (I did an NSLog) which is round I think. \$\endgroup\$ Commented Jul 12, 2013 at 8:27
  • 1
    \$\begingroup\$ Just to be sure, what happens when rendering white untextured quads? Since you're not reusing vertices, I'd try letting them overlap a tiny bit. This can be hardware and resolution dependent, but I'd try some small value. \$\endgroup\$
    – Mario
    Commented Jul 12, 2013 at 8:36
  • \$\begingroup\$ Super @Mario, yes.. When I run untextured quads, there is no lines in between.. Oops and I need it to be textured. \$\endgroup\$ Commented Jul 12, 2013 at 8:48
  • \$\begingroup\$ Then there's something happening with your texture, try playing around with texture quality/filtering options as well as texture wrapping. \$\endgroup\$
    – Mario
    Commented Jul 12, 2013 at 9:01
0
\$\begingroup\$

Okay I solved it. The issue was pretty basic, and I guess basics is what I haven't learn about openGL.

I was using a texture of dimension 200 x 200, but openGL requires textures to be the power of 2 to avoid rounding artifacts. So I changed my texture to 256 x 256, and voila the black lines went away.

One other thing causing this weird lines is explained here.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .