Sending an array (of structs) to a usf shader

I’m trying to send an array of positions (and other info) to a usf pixel shader.
I know I can send float, FMatrix, FVector stuff to the shader via the following macros:

BEGIN_UNIFORM_BUFFER_STRUCT(FMyPixelShaderVarParams

DECLARE_UNIFORM_BUFFER_STRUCT_MEMBER

DECLARE_UNIFORM_BUFFER_STRUCT_MEMBER_ARRAY

  • Can I send an array of floats to this FMyPixelShaderVarParams struct? - Yes, by using DECLARE_UNIFORM_BUFFER_STRUCT_MEMBER_ARRAY(float, varName, [10])

  • Can I send a custom struct inside this FMyPixelShaderVarParams struct? - NO? What exactly makes FVector struct eligible and mine not?

  • Can I send an array of structs inside FMyPixelShaderVarParams? - Same

Hi, I’m trying to figure how to send 4x4 Matrix from C++ to usf shader. Any idea how can I achieve this?

uniform buffer may can help you,but i also don’t konw how to send uniform buffer corectly.this is my questionhttps://answers.unrealengine.com/questions/783475/%E5%A6%82%E4%BD%95%E7%BB%99shader%E4%B8%8A%E4%BC%A0uniformbuffer.html

However,when i finish

BEGIN_UNIFORM_BUFFER_STRUCT(FMyUniformStructData, )
DECLARE_UNIFORM_BUFFER_STRUCT_MEMBER(FVector4, ColorOne)
DECLARE_UNIFORM_BUFFER_STRUCT_MEMBER(FVector4, ColorTwo)
DECLARE_UNIFORM_BUFFER_STRUCT_MEMBER(FVector4, ColorThree)
DECLARE_UNIFORM_BUFFER_STRUCT_MEMBER(FVector4, ColorFour)
DECLARE_UNIFORM_BUFFER_STRUCT_MEMBER(uint32, ColorIndex)
END_UNIFORM_BUFFER_STRUCT(FMyUniformStructData)

IMPLEMENT_UNIFORM_BUFFER_STRUCT(FMyUniformStructData, TEXT(“FMyUniform”));

the code won’t work! HLSL compiling failed.

4.20: Update to
#define UNIFORM_MEMBER_ARRAY_EX(MemberType,MemberName,ArrayDecl,Precision)
#define UNIFORM_MEMBER_ARRAY(MemberType,MemberName,ArrayDecl)
#define UNIFORM_MEMBER(MemberType,MemberName)
#define UNIFORM_MEMBER_EX(MemberType,MemberName,Precision)
#define UNIFORM_MEMBER_SRV(ShaderType,MemberName)
//#define DECLARE_UNIFORM_BUFFER_STRUCT_MEMBER_UAV(ShaderType,MemberName)
#define UNIFORM_MEMBER_SAMPLER(ShaderType,MemberName)
#define UNIFORM_MEMBER_TEXTURE(ShaderType,MemberName)
#define UNIFORM_MEMBER_STRUCT(StructType,MemberName)

AOS seems still not available for uniform buffer, I tried to create a SHADER_PARAMETER_STRUCT and reference it in a GLOBAL_SHADER_PARAMETER_STRUCT, but got crash on CreateHLSLUniformBufferStructMembersDeclaration