You can broadcast a 1d,2d,3d texture or render target texture to all shaders (or materials as you would call them in UE4). You can then sample a texture of specified type and name. For example you can do this in code:
Shader.SetGlobalTexture(“MyTextureName”, textureObject);
In the shader you then sample texture called MyTextureName.
Is there anything similar inside UE4 API?
What I am trying to do is to broadcast screen-space texture to all materials and sample it. I want to change this texture at runtime (update it’s contents, swap it). I imagine that it should be possible to set up a dummy Texture Sampler that points to a texture with specified name and in C++ I should broadcast the texture with the same name.
There’s not really any need to approach this differently from a regular texture. Simply create a render target in the editor and reference this in your material instead of a regular texture. You can then write to this texture at runtime and all materials will update.
I thought about Material Parameter Collection but it does not support textures (but it would be nice if it could!). But yea, render target will work perfectly in my situation.