Home Unreal Engine

Creating gravitational lensing effect

polycounter lvl 13
Offline / Send Message
16bit polycounter lvl 13
BlackHole_Lensing.gif

I'm looking to create the distortion that a black hole makes.

But I find it too hard to comprehend. How do you make things behind a black hole to the left, appear on the right?

Replies

  • Ace-Angel
    Options
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    A World Transformed Refraction :)

    Problem is, UDK doesn't allow for proper distortion with refraction unless you're planning to make the effect a Post-Process that's constantly infront of the player and follows the camera.

    What exactly are you trying to do? Is the effect going to be on a mesh? Is it camera oriented? Can the player move around (which will break the effect), etc...
  • 16bit
    Options
    Offline / Send Message
    16bit polycounter lvl 13
    It's a player deployed bomb that creates a black hole.

    I had planned on creating a distort material and applying it to a player facing particle.

    The view will be top down, but rotatable.

    Can you go more into this World Transformed refraction? I tried to google it, but this thread popped up as number 1, and the other results showed nothing.
  • Ace-Angel
    Options
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    Cheapest way would be to setup a ScreenTexture, and feed one of them (standard), and the another one flipped (180*) into a Lerp node, with a phong like texture in the Alpha for the effect, should be cheap and convincing enough.

    Then, multiply a black phong like texture which is smaller, in the place where the you want the black hole to be. Should be good enough and cheap.

    ===

    A more complicated way and more 'law' accurate:

    You need to first setup your Refraction, the most standard and common one is Snell's, which can be found here:

    http://thangnguyendemo.blogspot.com/2009/04/new-beginning.html

    Once that is done, IIRC, you need to then feed the setup into a Transform node, and that will essentially 'flip' the cubemap/screen 180* automatically.

    I suggest lerping then between a cube/screen texture and the flip with an Alpha, the alpha should be an inverted fresnel with an alpha to guide it, which will distort stuff at the center and the outer parts will be normal parts.

    You then multiply a black texture over the 'black' hole point, and that should give your a correct looking effect.

    ===

    Both ways are valid, it's just one of them is more 'realistic' and physical law correct while the other is just the 'effect', should be good enough for games :)
  • Xendance
    Options
    Offline / Send Message
    Xendance polycounter lvl 7
  • sprunghunt
    Options
    Offline / Send Message
    sprunghunt polycounter
    16bit wrote: »
    I had planned on creating a distort material and applying it to a player facing particle.

    I'd just do this. The complicated solutions aren't worth the hassle. And nobody will know any different.
  • haba_haba
    Options
    Offline / Send Message
    Hi there, this is what i managed to do, it's not exact copy of real effect, but maybe you will find it useful:
    1.jpg
    2.jpg
    3.jpg
    4.jpg
    5.jpg

    i'd upload gif but i can't get to work :(
  • 16bit
    Options
    Offline / Send Message
    16bit polycounter lvl 13
    haba you were a great help. I'm trying to convert it from a uv distort to a distortion effect and it's... not going as well as i'd hoped.

    blackhole.png

    It's a cool effect. But for some reason it seems to be shifted from the top right to the bottom left. Stretching it at the top right and squashing at the bottom left.

    Then theres the black hole center. Since distortion is additive, I can't really multiply black. Maybe negative?

    -edit-
    oh and theres also the fact if it's near the top of the screen it kind of stops working properly.
  • Computron
    Options
    Offline / Send Message
    Computron polycounter lvl 7
    The gravity hammer in halo 3 creates an effect similar to this if you look in theatre. I love the way it looks!
  • 16bit
    Options
    Offline / Send Message
    16bit polycounter lvl 13
    I played with it a little since then trying to get it to expand in the center instead of how it does in Haba's example.

    postiveSR.jpg

    It now does. I guess what i've created is basically a giant sphere on the uv map.

    negativeSR.jpg

    Using a negative square root it curves a grid into this. It goes on forever no matter how much you zoon in, that's neat I suppose. But I mainly posted this so you can see the material tree.
  • 16bit
    Options
    Offline / Send Message
    16bit polycounter lvl 13
    bhd.gif

    Additional info I may be over looking.

    I suppose you can think of there being 2 rings around a black hole, the outer ring distorts objects around it, and an inner ring with shows the object distorted directly on the opposite side like a mirror.

    I guess my question is, while I'm doing this all for testing on a uv of a texture, as doing it all on the distortion node is very hard.

    Can I just unplug it from texture uv and into distortion?
  • haba_haba
    Options
    Offline / Send Message
    16bit wrote: »
    .. But for some reason it seems to be shifted from the top right to the bottom left. Stretching it at the top right and squashing at the bottom left..

    this is done by design in segment "2". I thought it will be more mathematiclly correct (maybe i was wrong). Shifting from TR to BL is done by sub(0.5) mult(-1) add(0.5). Stretching is done by mult with sphere mask.

    Unfortunately i have no idea how distortion material on particles works.
    One thing that comes to my mind how to solve this is creating scene capture and operating on captured frame the way i did and then displaying this in front of player. I don't know if that makes any sens. :(
  • Ace-Angel
    Options
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    UDK doesn't take into account 3 vectors for most textures, EXCEPT the cubemap, which in turn, doesn't take into account RT environments in most cases, and those that do, don't show their posterior.

    So that's why you're getting the Rubik cube effect inside a black hole, as I previously stated.

    Honestly, as I said, just used two ScreenTexture's, flip one 180 and the other one, keep it standard, then use an Alpha in a lerp (phong like textures) and have that manage your distortion.

    Then, mutiply a black spot in the final result (for the Diffuse) with the Alpha.

    It's the easiest solution without getting overly complicated.

    You either full physical with Snell's refraction and account for a bazillion variables and manage a whole slew of problems, or you just fake it. You can't get the middle ground since UDK doesn't allow it.
  • 16bit
    Options
    Offline / Send Message
    16bit polycounter lvl 13
    I replaced Haba's "1" to make it expand around the sphere and this gives the perfect result.

    blackholefinished.jpg

    I'm not sure how to do yours Ace, but here's the result.

    mirrorball.jpg

    I just replaced the uv alteration of the grass with the scenetexture. The problem being it looks like a mirror ball and doesn't actually distort. Theres also the problem with those black.. taco shaped things. I have no idea what's causing those.

    I have no idea if this is what you intended it to look like or I didn't do it right.
  • 16bit
    Options
    Offline / Send Message
    16bit polycounter lvl 13
    blackholenear.jpg

    It's nearly finished.
    It distorts things behind it around it. And it reflects objects (although not accurately, but I can't see it mattering much).

    Things that need to be solved now, it still looks like glass, and its glowing. Also the black tacos, I guess the uv manipulation is behind it or something, I'm not entirely sure.
  • Xendance
    Options
    Offline / Send Message
    Xendance polycounter lvl 7
    Here's what I did:

    TJS0l.png
    0UL8Z.jpg
    49DdB.jpg
  • 16bit
    Options
    Offline / Send Message
    16bit polycounter lvl 13
    Neat effect, but I wonder how well geometry would play with the inner reflection.

    Speaking of which, I recreated your material and tested it out. The farther you zoom out from it, it actually flips the distortion reflecting the sky on the bottom, etc.

    Would you know why that is?
  • Xendance
    Options
    Offline / Send Message
    Xendance polycounter lvl 7
    16bit wrote: »
    Neat effect, but I wonder how well geometry would play with the inner reflection.

    Speaking of which, I recreated your material and tested it out. The farther you zoom out from it, it actually flips the distortion reflecting the sky on the bottom, etc.

    Would you know why that is?

    My guess is that it's because how Epic implemented distortion in the material.
Sign In or Register to comment.