3D Skyboxes
3D Skyboxes
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...
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...
-
- Posts: 2126
- Joined: Sat Nov 25, 2006 1:49 pm
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)
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.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.
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.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.
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?).
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.
-
- Posts: 2126
- Joined: Sat Nov 25, 2006 1:49 pm
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" weirdnessSpike 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.
Of course! Things like a dragon flying in circles, for example. That would be really cool.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.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC (LordHavoc)
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.
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.
But remember Unreal? You could actually shoot the birds down It's unfair that they are off in magic untouchable skyroom land.frag.machine wrote: dragon flying in circles, for example. That would be really cool.
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.
-
- Posts: 2126
- Joined: Sat Nov 25, 2006 1:49 pm
Wow, I can foresee a huge FPS drop here...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.
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)
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.
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.
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...
Besides, a simple elegant implementation would support 'chained' skyroomes. If you only supported one, it would be more of a hack.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.
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.
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.
-
- Posts: 2126
- Joined: Sat Nov 25, 2006 1:49 pm
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.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 know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC (LordHavoc)