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.Resources[0], ResourceType 0x6

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

相关推荐
 M͏⁠͏r.D2 天前
UE4 材质学习笔记01(什么是着色器/PBR基础)
ue4·材质
cainiao0806052 天前
UE4/UE5开发资源
ue5·ue4
AllBlue4 天前
ue4多个面重叠闪烁
ue4
小江村儿的文杰4 天前
UE4中 -skipbuild -nocompile 有什么区别
ue4
Growthofnotes4 天前
UE4_Niagara基础实例—7、如何让粒子照亮周边环境
ue4
Growthofnotes5 天前
UE4_Niagara基础实例—5、骨架网格体表面生成粒子及过滤骨骼位置生成粒子
ue4
Growthofnotes5 天前
UE4_Niagara基础实例—6、蓝图与粒子系统的通信
ue4
@Unity打怪升级6 天前
Unity 与虚幻引擎对比:两大游戏开发引擎的优劣分析
游戏·unity·ue5·游戏引擎·ue4·游戏程序·虚幻
UTwelve11 天前
【UE5】将2D切片图渲染为体积纹理,最终实现使用RT实时绘制体积纹理【第三篇-着色器光照】
ue5·ue4·虚幻·着色器
UTwelve15 天前
【UE5】将2D切片图渲染为体积纹理,最终实现使用RT实时绘制体积纹理【第一篇-原理】
ue5·ue4·虚幻·虚幻引擎·着色器