Sky stretching

From ZDoom Wiki
Jump to navigation Jump to search
Looking right ahead.
Looking upwards.

Sky stretching is a feature in ZDoom to accommodate free look with sky textures meant for an unchangingly horizontal point of view.

By vertically stretching the sky texture, ZDoom can avoid tiling it, which would look odd. However, the stretching effect does not necessarily look good either.

In either case, it is meant to compensate for looking up, and tiling might still happen when looking down.

The two screenshot collages show the effects of a stretched sky compared to unstretched sky. On the first screenshot, the mountains look normal when unstretched, and are too high when stretched. But as seen on the second, the mountains become tiled in the sky when aiming upward if they are left unstretched.

Sky stretching also depends on sky texture height:

Texture height Behavior
Less than 128 The texture is always unstretched, centered on the horizon, and tiled above and below.
128 or more, but less than 200 Sky stretching is optional and governed by the r_stretchsky console variable.

If unstretched, the baseline is 28 rows below the horizon so that the top of the texture aligns with the top of the screen when looking straight ahead.

If stretched, it is scaled to 228 pixels with the baseline in the same location as an unstretched 128-tall sky, so the top of the texture aligns with the top of the screen when looking fully up.

Exactly 200 Unstretched, baseline is on horizon, and top is at the top of the screen when looking fully up.
More than 200 Unstretched, but the baseline is shifted down so that the top of the texture is at the top of the screen when looking fully up.

In all cases, tiling may happen when looking down, for example when a sky floor is used or if the sky is allowed to go below the horizon. A texture needs to be at least 544 texels high to avoid any sort of tiling.

Note that sky stretching does not happen in the OpenGL renderer of source ports such as GZDoom or Zandronum.