Sample Render using the custom Voronoi 3D Texture Node.
The following package contains all the material described in this tutorial: Custom_Hypershade_Nodes.zip.
Section | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Main Components
To create a single node only compiled OSL shader is needed. Optionally, it is possible to add icons to have a better visual representation of the node inside Hyerpshade and the Outliner.
The following table shows where each component should be installed for a Maya 2015 package.
Component | Installation Environment Variable | Default Location |
---|---|---|
Compiled OSL shader path | _3DFM_USER_OSL_PATH | |
Icons | XBMLANGPATH | C:\Program Files\3Delight\maya\2015\icons |
Creating a Custom 3D Texture Node
After correctly providing the compiled OSL shader path, you will be able to render using the new texture as with any other Maya 3D Texture.
The Voronoi node viewed in the Create menu of the HyperShade
place3dTexture
node is automatically supported.
Voronoi noise connected to the
The OSL Source Code
The Voronoi texture looks like a standard Open Shading Language surface shader but with some optional metadata:
string maya_name
string maya_label
string maya_type
string maya_group
float maya_min
float maya_max
int maya_hidden
The source code for our voronoi texture follows. To use it as Maya HyperShade node, the shader should be compiled using oslc utility from the OSL package.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
#include "texture3d.h" #include "utils.h" surface OSLVoronoi [[ string maya_type = "texture" ]] ( float i_jitter = 1.0 [[ string maya_name = "jitter", string maya_label = "Jitter", float maya_min = 0.0, float maya_max = 1.0, string maya_group = "3Delight Voronoi" ]], float i_scaleseed = 1.0.1 [[ string maya_name = "scaleseed", string maya_label = "ScaleSeed", float maya_min = 0.0010, float maya_max = 2.0, string maya_group = "3Delight Voronoi" ]], float i_seeduvCoord[2] = 1.0{GetS(), GetT()} [[ string maya_name = "seeduv", stringint maya_labelhidden = "Seed"1, floatint mayaskip_mininit = 0.0, float maya_max = 2.0, string maya_group = "3Delight Voronoi" 1 ]], float i_uvCoorduvFilterSize[2] = {GetS() / i_scale, GetT() / i_scale0, 0} [[ string maya_name = "uvCoorduvFilterSize", int maya_hidden = 1, int skip_init = 1 ]], output color outColor = 0.0 [[ int maya_hidden = 1 ]], output float outDistance = 0.0 [[ int maya_hidden = 1 ]] ) { float edgeDist; float outside; point pp = point(i_uvCoord[0], i_uvCoord[1], i_seed); point position; point thiscell = point( floor(pp[0])+.5, floor(pp[1])+.5, floor(pp[2])+.5); float f1 = 1000; for (int i = -1; i <= 1; i += 1) { for (int j = -1; j <= 1; j += 1) { for (int k = -1; k <= 1; k += 1) { point testcell = thiscell + vector(i,j,k); point pos = testcell + i_jitter * ((vector)cellnoise(testcell) - 0.5); vector offset = pos - pp; float dist = dot(offset, offset); /* actually dist^2 */ if (dist < f1) { f1 = dist; position = pos; } } } } outDistance = sqrt(1 - f1); outColor = outDistance; } |
Adding Icons for the Outliner and Hypershade
You can add icons to both the Outliner and Hypershade (this applies to both texture nodes and shader nodes). The table below details the convention for creating the icons for our Voronoi Noise.
Outliner | HyperShade - Node Lister | HyperShade - Work Area | |
---|---|---|---|
Icon Resolution | 20 x 20 pixels | 32 x 32 pixels | 128 x 128 pixels (up to 512 x 512 pixels) |
Format | Transparent 24 bits PNG | Transparent 24 bits PNG | Transparent 24 bits PNG |
Naming Convention | "out_" + <node_type> + ".png" | "render_" + <node_type> + ".png" | <node_type> + ".png" |
Example | Note the transparent corners of the icon matching Maya |