Driving lamp intensity with material function

I’m trying to modify the Good Sky storm to actually light up the scene when the lightning flashes. Good Sky uses a material function to control the random flashes, but I have no idea how I can use this to control the lamp. I have not yet found a way to output a material function to a variable that I can use in the lamp blueprint.

Does anyone know of a way I can make this work?

I don’t know if it’s possible to get that information from material to blueprints (except some crazy setups with rendertarget checking scene for lightnings every frame), so I think better approach would be is to control where that randomness is coming from.

Make a blueprint that would be driving lighting parameter in you material, and use it for your light actors as well.

I’m not quite sure what you mean. Good Sky already has a blueprint that does that. It’s a material function that outputs a random number and that is then used to control the lightning textures in the sky material. Surely it can’t be that difficult to take the numerical output of the material function and plug it into the lamp intensity?

If the pseudo-randomness comes from the material, and cannot be recreated in blueprints, then it’s not that trivial. At least I don’t know of an easy way to get any values from shader (GPU part) into blueprints (CPU part). It’s simple to do the other way around though. I haven’t used GoodSky, but how exactly is that random number generated?

It uses these nodes:

So all I really need is to get the output value of that last multiply and use it to drive the intensity of a sky light.

Getting value from that multiply is exactly the hard part, because this everything happens on GPU side of things. But I don’t see anything that cannot be replicated inside of blueprints and provided as a parameter, instead of that graph.

Edit: If you are more of a tech type, this may help:
https://forums.unrealengine.com/development-discussion/rendering/19556-get-data-back-from-compute-shader