Sloth – Shader Generator

Ask questions about mapping in general, and show off your in-progress work.
User avatar
Viech
Project Head
Posts: 2139
Joined: Fri Aug 03, 2012 11:50 pm UTC
Location: Berlin

Sloth – Shader Generator

Postby Viech » Thu Jan 09, 2014 12:19 am UTC

Sloth is a Python console application that generates Quake3/XreaL/Daemon compatible shader files given a texture map source directory.

Features

  • Supports diffuse, normal, height, specular and addition maps as well as preview images
  • Generates light emitting shaders from addition maps given a number of named colors and intensities
  • Detects alpha channels and supports different blending modes
  • Detects texture variants (shaders sharing non-diffuse maps)
  • Can generate multiple sets at once or merge different source folders into one set
  • Supports hierarchical configuraton files (per-directory/prefix/shader) for full automation
  • It's not slow, it's named Sloth because it's made for lazy mappers!

Usage

Code: Select all

usage: sloth.py [-h] [-e] [-v] [-f FILE] [-g] [--height-normals VALUE]
                [--daemon | --xreal | --quake3] [-d SUF] [-n SUF] [-z SUF]
                [-s SUF] [-a SUF] [-p SUF] [-c NAME:COLOR [NAME:COLOR ...]]
                [-l VALUE [VALUE ...]] [-i VALUE [VALUE ...]]
                [--color-blend-exp VALUE]
                [--gt0 | --ge128 | --lt128 | --alpha-test VALUE]
                [--no-alpha-shadows] [-r ROOT | -x SUF] [-t FILE] [-o DEST]
                PATH [PATH ...]

Generates XreaL/Daemon shader files from directories of texture maps.

positional arguments:
  PATH                  Path to a source directory that should be added to the
                        set

optional arguments:
  -h, --help            show this help message and exit
  -e, --example-config  Prints an example per-directory/shader configuration
                        file (default: None)
  -v, --verbose         Print debug information to stderr. Supply twice for
                        more verbosity. (default: None)
  -f FILE, --config FILE
                        Read global configuration (takes precedence over
                        command line arguments) (default: None)
  -g, --guess           Guess additional keywords based on shader (meta)data
                        (default: False)
  --height-normals VALUE
                        Modifier used for generating normals from a heightmap
                        (default: 1.0)

Renderers:
  --daemon              Use renderer features of the Daemon engine. Makes the
                        shaders incompatible with XreaL and Quake3. (default:
                        False)
  --xreal               Use renderer features of the XreaL engine. Makes the
                        shaders incompatible with Quake3. This is the default.
                        (default: False)
  --quake3              Use renderer features of the vanilla Quake3 engine
                        only. (default: False)

Texture map suffixes:
  -d SUF, --diff SUF    Suffix used by diffuse maps (default: _d)
  -n SUF, --normal SUF  Suffix used by normal maps (default: _n)
  -z SUF, --height SUF  Suffix used by height maps (default: _h)
  -s SUF, --spec SUF    Suffix used by specular maps (default: _s)
  -a SUF, --add SUF     Suffix used by addition/glow maps (default: _a)
  -p SUF, --prev SUF    Suffix used by preview images (default: _p)

Light emitting shaders:
  -c NAME:COLOR [NAME:COLOR ...], --colors NAME:COLOR [NAME:COLOR ...]
                        Add light colors with the given name, using a RGB hex
                        triplet. They will only be used in combination with
                        grayscale addition maps. (default: ['white:ffffff'])
  -l VALUE [VALUE ...], --custom-lights VALUE [VALUE ...]
                        Add light intensities for light emitting shaders with
                        custom colors (grayscale addition map) (default:
                        [1000, 2000, 4000])
  -i VALUE [VALUE ...], --predef-lights VALUE [VALUE ...]
                        Add light intensities for light emitting shaders with
                        predefined colors (non-grayscale addition map)
                        (default: [0, 200])
  --color-blend-exp VALUE
                        Exponent applied to custom light color channels for
                        use in the addition map blend phase (default: 1.0)

Alpha blending:
  --gt0                 Use alphaFunc GT0 instead of smooth alpha blending.
                        (default: False)
  --ge128               Use alphaFunc GE128 instead of smooth alpha blending.
                        (default: False)
  --lt128               Use alphaFunc LT128 instead of smooth alpha blending.
                        (default: False)
  --alpha-test VALUE    Use alphaTest instead of smooth alpha blending.
                        (default: None)
  --no-alpha-shadows    Don't add the alphashadows surfaceparm. (default:
                        False)

Input & Output:
  -r ROOT, --root ROOT  Sets the namespace for the set (e.g.
                        textures/setname). Can be used to merge source folders
                        into a single set. (default: None)
  -x SUF, --strip SUF   Strip suffix from source folder names when generating
                        the set name (default: _src)
  -t FILE, --header FILE
                        Use file content as a header, "// " will be prepended
                        to each line (default: None)
  -o DEST, --out DEST   Write shader to this file (default: None)


Download

Get it on GitHub. There's also an Archlinux package for it.
Responsible for: Arch Linux package & torrent distribution, Parpax (map), Chameleon (map texture editor), Sloth (material file generator), gameplay design & programming, artistic direction
User avatar
poVoq
Dretch
Posts: 59
Joined: Tue Oct 09, 2012 5:01 pm UTC

Re: Sloth – Shader Generator

Postby poVoq » Thu Feb 06, 2014 7:24 pm UTC

That is very usefull ;) Thanks!

Return to “Level Design”

Who is online

Users browsing this forum: illwieckz and 1 guest