Community
Arnold General Rendering Forum
abbrechen
Suchergebnisse werden angezeigt für 
Anzeigen  nur  | Stattdessen suchen nach 
Meintest du: 

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

4 ANTWORTEN 4
Antworten
Nachricht 1 von 5
Anonymous
348 Aufrufe, 4 Antworten

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

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

Tags (1)
Beschriftungen (1)
  • OSL
4 ANTWORTEN 4
Nachricht 2 von 5
madsd
als Antwort auf: Anonymous

OSL N source the mesh/face normals.

Nachricht 3 von 5
Anonymous
als Antwort auf: Anonymous

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;

}


Nachricht 4 von 5
adrien.herubel
als Antwort auf: Anonymous

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.

Nachricht 5 von 5
Anonymous
als Antwort auf: Anonymous

Many thanks.

Malcolm


Sie finden nicht, was Sie suchen? Fragen Sie die Community oder teilen Sie Ihr Wissen mit anderen.

In Foren veröffentlichen  

Autodesk Design & Make Report