Skip to content
Oliver edited this page Sep 24, 2021 · 20 revisions

Index


General syntax

The syntax for techsets seems really weird and I'm not entirely sure how it works. It seems like names placed inside <> are evaluated to GDT values, stuff placed inside "" are evaluated to the proper type for the field in question, arrays or lists are made with "item1", "item2", .... and various other odd things. There even seems to be a select few mathematical expressions and functions that can be placed into "" along with other data to make various calculations. See rest of docs for more details.

Constants

Constants define values and resources for the shader. The constants are stored in the GDT file.

Note: Primitive values stored in the GDT are accessed exactly like <property_name>. An example of this is:

tile = <tileColor>

which accesses the value tileColor from the GDT. Otherwise some unmodifiable constants can be hardcoded into the techset.

Note: It seems like the mod tools will evaluate some strings containing more complicated stuff such as:

// /include/flag_base.techsetdef
float2( "wind1Parms" )
{
    value = "float2( cos( radians( <gFoamScrollAngle0> ) ), sin( radians( <gFoamScrollAngle0> ) ) )"
}
// or
// /include/micro_tile_mix_base.techsetdef
Color( "colorTint1" )
{
    value = "srgb_to_linear( <colorTint1> )"
}
// or
// /include/water_shore_base.techsetdef
float4("controlVar0")
{
    x = "2.0 / (<cg14_x> * <cg14_x>) - 2.0"
    y = "2.0 / (<cg14_y> * <cg14_y>) - 2.0"
    z = "((1.000293 - <cg14_w>) / (1.000293 + <cg14_w>))*((1.000293 - <cg14_w>) / (1.000293 + <cg14_w>))"
    w = "1.0 - (((1.000293 - <cg14_w>) / (1.000293 + <cg14_w>))*((1.000293 - <cg14_w>) / (1.000293 + <cg14_w>)))"
}

I'm not really sure what the full syntax on that is or what is really allowed though.

Syntax:

ConstantType("constant name")
{ 
    property0 = j
    property1 = k
}

ConstantType("constant name").property0 = j
ConstantType("constant name").property1 = k

ConstantType("propertyValue0", "propertyValue1", "propertyValue2", ...)      ??? Unsure about this one

Constant Types:

Base

Base type, all constant types inherit these features.
Available Properties:

  • tweak
    Defines a tweak to visually represent the property in the editor. (Tweak())
  • value
    Directly sets the value to something

Sampler

Texture sampler
Available Properties:

  • tile
    Tiling mode (String)
  • filter
    Filtering mode (String)
  • nobias
    Unknown (Boolean)

Texture

Texture resource
Available Properties:

  • ref
    Unknown (Boolean)
  • image
    Image (Image())
  • semantic
    Unknown (String)
  • usage
    Image asset type that is allowed (String)

Color

Color value
Available Properties:

  • value
    Linear color values separated by spaces or srgb values with srgb_to_linear("1.0 0.5 0.1 1") (String)

Bool

Boolean value
Available Properties:

  • value
    Value (Boolean)

Int

Int value
Available Properties:

  • value
    Value (Integer)

uint1

Single uint
Available Properties:

  • value
    Value (UInt)

uint2

2 uints
Available Properties:

  • x
    Value (UInt)
  • y
    Value (UInt)

uint3

3 uints
Available Properties:

  • x
    Value (UInt)
  • y
    Value (UInt)
  • z
    Value (UInt)

uint4

4 uints
Available Properties:

  • x
    Value (UInt)
  • y
    Value (UInt)
  • z
    Value (UInt)
  • w
    Value (UInt)

float1

Single float
Available Properties:

  • x
    Value (Float)

float2

2 floats
Available Properties:

  • x
    Value (Float)
  • y
    Value (Float)

float3

3 floats
Available Properties:

  • x
    Value (Float)
  • y
    Value (Float)
  • z
    Value (Float)

float4

4 floats
Available Properties:

  • x
    Value (Float)
  • y
    Value (Float)
  • z
    Value (Float)
  • w
    Value (Float)

Sub-Constant Types:

Tweak()

Contains information for displaying the tweak. Tweaks are the sliders, fields and text boxes in APE which allow you to modify the constants from the mod tools.

Syntax:

Tweak() {}
Tweak("Category", "Title", "Sort Index (int)") {}


