[Feng yuchong] The shader of the unity3d tutorial book: Special answers to frequently asked questions

Source: Internet
Author: User

  Special note: FAQs

This lecture will answer some questions one after another.

Q:(1) What is transform_tex?(2) The _ maintex_st variable in float4 _ maintex_st is also useless. Why do I have to declare it?
A:(1) In simple terms, transform_tex is mainly used to calculate the vertex UV and tiling and offset of the material ball to ensure that the scaling and offset settings in the material ball are correct. (V. texcoord is the UV of the vertex)

 

The following two functions are equivalent.

O. UV =Transform_tex (V. texcoord, _ maintex );

 

O. UV = v.Texcoord. XY * _ maintex_st.xy + _ maintex_st.zw;

(2) The st of _ maintex_st should be samplertexture, that is, it declares that _ maintex is a sampling graph, that is, it performs UV operations.Without this sentence, you cannot perform the transform_tex operation. _ Maintex_st.xy is tiling, and ZW is offset.
If tiling and offset are the default values, that is, when tiling is () offset is (), O. UV = transform_tex (V. texcoord, _ maintex ); Change to O. UV = v. texcoord. XY; can also be displayed normally; equivalent to tiling is () offset is (), but such as the tiling value and offset value does not work

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.