简体   繁体   English

Unity将多个纹理(数组)传递到着色器?

[英]Unity Pass multiple textures(array) into shader?

Right now in my shader, I have 5 textures, 现在在我的着色器中,我有5种纹理,

 Properties
     {
         _MainTex ("Texture", 2D) = "white" {}
         _MainTex2("Texture2", 2D) = "white" {}
         _MainTex3 ("Texture3", 2D) = "white" {}
             _MainTex4 ("Texture4", 2D) = "white" {}
             _MainTex5 ("Texture5", 2D) = "white" {}
     }

Is that possible I can make it an array so that I dont need to declare so many textures? 有可能我可以将其设置为数组,这样就不需要声明太多纹理了?

You can use the 2DArray type which will allow you to do so. 您可以使用2DArray类型,它允许您这样做。

Properties
{
    _TheTextureArray ("Tex", 2DArray) = "" {}
}

You can find more information about it here : https://docs.unity3d.com/Manual/SL-TextureArrays.html 您可以在这里找到有关它的更多信息: https : //docs.unity3d.com/Manual/SL-TextureArrays.html

Please do take note of the tech limitations (example, DX11/12) so it will not work on all environments by default, certainly not the web (currently). 请注意技术限制(例如DX11 / 12),因此默认情况下它不适用于所有环境,当然不适用于Web(当前)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM