Steep cliff without texture stretching

Source: Internet
Author: User


Cliff with texture stretching Problems


Solves the problem of texture stretching.

If you have played some early 3D games dominated by outdoor terrain, such as the uprising, you will find that the ground textures are severely stretched when you encounter steep cliffs. With the introduction of shader and the improvement of graphics card functions, in many recently released high-quality 3D games, Cliff textures have become very fine and there is no longer a phenomenon of stretching. In farcry, there was a landscape like Guilin's landscape. The steep cliff and the clear river water in the deep valley left a deep impression. In fact, as long as you have a small skill, you can solve the problem of texture stretching, and it is not necessary for the shader to support, but without the shader support, you usually need three vertices UV stream to achieve these effects, the requirement for the bus bandwidth and memory capacity of the video card is higher. Next we will talk about this little trick in combination with illustrations. To facilitate our use of 2D images to illustrate the problem, we only need a little effort to imagine the effect in 3D space.



In the preceding figure, AB and BC are two sides of a cliff. We can see that AB is projected to the Y axis, while BC is projected to the X axis to obtain a larger projection length (compared to AB, BC to Y axis projection). If a texture is tiled along X and Y axis, AB to Y axis projection and BC to X axis projection can span a large range of texture scales. Select different projection Axes Based on the direction of the cliff to obtain the maximum projection length. Using the projection value as the UV coordinates of the cliff map can avoid the texture stretching problem caused by fixed UV. For three-dimensional space, if the XY plane is a horizontal plane, xz and YZ are two vertical planes, projection to the xz Z or YZ Plane Based on the direction of the cliff (the principle is to obtain a large projection span ), in these two cases, the X, Z, Y, and Z values obtained from the projection are used as the U and V coordinates of the vertex respectively. Generally, the UV coordinate maps over 1.0 texture maps across the entire texture. Therefore, the projection value is directly used as the UV coordinate, which is too large in most cases and is usually multiplied by a proportional factor. For example, if the projection span is 100 and represents 10 meters in your world, you need to multiply the projection value by 0.01 if you want the distance to just cross a texture.

traditional MPs queue vertices can be pre-computed and stored in the vertex buffer. If you use a programmable MPs queue, you can place the UV computation in Vs, instead of passing in the vertex buffer. No matter which method is used, the calculation is a simple dot multiplication. Assume that the unit vectors along the three axes are NX, NY, and NZ, the scaling factor is S, and the vertex coordinate is P, the following figure shows the calculation method of the cliff UV.
when projected to the xz plane:
U = (P dot Nx) * S
V = (P dot NZ) * S
when projected to the YZ plane:
U = (P dot NY) * S
V = (P dot NZ) * S
in actual calculation, multiply the unit vectors NX, NY, and NZ by the scaling factor s, and then perform point multiplication with the vertex coordinates, this saves the overhead of multiplying the scaling factor

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.