Unity Shader A brief introduction to some macros and built-in functions __ functions

Source: Internet
Author: User

Computescreenpos: Located in Unitycg.cginc, used to map the range of clipping space coordinates from [-w,w] to [0,w] (without perspective division, direct interpolation), and the pixel shader is typically divided by W map to [0,1] A UV value as a texture (such as a depth texture);

Tex2dproj: Similar to the tex2d, but the input of the UV is generally above the Computescreenpos calculated value, use the time to be divided by the W mapping;

Unity_proj_coord: processing platform differences, generally directly return the input value;

Sample_depth_texture: Located in Hlslsupport.cginc, generally used to get the color of depth texture, direct input UV;

Sample_depth_texture_proj: Basic ditto, but the input of UV is the above Computescreenpos calculated value, the internal use of tex2dproj implementation;

In Lineareyedepth:unity, the value we get from the depth map is generally not directly available (typically a value that is linearly related to the reciprocal of the z-value of the observed space), so it needs to be converted to the z value of the observed space, which is the function;

Linear01depth: Map The resulting z-value to the [0,1] range;

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.