question

Malcolm Allan Kesson avatar image
Malcolm Allan Kesson asked ·

Is OSL "N" the same as C++ sg->Nf ?

Is OSL "N" the same as C++ sg->Nf or sg->N ??

osl
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Malcolm Kesson avatar image
Malcolm Kesson answered ·

Many thanks.

Malcolm


Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Adrien Herubel avatar image
Adrien Herubel answered ·

In our implementation N in OSL corresponds to `Nf` in the C++ shader globals, meaning

the face-forward shading normal.


Ng corresponds to Ngf in the C++ shader globals, meaning the face-forward geometric normal.


To detect whether the shader is being executed on a back face, you would need to use the backfacing () function.

Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Malcolm Kesson avatar image
Malcolm Kesson answered ·

This shader does not work because the dot product never yields a value less than zero because N is in effect a front facing normal.


shader

sidemask(

color rearColor = color(0.7, 0.7, 0),

color frontColor = color(1,0,0),

output color resultRGB = 0)

{

vector i = normalize(-I);

vector n = normalize(N);

float angle = dot(i,n); // the cosine of the angle


// When the angle becomes negative we are shading

// the rear surface.

if(angle < 0)

resultRGB = rearColor;

else

resultRGB = frontColor;

}


Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Mads Drøschler avatar image
Mads Drøschler answered ·

OSL N source the mesh/face normals.

Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Welcome to the Arnold Answers community.

This is the place for Arnold renderer users everywhere to ask and answer rendering questions, and share knowledge about using Arnold, Arnold plugins, workflows and developing tools with Arnold.

If you are a new user to Arnold Answers, please first check out our FAQ and User Guide for more information.

When posting questions, please be sure to select the appropriate Space for your Arnold plugin and include the plugin version you are using.

Please include images, scene and log files whenever possible as this helps the community answer your questions.

Instructions for generating full verbosity log files are available for MtoA, MaxtoA, C4DtoA, HtoA, KtoA, and Kick.

If you are looking for Arnold Documentation and Support please visit the Arnold Support site.

To try Arnold please visit the Arnold Trial page.

Bottom No panel present for this section.