Thanks for posting these tips. I was devastated when my project dropped to 3 FPS because material properties don't work out of the box. I was able to edit the generated shader to go from 5000 draw calls to ~15. Here are some relevant snippets. I am only changing the color of my game objects in this example

Find all of these blocks of code (there are several copies)

Code (CSharp):
  1. CBUFFER_START(UnityPerMaterial)
  2. float4 _BaseColor;
  3. CBUFFER_END

Replace them with this

Code (CSharp):
  1. CBUFFER_START(UnityPerMaterial)
  2. UNITY_INSTANCING_BUFFER_START(Props)
  3. UNITY_DEFINE_INSTANCED_PROP(float4, _BaseColor)
  4. UNITY_INSTANCING_BUFFER_END(Props)
  5. CBUFFER_END

Then find every instance of _BaseColor in the shader functions (there are several copies)

Code (CSharp):
  1.  SurfaceDescription SurfaceDescriptionFunction(SurfaceDescriptionInputs IN) {
  2.         SurfaceDescription surface = (SurfaceDescription)0;
  3.         float4 _Property_A850853A_Out_0 = _BaseColor;
  4.         ....

Replace them with UNITY_ACCESS_INSTANCED_PROP(Props, _BaseColor)

Code (CSharp):
  1. SurfaceDescription SurfaceDescriptionFunction(SurfaceDescriptionInputs IN) {
  2.         SurfaceDescription surface = (SurfaceDescription)0;
  3.         float4 _Property_A850853A_Out_0 = UNITY_ACCESS_INSTANCED_PROP(Props, _BaseColor);
  4.         ...

And lastly don't forget to set the material properties on your game object

Code (CSharp):
  1. int colorPropId = Shader.PropertyToID("_BaseColor");
  2. var matProps = new MaterialPropertyBlock();
  3. matProps.SetColor(colorPropId, color);
  4. renderer.SetPropertyBlock(matProps);

hdrp gpu instance MPB不生效问题的更多相关文章

  1. [unity]GPU Instance学习

    前言我们之前研究过为什么Unity的UI可以合批,是因为使用了相同的材质进行渲染,UI上不同图片渲染是通过把图片打成一张图集后,使用Image组件对顶点填充了不同的UV值实现的.那么有没有什么办法可以 ...

  2. GPU Instance

    http://forum.china.unity3d.com/thread-17131-1-1.html https://docs.unity3d.com/Manual/GPUInstancing.h ...

  3. cocos2dx 实现gpu instancing

    所有的gpu instancing都是在unity3d上实现的,ue4实现起来应该压力也不大相关链接见下:https://www.cnblogs.com/hont/p/7143626.htmlhttp ...

  4. 深入GPU硬件架构及运行机制

    目录 一.导言 1.1 为何要了解GPU? 1.2 内容要点 1.3 带着问题阅读 二.GPU概述 2.1 GPU是什么? 2.2 GPU历史 2.2.1 NV GPU发展史 2.2.2 NV GPU ...

  5. GPU Skinning 结合 Instanced 高效实现大量单位动画

    GPU Skinning 与 Instance 蒙皮动画 计算骨骼信息 蒙皮 GPU Skinning CPU Skinning 与 GPU Skinning 实现方式 Skinning 类型 优点 ...

  6. 几个Graphics函数

    1.Graphics.Blit:Copies source texture into destination render texture with a shader 声明: 1.public sta ...

  7. File System Minifilter Drivers(文件系统微型过滤驱动)入门

    问题: 公司之前有一套文件过滤驱动,但是在实施过程中经常出现问题,现在交由我维护.于是在边看代码的过程中,一边查看官方资料,进行整理. 这套文件过滤驱动的目的只要是根据应用层下发的策略来控制对某些特定 ...

  8. 聊聊2018.2的Scriptable Build Pipeline以及构建Assetbundle

    0x00 前言 在这篇文章中,我们选择了过去几周Unity官方社区交流群以及UUG社区群中比较有代表性的几个问题,总结在这里和大家进行分享.主要涵盖了Scriptable Build Pipeline ...

  9. 开发自定义ScriptableRenderPipeline,将DrawCall降低180倍

    0x00 前言 大家都知道,Unity在2018版本中正式推出了Scriptable Render Pipeline.我们既可以通过Package Manager下载使用Unity预先创建好的Ligh ...

  10. Unity ECS 视频笔记

    视频摘要 本文视频资料:使用Entity Component System开发<快乐的Minecraft>游戏 使用Unity2018及以上版本才有ECS功能. 本文是看视频的一些摘要. ...

随机推荐

  1. Git上手教程

    不说费话,直接上链接 廖雪峰老师的GIT教程

  2. h5端安装调试工具,react版(但不限于react,vue等)

    首先 npm install vconsole -S 其次在非生产环境的时候可以使用 import VConsole from 'vconsole'; const vConsole = new VCo ...

  3. 使用windows平板学习与办公的一些经历(酷比魔方i9篇)

    大概是在2019年的时候,我在某平台上购买了900元的二手windows平板电脑,酷比魔方i9 首先谈谈背景.当时我手里是有个笔记本,屏幕大概15.6寸,4G+256G的,平时用的时候功率平均20几W ...

  4. 2021年爆出log4j漏洞修复

    (1)用户可自查系统是否引用 Apache log4j-core 依赖,没有引用则不受漏洞影响. (2)排查系统中日志配置是否采用远程动态加载模式.(3)排查系统中是否正在使用JDBCAppender ...

  5. Echarts 设置Y轴 || X轴的刻度只显示整数

    目前的效果如下:(有小数) 想要的效果如下:(整数) 解决方案: 在配置项的yAxis或者xAxis对象中添加属性:minInterval: 1,表示将刻度的最小间距设置为1 注意: minInter ...

  6. JS 动态获取 Url 参数(封装函数)

    话不多说直接上代码: 封装函数如下: (如果urls固定,可以只写一个name变量) getQueryString(name, urls) { var url = urls; // 获取URL // ...

  7. app内嵌H5踩坑

    内嵌的H5是用的vue2版本开发的,期间有很多的坑要踩: 1.调用app返回上一个页面不触发页面的onmouted和window.onPageShow app返回上一个页面调用的方法并不会出发vue的 ...

  8. 其他6-break,continue,exit,return区别

    break.continue.exit.return的区别 break 跳出整个循环语句 continue 跳过本次循环,进入下一次循环语句 exit n 退出当前shell,并返回状态值 retur ...

  9. Python爬取三国演义章节标题和内容(bs4爬取,解决中文乱码)

    import os.path import requests from bs4 import BeautifulSoup if __name__ == '__main__': if not os.pa ...

  10. react框架-知识点(ref,, setState)

    react的思想:无必要勿增实体 1. ref 使用 myRef = React.createRef() <input ref={this.myRef}></input> 2. ...