x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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

Product Version: UE 4.14
Tags:
more ▼

asked Nov 27 '16 at 06:30 PM in Rendering

avatar image

Tudor
48 3 9 11

avatar image panha Mar 28 '17 at 02:44 PM

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

(comments are locked)
10|2000 characters needed characters left

3 answers: sort voted first

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

more ▼

answered Apr 26 '18 at 04:28 AM

avatar image

小又
1 1 1

(comments are locked)
10|2000 characters needed characters left

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.

more ▼

answered Apr 26 '18 at 09:33 AM

avatar image

小又
1 1 1

(comments are locked)
10|2000 characters needed characters left

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)

more ▼

answered Oct 30 '18 at 04:18 PM

avatar image

道藏小道
1 1

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question