Unity CombineTexture
2024-08-21 21:42:23
public Texture2D CombineTexture(Texture2D background, Texture2D top)
{
int width = background.width;
int height = background.height;
Texture2D ret = new Texture2D(width, height);
for(int x = ; x < width; x++)
{
for(int y = ; y < height; y++)
{
ret.SetPixel(x, y, background.GetPixel(x, y));
}
} int topWidth = top.width;
int topHeight = top.height;
int x_start = width / - topWidth / ;
int y_start = height / - topHeight / ; for (int x = x_start; x < topWidth + x_start; x++)
{
for (int y = y_start; y < topHeight + y_start; y++)
{
Color bgColor = background.GetPixel(x, y);
Color topColor = top.GetPixel(x - x_start, y - y_start);
ret.SetPixel(x, y, Color.Lerp(bgColor, topColor, topColor.a/1f));
}
}
ret.Apply();
return ret;
}
tip: the background and top texture need can readable.
最新文章
- C#文件目录操作完全手册
- Android开发之JavaMail发送邮件(用户反馈)
- osg::NodeVisitor中计算一个节点对应的世界变换矩阵、法向量、顶点坐标
- Password Attacker
- 使用函数库(JAVA API)
- Nginx 笔记与总结(7)Location:正则匹配
- CSS从大图中抠取小图完整教程(background-position应用)
- login.java
- tomcat docBase 和 path
- 使用 Proxy + Promise 实现 依赖收集
- Jmeter之性能压测Stepping Thread Group 逐步增加并发数 阶梯式加压并发 (十五)
- 网络协议笔记-网络层-路由器的作用、IP地址
- ionic笔记
- ACM算法竞赛:抄课文
- [20190402]关于semtimedop函数调用2.txt
- 01.QT初学--两个窗口相互切换
- JDK1.8 LongAdder 空间换时间: 比AtomicLong还高效的无锁实现
- flask 第五章 WebSocket GeventWebsocket 单聊群聊 握手 解密 加密
- PAT A1142 Maximal Clique (25 分)——图
- windows2008r2系统破解登录密码方法