3D Skyboxes

Discuss programming topics for the various GPL'd game engine sources.
Preach
Posts: 122
Joined: Thu Nov 25, 2004 7:20 pm

3D Skyboxes

Post by Preach »

Exactly how difficult would it be to add support for 3d skyboxes - the kind of thing you see in half-life 2 - into the quake engine? The sort of thing I had in mind is having a worldspawn key called "skymap" that would tell you the bsp file to render in place of a 2D skybox - although to complicate things that bsp could have a conventional 2D skybox as well. The "skymap" could, if need be, be made at 1/16th scale so that you could render much further than usual with this.


I have this vague idea that the crude way of doing it would be to render the "skymap" in full first, then render the world - omitting the sky polygons - without clearing the buffer. But instantly two problems strike me with that: one is that there would be a lot of overdraw, the other is that this method leads to a problem from early ports of quake engines. You start to see bits of the map through what should be "solid", line of sight blocking sky. I don't think either of these things are a huge hurdle to overcome, but I've been wrong before, so thoughts welcome...
leileilol
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Post by leileilol »

q3map2's already got a hacky way, try it, it's _skyroom entity
i should not be here
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Post by frag.machine »

You don't need a separated .bsp to do that. Just be sure the map has a sealed room, render normally from inside it (ie. including ordinary sky textures or conventional skyboxes), then clear the Z buffer and render the world skipping any sky polygons. A simple "skyroom" coordinate in the worldspawn info would be enough. OTOH, separated sky rooms would help in the case of original id maps.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Labman
Posts: 62
Joined: Fri Nov 05, 2004 2:39 am
Location: Brisbane, Australia
Contact:

Post by Labman »

frag.machine wrote:You don't need a separated .bsp to do that. Just be sure the map has a sealed room, render normally from inside it (ie. including ordinary sky textures or conventional skyboxes), then clear the Z buffer and render the world skipping any sky polygons. A simple "skyroom" coordinate in the worldspawn info would be enough. OTOH, separated sky rooms would help in the case of original id maps.
The problem with this as stated in the first post, is that on some maps you would now be able to see through the skybox into other parts of the map which were previously not visible.

Another way would be to render the sky polys with a stencil buffer set and then after rendering the world, clear the depth buffer and draw your sky over the the screen only where the stencil was set. This would also lower your overdraw as well as not show through to other parts of the map.
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Post by Spike »

Labman wrote:Another way would be to render the sky polys with a stencil buffer set and then after rendering the world, clear the depth buffer and draw your sky over the the screen only where the stencil was set. This would also lower your overdraw as well as not show through to other parts of the map.
Stencil buffer is too complicated and breaks things like stencil shadows.
Just draw the sky surfaces like normal... except draw them first and turn the colour buffer writes off. glColorMask(0,0,0,0). then when you draw the rest of the world, the normal z buffer tests will prevent anything behind the sky from being drawn.

I'm not sure how well this works with minidrivers though, but chances are, stencils are worse.

An additional cool feature would of course be if you could have entities and things moving around in the skybox too. You'd need to combine pvs on the server, but it shouldn't be too bad.

Separate skybox bsps get really awkward when it comes to game code if you want things moving around (and if they don't, what's the point?).
Sajt
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Post by Sajt »

I think the method LordHavoc used to talk about was to split the depth range up if a sky surface is visible. That way you don't have to scale the sky room up when you draw it or whatever to make sure it doesn't poke through the world.
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Post by frag.machine »

Spike wrote: Just draw the sky surfaces like normal... except draw them first and turn the colour buffer writes off. glColorMask(0,0,0,0). then when you draw the rest of the world, the normal z buffer tests will prevent anything behind the sky from being drawn.
Yeah, this method looks better than my original idea. And can be used to draw regular skyboxes without the "oh-i-can-see-things-behind-the-sky" weirdness :)
Spike wrote:An additional cool feature would of course be if you could have entities and things moving around in the skybox too. You'd need to combine pvs on the server, but it shouldn't be too bad.
Of course! Things like a dragon flying in circles, for example. That would be really cool.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Sajt
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Post by Sajt »

