|Hosting by PhotoTangler Collage Maker|
Question submitted by (19 January 2000)
|Return to The Archives|
G'Day Midnight, (that's pretty trippy, eh? :)
I'm taking the step up to 3D and have seen that there's lots of docs and stuff out there on how to do all sorts of stuff with triangles, but one topic I haven't seen anything on is scale.
By this I mean what sort of scale is best to use, if there is one? Is it 1 unit == 1 metre, 1 unit == 1 centimetre or something else?
Along with this, is there a rule/guideline or something on what size textures to use along with the scale? I'm asking this because in some programs you see really sharp, crystal clear texturing where you can't see any blurring (like the water room in 3DMark2000), and in other programs (eg Tribes) the textures are blurry.
To me this seems like a really important thing to know if you want to produce top quality visuals. I know you and probably a lot of other people out there are thinking that I'm lazy for not experimenting (which is true, but hey - I'm an Aussie, it's summer down under and I'd rather be over at the beach with the scantily clad girls :), but I thought that this would be a good question to ask as I'm sure that it would be helpful to a lot of other people starting out with 3D.
Howdy Ben (greeting -- Texas style :),
I actually get this question about scale a lot. And the simple answer is, you don't use a scale in your code. You simply treat '1 unit' as '1 unit' (notice the words meter, foot, mile, kilometer, etc. didn't appear in that statement.) The scale comes from the art, not the code.
What I mean is, the tools that are used to create your data (either your level editor, 3DS Max, Maya, LightWave, Random Polygon Generator Pro v8.0, etc.) is what determines the scale. The important thing is that all of the art and level data has to follow the same scale. Consider this:
You build an entire city so that the extents of the entire city fit within a bounding volume that is 10,000 units wide/tall/deep. In this case, one unit might be one meter. On the contrary, you could build that entire city to fit within a bounding volume that is 1 unit wide/tall/deep. In this case, one meter would be 0.0001 units. Will it look any different if everything is scaled equally (including the viewpoint position)? Nope. You might run into precision issues, but other than that, it's the same thing.
There are a few places in your code that you'll need to know about scale. One of them might be your player's movement vector. If your player moves three meters per second and your art is scaled so that 1 meter = 0.0001 units, then your code had better be aware of this. If your code thinks the scale is set to 1 unit = 1 meter, your player will run through the city at light speed. This can easily be fixed by scaling to a constant that is read in from a configuration file that goes along with the art & level data. After all, the speed of a bullet (shot by a weapon) should be set by the level designer who designed the weapon, not by the programmer's code.
Texture quality is best defined as "texel density". In a game like Quake, you might have a texel density of 12 texels to a meter (for example.) If you calculate the surface area of everything that is currently visible, you can multiply by 12 and calculate how many texels must be visible (ignoring the use of mipmapping.) In a game like Quake, there's actually not a lot of surface area to cover, and there's also a lot of tiled textures in use.
However, in a flight simulator that uses satellite imagery, there is a vast amount of texture memory required because there is no tiling (each polygon gets its own unique slice of the satellite image) and you might be able to see for many Kilometers. In this case, you might need a thousand textures or more, which means you'll have to limit your texture size if you plan to fit them all on the card (or at least to reduce texture cache thrashing.)
Let's take a look at Tribes as an example. It's been a long time since I've seen the game so if my example is a little off, please forgive me. Let's assume they're using a ground-tile size of 100x100 meters. Since we can't tile multiple textures over a single polygon, we have to stretch one texture across the polygon. If they used a 256x256 texture, each texel ends up being roughly 40x40 centimeters. That's a pretty big texel. It's also a pretty big tile. Let's reduce the size of the tile, so we get a better texel density. We'll reduce it to 10x10. Now we're looking at each texel being roughly 4x4 centimeters. That's pretty decent, but we've just increased our polygon count by 100x!
Level of detail is a good solution here, in both cases (the standard terrain engine, and the flight simulator.) There are a few other solutions, too, but I'll leave that up as an exercise for the reader.
Response provided by Paul Nettle
This article was originally an entry in flipCode's Ask Midnight, a Question and Answer column with Paul Nettle that's no longer active.