Sign in to follow this  
DarkSlayer

What is the W in UVW mapping?

Recommended Posts

DarkSlayer    100
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 this post


Link to post
Share on other sites
Nik02    4351
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 this post


Link to post
Share on other sites
Nik02    4351
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 this post


Link to post
Share on other sites
DarkSlayer    100
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 this post


Link to post
Share on other sites
mrbastard    1577
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 this post


Link to post
Share on other sites
ernow    732
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this