Fixing DXT Green Tint Compression: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
(Page updated.)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[File:DXT compression demo.jpg|thumb|right|300px|Original texture (left) versus a re-converted, untreated copy (right), demonstrating the effects of DXT compression.]]
[[File:DXT compression demo.jpg|thumb|right|300px|Original texture (left) versus a re-converted, untreated copy (right), demonstrating the effects of DXT compression.]]
{{update|This is not a problem with DXT compression, but rather with regular {{VTFEdit|4|addtext='s}} DXT decoder, which affects its viewer and exporter! Use [https://github.com/Sky-rym/VTFEdit-Reloaded VTFEdit Reloaded] instead. (The {{photoshop|2}} plug-in also seems to have this issue.)<br>The colors of VTFs created with Vtex, VTFEdit, VTFEdit Reloaded, and Vtex2 will all look imperceivable from each other when viewed side-by-side in-game or in Hammer. Nonetheless, newer compressors are likely to be marginally more effective at reducing visible compression artefacts and improving mipmap quality. {{tf2}} Vtex also produces significantly worse results than other versions of Vtex, such as {{asw}}, {{hl2}}, or {{csgo}}.}}
In the {{src|2|nt=1}}, textures are stored using the Valve Texture Format (VTF), which can store image data in a great variety of formats. The most common and standard ones are the lossy and compression-based DXT1 (used for textures with no alpha channel) and DXT5 (used for textures with an alpha channel).  
In the Source Engine, textures are stored using the Valve Texture Format (VTF), which can store image data in a great variety of formats. The most common and standard ones are the lossy and compression-based DXT1 (used for textures with no alpha channel) and DXT5 (used for textures with an alpha channel). Due to the technical nature of these format’s sampling methods, a slightly green-tinted output is generated whenever sampling colors from these formats. Usually, this altered result would merit no tampering. However, if a project requires both a texture and a modified version to be side by side, differences will inevitably become evident, calling for a workaround to be implemented.


A natural solution would be to store the texture using a different format, such as an uncompressed and, therefore, lossless one, like BGR888 or BGRA8888. However, these formats will considerably increase file size and VRAM usage, demanding for yet another workaround to be implemented.
However, when a VTF file with DXT compression is viewed or extracted using {{VTFEdit|2}} (which also seems to affects {{ps|1}}'s VTF plug-in), a slightly green-tinted output is generated, due to issues with VTFEdit DXT decoder. This doesn't affect the VTFEdit DXT encoder (used to encode VTFs from [[TGA]]/[[PNG]]/other raster image formats). Usually, this altered result would merit no tampering. However, if a project requires both a texture and a modified version to be side by side, differences will inevitably become evident, calling for a workaround to be implemented.


==Steps==
The proper solution is to use {{vtfeditreloaded|2}}, which fixes the green tint issue when viewing or extracting texture. Another solution would be to store the texture using a different format, such as an uncompressed and, therefore, lossless one, like BGR888 or BGRA8888. However, these formats will considerably increase file size and VRAM usage.
 
==Fixing green tint issues==
# Open the original texture in the image editor of your choice.
# Open the original texture in the image editor of your choice.
# Create a blank layer with alpha channel support on top of the original texture.
# Create a blank layer with alpha channel support on top of the original texture.
Line 12: Line 13:
# Set the layer mode to Legacy Addition (GIMP),<sup>[1]</sup> Linear Dodge (Add) (Photoshop) or the equivalent addition-based blend mode of your editor.
# Set the layer mode to Legacy Addition (GIMP),<sup>[1]</sup> Linear Dodge (Add) (Photoshop) or the equivalent addition-based blend mode of your editor.
# Flatten the image if the texture has no transparency. Otherwise, merge all visible layers.
# Flatten the image if the texture has no transparency. Otherwise, merge all visible layers.
# Export as TGA and convert to VTF using [[VTFEdit]]. For the image data format, use either DXT1 or DXT5, depending on your source material.
# Export as TGA and convert to VTF using {{Vtfeditreloaded|4}}. For the image data format, use either DXT1 or DXT5, depending on your source material.


===Footnotes===
===Footnotes===
# For GIMP 2.10, the entire program was ported to the GEGL image processing library, which is based around linear RGB color space as opposed to gamma-corrected (perceptual) RGB color space, which modifies the behavior of several blending modes. This is why switching blending modes from Normal to Legacy is required; for pre-2.10 backwards compatibility.
# For GIMP 2.10, the entire program was ported to the GEGL image processing library, which is based around linear RGB color space as opposed to gamma-corrected (perceptual) RGB color space, which modifies the behavior of several blending modes. This is why switching blending modes from Normal to Legacy is required; for pre-2.10 backwards compatibility.


==See Also==
==See also==
* [[Restoring Texture After DXT Compression]]
* [[Restoring Texture After DXT Compression]]



Latest revision as of 05:01, 7 May 2025

Original texture (left) versus a re-converted, untreated copy (right), demonstrating the effects of DXT compression.

In the Source Source Engine, textures are stored using the Valve Texture Format (VTF), which can store image data in a great variety of formats. The most common and standard ones are the lossy and compression-based DXT1 (used for textures with no alpha channel) and DXT5 (used for textures with an alpha channel).

However, when a VTF file with DXT compression is viewed or extracted using VTFEdit VTFEdit (which also seems to affects Adobe Photoshop's VTF plug-in), a slightly green-tinted output is generated, due to issues with VTFEdit DXT decoder. This doesn't affect the VTFEdit DXT encoder (used to encode VTFs from TGA/PNG/other raster image formats). Usually, this altered result would merit no tampering. However, if a project requires both a texture and a modified version to be side by side, differences will inevitably become evident, calling for a workaround to be implemented.

The proper solution is to use VTFEdit Reloaded VTFEdit Reloaded, which fixes the green tint issue when viewing or extracting texture. Another solution would be to store the texture using a different format, such as an uncompressed and, therefore, lossless one, like BGR888 or BGRA8888. However, these formats will considerably increase file size and VRAM usage.

Fixing green tint issues

  1. Open the original texture in the image editor of your choice.
  2. Create a blank layer with alpha channel support on top of the original texture.
  3. Bucket-fill the new layer with RGB 7 3 7 (HTML notation #070307).
  4. Copy the original texture and paste it into the alpha channel of the new layer.
  5. Set the layer mode to Legacy Addition (GIMP),[1] Linear Dodge (Add) (Photoshop) or the equivalent addition-based blend mode of your editor.
  6. Flatten the image if the texture has no transparency. Otherwise, merge all visible layers.
  7. Export as TGA and convert to VTF using VTFEdit Reloaded VTFEdit Reloaded. For the image data format, use either DXT1 or DXT5, depending on your source material.

Footnotes

  1. For GIMP 2.10, the entire program was ported to the GEGL image processing library, which is based around linear RGB color space as opposed to gamma-corrected (perceptual) RGB color space, which modifies the behavior of several blending modes. This is why switching blending modes from Normal to Legacy is required; for pre-2.10 backwards compatibility.

See also