简体   繁体   English

(Unity C#)Texture2D缩放之谜

[英](Unity C#) Texture2D scaling mystery

Alright, I've seen there's a number of threads about scaling a Texture2D both on here and the Unity forums. 好吧,我已经看到有很多关于在这里和Unity论坛上扩展Texture2D的线程。 That line of searching brought me to now being able to scale Texture2Ds by using this class: http://wiki.unity3d.com/index.php/TextureScale 这一行搜索让我现在能够通过使用这个类来扩展Texture2Ds: http//wiki.unity3d.com/index.php/TextureScale

Now, what I'm currently working on is applying decals directly to the targeted texture. 现在,我正在研究的是将贴花直接应用于目标纹理。 That's working fine. 这工作正常。 BUT, depending on the texture size and how much it's being scaled over it's geometry, the decal appears at different sizes (without any scaling, see attached image). 但是,根据纹理大小以及它在几何体上的缩放程度,贴花以不同的尺寸显示(没有任何缩放,请参见附图)。 That's what lead me to even look into scaling a Texture2D. 这就是让我甚至考虑缩放Texture2D的原因。

The mystery is, I'm not sure what kind of math to throw at the scale function to make the decal appear the same size visually no matter which mesh and texture it's on. 谜团是,我不确定在刻度函数中投入什么样的数学运算才能使贴花在视觉上看起来大小相同,无论它在哪个网格和纹理上。

基于网格的贴花差异大小

Any help is much appreciated : ] 任何帮助深表感谢 : ]

If the texture is twice as large, the decal will be twice as large. 如果纹理是两倍大,贴花将是两倍大。 So, scale the decal by half, and it will be normal size. 因此,将贴花缩小一半,这将是正常尺寸。

In general, every place you multiply the scale for the texture, divide the scale for the decal by the same amount. 通常,每增加一个纹理比例的位置,将贴花的比例除以相同的量。

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

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