- Substance 3D home
- Home
- Command Line Tools
- Command Line overview
- sbsbaker
- sbscooker
- sbsmtools
- sbsmutator
- sbsrender
- sbsupdater
- Command Line overview
- Pysbs - Python API
- Pysbs - Python API overview
- Getting started
- General topics
- Examples
- API Content
- API Content overview
- Substance definitions
- Common interfaces
- compnode
- context projectmgr
- graph
- mdl
- modelgraphindex
- modelannotationnames
- modelgraph
- modelgraphgenerator
- modelgraphimplementation
- modelnodenames
- modeloperand
- modulegraphindex
- moduleannotation
- moduleconnection
- modulegraph
- modulegraphgenerator
- modulegraphimplementation
- modulegraphlibrary
- modulegraphregister
- modulenode
- modulenodeimplementation
- modulenodeinstance
- moduleoperand
- moduleoutputbridging
- moduleparaminput
- params
- projectmgrdoc
- sbsarchive
- sbscommon
- sbspreset
- sbsproject
- substance
- Libraries
- sbsenum
- sbslibrary
- sbsbakerslibrary
- Helpers
- Execution context
- API Change log
- Samples
- Setup and Getting Started
- Integrations
- Substance Maya toolset
- Changelog overview
ag_functions
Module ag_functions provides the definition of the classes FunctionContext
, used for making it simpler to define functions using the ag_types
classes.
class autograph.ag_functions.FunctionContext(doc, fn_node=None, name=None, use_constant_cache=True, layout_nodes=True, remove_unused_nodes=True)
Bases: object
Class helping out generating functions by keeping track of the document and the root node in which the construction happens
input_parameter(name, widget_type)
Creates an input parameter for the graph and returns the node for accessing it.
Parameters: |
|
---|---|
Returns: |
variable(self, name, widget_type, use_param_type=False)
Creates a reference to a variable in the graph and returns the node for accessing it.
Parameters: |
|
---|---|
Returns: |
constant(constant, t=None)
Creates a constant
Parameters: |
|
---|---|
Returns: |
import_external_function(path)
Imports a function from the same document as the function is created in
Parameters: | path (string) – Path to function to import |
---|---|
Returns: | Type the node representing the imported function |
import_local_function(name)
Imports a function from an external file
Parameters: | name (string) – Name of function to import |
---|---|
Returns: | Type the node representing the imported function |
generate(output_node)
Finalizes function generation.
dot(a, b)
Dot product
sqrt(a)
Sqrt
atan2(a)
Atan2
abs_of(a)
Modulus, or Absolute value, of a.
log(a)
Log
exp(a)
Exp
log2(a)
Log2
pow2(a)
Pow2
floor(a)
Floor
ceil(a)
Ceil
cos(a)
Cos
sin(a)
Sin
tan(a)
Tan
rand(a)
Rand
cartesian(a, b)
Cartesian
max_of(a, b)
Maximum of a and b
Parameters: |
|
---|---|
Returns: |
maximum(*values)
Maximum value of the values
Parameters: | values (VectorType , int, float, list of float or list of int) – input values |
---|---|
Returns: | VectorType |
min_of(a, b)
Minimum of a and b
Parameters: |
|
---|---|
Returns: |
minimum(*values)
Minimum value of the values
Parameters: | values (VectorType , int, float, list of float or list of int) – input values |
---|---|
Returns: | VectorType |
clamp(a, b, x)
Clamp value x between a and b.
Parameters: |
|
---|---|
Returns: |
lerp(a, b, x)
Lerp
swizzle_float1(src, out_vars)
Swizzle Float1
swizzle_float2(src, out_vars)
Swizzle Float2
swizzle_float3(src, out_vars)
Swizzle Float3
swizzle_float4(src, out_vars)
Swizzle Float4
swizzle_int1(src, out_vars)
Swizzle Int1
swizzle_int2(src, out_vars)
Swizzle Int2
swizzle_int3(src, out_vars)
Swizzle Int3
swizzle_int4(src, out_vars)
Swizzle Int4
expand_to_int2(src, fill)
Expands a Int1 to Int2
expand_to_int3(src, fill)
Expands a Int1 or Int2 to Int3
expand_to_int4(src, fill)
Expands a Int1, Int2 or Int3 to Int4
expand_to_float2(src, fill)
Expands a Float1 to Float2
expand_to_float3(src, fill)
Expands a Float1 or Float2 to Float3
expand_to_float4(src, fill)
Expands a Float1, Float2 or Float3 to Float4
expand(*vectors)
Expand two vector to a vector of the appropriate type and dimension.
The sum of the dimension of the input vectors must not be larger than 4. Plus all input vectors must be integers or all input vectors must be float.
Parameters: | vectors (VectorType , int, float, list of int, list of float) – vectors to concatenate |
---|---|
Returns: | VectorType |
cast_to_float1(src)
Casts an Int1 to Float1
cast_to_float2(src)
Casts an Int2 to Float2
cast_to_float3(src)
Casts an Int3 to Float3
cast_to_float4(src)
Casts an Int4 to Float4
auto_cast_to_float(src)
Casts a numeric vector to a float vector of the same dimension
cast_to_int1(src)
Casts a Float1 to Int1
cast_to_int2(src)
Casts a Float2 to Int2
cast_to_int3(src)
Casts a Float3 to Int3
cast_to_int4(src)
Casts a Float4 to Int4
auto_cast_to_int(src)
Casts a numeric vector to an Int vector of the same dimension
if_else(condition, value_on_true, value_on_false)
Choose one of two values based on a condition
Parameters: |
|
---|---|
Returns: |
seq(a, b)
Execute all nodes resulting in branch a then execute all nodes resulting in branch b. Outputs the output of branch b.
sequence(*values)
Execute all nodes in sequence and output the output of the last input.
set_var(a, name)
Set a variable name to the give value.
create_color_sampler(pos, input_index)
Creates a color sampler
Parameters: |
|
---|---|
Returns: |
create_gray_sampler(pos, input_index)
Creates a gray scale sampler
Parameters: |
|
---|---|
Returns: |
create_passthrough(src)
passthrough(src) Create a PassThrough (dot) node function
Parameters: | src (Type , any class that inherits Type) – source |
---|---|
Returns: | SBSFunction |
normalize(a)
Normalize a vector
autograph.ag_functions.generate_function(fn, doc, fn_node=None, name=None, layout_nodes=True, remove_unused_nodes=True)
Generates a function by calling back to the generator function
Parameters: |
|
---|---|
Returns: | function to call to create node |