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);

最新文章

  1. pyqt信号和槽应用举例
  2. ios 修正waring:Method override for the designated initializer of the superclass '-init' not found
  3. 第一章 Mysql 简介及安装和配置
  4. apple个人开发者证书无线发布app的实现(转)
  5. ASI进行POST网络请求
  6. Mac下搭建Eclipse Android开发环境
  7. angularjs学习笔记—事件指令
  8. ORACLE 中写入txt文本与从Txt文件中读入数据 修改表结构
  9. Maven导出Project依赖的jar包
  10. 我来给.Net设计一款HttpClient
  11. Linux库函数制作(静态库、动态库)
  12. iOS 社交化分享功能
  13. http-request详解
  14. python全栈开发day33-进程间的通信、进程间的数据共享,进程池
  15. 【微信小程序】下拉刷新真机测试无效
  16. 第7章 使用寄存器点亮LED灯—零死角玩转STM32-F429系列
  17. PCL利用RANSAC自行拟合分割平面
  18. php 设置自动加载某个页面
  19. LOJ 10189 仓库建设 ——斜率优化dp
  20. IntelliJ IDEA Sringboot 项目部署到外部Tomcat服务器

热门文章

  1. 微信电脑版 v3.9.2.12 绿色便携版
  2. React父组件如何调用子组件方法,访问子组件State
  3. centos8下安装gcc11
  4. Less 1-3
  5. bat 脚本用 winrar 自动打包压缩文件
  6. Newtonsoft.Json高级用法--转载至 焰尾迭 随笔
  7. 合格できる日本語能力試験, N1.PDF
  8. Python的入门学习Day 14~15——form”夜曲编程“
  9. java心形打印999
  10. (原创)Onlyoffice docs docker实例安装示例后,打开文档提示:文档下载失败