diff --git a/source/core/textures/buildtiles.cpp b/source/core/textures/buildtiles.cpp
index d90c59c06..e76def804 100644
--- a/source/core/textures/buildtiles.cpp
+++ b/source/core/textures/buildtiles.cpp
@@ -1006,7 +1006,6 @@ bool PickTexture(int picnum, FGameTexture* tex, int paletteid, TexturePick& pick
 	if (picnum == -1) picnum = TileFiles.GetTileIndex(tex);	// Allow getting replacements also when the texture is not passed by its tile number.
 
 	if (!tex->isValid() || tex->GetTexelWidth() <= 0 || tex->GetTexelHeight() <= 0) return false;
-	pick.texture = tex;
 	int usepalette = GetTranslationType(paletteid) - Translation_Remap;
 	int usepalswap = GetTranslationIndex(paletteid);
 	int TextureType = hw_int_useindexedcolortextures && picnum >= 0 ? TT_INDEXED : TT_TRUECOLOR;
@@ -1061,6 +1060,7 @@ bool PickTexture(int picnum, FGameTexture* tex, int paletteid, TexturePick& pick
 		pick.tintFlags = -1;
 		pick.tintColor = 0xffffff;
 	}
+	pick.texture = tex;
 
 	return true;
 }
diff --git a/source/glbackend/gl_texture.cpp b/source/glbackend/gl_texture.cpp
index 93aa667d9..e6899652f 100644
--- a/source/glbackend/gl_texture.cpp
+++ b/source/glbackend/gl_texture.cpp
@@ -84,7 +84,7 @@ bool GLInstance::SetTexture(int picnum, FGameTexture* tex, int paletteid, int sa
 	SetBasepalTint(texpick.basepalTint);
 	auto &mat = renderState.mMaterial;
 	int flags = hw_useindexedcolortextures ? CTF_Indexed : 0;
-	mat.mMaterial = FMaterial::ValidateTexture(tex, flags); // todo allow scaling
+	mat.mMaterial = FMaterial::ValidateTexture(texpick.texture, flags); // todo allow scaling
 	mat.mClampMode = sampler;
 	mat.mTranslation = texpick.translation;
 	mat.mOverrideShader = 0;