Personal tools

WritingShaders

From Odwiki

Jump to: navigation, search


[edit] General Concepts

Whether you like using VOPs or VEX to write shaders, you'll need to be familiar with some concepts that apply to both. This is a "what it means and how it works" section, with examples in VEX. (...hopefully user posted image)





[edit] Case Studies

Step by step descriptions of how a particular shader is put together.

(NOTE: If any of your examples use some cool helper functions, then consider adding them to the Odwiki library (see below) and including that module instead.)


  • SurfaceStudies
  • LightStudies
  • ShadowStudies
  • DisplacementStudies
  • PhotonStudies
  • Image3dStudies
  • VolumeStudies



[edit] The Odwiki Library

This is not much more than a skeleton right now, but it demonstrates a few design ideas that may come in handy when writing your own VEX libary. The intent is to make this a kind of repository for useful functions, so please feel free to "add some meat to the bones"!

(NOTE: If you are a licensed Houdini user and have access to the VEX header files that ship with Houdini, please do not post those functions here, as that is not public software!)


The modules:

wikiComplex.h Package for complex number arithmetic.
wikiFilter.h Filter size estimation functions (for AntiAliasing).
wikiMath.h Low level math functions.
wikiMathConst.h Mathematical constants like PI, E, etc.
wikiOpShader.h Preprocessor defines common to all shading contexts.

Preprocessor Symbols:

  • From wikiOpShader.h - Symbols common to all shading contexts
  • WM_HAVE_DERIVS - Derivative functions are available (Du(), Dv(), area(), etc.)


Function Descriptions and Sample Usage:


filterwidth Calculates the approximate size of the filter for AntiAliasing.

  filterwidthX(floatX); filterwidthST(float ss,tt); filterwidthP(vector p); filterwidthP4(vector4 pT);

fadeout Fades to a function's average as we approach the Nyquist limit.

  fadeout(g,f_avg,featuresize,filtwidth);


bias Biases the [0,1] argument towards the extremes of the range.

  bias(float v,user posted image; biasV(vector v; float user posted image;

equal Epsilon equality test.

  equal(float a,user posted image; equalV(vector a,user posted image; equalV4(vector4 a,user posted image;

gain Boosts or dampens the midrange of the [0,1] argument.

  gain(float v,g); gainV(vector v; float g);

modulo Similar to modulus operator =(%)=.

  modulo(float a,user posted image; moduloV(vector a; float user posted image; moduloV4(vector4 a; float user posted image;

sign Returns the sign of the argument =(+1 or -1)=.

  SIGN(v); SIGNI(v); sign(float v); signI(int v);

solveQuad Quadratic equation solver.

  solveQuad(float a,b,c; export float r1,r2);