UE4.27.2 自定义 PrimitiveComponent 出现的问题

目录

在看大象无形,其中关于静态物体网络绘制的代码出错的 bug 我也搞了一会......

一开始是 ShaderCore 这个模块已经过时了,直接删掉就好了

然后是 GetRenderProxy() 不需要参数了

CreatePrimitiveUniformBufferImmediate

然后是 CreatePrimitiveUniformBufferImmediate 这个函数的用法发生了改变,具体看:

https://github.com/TriAxis-Games/RealtimeMeshComponent/issues/144

代码上来看,就是要改成

cpp 复制代码
		FBoxSphereBounds PreSkinnedLocalBounds;
		GetPreSkinnedLocalBounds(PreSkinnedLocalBounds);
		BatchElement.PrimitiveUniformBuffer = CreatePrimitiveUniformBufferImmediate(GetLocalToWorld(), GetBounds()
			, GetLocalBounds(), PreSkinnedLocalBounds, ReceivesDecals(), DrawsVelocity(), LpvBiasMultiplier);

FLocalVertexFactory 默认构造函数

然后是顶点工厂这个类没有默认构造函数了,所以需要在派生类里面显式调用顶点工厂基类的构造函数

cpp 复制代码
	FTestCustomComponentVertexFactory() : FLocalVertexFactory(ERHIFeatureLevel::SM5, "FTestCustomComponentVertexFactory") { }

这个 level 我随便填的,我也不懂

GetTypeHash

然后是派生自 FPrimitiveSceneProxy 的类差一个虚函数没有实现,所以仍然是抽象类,不能实例化

差的这个是 GetTypeHash

我找了一些引用,抄了一个

cpp 复制代码
	SIZE_T GetTypeHash() const override
	{
		static size_t UniquePointer;
		return reinterpret_cast<size_t>(&UniquePointer);
	}

ENQUEUE_RENDER_COMMAND

然后是 DataType 改成 FDataType

然后是 ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER 改成了 ENQUEUE_RENDER_COMMAND 于是新的命令为

cpp 复制代码
			ENQUEUE_RENDER_COMMAND(InitTestCustomComponentVertexFactor)([VertexBuffer, this](FRHICommandListImmediate& RHICmdList) {
				//Initialize the vertex factory's stream componnents,
				FDataType NewData;
				NewData.PositionComponent = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(
					VertexBuffer, FDynamicMeshVertex, Position, VET_Float3);
				NewData.TextureCoordinates.Add(FVertexStreamComponent(VertexBuffer, STRUCT_OFFSET(FDynamicMeshVertex, TextureCoordinate), sizeof(FDynamicMeshVertex), VET_Float2));
				NewData.TangentBasisComponents[0] = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VertexBuffer,
					FDynamicMeshVertex, TangentX, VET_PackedNormal);
				NewData.TangentBasisComponents[1] = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VertexBuffer,
					FDynamicMeshVertex, TangentZ, VET_PackedNormal);
				SetData(NewData);
			});

null resource entry in uniform buffer parameters FLocalVertexFactory

然后虽然能够编译了,但是添加组件的时候崩溃了

null resource entry in uniform buffer parameters FLocalVertexFactoryUniformShaderParameters.Resources0, ResourceType 0x6

我只能说不懂......我搜也搜了,没搜到什么,我去也去论坛提问了,希望有结果吧

相关推荐
清泓y15 天前
UE移动开发技术面试题
android·面试·ue5·ue4·游戏程序
清泓y15 天前
UE基础知识与引擎架构面试题
面试·架构·ue5·ue4·游戏程序
Duo1J19 天前
【UE】Slate 编辑器工具开发03 - 节点编辑器 (EdGraph)
ue5·编辑器·游戏引擎·ue4
学习!!!25 天前
针对虚幻引擎4中光线追踪内容兼容性的实用解决方案
ue4
Duo1J25 天前
【UE】Slate 编辑器工具开发01 - Slate语法 & 常用控件
ue5·编辑器·游戏引擎·ue4
DoomGT1 个月前
UE5 - 制作游戏中切换窗口后游戏自动暂停功能
游戏·ue5·ue4·虚幻·虚幻引擎·unreal engine
Yuk丶2 个月前
厌倦了假AI对话?本地 LLM 语音对话 + 口型同步系统 2.0(已开源!)
c++·人工智能·语言模型·开源·ue4·语音识别·游戏开发
归真仙人2 个月前
【UE】LineTraceByProfile
ue5·游戏引擎·ue4·unreal engine
上山老人2 个月前
UE4布娃娃约束修改
ue4
Yuk丶3 个月前
厌倦了假AI对话?用本地大模型给UE注入真智能(已开源!)
c++·人工智能·开源·ue4·游戏程序·ue4客户端开发