RenderTexture坐标之UNITY_UV_STARTS_AT_TOP内置变量

来源:互联网 发布:淘宝货到付款不付款 编辑:程序博客网 时间:2024/05/16 04:30

UNITY_UV_STARTS_AT_TOP

Always defined with value of 1 or 0. A value of 1 is on platforms where Texture V coordinate is 0 at the “top” of the Texture. Direct3D-like platforms use value of 1; OpenGL-like platforms use value of 0.

Render Texture coordinates

Vertical Texture coordinate conventions differ between two types of platforms: Direct3D-like and OpenGL-like.

1. Direct3D-like: The coordinate is 0 at the top and increases
downward. This applies to Direct3D, Metal and consoles.
2. OpenGL-like:
The coordinate is 0 at the bottom and increases upward. This applies
to OpenGL and OpenGL ES.

Image效果和在uv中绘制是shader中需要注意坐标问题的两个地方。

o.screenPos = o.pos;#if UNITY_UV_STARTS_AT_TOP   if(_MainTex.y < 0.0)      o.screenPos.y *= -1;#endifreturn 0;

参考:
https://docs.unity3d.com/Manual/SL-PlatformDifferences.html
https://docs.unity3d.com/Manual/SL-BuiltinMacros.html

原创粉丝点击