Available Properties:

  • category
    Which category to place under (String)
  • title
    Display name (String)
  • sortindex
    Position in category to place tweak (Int)
  • range
    Limits input min and max amount and increment amount. Multiple comma separated strings with the corresponding type e.x. (for float type) range = "0.0, "1.0", "0.1" for min of 0, max of 1 and 0.1 increments.
  • color
    Not sure but probably adds a color wheel (Boolean)
  • default
    Default values for the tweak (String array)
    Example:
// /sw4/sw4_2d_heatmap.techsetdef
float4( "HeatmapColor" )
{
    x     = <cg05_x>
    y     = <cg05_y>
    z     = <cg05_z>
    w     = <cg05_w>
    tweak = Tweak()
    {
        title     = "HeatmapColor"
        sortindex = "0"
        default   = "0.214286", "0.678571", "1.000000", "1.000000"
        range     = "-1e+009", "1e+009", "0.01"
        color     = false
    }
}

Image()

Contains image information for textures

Alternate Syntax:

Image( "primaryImage", "fallbackImage" )
// e.x.
image = Image( <colorMap05, $white_diffuse> )
// for no fallback
image = Image( <colorMap05> )
// or
image = Image( "$default" )


Available Properties:

  • map
    Main image path (String)

Techniques and Technique Templates

Techniques are what determine which shaders are used during different lighting states. Not too sure how this works, specifically which lighting states go to what and how multiple states in one technique works...

Technique()

Syntax:

Technique("state1 state2 state3....")
{
   property0 = j
   ...
}
Technique("state1", "state2", "state3", ....)  // This might actually try to use state 1 and then fall back to the next state? And example I found has both lit and unlit in 'fullscreen/cinematic_mp4_add.techsetdef'....
{
   property0 = j
   ...
}
Technique("state1 state2 state3....") : "state1 state2 state3...."    // This either makes it extend or fallback to the states in the second half, not sure which.
{
   property0 = j
   ...
}


Available Properties:

  • source
    The base name for a shader to be used e.g. no ps or vs or anything (String)
  • vs
    The Vertex Shader (String) or (VertexShader())
  • ps
    The Pixel Shader (String) or (PixelShader())
  • gs
    The Geometry Shader (String) or (GeometryShader())
  • defines
    Defines preprocessor directors to compile the shader with (String array)
    Example: defines += "GENERATE_MOTION_VECTOR" sets the directive GENERATE_MOTION_VECTOR
    Example: defines = "USE_COLOR_SPEC", "USE_COLOR_TINT", "CHARACTER_CUSTOMIZATION", "NO_VERT_COLOR"
    Example: defines = "USE_VERTCOL 1"
    NOTE: Modifying the defines will change the shader that mod tools looks for when compiling. This is important for an example, if you change the defines on a base-game shader that you do not posses and there is not a compiled version of it for the defines in the shader cache, then the mod tools will say that it could not find the shader.
  • state
    Unknown. Sets the next state maybe?
    Example: state = "replace + depth"
  • pragmas
    Unknown. Sets pragmas for the shader. No examples of it being used.

Technique Template

Not sure what this is used for but it seems to have the same syntax and properties as Techniques. Just it is called TechniqueTemplate

Shaders

Base

All the shader types share the same syntax and some properties (excluding compute shaders)

Syntax:

Shader() {}
Shader("decl name") {}  // e.x.  PixelShader("ps_sky") {}
Shader() : "decl name" {}  // e.x.  VertexShader() : "vs_sky" {}

An important thing to note is that I think some constant properties can be defined inside the shader rather than outside the technique. For an example:

// /include/extracam_base.techsetdef
ps = PixelShader()
{
#if TOOLSGFX != "1"
    extracamTexture1 = CodeTexture( "extracamTexture1" )
    extracamTexture2 = CodeTexture( "extracamTexture2" )
    extracamTexture3 = CodeTexture( "extracamTexture3" )
    extracamTexture4 = CodeTexture( "extracamTexture4" )
#endif

    extracamSampler = Sampler( "no tile", "nomip bilinear" )
}

In this example extracamTexture1 through 4 and extracamSampler are available for use in the shader.

Available Properties:

  • source
    The base name for a shader to be used e.g. no ps or vs or anything (String)
  • defines
    I think it defines preprocessor directors to compile the shader with. Not sure how it works in the context of the shader type. (String array?)
    Example: defines += "GENERATE_MOTION_VECTOR" sets the directive GENERATE_MOTION_VECTOR
    Example: defines = "USE_COLOR_SPEC", "USE_COLOR_TINT", "CHARACTER_CUSTOMIZATION", "NO_VERT_COLOR"
    Example: defines = "USE_VERTCOL 1"
    NOTE: Modifying the defines will change the shader that mod tools looks for when compiling. This is important for an example, if you change the defines on a base-game shader that you do not posses and there is not a compiled version of it for the defines in the shader cache, then the mod tools will say that it could not find the shader.

