Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tips for creating CTF (red and blue) textures in Linux
04-29-2009, 06:04 PM (This post was last modified: 04-29-2009 06:21 PM by -z-.)
Post: #1
Tips for creating CTF (red and blue) textures in Linux
I've CTFified a few maps and when doing it, you usually want to have the trims and textures have hints of blue or red to tell the player which side of the map they are on. I don't feel like editing a bunch of images by hand, so I don't.

I use the amazing command line tool called "image magick" (apt-get install imagemagick). Usually it's a simple -modulate with some RGB color levels. This only works with trim that has a base color of a gray hue, otherwise, you're modulating the entire wall and breaking the flow in the textures (i.e. you can turn green to purple or something).

Here's an example of the simple modulation command where I turned the yellow image to a red one:
[Image: owzytu1rhyfemap6c4g.png]

For those of you familiar with the Egyptian texture pack, you probably noticed there are some missing red textures. Well today, I gave batch converting a shot and here's what I discovered...


Making mask from a single source file on a complex image is hard, sloppy and doesn't come out too well (red exaggerated for effect, you can see how it leaks into the stone).

1. I extract the blue channel
2. I adjust the levels to exaggerate the dark and light spots
3. I colorize the mask
4. I layer it on top of the old texture and output it
[Image: pgtaa42ip3yju9jxwjv9.png]

Here's the most accurate code for this method I found, though you'll likely have to play with the values to get it right for your textures.
Code:
convert s064-02d.tga -channel B -separate separated_b.tga
convert separated_b.tga -level 8%,45%,0.4 b_leveled.tga
convert b_leveled.tga -background "#972F2F" -alpha Shape b_mask.tga
convert s064-02d.tga -page +0+0 b_mask.tga -flatten new_texture.tga

Fortunately for me, this texture pack has a lot of neutral textures of the same style. So rather than try bust my ass failing with the previous method (which can actually work out pretty well for less complex textures mind you), I created a mask based on the difference between the images.

1. I create a mask based on the difference of the images
2. I colorize the mask
3. I overlay it and flatten the image
[Image: hw6axas88th57ieffi2n.png]

And for this image technique:
Code:
convert s064-02d.tga s064-02b.tga -compose ChangeMask -composite b_mask.tga
convert b_mask.tga -fx G -fill "#C62D2D" -tint 100 r_mask.tga
convert s064-02d.tga -page +0+0 r_mask.tga -flatten new_texture.tga

I experiment a little with matching it to the red version of this texture I was working with and here's the values I came up with:
Code:
-fx G -fill "#740E00" -tint 70


With some clever bash scripting, I can loop this and batch create complementary images for the texture pack \m/(-.-)\m/

Hope this helped explain some things to people / inspire them :).


Image Magick Resources:
Usage with examples
Command line options


If you ask me why I didn't use <image editing software>, I will ignore your post.
Inspire your neighbor, they'll inspire you back.

maps.nn | pics.nn | chat.nn | 2.5 cvar browser
Visit this user's website Find all posts by this user
Quote this message in a reply
04-29-2009, 11:27 PM (This post was last modified: 04-29-2009 11:30 PM by -z-.)
Post: #2
RE: Tips for creating CTF (red and blue) textures in Linux
I've generated most of them now with the following script:

Code:
#!/bin/bash
# Script written by Tyler "-z-" Mulligan
# made specifically to create complimentary red colors for CTF
# in the egyptsoc pack.  However, this can be apply to textures that
# follow a similar pattern

# blue_and_neutral matches two textures against each other to create
# a mask that can be colorized and applied to create a red style
# texture as a compliment to blue for CTF
#
# @ parms:
#   $1 - blue texture (string)
#   $2 - neutral texture (string)
#   $3 - hex color (red) to convert to (string)
function blue_and_neutral {
    # get variables
    blue=$1
    neutral=$2
    hex=$3
    noext=$(echo $blue |sed 's/\..\{3\}$//')
    ext=$(echo $blue |sed 's/.*\.//')
    
    # start conversion
    convert $neutral $blue -compose ChangeMask -composite ${noext}_b_mask.${ext}
    convert ${noext}_b_mask.${ext} -fx G -fill "#${hex}" -tint 70 ${noext}_r_mask.${ext}
    convert $neutral -page +0+0 ${noext}_r_mask.${ext} -flatten ${noext}_r.${ext}
    
    # remove temp files
    rm ${noext}_b_mask.${ext}
    rm  ${noext}_r_mask.${ext}
}

# test case
#blue_and_neutral s064-02b.tga s064-02d.tga 740E00

# cycle through a directory
#
# naming convetion is a = neutral c = blue
for file in $(find -name "*a.tga"); do
    with_c=$(echo $file |sed 's/a\./c\./')
    if [[ -f $with_c ]]; then
        blue_and_neutral $with_c $file 740E00
    fi
done

[Image: zfi9wwwuh2vur6elezib_thumb.png]

I updated with >> b / d and a/e g/f or whatever for some textures that didn't follow this pattern. divVerent said the pack was designed with stories (levels, planes, floors) of the map in mind. So a would be first floor, b second, etc.

I still need to make glow maps for some of them.
Inspire your neighbor, they'll inspire you back.

maps.nn | pics.nn | chat.nn | 2.5 cvar browser
Visit this user's website Find all posts by this user
Quote this message in a reply
04-30-2009, 11:35 AM
Post: #3
RE: Tips for creating CTF (red and blue) textures in Linux
I had moved the normal maps to another directory when working on the textures so as not to take up extra space and waste time confusing myself. Today I had to bring those back and link them to the new textures, but again, this isn't something I'd ever do manually.

Code:
#!/bin/bash

# Script written by Tyler "-z-" Mulligan

for file in $(ls *.tga); do
    noext=$(echo $file |sed 's/\..\{3\}$//')
    ext=$(echo $file |sed 's/.*\.//')
    
    norm=$(echo $file |sed 's/_r\.tga/_norm\.tga/')
    
    if [[ -f "/home/tyler/Desktop/textures/normals/$norm" ]]; then
        r_norm=$(echo $norm |sed 's/_norm\.tga/_r_norm\.tga/')
        cp "/home/tyler/Desktop/textures/normals/$norm" $r_norm
    fi
done
Inspire your neighbor, they'll inspire you back.

maps.nn | pics.nn | chat.nn | 2.5 cvar browser
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: