Skip to content

Commit

Permalink
Fixed|Heretic: Sky textures are incorrectly sized
Browse files Browse the repository at this point in the history
The SKY* patches in Heretic are 200 pixels tall even though the texture is declared as 128 pixels tall. The extra height is supposed to make the sky extend upward to facilitate looking up. However, for some reason only Composite::dimensions() is updated to account for this extended height, and not Composite::logicalDimensions(). If both are updated, skyfix walls appear as black in DOOM (for an unknown reason). Therefore, apply a hacky workaround that uses the true composite dimensions for sky textures only.

IssueID #2446

# Conflicts:
#	doomsday/apps/libdoomsday/src/resource/textures.cpp
  • Loading branch information
skyjake committed Jan 31, 2021
1 parent aa36c91 commit b9de854
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
4 changes: 3 additions & 1 deletion doomsday/apps/client/src/render/skydrawable.cpp
Expand Up @@ -118,7 +118,9 @@ struct Hemisphere
{
if (world::Material *mat = chooseMaterialForSkyLayer(layer))
{
MaterialAnimator &matAnimator = mat->as<ClientMaterial>().getAnimator(SkyDrawable::layerMaterialSpec(layer.isMasked()));
MaterialAnimator &matAnimator =
mat->as<ClientMaterial>()
.getAnimator(SkyDrawable::layerMaterialSpec(layer.isMasked()));

// Ensure we've up to date info about the material.
matAnimator.prepare();
Expand Down
5 changes: 4 additions & 1 deletion doomsday/apps/libdoomsday/src/resource/composite.cpp
Expand Up @@ -284,7 +284,10 @@ Composite *Composite::constructFrom(de::Reader &reader,
if (geom.top() < 0) geom.setTop(0);
if (geom.height() > int(pctex->d->logicalDimensions.y))
{
pctex->d->dimensions.y = geom.height();
// BUG: Why not update both logical dimensions and pixel dimensions? Are these
// only intended to be different if there are more than 1 pixel per logical unit?

/*pctex->d->logicalDimensions.y = */pctex->d->dimensions.y = geom.height();
}

if (!foundComponentCount)
Expand Down
21 changes: 17 additions & 4 deletions doomsday/apps/libdoomsday/src/resource/textures.cpp
Expand Up @@ -267,7 +267,7 @@ DENG2_PIMPL(Textures)

// Ensure the offset is within valid range.
if (offset < 0 || unsigned(offset) < unsigned(definitionCount) * sizeof(offset) ||
dsize(offset) > reader.source()->size())
dsize(offset) > reader.source()->size())
{
LOG_RES_WARNING("Ignoring definition #%i: invalid offset %i") << i << offset;
}
Expand Down Expand Up @@ -474,9 +474,22 @@ DENG2_PIMPL(Textures)

try
{
TextureManifest &manifest =
self().declareTexture(uri, flags, def.logicalDimensions(),
Vector2i(), def.origIndex());
// BUG: See IssueID #2446 -- The SKY* patches in Heretic are 200 pixels tall
// even though the texture is declared as 128 pixels tall. The extra height
// is supposed to make the sky extend upward to facilitate looking up.
// However, for some reason only Composite::dimensions() is updated to account for
// this extended height, and not Composite::logicalDimensions(). If both are
// updated, skyfix walls appear as black in DOOM (for an unknown reason).
// Therefore, apply a hacky workaround that uses the true composite dimensions
// for sky textures only.

TextureManifest &manifest = self().declareTexture(
uri,
flags,
def.percentEncodedName().beginsWith("SKY") ? def.dimensions()
: def.logicalDimensions(),
Vec2i(),
def.origIndex());

// Are we redefining an existing texture?
if (manifest.hasTexture())
Expand Down
5 changes: 3 additions & 2 deletions doomsday/apps/plugins/heretic/defs/heretic/skies.ded
Expand Up @@ -8,11 +8,12 @@ Header { Version = 6; }

Sky {
ID = "sky1";
Height = 0.6;
Horizon offset = -0.105;
Height = 0.75;
Horizon offset = 0;
Layer 1 {
Flags = enable;
Material = "textures:SKY1";
Color limit = 0.1;
};
}

Expand Down

0 comments on commit b9de854

Please sign in to comment.