Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Marscaleb

Looking for some technical info on sky rendering

Recommended Posts

I'm trying to find some technical info on how doom render's its sky; I recall seeing someone describe this once, but I can't seem to find it.  I don't see it in the Doom wiki.

 

When Doom renders the sky, the sky texture isn't just "flat."  The further the image is from the screen, the more it gets stretched.

Does anyone have data for how much/when the image gets stretched?

 

I am trying to recreate this effect, and it would be nice to have that data.

Share this post


Link to post

What you're seeing is pincushion distortion from mapping the cylindrical projection used in sky textures to the gnomonic perspective used to render the game world, so that the rendering of the sky visually matches the rest of the world. For example, step onto the balcony at the start of Doom 2 MAP01, and turn slowly while looking at the sky through the fence. Observe that the horizontal spacing between the fence posts changes as your view rotates due to perspective, and the sky distorts to match it (at least on the horizontal axis).

 

The perspective mapping of the sky is done using the precomputed math table xtoviewangle[], which is generated in R_InitTextureMapping() using the tangent table. The effect is that each vertical column of pixels in the sky texture is stretched horizontally by a factor of 1/cos2(α) where α is the viewing angle relative to the centre of the screen.

Share this post


Link to post
2 hours ago, Foxpup said:

The effect is that each vertical column of pixels in the sky texture is stretched horizontally by a factor of 1/cos2(α) where α is the viewing angle relative to the centre of the screen.

Ah, so the precomputed table is based on that formula?  Interesting and useful to know.

I was really just asking to know what the values are within that precomputed table, but at this point I'm not so sure seeing the raw numbers would mean much to me.

Thank you for the response.

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
×