Download

Accessing Actor Locations in Material

I am looking for a way to access the locations of all actors of a certain class in a material and then performing a certain operation for each of these locations.
Unfortunately, I am stuck and need some ideas.

My thoughts so far:

  • The best way to get an array into a material seems to be a texture. I can encode the (x,y,z) location in the rgb color channels. This way each actor would write its location to one pixel in the texture. I am sure it is possible to do this. Can someone give me a hint how to write pixel values to a texture object. Both Blueprint and C++ solutions would be fine.
  • I want to use the Actor locations to generate spherical masks. I need some ‘ForEachLoop-like’ behavior within the material. However, my experience with materials is limited and so far I was not able to create something like that. It is surprisingly difficult for me to wrap my head around the parallel nature of material instructions. :slight_smile:

Any help would be much appreciated. :slight_smile:

My post on this thread illustrates both writing locations to a texture, and a for loop over them.

Fantastic. That is what I am looking for. Thanks a lot.