Download

How to write usf for my vertex factory?

Hi, I’m making a shader that use additional two float4 my shading calculation. First, I made a plugin for vertex factory and marked using IMPLEMENT_VERTEX_FACTORY_TYPE macro. Then engine try to compile my usf when start up. but start up is always fail because of my usf was not compiled successfully.



#include "Common.usf"
struct FVertexFactoryInput
{
	float4 Position		: ATTRIBUTE0;
	float3 TangentX		: ATTRIBUTE1;
	float4 TangentZ		: ATTRIBUTE2;
	float2 TexCoord		: ATTRIBUTE4;
	float4 BlendWeight0 : ATTRIBUTE13;
	float4 BlendWeight1 : ATTRIBUTE14;
};

I wrote usf like above.
FVertexFactoryInput match with vertex factory’s input components.

and some more code is there but it was just copy pasted from other usf in engine.
In the end, I really wonder that what should I implement in usf?

Is there any template?

and critical question is there.
Let me assume that the usf was compiled then how to apply that to mesh?

I’m also interested in this, did you eventually figured this out ?

Few reference points: Cable component, Custom mesh component and local vertex factory.

ok, after looking at those classes I have to admit that I’m completly lost in the depths of Unreal4 :]

From what I understand simple meshes imported from FBX are represented as UStaticMesh (and UStaticMeshComponent)
I could derive from UStaticMeshComponent, or add UStaticMesh to my own class (that derives from UMeshComponent)
but … unless I do not understand something, there is no way to change vertex factory of UStaticMesh (UStaticMesh::RenderData::LODResources[0]::VertexFactory) to my own.
So how could I IMPORT mesh from FBX, AND be able to specify my custom vertex factory ? (without rewriting parts of FBX importer, and probably some other classes)
(Or modify the engine, to hold in FStaticMeshLODResources pointer to generic FVertexFactory, that could be changed later - but I’m afraid consequences of such an modification …)

I am trying to do something similar now (trying to pass the vertex positions of the StaticMeshComponents in my scene to the vertex shader by using a Vertex Factory.) Was this ever resolved?