If anyone actually implements skyrooms, make sure that it is robust - Allow skyrooms to have skyrooms, and allow each to have 'parallax' scroll factors, like HL2, so they can move by a small amount so that things appear far away but not infinitely far.
frag.machine wrote: dragon flying in circles, for example. That would be really cool.
But remember Unreal? You could actually shoot the birds down :) It's unfair that they are off in magic untouchable skyroom land.

A cool thing though is allowing players or monsters to teleport to the skyroom. I think something like this was possible in UT2k4. You would appear massive in the sky to any players in the normal part of the level. Kind of like that part of Prey where you are in the small planetoid in a box.
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Urre
Posts: 1109
Joined: Fri Nov 05, 2004 2:36 am
Location: Moon
Contact:

Post by Urre »

Hahah, yeah. That was already possible in the original Unreal. Me and my brother played some LAN Unreal action every now and then, and once I noclipped into the skyroom just to prove that very point to my brother, and he freaked out when seeing a huge Skaarj in the sky.
I was once a Quake modder
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Post by frag.machine »

Sajt wrote:If anyone actually implements skyrooms, make sure that it is robust - Allow skyrooms to have skyrooms, and allow each to have 'parallax' scroll factors, like HL2, so they can move by a small amount so that things appear far away but not infinitely far.
Wow, I can foresee a huge FPS drop here... :D

2 skyrooms may be feasible, but is it worth the effort ? Even now you barely see people using regular skyboxes, let alone something so out of the regular Quake bread and butter mapping.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Sajt
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Post by Sajt »

It's true that nobody would ever use it. The mappers don't use fancy engines.

But the use for 2 skyrooms would be one to have a distant building (like the evil Mount Doom skyscraper in HL2), which scrolls slightly as you move around, then a normal infinite skybox behind that one.
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Preach
Posts: 122
Joined: Thu Nov 25, 2004 7:20 pm

Post by Preach »

See, I think this would be something that mappers would use, because they use regular skyboxes all the time. In fact it was a mapper who requested this to me. The way I suggested setting it up would mean that it has sensible fallbacks in other engines(2d skyboxes then regular sky render). I agree with the parallax thing being desirable, but don't see why you'd want to chain skyrooms, what you'd gain from it...
Sajt
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Post by Sajt »

Sajt wrote:But the use for 2 skyrooms would be one to have a distant building (like the evil Mount Doom skyscraper in HL2), which scrolls slightly as you move around, then a normal infinite skybox behind that one.
Besides, a simple elegant implementation would support 'chained' skyroomes. If you only supported one, it would be more of a hack.
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Preach
Posts: 122
Joined: Thu Nov 25, 2004 7:20 pm

Post by Preach »

I can see the need for a regular 2D skybox behind the mount doom monolith citadel, sure, but that wouldn't need to be another skyroom, in fact that would often be worse than just a 2D-skybox. There's a lot of things that are just done better in 2D, like clouds and sun. So I'm not convinced that rendering another actual skyroom is ever gonna give you something you couldn't sensibly do with one. Robustness isn't really a factor then, sky polygons rendered in the skyroom are done as a 2D skybox, sky polygons in the actual map show the skyroom, sounds like a sensible convention.
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Post by frag.machine »

Preach wrote:I can see the need for a regular 2D skybox behind the mount doom monolith citadel, sure, but that wouldn't need to be another skyroom, in fact that would often be worse than just a 2D-skybox. There's a lot of things that are just done better in 2D, like clouds and sun. So I'm not convinced that rendering another actual skyroom is ever gonna give you something you couldn't sensibly do with one. Robustness isn't really a factor then, sky polygons rendered in the skyroom are done as a 2D skybox, sky polygons in the actual map show the skyroom, sounds like a sensible convention.
I second that. Besides, there are more interesting effects than multiple skyrooms. For example, a long time ago MH posted in the now offline quakesrc.org forums a nice tut about implementing skydomes (2 spheric layers scrolling smoothly combined with fog) that gives to GlQuake a very impressive effect of depth. It's a really nice and original alternative to the regular skyboxes.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Post Reply