Jump to content

filterwidth() D.D.Derivatives for a Cel Shader


Mcronin

Recommended Posts

I am building a cel shader in VOPs based on a Renderman Shader I found. The Renderman Shader uses this macro, filterwidth. It's supposed to filter the outline I guess, and I need some help figuring out how to implement this in VOPs. I have all the other pieces for the shader pretty much, but my edges are pretty harsh, and I understand this macro presumably will fix that problem. I will gladly submit the shader to the codex section if some one can help me out.

Some explanation;

x is the result of the absolute value of the dot product of N and I. I guess Du() and Dv() return derivatives of x, but Calc wasn't exactly my strongest subject:angry: This is my main sticking point, the derivative thing. I'm guessing du and dv are analogous to dPds and dPdt, and I can make MINFILTWIDTH a constant, make all this crap a vector and use Max Vector Component. I'm going to stop typing now, because I'm giving myself a headache just by thinking about the word "derivative". Can anyone help? I'm so close to getting this done and time is short.

#ifndef MINFILTWIDTH
#  define MINFILTWIDTH 1.0e-6
#endif


/* The filterwidth macro takes a float and returns the approximate 
 * amount that the float changes from pixel to adjacent pixel.
 */
#define filterwidth(x)  max (abs(Du(x)*du) + abs(Dv(x)*dv), MINFILTWIDTH)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...