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. web实践4

    web实践4 20201303张奕博 2023.1.27 创建胡萝卜 接着,在地面上添加一些胡萝卜 .胡萝卜身体部分是通过四棱柱 CylinderBufferGeometry 实现的,然后通过 Box ...

  2. error Unnecessary return statement no-useless-return

    语法错误 原本是 addUser() {       this.$refs.addFormRef.validate((valid) => {         if (!valid) return ...

  3. ORACLE 遇到ORA-31693 ORA-31617 ORA-19505 ORA-27037

    今天发现生产的RAC环境expdp计划任务出现报错 之前一度认为是备份目录权限的问题 官方文档: MOS参考文档:DataPump Export (EXPDP) Fails With Errors O ...

  4. Centos 升级glibc 亲测好用

    wget http://ftp.gnu.org/gnu/glibc/glibc-2.18.tar.gz  tar zxf glibc-2.18.tar.gz cd glibc-2.18/ mkdir ...

  5. 阐述智能站变电站时钟同步系统(NTP时间同步服务器)的意义

    阐述智能站变电站时钟同步系统(NTP时间同步服务器)的意义 阐述智能站变电站时钟同步系统(NTP时间同步服务器)的意义 阐述观点只代表本人,如有疑问可加微 ahjzsz 1.概述 在现代电网中,统一的 ...

  6. Linux 关闭系统时间同步-timedatectl的使用

    源于一次项目需要修改系统时间,但是每次修改后又被同步回网络时间,找了好久发现是这个原因: NTP即Network Time Protocol(网络时间协议),是一个互联网协议,用于同步计算机之间的系统 ...

  7. C# 通过程序执行svn更新或提交更改

    实现方法: private static void RunBat(string program, string parm) { try { Process proc = new Process(); ...

  8. Windows 与Docker

    https://docs.microsoft.com/zh-cn/windows/wsl/install-manual#step-4---download-the-linux-kernel-updat ...

  9. (已解决)MYSQL怎么实现表的id在插入删除的前提下连续递增?

    其实就是用了sql语句. 思路是重置所有id和auto_increment. SET @i=0; UPDATE records SET id=(@i:=@i+1); ALTER TABLE recor ...

  10. python中如果获取对象的内存地址,及字典的地址

    在python中,如果查看一个对象的内存地址,可以用到id这个内置函数:使用方式是: id(object)--->返回该对象的10进制的内存地址: 以下是官方定义:翻译为大白话就是,返回一个对象 ...