静态批处理

没有加批处理绘制次数很高 FPS 81
加批处理绘制次数降低 FPS 94
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class StaticBatchProcessing : MonoBehaviour
{
public Texture2D texture;//纹理
public int wnum;
public int hnum;
int w = 128;
int h = 128;
// Start is called before the first frame update
void Start()
{
//顶点是有个数限制的最多65000个
//纹理尽力取2的次方
wnum =4;
hnum = 4;
//补缝用
int w2 = w + 2;
int h2 = h + 2;
for (int i = 0; i < wnum; i++)
{
for (int j = 0; j < hnum; j++)
{
for (int x = 0; x < w2; x++)
{
for (int z = 0; z < h2; z++)
{
//柏林噪声算法,传入两个坐标返回一个0-1的值(传入两个相同的值,返回结果一定相同)
float y = Mathf.PerlinNoise((i * w + x) * 0.02f, (j * h + z) * 0.02f);
GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.transform.parent = this.transform;
cube.transform.localPosition = new Vector3(w*i+x,y*5,h*j+z);
}
}
}
}
StaticBatchingUtility.Combine(gameObject);//此代码就是静态批处理代码
}
// Update is called once per frame
void Update()
{
}
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!