# Scaling a float by its derivative

42 views

Feb 27, 2020, 4:38:05 PM2/27/20
to OSL Developers
Hi everyone,

I'm quite a novice and not a developer really. I'm naively attempting to piece together stuff from well...RSL (no experience in that at all, but it seems like the resources available for it were one way of getting into OSL and the concepts in general)

Larry, in the Advanced Renderman book, you give a toon outline example where you correct for low/high curvatures at certain viewing angles that the outlines go out of wack by dividing the angle by its derivative. Could that work in OSL?

I thought I'd just try:

``float a = abs(dot(normalize(N), normalize(I)));float da = filterwidth(a);``

At least in RM I got...0 for da. My gut feeling was that I couldn't pass just any variable to filterwidth(). (That seemed too easy:)
Then I tried the partialDeriv() function from PxrBump2Roughness.h thinking that I could get the rate with respect to u and to v... but I was wrong.
It uses Dx() and Dy() and both return 0 for a. So, now i'm thinking I've no clue what i'm doing. Can anyone see where i'm going wrong with this?

Thanks!
Hristo

### Anders Langlands

Feb 27, 2020, 5:09:53 PM2/27/20
I think you’re falling victim to a lack of second derivatives in OSL. See the recent thread called “Calculate Principal Curvature” on this list - you’re essentially doing the same thing trying to calculate the derivative of N. Solution there was to attach the normal as a primvar then take the derivative of that.

--
You received this message because you are subscribed to the Google Groups "OSL Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osl-dev+u...@googlegroups.com.

Feb 27, 2020, 5:41:05 PM2/27/20
to OSL Developers
I've just read it. That explains.
Thank you.

On Thursday, February 27, 2020 at 11:09:53 PM UTC+1, Anders wrote:
I think you’re falling victim to a lack of second derivatives in OSL. See the recent thread called “Calculate Principal Curvature” on this list - you’re essentially doing the same thing trying to calculate the derivative of N. Solution there was to attach the normal as a primvar then take the derivative of that.
On Fri, 28 Feb 2020 at 10:38, Hristo Arabadzhiyski <hristo.ar...@gmail.com> wrote:
Hi everyone,

I'm quite a novice and not a developer really. I'm naively attempting to piece together stuff from well...RSL (no experience in that at all, but it seems like the resources available for it were one way of getting into OSL and the concepts in general)

Larry, in the Advanced Renderman book, you give a toon outline example where you correct for low/high curvatures at certain viewing angles that the outlines go out of wack by dividing the angle by its derivative. Could that work in OSL?

I thought I'd just try:

``float a = abs(dot(normalize(N), normalize(I)));float da = filterwidth(a);``

At least in RM I got...0 for da. My gut feeling was that I couldn't pass just any variable to filterwidth(). (That seemed too easy:)
Then I tried the partialDeriv() function from PxrBump2Roughness.h thinking that I could get the rate with respect to u and to v... but I was wrong.
It uses Dx() and Dy() and both return 0 for a. So, now i'm thinking I've no clue what i'm doing. Can anyone see where i'm going wrong with this?

Thanks!
Hristo

--
You received this message because you are subscribed to the Google Groups "OSL Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osl...@googlegroups.com.