Performance issues with textures

Started by
14 comments, last by MARS_999 20 years, 6 months ago
Why would you need to render a 256x256 texture across every ''tile''? I get away with ever four or six, and the new method I am planning on implementing should allow for only every 10 or 12.
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
Advertisement
quote:Original post by Raloth
Why would you need to render a 256x256 texture across every ''tile''? I get away with ever four or six, and the new method I am planning on implementing should allow for only every 10 or 12.


I only know of two ways to apply textures to a polygon.

1. set texture coords to 0 through X where X is the number of times you want the texture to tile. e.g. 0,1,2,3.. 256

2. however many polygons you have is X / Map_size to stretch the texture over the whole 256x256 map e.g. 0/256 1/256 ect..

I don''t know any other ways to do this? I wouldn''t even know how to tile 20 times over a 256x256 terrain map?
quote:Original post by rick_appleton
yes you are right about culling being a fillrate problem.

So you have a gods viewpoint of the entire map. And the map is instead of a scanner do I understand? Or can you zoom out. Either way, if you need to tile that texture that often for the result to look good, it is too detailed a texture. Here''s another calculation for you.

If you use mipmapping (which you are I believe), the GPU selects a level of mipmap that corresponds to the approximate size on screen.

Assuming all 256x256 tiles are visible, with each tile a 256x256 pixel texture:
So we have your 256x256 texture tiled acros the screen 256 times in two directions. Using the width of your screen 1280 means that each tile takes about 5 pixels on the screenwidth, and for ease of calculation also 5 pixels vertically. So your 256x256 texture is mipmapped to 128, 64, 32, 16, 8. The 5th level of mipmapping is used. To get the exact same visuals, you should be able to replace your 256x256 pixel texture with a 8x8 pixel texture.

I''m not sure if this would also have a large effect on framerate, but I''d be interested in seeing what this does to the framerate.

Could you try this out and post the results here?

If you are zooming in and out, and need the detail when at ground level, maybe you should try to fade out certain texture levels when zooming out. So when zoomed all the way out, you want need the most detailed texture. As you zoom in, gradually fade in that detailed texture, until at some certain viewpoint, you can see it all.

about your other question: why are mipmaps used. If you don''t use them, the GPU will have to skrunch up your texture on the fly it the texture is not mapped one-on-one to the screen. Normally this skrunching is not optimal. By using mipmaps you can precalculate the skrunching, and you will have more time to do it (normally). Therefore, better algorithms can be used to generate a nicer result.
You can try it easily your self. Create a checkerboard image, and stick it onto a quad as in this picture (the right quad with perspective): http://www.cmlab.csie.ntu.edu.tw/~robin/JavaGL/Example-app/images/checker.gif . Now check the difference between using mipmaps or not using them (run it twice with different settings, or better make two quads and load the texture twice with different settings). If you make the quad bigger than no this picture, you should clearly see the better visual result of using mipmaps.

[edited by - rick_appleton on October 10, 2003 3:15:14 AM]



Rick I hope to try that test run to check for performance soon. I just been really busy. I will post them when I get them done.
no problem, and thanks for keeping us updated
about your question on how to tile less.

You could calculate the texture coordinates for each vertex. Then the texture coordinates would be 0 for the first vertex, 0.5 for the second and 1.0 for the third. Then 1.5, 2.0, 2.5 etc. This stretches the texture over two tiles (in one direction, so actually over 4 tiles). Another option is calculating texture coordinates such that the bottom left of the entire grid has uv (0,0), and the top right of the entire grid is (1.0, 1.0) and then using a scale in texturespace. Not sure how to do that, you could search for it. Basically, that way you could VERY easily tile your texture a certain number of times, by just changing the texturetransform. It might cost a little overhead since the texture coordinates will have to be transformed (should be very small overhead tho, simply a matrix multiplication).

Googled it for you:

glMatrixMode(GL_TEXTURE);
glScalef(0.5, 0.5, 1.0); // dont care about last coordinate?
glMatrixMode(GL_MODELVIEW);

should do the trick I think. This will obviously scale the texture twice.
Thanks Rick.

This topic is closed to new replies.

Advertisement