I'm drawing a quad and binding a texture to this quad like this:
#define TERRAIN_WIDTH 2000 #define TERRAIN_LENGTH 2000 #define TERRAIN_WIDTH_2 (TERRAIN_WIDTH / 2) #define TERRAIN_LENGTH_2 (TERRAIN_LENGTH / 2) glBindTexture(GL_TEXTURE_2D, gameTextures.terrain); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex3f(-TERRAIN_WIDTH_2, 0.0f, TERRAIN_LENGTH_2); glTexCoord2f(X, 0); glVertex3f( TERRAIN_WIDTH_2, 0.0f, TERRAIN_LENGTH_2); glTexCoord2f(X, X); glVertex3f( TERRAIN_WIDTH_2, 0.0f, -TERRAIN_LENGTH_2); glTexCoord2f(0, X); glVertex3f(-TERRAIN_WIDTH_2, 0.0f, -TERRAIN_LENGTH_2); glEnd(); glBindTexture(GL_TEXTURE_2D, 0);
X would be equal to
1 but this will stretch the texture because the quad is very large. The idea is to increase that value so the texture is repeated (the texture was generated with
GL_REPEAT of course).
But how should I find the best value for
X? I have a few 512x512 textures which look nice if I replace
X=512. Then I have another 1024x1024 texture which looks good to with
X=512 but doesn't start to look so good with a higher/lower value. Another texture is 2048x2048 and now I need to go down to
X=256, otherwise it won't look so good.
What's confusing me even more is the fact that both 512x512 and 1024x1024 textures look good with
X=512. The way I see it, the lower the texture resolution, the more times I need to repeat it.
How should I calculate the value of X then?
Xso that it “looks good” I doubt there is a formula. Could you maybe provide some screenshots of the visual effects that disturb you? Also, remember that quads are deprecated in OpenGL and you should use triangles instead (together with vertex buffers). Finally, displaying several quads instead of a large one will help you organise your scene better. \$\endgroup\$
X = 524288 / Swhere
Sis your texture size should work. \$\endgroup\$
Xfor 1024 textures) but it actually looks much better with
X=1024, which is the number that little formula gives for
S=512. Everything makes sense now. You want to answer that below so I can mark the answer as accepted? About mipmaps, I haven't generated them yet, why? \$\endgroup\$