Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
Blastfrog

Converting skyboxes to sky drums

Recommended Posts

So, say that I have a skybox that I want to convert to a cylinder. What formula should I use? I was thinking something along the lines of keeping the center of each wall panel the same in scale, but scale the side columns down based on the distance between each column/ray and that portion of the wall (for example, the left and rightmost columns would be scaled at approximately 0.71 times the normal size). I suppose it'd be similar to how raycasting looks without the perspective corrected.

I'm still not sure if this would be correct way to go about this. Either way, I want to make this an automated (or close to automated) process, as I'd have likely many skyboxes to do this to when I get about to doing this.

Note that I'm only dealing with skybox walls, no floors or ceilings. To compensate, I'll be increasing the size of the walls vertically and using a higher vertical FOV when I render/generate the skyboxes. The walls would obviously still be exactly 90 degrees in FOV horizontally.

Share this post


Link to post

I presume this is a ray casting engine?

If so, you could do what Doom does, it pretty much just stretches the sky in a bendy kind of shape.

Otherwise, if it is OpenGL? or DirectX? You can just draw the sky as a gigantic cylinder, then clear the depth buffer.

Share this post


Link to post

I probably should've made myself more clear. I'm using Blender to create hires skyboxes for Koliko's Adventure, and I want to take the resulting images, stitch them together in a 360 panorama, and apply perspective correction to each of the sides (every 90 degrees/quarter of the panorama) to be used as a sky drum in Boom in the software renderer.

Share this post


Link to post
ducon said:

Use the polar coordinates?

That's pretty much exactly what I had in mind, but I'm unsure of what the exact formula that I should use should be to translate a flat plane with a horizontally 90 degree rendering (skybox wall/side) into a plane meant to be wrapped around the inside of a 90 degree section of a cylinder.

Here's the formula I came up with, but again, I'm not too sure of my own math, and I asked here because I figure that some of you guys are better at this 3D math stuff than I am.


Horizontal scale of skybox wall (which covers 90 degrees) = 2.0
Distance from camera origin to skybox wall's center (it is perpendicular) = x = 1.0
True distance from camera origin to particular skybox wall slice = y
Vertical scale for each column in the output image = x / y


Does this look about right?


As an aside, I am aware that Doom doesn't scale the cylinder's rendered columns vertically, but I choose to ignore that, as it's the horizontal perspective I'm more concerned about anyway. IIRC, Doom's sky rendering actually does use cylindrical perspective as it displays the sky (only horizontally though), they just forgot (or perhaps chose) to apply vertical perspective as well.

Share this post


Link to post
Sodaholic said:

Horizontal scale of skybox wall (which covers 90 degrees) = 2.0


Not sure what you mean here, but Doom will try to show all 256 pixels of a single wall tile if you look precisely N/S/W/E etc.

Assuming that normal skies are supposed to be 1024 pixels wide (mapped to 360 degrees) and that you see 256 of them at once (albeit with distortions), I'd say that this is "scale 1.0".

If you use a narrower sky texture, vanilla code won't stetch it: it will simply tile it like a normal wall texture. Using longer wider ones will just waste space.

Now, if the engine can actually stretch short skies (e.g. ZDoom) then we're talking about a variable scale e.g. 512 px to 1024 would be a scale of 2.0.

If by "scale" you mean how much of the total wall texture you see at once however, then it would be 1/4.0, as you see 1/4th of the wall at once. A scale of 2.0 would mean you see two tiles at once in your view field.

Sodaholic said:

Distance from camera origin to skybox wall's center (it is perpendicular) = x = 1.0


You could say that it's "1.0" if considered as a normalized distance,
used as a reference for the others.

Sodaholic said:

True distance from camera origin to particular skybox wall slice = y


If by y you mean the distance from the center of the screen, then yeah. Actually, since the distance could also be negative (below the origin), you actually need sqrt(y^2 + x^2) = abs(y) if x =0.

Sodaholic said:

Vertical scale for each column in the output image = x / y


Doom has no concept of vertical scale for skies, there's however a horizontal scale based on the tangent of the view angle (pixels at the borders of the screen get stretched).

To sum up, Doom already does a half-assed "sky cylinder" or "sky drum" effect, only that there's no vertical perspective whatsoever, and so even the horizontal one looks very stiff. You don't need to change anything in your images to achieve that effect. Also, normally the sky is not supposed to be "freelooked", while even the Heretic freelook function has no additional vertical perspective correction or scaling, it simply has extra pixels that prevent tiling (not sure what ZDoom does).

HOWEVER, if you want to achieve a "cylinder effect" height wise, so that your sky pictures appear slightly curved outwards from the viewer, you sure can pre-process them to achieve that effect, though the final effect will be dubious. Also, the effect will always be in plain view, unlike a true 3D engine that has proper 3D perspective, and the effect will be view direction-dependent.

So in the end it also depends on whether you want to give a "faux sky cylinder" effect to vanilla Doom, or use an advanced source port which offers some better support for those effects.

Share this post


Link to post
Maes said:

Also, normally the sky is not supposed to be "freelooked", while even the Heretic freelook function has no additional vertical perspective correction or scaling, it simply has extra pixels that prevent tiling (not sure what ZDoom does).

All explained here.

Share this post


Link to post

Actually, I asked around on Blender's IRC, turns out it can already output a panoramic view with the correct perspective. This thread can be disregarded.

Oh, and Maes, check your PM's, I just sent you a message.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×