Aquellos que hayáis modificado, o creado contenido para el videojuego Half-Life (la entrega original de 1998) sabréis lo exquisito que su motor GoldSrc se puede poner en lo relativo a formatos de archivo. Algunas limitaciones deben aplicarse de forma estricta salvo que quieras ver una larga lista de errores. Esto se extiende a las imágenes que vayan a ser usadas como texturas del mapa o los modelos.
Y aunque hay disponibles varias herramientas como el veterano Wally o los Half-Life Texture Tools, estas se enfocan más en crear y editar archivos WAD (contenedores con paquetes de texturas). A veces necesitas algo más rápido y sencillo, y es por ello que escribí un pequeño plug-in del editor de imágenes gratuito GIMP para hacer exactamente eso.
Este plug-in (que realmente es un script de Script-Fu, una variante del lenguaje Scheme usada sólo por GIMP) ofrece una interfaz sin complicaciones para convertir la imagen actualmente abierta al formato correcto para GoldSrc. También la redimensionará a 512x512 píxeles (el máximo tamaño permitido para texturas de modelos) o 256x256 (para texturas usadas en los mapas), acorde a tu elección. La imagen resultante se guardará en la misma carpeta.
Aunque el plug-in no cuenta con traducción al castellano, esto no es ningún detrimento para su uso, como se puede ver:
Aquí puedes descargar y comprobar una textura de muestra, antes y después de la conversión:
- floor_concrete.png (original)
- floor_concrete.bmp (convertida)
Descarga
- GitHub Gist
- script-fu-goldsrc-export.scm (alternativo)
Código
#!/usr/bin/env gimp-script-fu-interpreter-3.0
; Script-Fu script for GIMP 3 that exports the current image to valid GoldSrc
; (Half-Life 1) texture format. It resizes to 256x256 or 512x512 if needed,
; changes the precision to 8-bit integer, converts it to indexed mode with
; optimum palette generation, then exports it to BMP without writing color space
; information.
; Usage:
; To install it, copy it to your GIMP scripts folder (see which one(s) in
; Edit->Preferences->Folders->Scripts) and restart the program. Then, open
; the image you want to export and run Filters->Custom->GoldSrc Export...
(define (script-fu-goldsrc-export image drawables size_small)
; GIMP 3-only script.
(script-fu-use-v3)
(let* (
; Compose the new BMP export filename from the original image. This
; procedure will return %NULL if not loaded/imported/saved/exported yet.
(old_filename (gimp-image-get-file image))
(new_filename (if (or (equal? old_filename '()) (equal? old_filename ""))
; A newly created image, unsaved. Append the extension to the name.
(string-append (gimp-image-get-name image) ".bmp")
; An existing image. Replace the file extension. NOTE: this will not
; work with extensions different than 3 characters!
(string-append (substring old_filename 0 (- (string-length old_filename) 4)) ".bmp")))
(max_size (if (eq? size_small TRUE) 256 512)))
; Resize the image if bigger than 256x256 (small) or 512x512 (large).
(let* ((width (gimp-image-get-width image))
(height (gimp-image-get-height image)))
(when (or (> width max_size) (> height max_size))
(let* ((scale_factor (min (/ max_size width) (/ max_size height))))
(gimp-image-scale image (* scale_factor width) (* scale_factor height))
)
)
)
; Change precision to 8-bit integer (if not already so).
(let* ((current_precision (gimp-image-get-precision image)))
(when (not (= current_precision PRECISION-U8-NON-LINEAR))
(gimp-image-convert-precision image PRECISION-U8-NON-LINEAR)
)
)
; Convert image to indexed mode, generating optimum palette.
(let* ((base_type (gimp-image-get-base-type image)))
(when (not (= base_type INDEXED))
(gimp-image-convert-indexed image CONVERT-DITHER-FS-LOWBLEED CONVERT-PALETTE-GENERATE 256 #t #t "")
)
)
; Export as BMP, without writing color space information.
(file-bmp-export RUN-NONINTERACTIVE image new_filename '() #f #f "rgb-888")
(gimp-displays-flush)
)
)
(script-fu-register-filter
"script-fu-goldsrc-export" ; Procedure name.
"GoldSrc Export..." ; Menu label.
"Export image to valid GoldSrc (Half-Life 1) texture format." ; Description.
"DaSalba" ; Author.
"Copyright (c) 2025 DaSalba. MIT License." ; Copyright notice.
"March 26, 2025" ; Date created.
"*" ; Image type that the script works on.
SF-ONE-DRAWABLE ; This plugin works with only one image/layer.
SF-TOGGLE "S_mall size (256x256)?" FALSE ; Single parameter, if TRUE image will be max 256x256 instead of 512x512.
)
(script-fu-menu-register "script-fu-goldsrc-export" "<Image>/Filters/Custom")