computenormal()

   3949   2   1
User Avatar
Member
45 posts
Joined: July 2005
Offline
Hi,

According to VEX reference,
==========================
vector computenormal(vector P, …)
vector computenormal(vector P, N, Ng, …)
Computes the normal for the described by P. This is done performing the cross product of the derivatives of P. The second form takes the original surface normal and geometric normal. The computed normal will be “adjusted” so that interpolated normals will be relatively correct.
==========================
If I'm not mistaken, computenormal(P) is approximated by cross(Du(P), Dv(P)).
How about computenormal(vector P, N, Ng, …)?
What is the “relatively correct normal”?

Thanks,
User Avatar
Member
12474 posts
Joined: July 2005
Offline
Hi Sho,

I'm pretty sure what this is talking about is it adds back part of the smooth-shaded (interpolated) normal (N-Ng) to the freshly computed accurate geometric normal derived from the derivatives.

If you do an ordinary computenormal() on poly faces then you'll always shade the model in a faceted way - where in Renderman it's left up to you to add back part of the smoothed normal yourself, here VEX/mantra will try to do this for you by taking N and Ng into consideration… And since the whole smoothed normal was an approximation to begin with and it can't possibly know what crazy displacement you're trying to do in your shader, it can't possibly guarantee a fully “correct” normal. But you get what you expect and it does look good and that's what counts.

Cheers,
Jason

PS. You'll notice that many VOPs and SHOPs have a “Fix for Polygons” option which do computenormal(P,N,Ng) instead of computenormal(P).
Jason Iversen, Technology Supervisor & FX Pipeline/R+D Lead @ Weta FX
also, http://www.odforce.net [www.odforce.net]
User Avatar
Member
45 posts
Joined: July 2005
Offline
Thanks Jason!

I always used computenormal(P). That's why my displacement shader sometimes brings out polygon edges…
ops:
I learned a lot from your explanation.
  • Quick Links