hdrp gpu instance MPB不生效问题
2024-09-08 18:42:30
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):
- CBUFFER_START(UnityPerMaterial)
- float4 _BaseColor;
- CBUFFER_END
Replace them with this
Code (CSharp):
- CBUFFER_START(UnityPerMaterial)
- UNITY_INSTANCING_BUFFER_START(Props)
- UNITY_DEFINE_INSTANCED_PROP(float4, _BaseColor)
- UNITY_INSTANCING_BUFFER_END(Props)
- CBUFFER_END
Then find every instance of _BaseColor in the shader functions (there are several copies)
Code (CSharp):
- SurfaceDescription SurfaceDescriptionFunction(SurfaceDescriptionInputs IN) {
- SurfaceDescription surface = (SurfaceDescription)0;
- float4 _Property_A850853A_Out_0 = _BaseColor;
- ....
Replace them with UNITY_ACCESS_INSTANCED_PROP(Props, _BaseColor)
Code (CSharp):
- SurfaceDescription SurfaceDescriptionFunction(SurfaceDescriptionInputs IN) {
- SurfaceDescription surface = (SurfaceDescription)0;
- float4 _Property_A850853A_Out_0 = UNITY_ACCESS_INSTANCED_PROP(Props, _BaseColor);
- ...
And lastly don't forget to set the material properties on your game object
Code (CSharp):
- int colorPropId = Shader.PropertyToID("_BaseColor");
- var matProps = new MaterialPropertyBlock();
- matProps.SetColor(colorPropId, color);
- renderer.SetPropertyBlock(matProps);
最新文章
- pyqt信号和槽应用举例
- ios 修正waring:Method override for the designated initializer of the superclass '-init' not found
- 第一章 Mysql 简介及安装和配置
- apple个人开发者证书无线发布app的实现(转)
- ASI进行POST网络请求
- Mac下搭建Eclipse Android开发环境
- angularjs学习笔记—事件指令
- ORACLE 中写入txt文本与从Txt文件中读入数据 修改表结构
- Maven导出Project依赖的jar包
- 我来给.Net设计一款HttpClient
- Linux库函数制作(静态库、动态库)
- iOS 社交化分享功能
- http-request详解
- python全栈开发day33-进程间的通信、进程间的数据共享,进程池
- 【微信小程序】下拉刷新真机测试无效
- 第7章 	使用寄存器点亮LED灯—零死角玩转STM32-F429系列
- PCL利用RANSAC自行拟合分割平面
- php 设置自动加载某个页面
- LOJ 10189 仓库建设 ——斜率优化dp
- IntelliJ IDEA Sringboot 项目部署到外部Tomcat服务器
热门文章
- 微信电脑版 v3.9.2.12 绿色便携版
- React父组件如何调用子组件方法,访问子组件State
- centos8下安装gcc11
- Less 1-3
- bat 脚本用 winrar 自动打包压缩文件
- Newtonsoft.Json高级用法--转载至 焰尾迭 随笔
- 合格できる日本語能力試験, N1.PDF
- Python的入门学习Day 14~15——form”夜曲编程“
- java心形打印999
- (原创)Onlyoffice docs docker实例安装示例后,打开文档提示:文档下载失败