前一篇:
- Unity GPU Instancing 自己写个简单的测试用例1 实现了 Unity 中最简单的 Instancing draw 的方式
- Unity GPU Instancing 自己写个简单的测试用例2 在1的基础上做了一丢丢优化
这一篇直接使用 Graphics.DrawInstanced API 来绘制 Instancing 的内容,减少 Hierarchy中 GameObject 的层级树的维护开销
CSharpusing Unity.Collections;
using Unity.Jobs;
using UnityEngine;
using UnityEngine.Rendering;
public class InstancedScript_Solution2 : MonoBehaviour
{
private static int _Color = Shader.PropertyToID("_Color");
private static MaterialPropertyBlock mpb;
public int instance_count = 5;
public Mesh mesh;
public Material mat;
public bool procedurce_fill_data;
private bool last_fill_data = true;
public Color[] col;
public float[] angle_offset;
public Vector3[] pos_offset;
private Matrix4x4[] model_mats;
private Vector4[] col_vec4;
private void Start()
{
mpb = new MaterialPropertyBlock();
UpdateDatas();
}
private void Update()
{
UpdateDatas();
RenderCoins();
}
private void ProcedureFillData()
{
for (int i = 0; i
关注
打赏
热门博文
- 3D Assets (Textures & Model & Animations) & Game Design Ideas & DCC Tutorials & TA
- LearnGL - 学习笔记目录
- Unity - Timeline 知识汇总
- Unity Graphics - 知识点目录 - 停止翻译,因为发现官方有中文文档了
- Graphic资料
- Unity Lightmap&LightProbe局部动态加载(亲测2020以及以上版本官方修复了)
- Unity - 踩坑日志 - 低版本线性颜色空间渲染异常的 “BUG”
- Unity Shader - PBR 渲染 SP 导出的素材
- 什么是 3A 游戏?
- Photosohp - 实现 2D MetaBall、MetaFont