Download

Best way to pass large array of values from Blueprint to Material

I’m creating an experimental shader that requires sending quite a large number of vector variables to the material from the scene, which are updated every tick.

With smaller numbers of variables, I was using a Material Parameter Collection, updating the values in BP and then bringing them all in and wiring them up to a custom node individually. This is fine for a small number of variables, but for a large number it becomes laborious having to: (1) create and name the variable in the Material Parameter Collection, (2) update it in the BP, (3) bring each variable individually into the material, then (4) create the variable on the custom node.

All of this could be avoided if I could simply send an array of vectors to a material, but that doesn’t seem possible.

I’ve been trying to figure out a way to streamline this process, and then realised a texture is just an array of vectors. So I’m wondering if there’s some way within Blueprint to write my vectors as RGB values in a texture (Render Target 2D?) and then send that texture to the material and read the vectors off, pixel by pixel?

Has anyone done anything like this, or know how I could go about setting it up?

Thanks!

My post in this thread illustrates how to do that.

Awesome, thanks so much!