Just came accross my mind when making an effect, I would be pretty awesome if a shader could bend light like a black hole/lens!: @bgolus, would this be potentially hard to code into the engine, orrrrrrr PS. Gonna post a video soon of the effect I want to use it on.
AKAIK extreme light bending - like the black hole effect shown in your picture - isn't possible in the setup Uber uses. It's only possible within really narrow use cases, like doing it only against the sky box, or when an environment cube map already exist for this view point and the distortion doesn’t magnify a lot.
Well, couldn't it be made artificial instead of a very complicated ray tracing simulation? A 2D effect.
I believe doing it to the entire screen as a 2D camera lens effect would just be a matter figuring out the math. But I'm doubtful you could do a post effect based on a unit location - not that I've looked into the shaders in any detail.
In theory, you could. The vision radius shader for example does precisely that, it gets fed a list of all units on screen and there respective vision radius, iterates over that, and executes a fragment shader which samples every single location of the screen. The same way, it would be possible to add a distortion during the sampling phase of that shader. Unfortunately, it isn't possible to configure any other unit attribute except for vision radius as an input to that shader.
I suppose you could still use that, but then only do the effect for specific infeasible vision radii, like -1.0 or -2.0.