VEXUsageTips
From Odwiki
Contents |
VEX Usage Trick & Tips
Varying parameters of VEX shaders (MantraShaders) and VEX operations across geometry
Any parameters of a VEX operation (eg. Mantra shader or VEX Sop/Pop, etc) can be overridden by point attributes on geometry. This is extremely useful because it means you do not have to write specialized shaders to support this. This is possible to perform in VEX source code and in VOPs.
For example, to vary the diffuse colour of a surface along a plane, you can easily do something like this:
As a shader:
- Create an XY grid
- Apply a VEXPlasticSHOP to it. Hover the mouse over the Diffuse parameter and you'll see a pop-up says the name of the parameter is "diffr diffg diffg". If you're accessing triplets like RGB, you can specify them as a shortened equivalent like "diff".
- Append an AttribCreateSOP. Name the point attribute "diff". Type Float, size 3, and in the Value fields put "$BBX, $BBY, $BBZ". Middle-clicking on the SOP node will show you the point attribute "diff" has been added to your geometry. Feel free to inspect the values of this attribute in geometry SpreadSheet.
- Render it (don't forget a light in the scene). You'll see the colour vary across the surface. This can be done with all numeric parameters. Try it with Roughness (rough) too.
As a VEX Sop:
- Create an XZ grid, make the grid denser, say 50x50.
- Append an AttribCreateSOP. Name the point attribute "height". Type Float, size 1, and in the Value fields put "$BBX"
- Append a VEXMountainSOP. You'll see the mountain height growing from one side of the gid to the other. It's more visible if you make the Frequency a higher number.
Varying string attributes:
- You can also have string attributes (such as texture map names) vary across a surface. Since there is no way to smoothly interpolate strings across a surface, these must be created as primitive string attributes and not point attributes. This feature is extremely useful for sprite renders where every polygon card might want to access a different map.



