zoukankan      html  css  js  c++  java
  • Graphics.DrawMeshInstanced

    Draw the same mesh multiple times using GPU instancing.
    可以免去创建和管理gameObj的开销
    并不是立即绘制,如需:Graphics.DrawMeshNow
    每帧调用一次,当帧发送绘制请求
    Meshes are not further culled by the view frustum or baked occluders, nor sorted for transparency or z efficiency.
    You can only draw a maximum of 1023 instances at once
    SE 3.0 以上支持
    材质要勾上 enableInstancing  总的检查:material.enableInstancing && SystemInfo.supportsInstancing 

    过程中遇到的问题:
    导入mesh,的Use File Scale 勾上就不显示??? 模型的缩放调整有问题,去掉后原本的模型直接放显得特别大
    感觉像是这个函数强行用了一次file scale,再用会变得更小(函数自身*导入参数)
    去掉设置,这个函数的变正常,但直接拖到游戏就不对,应该是个bug

    public class GpuInstancingTest : MonoBehaviour {
    	public Mesh mesh;
    	public Material material;
    	
    	List<Matrix4x4> matrices = new List<Matrix4x4>();
    
    	void Start()
    	{
    		if (!material.enableInstancing || !SystemInfo.supportsInstancing)
    		{
    			enabled = false;
    			return;
    		}
    
    		for (int i = 0; i < 10; ++i)
    		{
    			Matrix4x4 mt = Matrix4x4.TRS(transform.position + (i * 1.1f) * Vector3.up, transform.rotation, Vector3.one);
    			matrices.Add(mt);
    		}
    	}
    
    	// Update is called once per frame
    	void Update () {
    		Graphics.DrawMeshInstanced(mesh, 0, material, matrices);
    	}
    }








  • 相关阅读:
    软件架构学习小结
    20+ 个很有用的 jQuery 的 Google 地图插件 (英语)
    网页JS获取当前地理位置(省市区)
    前端Js框架汇总(工具多看)
    MUI简介-最接近原生App体验的前端框架
    Bootstrap手机网站开发案例
    jQuery Mobile手机网站案例
    历届图灵奖 (Turing award)得奖名单
    js进阶 10-9 -of-type型子元素伪类选择器
    网页如何实现隔多久自动调用某个方法
  • 原文地址:https://www.cnblogs.com/Hichy/p/7730353.html
Copyright © 2011-2022 走看看