Portal Skies / Having parts of level hidden in sky

In unreal 4, it seems like skies are done by having a gigantic sky sphere in the level.

Other engines, especially idtech based, like Source or DooM, or Quake, etc… use kindof a texture/material. Wherever that material is used it instead renders a sky or shows a view into a sky via a portal like system. I think even older unreal engine games did this. You basically create a pocket world within the level and it’s projected as the sky in other parts of the level.

I have parts of my level I want completely hidden when the player looks into the sky. This is partly because I have a procedurally generated level and some parts of the procedurally generated level will have a visible sky. The player will essentially see complete garbage in the sky of some parts of the level they’re not supposed to see.

If I could just have some rooms in my procedurally generated level have the ceiling use a “Sky” material and it showed a sky portal, that would solve the problem.

I’m not sure if there are any tutorials or other similar solutions for UE4. We might also need this for VR. This would really help for our game in general since it’s mostly randomly generated levels as opposed to a gigantic landscape and I’d prefer to define some surfaces as “this shows the sky” like other engines can, as opposed to just placing a giant skybox. Most of the rooms in the procedurally generated level will be just rooms and no outside building geometry, so players will see into far away rooms due to back face culling and such.

It’s especially hard to even find results on google, like “Sky Material”, “Sky Surface”, “Sky Texture”, etc are all about how to create nice looking skies on the default sky sphere. Not how to set a polygon to render a sky on. Not much on Portal Skies since unreal 4 doesn’t really seem to have much of a portal system if any.

If you just want hide that geometry with a sky texture, then you should be able to do this with a cubemap (maybe like an interior cubemap, just with a regular sky + landscape), that is projected on a mesh, or your area, that should represent the sky. I guess, why you will not find much with sky portals, is because they are a special case, and a little bit more complicated, than your regular skybox. As far, as i understand, the difference is, that your sky portal is actually a texture, which is generated by a second camera in your scene, which sits in a tiny cube, isolated from the rest of the world, with your sky cube map, and additional geometry like some city buildings etc, to generate a more interesting skyline for the horizon. It was used in early DOOM and Quake and Wolfenstein games.
But nowadays, i guess you just need to project a good sky cubemap on those areas, that would solve the trouble from having two cameras.

Your real sky portal couldd be done too, with rendertargets, but afaik they are not exactly cheap in terms of processing power :slight_smile:

I was definitely looking at those seamless portals videos earlier.

Actually the more modern source ports of DooM like Zdoom have straight up fancy projected skies, just like source engine.

I was starting to think about rendering to a render target of some sort with a camera set in a pocket world that matches the looking direction of the player and seeing if my material can sample that texture. I could also make that camera move slightly in actual space to give the sky a tiny bit of parallax as you move. Then I don’t really even need a cube map and worry about rendering quality of the sky. It might tank perf if the sky is super complicated with geometry that won’t even be visible most of the time, but I think I’m OK taking the hit, especially if we keep the sky fairly simple for this. Even in Source games if you go to the sky world, the geometry is super low detailed in there.

It would especially be useful if the render target can avoid being even rendered to unless the sky is visible.

Seems like just sampling a static cubemap may be the way to go actually. I was also experimenting with modifying the existing swirling clouds material to work on an arbitrary surface instead of a sphere and got some parts of it looking good.

Perf wise, especially in VR, this will have issues. The material should be able to render all sorts of cool effects in the sky like clouds if it maps the geometry onto a virtual giant sphere. You will need a scene capture for literally every view port possible, so in VR you might even need 2 renders. And in VR there’s actually a delay due to late update so as you look around, the sky lags behind. So you could render to a cubemap but then you’re trying to scene capture onto a cubemap which is even more heavy.

Wow I just tried a material with sampled cubemap except motion blur ends up affecting it. It’s probably because it’s so close to the camera that it thinks those pixels are moving a lot and should be blurred. I fixed it by making the material transluscent instead of opaque. Disable Motion Blur for Translucent Material - UE4 AnswerHub

Apparently as of 4.23 there’s a checkbox on transluscent materials to make them output velocity and the solution is to simply set the material as transluscent and not leave that checkbox off.