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"

How do I pass an array of values into a shader?

Greetings.

As the title says, I need to pass an array of values, likely floats, into a material shader. The purpose is to use those values to deform the vertices of the mesh. I've tried Material Parameter Collections, but that doesn't seem to be the most practical way to do it (imagine adding dozens of parameters to a collection manually...).

Any suggestions?

Thanks in advance!

Product Version: Not Selected
Tags:
more ▼

asked May 19 '14 at 11:37 AM in Rendering

avatar image

dsl
48 3 6 8

avatar image Lovecraft_K ♦♦ STAFF May 19 '14 at 09:07 PM

Hey dsl -

I may need some clarification here as to why and how you are going to use these values. You are wanting to use world position offset to animate the vertexes of your mesh, but that can be set up with a lerp between two constant 3 values with the alpha set up to either a timed event like a sine wave or a static event like vertex coloring or a combination of the two.

If you can elaborate on what exactly you are trying to achieve I can try to take down an answer for you.

-Eric Ketchum

avatar image dsl May 20 '14 at 08:45 AM

Hi, thanks for the reply.

Yes, I've been trying to use the world offset position, but the problem is that I'm using custom external data to define those exact positions. I haven't found any way to bring those external values into the material editor. The closest I've been able to do is to code those values into a texture and decode them within the editor.

I'll give an example: imagine a flat plane which you wish to deform with a custom animation created outside UE4. The animation file is somehow read into UE4 and its values must be applied to the vertices. This last step is the reason behind my question.

Isn't there some kind of "ArrayParameter" node in the material editor? :-)

Thanks!

avatar image garrettorious May 11 '15 at 11:32 PM

Hey, can I get a simple answer as to whether or not you can pass a dynamic array into a material at this time? This is the only question on the topic, but I'm still unsure.

It seems "dynamic parameter" is only intended for the particle editor, and only deals with up to 4 parameters.

Is there no way to pass in an array? Is my best bet to either use some kind of dynamic texture as a lookup table, or daisy chain 20 parameters by hand?

avatar image Lovecraft_K ♦♦ STAFF May 12 '15 at 07:05 PM

Hi -

Without changing and adding to the source code base for your project, Materials are not set up currently to take arrays.

Thank You

Eric Ketchum

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

1 answer: sort voted first

Hey dsl -

So there is a way to do what you are wanting to do but it requires some blueprinting in addition to your material setup. In the material you should be able to setup a parameter which makes your array input type, since you are using vertex animation I would assume you are going to be setting up a vector parameter. Now in blueprints you will want to setup a Dynamic Material Instance for the object in the world that is using that material and assign the Dynamic Material to that object in your blueprint. For using the custom animation and changing the vector parameter, you can use Matinee to animate over time and set to play and loop from the blueprint or through play on level load and looping in the Matinee actor.

The one clarification that I want to make is exactly how is your animation getting imported in, because it also sort of sounds like **Morph Targets** might also solve your problem as well.

-Eric Ketchum

more ▼

answered May 20 '14 at 03:36 PM

avatar image

Lovecraft_K ♦♦ STAFF
36.8k 702 256 733

avatar image plangton Oct 12 '15 at 12:35 PM

Can you show with a picture how you pass the array ? the vector parameter just takes one input not an array. https://docs.unrealengine.com/latest/INT/Engine/Rendering/Materials/MaterialInstances/index.html

(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