Graphic details Unity3d in material tiling and offset is what's going on

Source: Internet
Author: User

Graphic details Unity3d in material tiling and offset is what's going on

Tiling and Offset overview

Tiling represents the magnification of the UV coordinates, offset represents the starting position of the UV coordinates.

This, of course, is ineffective.

The following uses the *.3DS file as the model, describes the tiling and offset exactly what is going on.

3DS Format parsing

For example, I have such a tank_player.3ds model. The image at the right of ' select ' is the decal.

The most basic content of the *.3ds file includes the vertex list Vertices, the map coordinate list UVs, and the polygon list Faces. Where the number of vertices and Uvs is equal . The following is the content of the tank_player.3ds file described in text, which is a tree structure that can be rewritten as a binary 3DS file with the first order traversal. This XML structure is a binary tank_player.3ds analysis.

1 <_mainchunkLength= "8386">2   <_cversionLength= "Ten">3</_cversion>3   <__3deditorchunkLength= "8370">4     <_objectblockLength= "8364">5       <StringLength= "+">Tank_playermesh</String>6       <_triangularmeshLength= "8342">7         <_verticeslistLength= "3776">8           <NumvertsLength= "2">314</Numverts>9           <VectorX= "0.7707"Y= "52.527"Z= "104.4209"Length= " a" />Ten           <VectorX= "6.2672"Y= "58.6059"Z= "104.4909"Length= " a" /> One ... .. A           <VectorX= " -0.4168"Y= "65.2885"Z= "104.4949"Length= " a" /> -         </_verticeslist> -         <_mappingcoordinateslistLength= "2520"> the           <TexcoordcountLength= "2">314</Texcoordcount> -           <Texcoordu= "0.7052"v= "0.9314"Length= "8" /> -           <Texcoordu= "0.7434"v= "0.9053"Length= "8" /> - ... .. +           <Texcoordu= "0.7701"v= "0.9442"Length= "8" /> -         </_mappingcoordinateslist> +         <_facesdescriptionLength= "2040"> A           <numindicesLength= "2">254</numindices> at           <Triindexv1= "0"v2= "1"v3= "2"Length= "8" /> -           <Triindexv1= "0"v2= "2"v3= "3"Length= "8" /> - ... .. -           <Triindexv1= "4"v2= "5"v3= "6"Length= "8" /> -         </_facesdescription> -       </_triangularmesh> in     </_objectblock> -   </__3deditorchunk> to </_mainchunk>

The _verticeslist in this is a list of vertex coordinates, each of which is a vertex in the 3D model; _mappingcoordinateslist is the map coordinate list UVs, Each texcoord is a coordinate point on the map. Facesdescription is a polygon list, and each triindex uses an index to specify 3 vertex and 3 Uvs, because the number of vertices and uvs are equal. 3 Vertex a triangle is drawn in the 3D world , and these triangles form the tank model shown. 3 Uvs Draw a triangle on the map . The map is like this:

The triangles drawn on the map are shown in the Uvs.

Can be seen to be exactly the corresponding. A triindex specifies a triangle plane A for the 3D model, a triangle plane B on the map, and a B on the A, which is the 3D model we see.

The 3DS file format has been explained for so long that it is convenient to start by explaining the usage of tiling and offset.

What does offset mean?

For simplicity, let's look at the model below. It is a square of 4 triangles stitched together.

The Uvs of this model is drawn out like this:

The map for this model is as follows.

The concept of offset starts with this sticker.

As shown, the bottom left corner of the map is the Origin (0, 0), the upper-right corner is (1, 1), the Cartesian coordinate system is drawn, the axis is offset in the x direction, and the vertical axis is offset in the y direction.

The function of offset is to determine the starting position of the Uvs on the map.

As shown, offset is 0 o'clock in both the X and Y axes. Uvs coordinates the part on the left side of the decal, then this part of the map will be pasted onto the model.

So you'll see the result.

Now I set the offset of the Y axis to 0.5. It means that the lower left corner of the Uvs becomes (0, 0.5).

So the Uvs on the map as shown, at this time Uvs frame the map on the left side of the block (red semicircle).

Can you imagine what the model looks like now?

What do you mean, tiling?

It's a good idea to finish offset,tiling. Offset controls the starting position of the Uvs, while the tiling controls the Uvs scale. The default (1, 1) scale is the original scale. Now I change the y-axis tiling to 2.

Then the Uvs with the map is the case:

The map or the map, the Uvs's ordinate is multiplied by 2. So the final model would be this:

Summarize

Tiling represents the magnification of the UV coordinates, offset represents the starting position of the UV coordinates.

With the use of offset and tiling, you can do something interesting.

The model of this paper is from the tank fleet analysis and transformation. I'll explain the conversion method in another article.

Graphic details Unity3d in material tiling and offset is what's going on

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.