Prevent SurfaceGui Render Skipping for Black Hole Gravitational Lensing Effect

So I am working on a black hole that simulates gravitations lensing with its accretion disk. To do this I’ve had to use surface guis to dynamically resize the disk in relation to the player perspective. Here’s what it looks like in action. In order to achieve such massive scale (the black holes in the gif below are around 4000 units wide) I’ve had to extend the surfaceguis beyond the part.

Current Black Hole Effect:
ezgif-2-0b3083c5a27e
(In case you’re confused, that black hole is actually massive - the ship is only 4x4x13 and going at around 3-4k units/second. If it were to-scale this would be around 20k mi/h aka 300k km/h)

The issue I’m facing is that whenever the small center parts that the surfaceGuis are parented to leaves the player’s camera, the entire surfacegui disappears. I understand that this makes sense for most applications, but I was wondering if anyone had any ideas as to how to overcome this?

Example of issue:

So far I’ve considered using decals on blockmeshes, however decals lack the ZOffset control that SurfaceGuis have. Same with BillboardGuis.

3 Likes

So I’m thinking of dynamically changing the center part to always be in camera range by offsetting the surfaceUI proportionally. Anyone have any reason why this may backfire before I spend a few hours trying to get it to work? Still open to other ideas to make this work. Thanks!

Have you seen this post?

Yep, I read it earlier and that explained the initial fade away behavior. I assumed the second part of the post was him musing about potential backend changes. Maybe I misunderstood though.

I currently do track the max size of UI elements when distorting them for the lensing effect, but unfortunately due to the massive scale of the black hole they appear to consistently be above whatever the backend limits are.

Do you plan on showing how to gain that kind of effect in the future on a smaller scale?

Trying to create a miniature galaxy and I have gotten some really neat galaxy structures down in practice, but an effect like this at the center would be killer.
galaxy
Let me know please!

Galaxy looks awesome!

Sure thing! Actually just upgraded the visuals of it yesterday.

So the first thing to understand is that physically, the accretion disk of a black hole is just that - a disk. Similar to the rings of Saturn. The lensing occurs because the gravity bends the light from the other side of the disk, allowing the viewer to see both the top and bottom of it at the same time.

So since it’s the far side of the ring that’s being bent, I decided to make the side facing towards the player flat. This was achieved by cutting the ring in half, then orienting that ring along the plane to face the player.

The next step was getting the lensing effect. The effect on the side of the player was simple, just take another half-copy of the ring, and orient it so that it is always perpendicular to the player’s POV, being along the shared axis with the rotating front ring from earlier.

The second lensing effect does the same thing, except it also dynamically resizes and offsets. The way I determined the offset was to get the angle which the player was viewing the inner ring side to determine would could and couldn’t be seen. I then used the tangent of that angle to determine the offset. So I’d offset the ring by that amount.

To get the second lensing size, I’d subtract the offset from the original radius, then divide that amount by the original radius. I multiplier the result on to the dimensions of the full sized half-ring.

Overall this took almost 20 hours of tweaking an rewriting, hopefully my explanation saves you some time. Good luck!

4 Likes