# What is the W in UVW mapping?

This topic is 4940 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I know what the U and the V is for. They are the coordinates for the vertex on a 2D image. They have a value from 0.0 to 1.0. So a triangle has 3 vertex, and thus 3 coordiantes on an image to where it will get the image pice for the triangle but ... what is the W for? I found some explanation via google, but I can't understand it well ... could someone try explain?

##### Share on other sites
In context of texture coordinates, w is the third dimension of a texture coordinate. It can be used with u and v to address texels of a volume or a cubemap, for example.

##### Share on other sites
huh?

not that I understood much ... but where would the W come in handy?

##### Share on other sites
Consider a 3d array of texels, AKA a volume texture. It's conceptually comprised of one or more "slices" which can be thought of 2d images stacked on top of each other.

To address an individual slice's texels, you use the U and V coordinates. With conjunction to these, you use W to select which slice to sample the texel U, V from. In practice, W is often filtered so that the texture sample comes from 2 nearest slices that it matches - just like U and V are filtered - with bilinear interpolation.

Then, a cubemap: consider a cube comprised of 6 textures representing each face. To address this type of texture meaningfully, you need three-dimensional texture coordinate vector (UVW), in contrast to a 2d texture which can be addressed with a two-dimensional vector (UV).

There are other uses, but they are more advanced and IMHO should be studied after aforementioned concepts are clear in your mind.

##### Share on other sites
ok ... Is it so that if you had a square (2 triangles), and gave the square 2 textures, one grass and one bricks, then you could make a "road" of bricks over the square?

Several games I see seems to blend textures like this, and I suspect it is not done in PS...

EDIT: eh my brain is a bit slow ... I guess you would need several polys to create this road sine the UVW info is only on each vertex ... but the W is used to make a transistion from one texture to another?

##### Share on other sites
Nearly, but not quite. You could do that with a 3d texture, but that's not all.

A 2d texture is represented as a 2d array yeah? like char texture[128][128].
A 3d texture would be represented as a 3d array like char texture[128][128][128].

can you see why you'd need 3 texture coords to map a 3d texture?

##### Share on other sites
I think I do .... but then I wouldn't quite know where and why to use it ...

Du you have any examples of using such texturing?

##### Share on other sites
Why do you need an example? 3D texturing is a tool like any other, you just use when and how you want to (i.e. using your imagination).

##### Share on other sites
this might help illustrate. The vase is textured with a 3d texture.

##### Share on other sites
Imagine a tree trunck in a game that gets hit by a passing rocket (bullet, car, whatever...) and a part chips of. Now suppose that the size and shape of the chip are always different (depending on impact, size, direction, etc.) how would you determine the texture coordinates of the chip and the remaining stump... What you need is three-D texture information of the woodtexture. Knowing only the surface texture coordinates (wrapping some bitmap around the trunk) isn't enough anymore. This is one example of 3D texturing.

Another example is a good old 2D texture that changes over time. E.g.: decaying paint, rusting iron. In these cases consider the third dimension as time. Slowly moving the w-coordinate as time goes by animates the texture. Clouds are often simulated like that...

Cheers

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633722
• Total Posts
3013547
×