NokiMo
Megan Fox
Megan Fox

patreon


Sky Rooms

Sky rooms are a thing you probably know about if you've touched Source engine before, but otherwise? Probably not. Here's the gist:

Sky rooms are using a second camera to clear the screen and draw from a special room in your map, and after it finishes drawing, you clear the zbuffer and draw on top of that. It's like rendering your skybox ever frame manually. You sync up the rotation of the camera sitting in your skybox with the rotation of your actual game camera, so that when you look up, the skybox camera looks at the ceiling of its little room, and so on. If you get fancy, you can even translate (some) camera motion across into the skyroom, which is useful if you want to give some small sense of parallax.

That's ultimately what is cool about a skyroom: you're drawing actual 3d objects, not a flat skybox. They can move around. Want some clouds in the distance that behave like 3D clouds and drift and flit, but that you can never run into and that never obscure anything in-world? Sky rooms are GREAT for that.

Setting them up is simple, IF you have a rendering engine that can be made to draw from a bunch of cameras, one after another, on top of whatever was drawn before. Unity can currently do this, but they're actually talking about removing the capability? Which would seem insane? This is necessary for a ton of FX stuff. Anyways. In principle it's simple.

In Unity, you just put your skyroom stuff in a Sky layer, set your sky camera to render ONLY sky, and make sure its depth means it draws first. Set it to clear to a solid color (sky color) if you want to just render some 3D objects on top of a flat color. Do whatever you want in here. You can put a Kaiju model in here, stomping around above the camera, then build a game level that's of a city block, and it'll look like there's a Kaiju stomping around the city, smashing stuff, always just outside of where you are. It's super cool!

You just set your main camera up to clear ONLY depth, and not draw the sky but draw everything else, and there you go, done. Sky room! By the way, this camera layering trick is also how you can draw first-person guns/hands/etc that never collide or intersect with the world. It's handy if you want to render your guns with a different FOV from whatever the main game uses normally. That's how old-school shooters got such chunky-looking weapons, and why a lot of modern shooters have weapons and first person hands that just feel kind of small. Neat, eh?

Anyways, why do this? Well, it's neat, but also, look at my sky room again.

See how I've got an inside-out cylinder there capped with boxes? That means there are effectively no seams that you'll ever see. If this were a Unity skybox, there'd be big nasty box seems in every direction, and those can be a nightmare to fix without distorting whatever nice city skyline or the like you're wanting off in the distance. Here, though? It's dead easy to make a horizontally wrapping city skyline or trees or anything else, and there you go. So long as you tape the top and the bottom to a solid color, and match that color in the caps meshes you put on either end, this is an instantly seamless sky approach that is incredibly easy to execute.

Trickiest part is the code to sync the camera! Which... $3 patrons, here ya go :D Seriously though, it isn't that hard. All you're really doing is taking your main render camera's rotation and applying it to your skybox camera. That's it. If you want to get fancy, you can take the offset from your main camera from (some point in the world or the room you're in), and translate that into an offset from center for your skybox camera. That lets you get some subtle parallax. It's useful if what you're looking at is, say, a ton of buildings, and you need them to shift so you can tell they're 3D as you run down a hallway looking out some windows at a huge city that FEELS like it's there but is just in the sky. Or you know, that kinda thing.

You might be asking "where do I put the skyroom", and the answer is: really far out of the way. Your rendering layer setup means PLAYERS never see it, but damn is it annoying if it's sitting in the middle of 0,0,0 and obscuring your editing. You can disable the layer instead if you want, but like... I just do this:


Sky Rooms

Related Creators