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. How to present a paper 怎么讲好一篇文献

    Author : 如果在冬夜一个旅人 Date : 2022/05/24 目录 背景说明 1 读文献 1.1 读文献的层次 1.2 论文阅读的首轮次序 2 讲文献 2.1 The Problem to ...

  2. 快捷方法1:csdn如何不登录复制代码

    按F12,在console里执行下面两句代码 $("#content_views pre").css("user-select","text" ...

  3. NSIS KillProcDLL插件 扩展使用

    客户端插件KillProcDLL ,用于结束进程. 官网文档:https://nsis.sourceforge.io/KillProcDLL_plug-in 使用场景 卸载程序时,结束正在运行的应用程 ...

  4. PHP面向对象(三)

    对象的引用 代码如下: <?php//类的定义以关键字class开始,类的命名通常以每个单词第一个字母大写    class NbaPlayer{        public $name = & ...

  5. 前端常见的Vue面试题目汇总

    请说一下响应式数据的原理 默认Vue在初始化数据时,会给data中的属性使用Object.defineProperty重新定义所有属性,当页面到对应属性时,会进行依赖收集(收集当前组件中的watche ...

  6. idea-lombok使用

    一.添加 lombok 插件 file -- setting  -- plugins - 输入 Lombok 搜索,进行安装 二.引入依赖 <dependency> <groupId ...

  7. AR设备使用Vuforia的优化

    主要是设置识别的范围,在应用内检测当前识别图和我的距离,以及识别图和我的角度,当进入了规定的范围和角度后, 在进行定位功能.我目前用的是距离在两米内 摄像机和识别图的角度正负不超过30度的范围 Vuf ...

  8. 【电路理论】Flyback dc-dc convertor 反激式dc-dc变换器

    最近在学dc-dc电源时,遇到Flyback电路的,感觉云里雾里,不太明白,四处翻阅,方才有所理解,记录一下 一般Flyback convertor的拓扑如下 认为,当VT导通时,原边变压器储能,由于 ...

  9. C# RichTextBox跳转到指定行(文本行跳转和显示行跳转)

    文本行跳转: 对禁止自动换行(WordWrap属性为False)有效 1 /// <summary>跳到指定行</summary> 2 private void JumpToL ...

  10. mybatis中xml新增一条数据获取自增id

    在insert的标签里加两个属性:useGeneratedKeys="true"         keyProperty="patentId"   ,这个key ...