![]() |
VEX Language Reference - Version 7.0Side Effects Software Inc. 2004 |
These are:
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 :)
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. |
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; ...)
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; ...)
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; ...)
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).
Derivative Functions
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.
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.
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
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:
The bit-field associated with this variable may change in
the future. Please see $HFS/houdini/vex/include/pop.h
POP/SOP Specific Functions
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:
This function returns 1 if a geometry is available on the
input number specified. Input numbers start at 0.
This function returns the number of points in the input
specified. This function will return 0 if there is no input
connected.
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.
The CHOP Context
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
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; 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.
Returns the start sample of the input specified.
Returns the time corresponding to the first sample of the
input specified.
Returns the frame corresponding to the first sample of the
input specified.
Returns the end sample of the input specified.
Returns the time corresponding to the last sample of the
input specified.
Returns the frame corresponding to the last sample of the
input specified.
Returns the sample rate of the input specified.
Returns the number of channels in the input specified.
Returns 1 if the Vex CHOP's Unit Menu is currently set to
'frames', 0 otherwise.
otherwise.
The 3D Image Context
Any export variables in the image3d context will cause additional channels to be created in the 3D texture map.
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:
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
Returns the density of the metaball field if metaball
geometry is specified to i3dgen.
477 Richmond Street West, Toronto, Ontario, Canada M5V 3E7