Hot answers tagged textures
28
I spent a few months at one job coming up with a better texture packing algorithm.
The algorithm we started with was simple. Collect all the input items. Sort them by total pixels consumed, large-to-small. Lay them out in your texture in scanline order, just testing stuff from the topleft pixel to the topright pixel, moving down a line, and repeating, ...
28
Why are the resolution of textures in games always a power of two
(128x128, 256x256, 512x512, 1024x1024, etc.)?
As Byte56 implied, the "power of two" size restrictions are (were) that each dimension must be, independently, a power of two, not that textures must be square and have dimensions which are a power of two.
However, on modern cards and which ...
27
The reason that most systems (even many modern graphics cards) demand power-of-2 textures is mipmapping.
What is mipmapping?
Smaller versions of the image will be created in order to make the thing look correctly at a very small size. The image is divided by 2 over and over to make new images.
So, imagine a 256x128 image. This would have smaller versions ...
22
I wouldn't worry about wasting VRAM for a few character textures.
To me using your option 2. (with different textures or different UV offsets if that fits) is the way to go: more flexible, data-driven, less impact on the code, less bugs, less worries.
This put aside, if you start to accumulate tons of characters with tons of sprite animations in memory, ...
19
I stumbled across this tutorial a while back, which looks to be a good resource:
http://www.gamedev.net/page/resources/_/creative/visual-arts/make-a-particle-explosion-effect-r2701
19
I think part of it may just be that Blizzard has an amazing number of texture artists. But let's rephrase the question a bit:
I have a limited budget and want to make a realtime strategy game without obviously tiling textures. How can I accomplish that?
Good question! Here's a few big tools that I'd use:
1) A reasonably large set of interchangeable ...
18
First of all, I'm not sure why you want to implement a height map (i.e. geometry displacement) if people won't be able to land, it just seems more efficient to normal map it or something.
With that said, what you want is to convert from an arbitrary (x, y, z) to a (u, v) coordinate, which is trivial. No cubemap needed.
Every (u, v) texel has a height ...
17
3D texture works like regular texture. But it is truly 3D. 2D textures has UV coords, 3D has UVW (you had to use them propably). Texture coords are unit cube (0 - 1, 0 - 1, 0 - 1).
Possible usage:
volumetric effects in games (fire, smoke, light rays, realistic fog)
caching light for realtime global illumination (CryEngine for example)
scientific (MRI, CT ...
16
Your understanding is close. Each 3D model is made out of vertexes. Each vertex usually defines the location of a point in space, a normal (used in lighting calculations) and 1 or more texture coordinates. These are generally designated as u for the horizontal part of the texture and v for the vertical.
When an object is textured, these coordinates are used ...
13
PVRTC 2BPP encoding, as introduced in this paper divides an image into 8x4-texel blocks, and compresses each block such that only two RGB colors are stored for each thirty-two texel block.
None of the thirty-two texels stores a color of its own - each texel stores only information about how to blend between the two RGB colors of its 8x4-texel block.
If ...
13
How I'd probably do it so I could maintain some art control and not potentially spend a long time trying to tweak a procedural method to get it just right...
First, manually create a number of sprites of tea leaf clumps as your art "pool" - not each as an entire cup's worth of tea leaves, but more like a smaller grouping. Say, 20 of them or so?
Then place ...
13
Sounds like the scaling algorithm you're using isn't interpolating pixels.
Pictures are best explained with pictures:
It's the Major, first in full, then scaled down with Lanczos (left) and nearest-pixel (a.k.a. no interpolation) (right) to two sizes.
The same comparison, in 3x magnified:
Make sure the scaling you're using is resampling sensibly. For ...
12
Why are textures always square powers of two?
Textures are not always square nor are they always powers of two. The reason why they tend to be powers of two is usually to increase compatibility with older video cards that imposed that restriction. As for non-square textures, that's not usually a problem. To summarize:
Textures typically don't need to ...
11
Terragen Classic is free for personal and non-commercial use: http://www.planetside.co.uk/content/view/19/31/
There are tutorials how to do it around the net.
Then, of course, there is Terragen 2, e-on Vue, and Bryce.
11
A texture atlas is simply a way to stuff multiple sprites into a single texture. You also will need an index into the texture so that you can find where each of the sprites are located.
The reason these are used is because it's more efficient to bind a texture once and change the UV values being used than to bind multiple textures for each sprite you draw.
...
11
JPG and PNG files will almost always be smaller on-disk than in memory; they need to be decompressed on-the-fly to acquire raw RGB data, thus requiring more processing power for the loading and more RAM afterwards. So many modern engines opt to store the same format on disk as they do in memory, leading to files that are the same size as the texture's memory ...
11
3D textures or 'Volume textures' are a series of normal textures arranged as slices, like a deck of cards. These are used in volumetric rendering which often takes real work data such as CT scans and then manipulates them. In games and graphics it's sometimes for volumetric effects like smoke where you trade the flexibility of a particles system for the ...
11
When I did this I ended up making a simple gradient file (xml or image based, doesn't matter) that predetermined the color used at the specified distance between the primary height colors (grass vs. sand for instance). This way, there were inbetween states. What is great about this is that you have full control over the transitions.
I suppose that you could ...
11
I don't understand why you wouldn't want to use an off-the-shelf loader. PNG, for example, is a good choice for a format but is complex to write a general purpose loader for (and probably not worth the effort of writing one that only loads the specific subset of PNG formats you care about).
Given that somewhat unusual requirement, TGA is probably your best ...
11
This is the way I understand it. Could be totally wrong, but I'm sure someone will flame correct me if I'm wrong.
The mathematical theory behind UVW texture mapping is similar to the theory behind UV texture mapping.
See Bummzack's link here: What exactly is UV and UVW Mapping? to get a better explanation of what UV mapping is. Basically, you're mapping ...
11
I think textures are sprites on a 3D object but not sure if that is correct?
No.
Strictly speaking, a texture is a term for one or more images that are bundled together in an object called a "texture", within the context of a GPU-based rendering system. A texture can be used when rendering a 3D object. Or it can be used when rendering a 2D object, ...
11
One option that'll be a lot easier than fiddling with mipmaps and adding texture coordinate fuzz factors is to use a texture array. Texture arrays are similar to 3d textures, but with no mipmapping in the 3rd dimension, so they're ideal for texture atlases where the "subtextures" are all the same size.
http://www.opengl.org/wiki/Array_Texture
10
Content creation tools for procedural texturing have been the biggest roadblock. Artist are very fast putting things together in Photoshop and the potential gains with procedural texturing haven't outweighed the increased content creation time.
Allegorithmic (http://www.allegorithmic.com/) has some interesting tools they've developed to try and make ...
10
Yes, a texture for most purposes is an image.
Once a texture is loaded from a file, it can be applied as a sort of "decal" to any polygon you wish.
When you see textures in an image file they typically appear a bit warped,
That's because when the texture is "wrapped" around the model, it will all even out and wrap around the model properly. You use a ...
10
This is where I will use a 3D painting program. I primarily use Blender for my modeling, and it has a 3D painter built in. Being able to paint directly on the model in a 3D environment, makes the strokes continue across seams.
I don't find the paint tools in Blender to be great, so I'll usually switch to something like GIMP once I've got a rough idea. Then ...
9
Noel Llopis's Games from Within blog touched on this recently in the "Remote Game Editing" post. The opening paragraph:
I’ve long been a fan of minimal game
runtimes. Anything that can be done
offline or in a separate tool, should
be out of the runtime. That leaves the
game architecture and code very lean
and simple.
(The article is a highly ...
9
To map your texture once on the mesh, your UV coordinates should go from 0..1 over the whole mesh. But depending on the mesh at hand, this can get really tricky.
Since it's a plane, this should be simpler. Just look at the plane from it's "up" direction and assign 0,0 to the top left and 1,1 to bottom right. The vertices in between should be fractions. Eg. ...
8
The PhD Thesis of Andrea Lodi is entitled Algorithms for Two Dimensional Bin Packing and Assignment Problems.
The thesis goes over some of the harder forms of this problems. Luckily, texture packing is the easiest version. The best algorithm he found was called Touching Perimeter.
To quote from page 52:
The algorithm, called Touching
Perimeter (TPRF ...
8
The basic idea of mega textures is the use of a texture atlas where you pack all your different textures into a big one and use UVs to index into this image. Good heuristics are needed to know what part of the texture you need to stream in from disk based on what you see on screen. The upside is that you can have completely unique textures throughout the ...
8
My guess is your CHECKGL macro is calling glGetError between a glBegin/glEnd, which is not one of the defined functions that can be called.
http://www.talisman.org/opengl-1.1/Reference/glEnd.html
http://www.opengl.org/sdk/docs/man/xhtml/glGetError.xml
Only top voted, non community-wiki answers of a minimum length are eligible