Spherical World Material Experiment

I was recently thinking about different methods of making the ‘world’ in a 3D game appear spherical, like one of the many small planets in Mario Galaxy. It occurred to me that it might be possible in UE4 by applying a material to everything in the world, and using the ‘World Position Offset’ property and a little bit of trigonometry…

I figure it would be a fun experiment at least, and after playing around for a bit yesterday afternoon, I got something semi-functional. I figured I might as well share it with everyone here, so everyone can see where it was successful, and the various issues that I ran into.

Here is a quick video of the normal ‘flat’ world that I built - with no special material.https://youtube.com/watch?v=bdejrl6wRF0
And here is a video of the same world with the ‘spherical’ material applied to all of the geometry.https://youtube.com/watch?v=qhBvgPPoIfs
Overall I think it works pretty well for a quick experiment… but there are several challenges which may make it in-feasible for use in an actual game.

-Obviously the system I set up in the material is far from perfect… I didn’t spend too much time on it, so you can see there is some odd distortion on everything - making the tops of tall towers look wider the the bottoms, for example.
-The material has to be applied to EVERYTHING in the scene - even characters and projectiles. If I removed the material from my projectile it would bounce of where the world geometry ‘really’ is, not where it is projected with the material.
-Since the actual world is flat, and has edges, the player can’t ‘loop’ around without some additional tricks.
-As you can see in the later half of the second video, when the ‘real’ location of geometry is outside the view frustum, the geometry is occluded, causing a lot of pop in/out, particularly when looking down.

Now I’ve been putting some thought into how one might solve the last issue elegantly, since I think it is the largest technical barrier… But I haven’t come up with anything terribly clever, yet.

Does anyone have any thoughts on any of those issues?
Think this is a worthwhile solution to rendering a spherical world in UE4? Or would actually modeling a spherical world, and messing with the gravity system be preferable?

Pretty cool idea :slight_smile:

I guess as long as you weren’t planning anything really intensive or need every last bit of performance, you could just increase the BoundsScale of everything to prevent the frustum popping? If it did alter performance more than desired, maybe its possible to adjust the culling code to offset the bounds based on screen position (as long as it didn’t cost more to do that than its worth).

Are you doing any rotation in the vertex shader? Does it cause problems when used on animated skel meshes? Does it work on particle sprites?

Not sure what would cause more headaches, this or the gravity thing… if it were me I’d probably try this route, since I’m not a coder :slight_smile:

I haven’t done any rotation yet… I’ll have to look into how complex that is.

Those are some interesting additional issues to overcome, though… good call.

If I pursue making this into a bigger project, I will probably keep the graphical style very abstract, to minimize the impact of the various issues, and cut down on the performance impact of the myriad of ‘hacks’ that will probably be necessary, like expanding the culling frustum/BoundsScale.

Cool, I actually made a material just like this last week!

I used the RotateAboutAxis node, and the 2dSphereMask node to generate the RotationAmount input.

How did you approach it?

-nick d

Wow, I totally missed that SphereMask node, somehow… I managed to implement something that looks very much like my original results, using SphereMask as an input to World Position Offset, in just a few minutes.

My original version was much more of a brute force method, where I calculated the vertex’s distance from the camera position, calculated that as a percentage of 1/4 of the circumference, and used the Cosine node to calculate how much the vertex be dropped and extended away from the camera…

Even if this isn’t terribly practical, I’m certainly learning a lot about the material system in UE4, this week… I’m a programmer by trade, but I’m really enjoying just playing around in the editor.

Could someone please advise me on how to corretcly hook up what they are talking about in this thread? I get that the spheremask and rotateaboutaxis nodes are used and hooked up to world position offset, but what else and how?

I imagine you’d be better off making a spherical world and messing with some gravity actors:

Link to this game project