VertexShader()

  • vertexDecl
    The decl name for the shader (String)
    Example: vertexDecl = "generic"
    Known decl types: generic, sky

PixelShader()

GeometryShader()

LocalShader()

HullShader()

DomainShader()

ComputeShader()

Compute shaders are in files similar to techsets called .csdef files. I think the only thing allowed is a ComputeShader() definition which behaves like and has similar properties to VertexShader() and PixelShader() but, it is not placed in a technique. Instead it inherits some properties from techniques like defines.

Syntax:

ComputeShader("shader name??")
{
    source = "shader name.hlsl"
    defines = ....
}

'Code' Resources

I think code resources are references to abstract resources in the game i.e. ones that are created at runtime. These are specified in the Technique's shader definition like in the extracam_base example above.

CodeTexture()

An example of this is the extra cam CodeTexture which is treated as a texture but is actually the output of a camera in memory and is constantly updated. If you are familiar with Unity, a CodeTexture here would be like a Render Texture.

CodeBuffer()

Could not find any examples of this in use so I have no clue how it works.

States

States seem to choose the overall rendering flags depending on the states selected

BlendState()

Chooses the blending flags
Available Properties:

  • colorBlendFunc
    Blending function can be one of [disable, add, ] (Incomplete?, needs more values)
  • colorBlendSrc
    Blending function source, can be one of [srcAlpha, One, Zero, DestAlpha] (Incomplete?, needs more values)
  • colorBlendDst
    Blending function destination, can be one of [invSrcAlpha, One, Zero, SrcColor, invSrc1Alpha, ] (Incomplete?, needs more values)
  • alphaBlendFunc
    Alpha blend function, can be one of [disable, add, ] (Incomplete?, needs more values)
  • alphaBlendSrc
    Alpha blend function source, can be one of [srcAlpha, One, Zero, DestAlpha, ] (Incomplete?, needs more values)
  • alphaBlendDst
    Alpha blend function destination, can be one of [invSrcAlpha, One, Zero, SrcColor, invSrc1Alpha, ] (Incomplete?, needs more values)
  • writeChannels
    Channels to blend (String)
    Example: writeChannels = "rba"

StencilState()

States for stencils

Syntax:

StencilState() {}
StencilState("flags list") {}


Available Properties:

  • enable
    Probably enables the stencil feature (Boolean)
  • func
    Stencil function to use. One of [Equal, Always, NotEqual] (Incomplete, needs more values)
  • opFail
    Result fail. One of [Keep, Replace, ] (Incomplete, needs more values)
  • opPass
    Result pass. One of [Keep, Replace, ] (Incomplete, needs more values)
  • opZFail
    Result Zfail. One of [Keep, Replace, ] (Incomplete, needs more values)

State()

State contains some base properties. States also allow to have one of the other sub-state types such as BlendState() or StencilState() inside of them.

Syntax Example:

// /specialty/hud_outline_model_zonly.techsetdef
State( "state" )
{
    blendState = BlendState()
    {
        // Replace
        colorBlendFunc = add
        colorBlendSrc  = One
        colorBlendDst  = Zero
        alphaBlendFunc = add
        alphaBlendSrc  = One
        alphaBlendDst  = Zero
        writeChannels  = ""
    }
    depthWrite  = true
    depthTest   = LessEqual
    cull        = "Back"
}


Available Properties:

  • rez
    Unknown (Boolean)
  • cull
    Faces to cull (String) Sides: ["None", "back", "front"] or [None, back, front] (Incomplete, needs more values)
    Example: cull = "back"
  • polygonOffset
    Unknown (String)
    Example: polygonOffset = "static decal"
  • depthTest
    Depth test value. One of: [less, Always, Disable, LessEqual, Equal] (Incomplete, needs more values)
  • depthWrite
    Turn on depth write (Boolean)
  • stencilFront
    Unknown (String)
    Example: stencilFront = "write stencil"
  • stencilBack
    Unknown (String)
    Example: stencilBack = "match ref"
  • stencilRef
    Probably the stencil id (int)
  • wireframe
    Unknown (Boolean)
  • blendState0
    Unknown (String), Example: blendState0 = "gbuffer albedo blend"
  • blendState1
    Unknown (String), Example: blendState1 = "gbuffer normal gloss blend"
  • blendState2
    Unknown (String), Example: blendState2 = "gbuffer reflectance occlusion blend"
  • blendState3
    Unknown (String)
  • blendState4
    Unknown (String)
  • blendState5
    Unknown (String)
  • blendState6
    Unknown (String)
  • blendState7
    Unknown (String)

