[SESI logo]

VEX Language Reference - Version 7.0

Side Effects Software Inc. 2004

VEX Context Definitions

  • OP Contexts
  • COP Context
  • SOP/POP Context
  • CHOP Context
  • 3D Image Context
  • Shading Contexts

  • OP Contexts

    There are several functions which are common to all OP contexts. The OP contexts refer to SOP, COP, POP, and CHOP contexts. These functions are not available in any of the shading contexts (Surface, Displacement, Light, etc.).

    These are:

  • float ch(string channel)
    float ch(string channel, float time)
    string ch(string channel)
    string ch(string channel, float time)

    These functions evaluate a channel (or parameter) and return its value. When evaluating string parameters at a specified time, the time value must be the same for all evaluations of the parameter. If the time is not constant over the all the points/pixels being evaluated, results are not predictable. For example, the following functions will produce unpredictable results: string s = ch(channel_path, ptnum); // SOP/POP string s = ch(channel_path, cinput(X, Y).r); // COP string s = ch(channel_path, age); // SOP/POP string s = ch(channel_path, V); // CHOP since the time specified will be different for every evaluation of the VEX function. The following functions will work correctly. string s = ch(channel_path, Time*.7); // SOP/POP string s = ch(channel_path, XRES); // COP string s = ch(channel_path, SR); // CHOP since the time specified will be the same for every evaluation of the VEX function. The time specified is in seconds.

  • matrix optransform(string path)
    matrix optransform(string path; float time)

    These functions will return the transform associated with an OP. If the OP specified has no transform associated with it (for example a COP), then an identity matrix is returned. It is possible to specify the time to evaluate the transform at (in seconds, not frames).

  • vector toNDC(string camera_name; vector point)
    This function will transform a position to the normal device coordinates for a camera. The point should be in the local space of the object (i.e. not in the space of the camera).


  • COP VEX Context

    The COP evaluation works by setting either the R, G, B, A or the Cr,Cg, Cb,C4 variables. The variables are initialized to the color of the first input (or zero for R, G, B and 1 for A if there is no input). It then calls the COP function. If any of the variables are modified, then they will be used to determine the new color for the current pixel.

    The RGBA variables are for programmer convenience; they read and write directly to the Color and Alpha planes. Reading from RGB and A will give you the value of the first input's color plane and alpha plane. If one or both of these planes do not exist, 0 will be returned. If you are writing to R, G, B or A and either Color and/or Alpha doesn't exist, the planes will be created for you. If you only write to R, a full Color plane will be created, but with the G and B channels set to 0.

    The channel variables, Cr to C4, are more flexible. They allow you to write to any plane's channels. If a channel of a plane does not exist and you write to it, nothing happens. For example,  when cooking the Alpha plane (with only 1 channel),  if Cg, Cb or C4 is written to, the data is lost; only Cr is valid. However, no error occurs, since it is possible to have planes with different sizes in the same sequence. You can read from a channel variable in exactly the same way as reading from the R,G,B and A variables. The channel variable will be filled with the pixel values from the plane in the first input corresponding to the one being cooked.

    You should not mix writing to R,G,B,A and Cr,Cg,Cb,C4 in the same VEX function. While it will not harm anything, it can lead to confusing results if you are writing different things to R and Cr and the function is cooking the Color plane. Confusing code is bad code, and bad code shouldn't be written :)

    Global Variables

    Variable Type Read/Write Description
    XRES int Read Only Contains the horizontal resolution (in pixels) of the image being processed.
    YRES int Read Only Contains the vertical resolution (in pixels) of the image being processed.
    AR float Read Only Contains the aspect ratio of the image being processed.
    IX int Read Only Contains the horizontal position of the pixel currently being shaded. This will be in the range of (0, XRES-1).
    IY int Read Only Contains the vertical position of the pixel currently being shaded. This will be in the range of (0, XRES-1).
    X float Read Only Contains the horizontal location of the center of the current pixel being shaded in the range 0 to 1. Zero being the left hand side of the image, and 1 being the right hand side.
    Y float Read Only Contains the vertical location of the center of the current pixel being shaded in the range 0 to 1. Zero being the bottom of the image, and 1 being the top.
    H float Read Only Contains the hue of the current pixel. The hue is expressed as a floating point number between zero and one. HSV is calculated based on the Color plane (C), not the current plane.
    S float Read Only Contains the saturation of the current pixel. The saturation is expressed as a floating point number between zero and one.
    V float Read Only Contains the value (or intensity) of the current pixel. The value is expressed as a floating point number between zero and one.
    R float Read/Write Contains the value of the red channel of the current pixel. The value is expressed as a floating point number between zero and one. If the COP does not have a color plane (C), one will be created.
    G float Read/Write Contains the value of the green channel of the current pixel. The value is expressed as a floating point number between zero and one. If the COP does not have a color plane (C), one will be created.
    B float Read/Write Contains the value of the blue channel of the current pixel. The value is expressed as a floating point number between zero and one. If the COP does not have a color plane (C), one will be created.
    A float Read/Write Contains the value of the alpha channel of the current pixel. The value is expressed as a floating point number between zero and one. If the COP does not have an alpha plane (A), one will be created.
    Cr,Cg,Cb,C4 float Read/Write Contains the value of the plane component 1, 2, 3 or 4. Unlike the R,G,B or A variables, these components represent the current plane's values.
    PNAME string Read Only Contains the name of the current plane being cooked.
    PL int Read Only Contains the index of the current plane being cooked.
    PS int  Read Only Contains the size of the current plane being cooked (the number of channels). 
    AI int Read Only Contains the array index of the current plane that is being cooked (from 0 to AS-1).
    AS int Read Only Contains the array size of the current plane.
    NP int Read Only Returns the number of planes in the image (ie, for a RGBA image, this would be 2 since the COP must contain 2 planes, Color and Alpha).
    NI int Read Only Returns the number of images in the sequence (ie, a sequence with a frame range of 1 to 19 would have 20 images in it).
    F int Read Only The frame number of the current image.
    SF int Read Only The starting frame of the current sequence.
    EF int Read Only The end frame of the current sequence.
    I int Read Only The index number of the current image, which always starts at zero for the first image in the sequence.
    TIME float Read Only The time of the current image.
    TINC float Read Only The time increment between frames at the global frame rate.
    FR int Read Only The frame rate of the current sequence.

    COP Specific Functions

    Many of the input functions have changed from the old COP context to allow access to any plane, instead of having specific functions to return color, depth or bump values. All pixel values are converted to floating point values (colors between 0 and 1). There are two classes of input functions, point sampled and filtered.
     

    Output Plane Functions

  • int hasplane(string planename)

  • Returns 1 if the plane specified by the parameter exists in this COP.
     
  • int planeindex(string planename)

  • Returns the index of the plane specified by the parameter, starting at zero.
     
  • string planename(int planeindex)

  • Returns the name of the plane specified by the index (ie. "C", "A").
     
  • string chname(int planeindex, int chindex)

  • Returns the channel name of the indexed plane. (ie. "r", "x")
     
  • int planesize(int planeindex)

  • Return the number of components in the plane (1 for scalar planes and up to 4 for vector planes). If the index is out of range, 0 is returned.
     
  • string colorname()
  • string alphaname()
  • string maskname()
  • string depthname()
  • string lumname()
  • string bumpname()
  • string pointname()
  • string normalname()
  • string velocityname()

  • Return the default name of the indicated type of plane (as it appears in the Compositor Preferences). This allows you to write COP2 VEX functions that don't hardcode the names of planes, so the function is portable between different Houdini configurations. The defaults are "C", "A", "M", "Z", "L", "B", "P", "N" and "V".
     

    Input Structure Functions

  • int isconnected(int input_number)

  • Returns 1 if there is an input connected to the specified number. Input numbers start at 0.
     
  • int inumplanes(int input_number)

  • Returns the number of planes in the given input.
     
  • int ihasplane(int input_number, string planename)

  • This function will return 1 if the specified input has a plane named 'planename'. Input numbers start at 0.
     
  • string iplanename(int input_number, int planeindex)

  • Returns the name of the plane specified by the planeindex of the given input (ie. "C", "A").
     
  • string ichname(int planeindex, int chindex)

  • Returns the channel name of the indexed plane of the given input (ie. "r" or "x").
     
  • int iplaneindex(int input_number, string planename)

  • This function will return the index of the plane named 'planename' in the specified input. Input numbers start at 0.
     
  • int iplanesize(int input_number, int planeindex)

  • This function will return the number of components in the plane named 'planename' in the specified input. Input numbers start at 0.
     
  • float irate(int input_number)

  • This function returns the frame rate of the specified input.
     
  • int istart(int input_number)

  • This function returns starting frame of the specified input.
     
  • int iend(int input_number)

  • This function returns last frame of the specified input.
     
  • float istarttime(int input_number)

  • This function returns the start time of the specified input.
     
  • float iendtime(int input_number)

  • This function returns the end time of the specified input.
     
  • int ixres(int input_number)

  • This function returns the X resolution of the specified input.
     
  • int iyres(int input_number)

  • This function returns the Y resolution of the specified input.
     
  • float iaspect(int input_number)

  • This function returns the aspect ratio of the specified input.
     

    Input Color Functions

    Point Sampled input functions are prefixed with "c", bilinear sampled functions are prefixed by "b", while filtered input functions are prefixed with "f". Point sampled input functions should be used whenever discrete pixel values are being modified, since these functions are much faster. Filtered functions should be used whenever UV coordinates are being manipulated. If multiple subsamples are being read and combined, bilinear lookups can produce a similar result to finput but much faster.

    Each function may take either floating point or integer UV coordinates. If floating point UVs are used, the values are interpreted as 0-1 UV values; that is, (0.5, 0.5) is the center of the image. If integer UVs are used, the values are considered to be in pixel units, ranging from (0,0) to (XRES-1, YRES-1).

    Each input function can return a float, vector or vector4 value. If the channel does not exist, the value returned for it will be 0. Whenever possible, use the vector versions rather that multiple float versions.

    There are three different complexity levels for each input function. The first level contains only UV parameters. The second contains the input #, plane # and UV parameters. The last level contains all the parameters: input #, plane #, array index, UV and frame #.  If not specified in the function, the input number is always 0, the plane index is the current cooked plane, the array index is the currently cooked array index, and the frame is the current frame.

    So,
    cinput(u, v)  is the same as  cinput(0, PL, u,v)  is the same as cinput(0, PL, AI, u,v, F)
     

    Simple point sampled and filtered input functions:

    Syntax:
    float                       {c,b,f}input( int channel; {int, float} u,v; ...)
    {vector, vector4}  {c,b,f}input( {int,float} u,v; ...)
  • float     cinput(int channel; int u, v; ...)
  • float     cinput(int channel; float u, v; ...)

  •  
  • vector   cinput(int u, v; ...)
  • vector   cinput(float u, v; ...)

  •  
  • vector4 cinput(int u,v; ...)
  • vector4 cinput(float u,v; ...)

  •  
  • float     binput(int channel; int u, v; ...)
  • float     binput(int channel; float u, v; ...)

  •  
  • vector   binput(int u, v; ...)
  • vector   binput(float u, v; ...)

  •  
  • vector4 binput(int u,v; ...)
  • vector4 binput(float u,v; ...)

  •  
  • float      finput(int channel; int u, v; ...)
  • float      finput(int channel; float u, v; ...)

  •  
  • vector   finput(int u, v; ...)
  • vector   finput(float u, v; ...)

  •  
  • vector4 finput(int u,v; ...)
  • vector4 finput(float u,v; ...)

  •  

    Normal point sampled and filtered input functions:

    Syntax:
    float                      {c,f}input( int input_number, plane_index, channel; {int, float} u,v; ...)
    {vector, vector4} {c,b,f}input( int input_number, plane_index;                 {int, float} u,v; ...)
  • float     cinput(int input_number, planeindex, component; int  u,v; ...)
  • float     cinput(int input_number, planeindex, component; float  u,v; ...)

  •  
  • vector  cinput(int input_number, planeindex; int  u,v; ...)
  • vector  cinput(int input_number, planeindex; float u,v; ...)

  •  
  • vector4 cinput(int input_number, planeindex; int u,v; ...)
  • vector4 cinput(int input_number, planeindex; float u,v; ...)

  •  
  • float     binput(int input_number, planeindex, component; int  u,v; ...)
  • float     binput(int input_number, planeindex, component; float  u,v; ...)

  •  
  • vector  binput(int input_number, planeindex; int  u,v; ...)
  • vector  binput(int input_number, planeindex; float u,v; ...)

  •  
  • vector4 binput(int input_number, planeindex; int u,v; ...)
  • vector4 binput(int input_number, planeindex; float u,v; ...)

  •  
  • float     finput(int input_number, planeindex, component; int  u,v; ...)
  • float     finput(int input_number, planeindex, component; float  u,v; ...)

  •  
  • vector  finput(int input_number, planeindex; int  u,v; ...)
  • vector  finput(int input_number, planeindex; float u,v; ...)

  •  
  • vector4 finput(int input_number, planeindex; int u,v; ...)
  • vector4 finput(int input_number, planeindex; float u,v; ...)

  •  

    Full Point sampled input functions:

    Syntax:
    float                       {c,b,f}input( int input_number, plane_index, channel; {int, float} u,v; ...)
    {vector, vector4}  {c,b,f}input( int input_number, plane_index;                 {int, float} u,v; ...)
  • float     cinput(int input_number, planeindex, arrayindex, component; int  u,v; int frame; ...)
  • float     cinput(int input_number, planeindex, arrayindex, component; float  u,v; int frame; ...)

  •  
  • vector   cinput(int input_number, planeindex, arrayindex; int  u,v; int frame; ...)
  • vector   cinput(int input_number, planeindex, arrayindex; float u,v; int frame; ...)

  •  
  • vector4 cinput(int input_number, planeindex, arrayindex; int u,v; int frame; ...)
  • vector4 cinput(int input_number, planeindex, arrayindex; float u,v; int frame; ...)

  •  
  • float     binput(int input_number, planeindex, arrayindex, component; int  u,v; int frame; ...)
  • float     binput(int input_number, planeindex, arrayindex, component; float  u,v; int frame; ...)

  •  
  • vector   binput(int input_number, planeindex, arrayindex; int  u,v; int frame; ...)
  • vector   binput(int input_number, planeindex, arrayindex; float u,v; int frame; ...)

  •  
  • vector4 binput(int input_number, planeindex, arrayindex; int u,v; int frame; ...)
  • vector4 binput(int input_number, planeindex, arrayindex; float u,v; int frame; ...)

  •  
  • float     finput(int input_number, planeindex, arrayindex, component; int  u,v; int frame; ...)
  • float     finput(int input_number, planeindex, arrayindex, component; float  u,v; int frame; ...)

  •  
  • vector  finput(int input_number, planeindex, arrayindex; int  u,v; int frame; ...)
  • vector  finput(int input_number, planeindex, arrayindex; float u,v; int frame; ...)

  •  
  • vector4 finput(int input_number, planeindex, arrayindex; int u,v; int frame; ...)
  • vector4 finput(int input_number, planeindex, arrayindex; float u,v; int frame; ...)

  •  

    Pixel Neighbor Input Function
     

    The function ninput() can be used to read a pixel and its eight neighbors into a 3x3 matrix, ideal for simple kernel and subpixel operations. Only one component is read at a time. To read a Color plane, you would need to call ninput() three times to read R,G and B (with component set to 0, 1 and 2).

  • matrix     ninput(int inputnumber, planeindex, arrayindex, component; {float,int} u,v; int frame);

  • Derivative Functions
     

  • float      Du(float       var ...)
  • vector   Du(vector    var ...)
  • vector4 Du(vector4  var ...)

  •  
  • float      Dv(float       var ...)
  • vector   Dv(vector    var ...)
  • vector4 Dv(vector4  var ...)

  •     The derivative of any VEX variable may be taken with respect to U or V. An optional parameter, "extrapolate" can be added to specify whether derivative extrapolation is done at the edges. It is enabled by default.
     
  • float       area(vector uv ...)

  •     This computes the area of the current pixel, which will not be1 if the UV coordinates are transformed. The optional parameter "extrapolate" may also be specified in this function.
     

    The POP/SOP Context

    The POP context has the same variables and functions as the SOP context. Both of these contexts allow processing of point attribute data. With the POP context, the points are typically used in a particle system, however, this is not a requirement of the context. In general, a function written for POPs will work as a SOP or vice versa.

    Export variables in the POP/SOP contexts will cause new attributes to be created on the geometry. The attribute will have the name and size of the export variable.

    Global Variables

    Variable Type Read/Write Description
    ptnum int Read Only Contains the point number of the point being processed.
    Npt int Read Only Contains the total number of points geometry.
    Frame float Read Only Contains the current frame. This may not be an integer value.
    Time float Read Only Contains the current time (in seconds)
    TimeInc float Read Only Contains the time increment for particle simulations. In the SOP context, this contains the time increment between frames.
    P vector Read/Write Contains the position of the current point.
    v vector Read/Write Contains the velocity of the current point.
    accel vector Read/Write Contains the acceleration of the current point.
    Cd vector Read/Write Contains the color (RGB) of the current point.
    id int Read/Write Contains the value of the id attribute.
    WARNING If this value is modified, it is possible to generate duplicate id's for particles.
    age float Read/Write Contains the age associated with the current point. This represents how many seconds a particle has been alive.
    life float Read/Write Contains the expected lifetime (in seconds) of the current point. It is possible that a particle may die earlier than expected (if a collision or some other event occurs).
    pstate int Read/Write Contains the state of the current particle. This is an integer bit field which has the following bits defined:
  • 0x01 - The particle is a "primary" particle (not birthed off an existing particle).
  • 0x02 - The particle will die before the next frame.
  • 0x04 - The particle is flagged as stopped.
  • 0x08 - The particle has collided
  • 0x10 - The particle is stuck to static or moving geometry.
  • 0x20 - The particle is associated with a rigid body dynamic simulation.
  • 0x40 - The particle is currently active
  • 0x80 - The particle motion is overridden by a CHOP.
  • The bit-field associated with this variable may change in the future. Please see $HFS/houdini/vex/include/pop.h

    POP/SOP Specific Functions

  • void addattribute(string aname; int value; ...)
    void addattribute(string aname; float value; ...)
    void addattribute(string aname; vector value; ...)
    void addattribute(string aname; vector4 value; ...)
    void addattribute(string aname; matrix3 value; ...)
    void addattribute(string aname; matrix value; ...)
    This function will add a new point attribute (or write to an existing attribute). The value of the attribute will be set to the value passed in.

    In Houdini, there are some additional type qualifiers on attributes. The addattribute() function will scan the variadic arguments for keywords to specify these additional type qualifiers. The keywords which are meaningful are:

    Keyword Meaning
    vector Instead of an array of 3 floats, this attribute should have special consideration when the geometry is transformed. Examples of vector attributes are N and v.
    This qualifier is only valid when the attribute being added is a vector.
    indexpair The attribute should be considered as a set of index pairs. Currently, only the capture attributes are this type of attribute.
    This qualifier is only valid when the attribute being added is a vector4 or matrix since an even number of floats should be specified.

  • void addvariablename(string aname; string vname)
    This function will add the mapping of the attribute aname to the local variable vname. In SOPs that support this, such as the Point SOP, one will then have the local variable $vname reference the attribute aname. This emulates the behaviour of the AttribCreate SOP.

  • void newgroup(string group_name)
    This will create a new group in which to put particles.

  • void addgroup(string group_name; int point_number)
    Adds the particle specified by point_number to the group specified. The point_number is not the id of the particle, but rather the geometry point associated with the particle.

  • int ingroup(string group_name; int point_number)
    Returns 1 if the particle specified by the point number is in the group specified by the string. This function returns 0 if the group doesn't exist or the point is not contained in the group.

  • void getbbox(vector &min, &max)
    This will return two vectors representing the minimum and maximum corners of the bounding box for the entire geometry.

  • vector relbbox(vector position)
    This will return the relative position of the point given with respect to the bounding box of the entire geometry. This is equivalent to getting $BBX, $BBY, $BBZ in the point SOP.

  • void computenormal(int state)
    The VEX context attempts to be intelligent about normals on the geometry. If:
    1. A normal attribute exists on the geometry before cooking
    2. The position (P) is modified by the VEX code
    3. The normal (N) is not modified by the VEX code
    then the VEX cooker will assume that the normal is out-of-date and re-compute it. In most cases, this is the desired behaviour. However, in some cases, this is not desired. The computenormal() function allows some control over this behaviour. The state parameter passed into the function behaves as follows:
  • 0 - normals will be un-modified at the conclusion of the cook.
  • 1 - normals will be re-computed if the cooker believes they are required.
  • 2 - normals will be forcibly computed regardless of whether they need to be re-computed or not.
  • Note: This function is performed at the conclusion of the cook and thus, this function has no effect on the state of the N variable during execution of VEX code.

  • SOP specific functions

    The SOP Context has some additional functions which the POP context does not have. This is because VEX SOPs allow for multiple inputs, whereas the POPs only allow one input. The additional functions are:
  • int isconnected(int input_number)
    This function returns 1 if a geometry is available on the input number specified. Input numbers start at 0.

  • int npoints(int input_number)
    This function returns the number of points in the input specified. This function will return 0 if there is no input connected.

  • int getneighbourcount(int ptnum, int inputnum)
    This function returns the number of points that are connected to the specified point. A point is considered connected if it is adjacent in some polygon, or is one of the four surrounding points in a grid or NURBs surface. This function will return 0 if there is no input, or the point number is out of range.

  • int getneighbour(int ptnum, int neighbournum, int inputnum)
    This function returns the point index of the given neighbour of the given point. The order is undefined, but will be consistent for consistent geometry. This will return -1 if the neighbournum is out of range for that point, or the point is out of range for that input, or the input doesn't exist.

  • int import(string attrib_name; int &result; int input)
    int import(string attrib_name; float &result; int input)
    int import(string attrib_name; vector &result; int input)
    int import(string attrib_name; vector4 &result; int input)
    int import(string attrib_name; matrix3 &result; int input)
    int import(string attrib_name; matrix4 &result; int input)

    int import(string attrib_name; int &result; int input, pt_num)
    int import(string attrib_name; float &result; int input, pt_num)
    int import(string attrib_name; vector &result; int input, pt_num)
    int import(string attrib_name; vector4 &result; int input, pt_num)
    int import(string attrib_name; matrix3 &result; int input, pt_num)
    int import(string attrib_name; matrix4 &result; int input, pt_num)


    The import() function will import attribute data from the SOP connected to the input specified. The return code of the function will be 1 if the data was successfully imported or 0 if the import failed. If the import was successful, the result will be set to the value of the attribute. Possible reasons for failure are:
    1. No input is connected to the specified index.
    2. The attribute doesn't exist on the input geometry.
    3. The attribute size/type doesn't match the VEX type.
    4. The input geometry has fewer points than the VEX SOPs geometry. Or the point number given is larger than the number of points in the input.
    There are two forms for the import() function. The first form will import the attribute data from the current point that the VEX function is working on. The second form allows you to specify an arbitrary point number of the input. Point numbers are indexed from 0.


  • The CHOP Context

    The CHOP context allows users to change values of channels in a CHOP. Each CHOP function works on a single sample of a single channel of a CHOP.

    Global Variables

    Variable Type Read/Write Description
    V float Read/Write Contains the value of the current sample. This variable should be set to the new value by the function. The variable is initialized to the value of the first input's channels.
    I int Read Only Contains the index or sample number of the current channel.
    S int Read Only Contains the index of the start of the current channel. This is the index of the first sample.
    E int Read Only Contains the index of the last sample (end sample).
    SR float Read Only Contains the sample rate for the channel.
    L int Read Only Contains the length of the channel (total number of samples).
    C int Read Only Contains the channel number for the current channel. When processing multiple channels, this is the index of the channel currently being evaluated.
    NC int Read Only Contains the total number of channels the CHOP will affect.

    CHOP Specific Functions

  • int isconnected(int input_number)
    Returns one if the specified input is connected to the CHOP. If the input is not connected, zero will be returned. Input numbering begins at 0.

  • float chinput(int input, channel, sample)
    float chinput(int input, channel; float sample)
    Returns the value of a channel at the specified sample in an input. If the sample is fractional, the value is linearly interpolated from the two nearest points.

  • int chstart(int input)
    Returns the start sample of the input specified.

  • float chstartt(int input)
    Returns the time corresponding to the first sample of the input specified.

  • float chstartf(int input)
    Returns the frame corresponding to the first sample of the input specified.

  • int chend(int input)
    Returns the end sample of the input specified.

  • float chendt(int input)
    Returns the time corresponding to the last sample of the input specified.

  • float chendf(int input)
    Returns the frame corresponding to the last sample of the input specified.

  • float chrate(int input)
    Returns the sample rate of the input specified.

  • int chnumchan(int input)
    Returns the number of channels in the input specified.

  • int isframes()
    Returns 1 if the Vex CHOP's Unit Menu is currently set to 'frames', 0 otherwise. otherwise.

  • int isseconds()
    Returns 1 if the Vex CHOP's Unit Menu is currently set to 'seconds', 0 otherwise otherwise.

  • int issamples()
    Returns 1 if the Vex CHOP's Unit Menu is currently set to 'samples', 0 otherwise otherwise.


  • The 3D Image Context

    The Image3D context is used by the stand-alone program i3dgen to generate 3D texture images. In turn, these 3D texture images may be used by the texture3d() function calls in VEX to efficiently evaluate the 3D texture images.

    Any export variables in the image3d context will cause additional channels to be created in the 3D texture map.

    Image 3D Specific Statements

    In the image3d context, when geometry is specified (i.e. metaball geometry or particles), it is possible to "loop" through all the metaballs which affect a point in space. The syntax for this type of loop is:

    forpoints ( position, [distance] ) statement; Where the position is a vector representing a point in space. The statement in the loop may in fact be multiple statements (like a while or for loop). The statement will be executed once for each metaball/particle which contains the position passed in.

    If the distance is specified, all metaballs/particles within the distance of the point specified will be iterated through. The distance parameter is optional and may result in slower execution of the shader.

    Inside the loop, the mdensity and mattrib functions may be called to query the contribution of the current point instead of getting a "blended" value.

    For example, the following code will take the point color of the metaball which contributes the maximum weight to the point in space:

    float d = 0, max = 0; vector clr = 0; vector blended_color; forpoints( P ) { d = mdensity(P); if (d > max) { clr = mattrib("Cd", P); max = d; } } blended_color = d * clr; Note that when calling mattrib() inside of a forpoints() loop, the attribute is not pre-blended by the density of the metaball.

    Global Variables

    Variable Type Read/Write Description
    P vector Read Only Contains the position being evaluated.
    density float Read/Write Specifies the value of the density channel at point P.

    Image 3D Specific Functions

  • float mdensity(vector P)
    Returns the density of the metaball field if metaball geometry is specified to i3dgen.

  • float mattrib(string name; vector P)
    vector mattrib(string name; vector P)
    vector4 mattrib(string name; vector P)
    Returns the value of the point attribute for the metaballs if metaball geometry is specified to i3dgen.

  • vector mspace(vector P)
    This function transforms the position specified into the "local" space of the metaball. This function is only valid inside the forpoints loop construct. An example use of this function would be to compute noise based on a "rest" position... For example: forpoints(P) { vector npos = mspace(P) - mattrib("rest", P); nval += noise(npos); }


  • Copyright © 1999-2004 Side Effects Software Inc.
    477 Richmond Street West, Toronto, Ontario, Canada M5V 3E7