Community
Arnold General Rendering Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

4 REPLIES 4
Reply
Message 1 of 5
mkesson
204 Views, 4 Replies

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

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

Tags (1)
Labels (1)
  • OSL
4 REPLIES 4
Message 2 of 5
madsd
in reply to: mkesson

OSL N source the mesh/face normals.

Message 3 of 5
mkesson4VQY4
in reply to: mkesson

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;

}


Message 4 of 5
adrien.herubel
in reply to: mkesson

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.

Message 5 of 5
mkesson4VQY4
in reply to: mkesson

Many thanks.

Malcolm


Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report