Misc

Globals()

Globals are needed at the top of your techset in order for them to appear in the mod tools. It also provides some access to some high level properties
Available Properties:

  • displayName
    Display name of material in mod tools
  • category
    Category to place material under in mod tools
  • renderFlags
    Unknown (Space separated string) or (RenderFlags()).
    Example: renderFlags = "lit transparent distortion"
  • availablePrefixes
    Unknown, something to do with material type (String)
    Example: availablePrefixes = "mc/ mcs/ wc/"
    Full list: mc/, mcs/, wc/, vd/, vdd/, ei/, el/, ec/ (the / is also interchangeable with _)
  • gameOnly
    Only allows it to be rendered in-game (Boolean)
  • radiantOnly
    Only allows it to be rendered in mod tools (Boolean)
  • deprecated
    Unknown (Boolean)
  • url
    Unknown (String)

Usage()

Not sure what Usage does or how it works. It must be specifying what types of texture maps are needed to something.
Available Properties:

  • colorMap
    Unknown (Boolean)
  • normalMap
    Unknown (Boolean)
  • specularMap
    Unknown (Boolean)
  • glossMap
    Unknown (Boolean)
  • aoMap
    Unknown (Boolean)
  • detailMap
    Unknown (Boolean)
  • camoMaskMap
    Unknown (Boolean)
  • doNotDrop
    Unknown (Boolean)
  • normalOverrideMap
    Unknown (Boolean)
  • glossOverrideMap
    Unknown (Boolean)
  • overrideMap
    Unknown (Boolean)
  • flowMap
    Unknown (Boolean)
  • effectMap
    Unknown (Boolean)
  • revealMap
    Unknown (Boolean)

RenderFlags()

Render flags probably provide a higher level way of adjusting the rendering states

Syntax:

RenderFlags()
{
    property0 = j
    ....
}
RenderFlags() : "spaced list of flags"
{
    property0 = j
    ....
}
// e.x. renderFlags = RenderFlags() : "lit deferred opaque" { isOccluder = false }


Known list of flags:

  • none
  • lit
  • deferred
  • forward
  • semi
  • opaque
  • nocull
  • animating
  • transparent
  • emissive
  • sss
  • distortion
  • decal
  • noduplicate
  • fx


Available Properties:

  • is2D
    Unknown (Boolean)
  • forFX
    Unknown (Boolean)
  • isEmissive
    Unknown (Boolean)
  • isTransparent
    Unknown (Boolean)
  • isOpaque
    Unknown (Boolean)
  • needCurrentResolve
    Unknown (Boolean)
  • needCurrentDepthResolve
    Unknown (Boolean)
  • needOpaqueResolve
    Unknown (Boolean)
  • needOpaqueDepthResolve
    Unknown (Boolean)
  • isOccluder
    Unknown (Boolean)
  • requiresPrepass
    Unknown (Boolean)
  • castsShadows
    Unknown (Boolean)
  • noDuplicate
    Unknown (Boolean)
  • postBlur
    Unknown (Boolean)
  • isWater
    Unknown (Boolean)
  • platformOrbis
    Unknown (Boolean)
  • isGbuffer
    Unknown (Boolean)
  • isAnimating
    Unknown (Boolean)
  • isDoubleSided
    Unknown (Boolean)
  • isDecal
    Unknown (Boolean)
  • isSubSurfaceScattering
    Unknown (Boolean)
  • noBspCollision
    Unknown (Boolean)
  • shouldSortIndices
    Unknown (Boolean)

PrimitiveType()

As far as I know this is only seen at the bottom of state.techsetdef. No clue what it does.
Available Properties:

  • value
    Unknown (String)
  • indexCount
    Number of vertices (int) From state.techsetdef
PrimitiveType ("trilist")
{
    value = "TriList"
    indexCount = 3
}

PrimitiveType ("patch")
{
    value = "Patch"
    indexCount = 1
}

PrimitiveType ("pointlist")
{
    value = "PointList"
    indexCount = 3
}

PrimitiveType ("rectlist")
{
    value = "RectList"
    indexCount = 3
}

#if PLAT_ORBIS == "1" 
PrimitiveType ("quadlist")
{
    value = "QuadList"
    indexCount = 4
}
#endif