forked from autodesk-forks/MaterialX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmx_conductor_brdf.osl
26 lines (23 loc) · 919 Bytes
/
mx_conductor_brdf.osl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "pbrlib/genosl/lib/mx_refraction_index.osl"
#include "pbrlib/genosl/lib/mx_fresnel.osl"
void mx_conductor_brdf(float weight, color reflectivity, color edgecolor, roughnessinfo roughness, normal N, vector U, string distribution, output BSDF result)
{
if (weight < M_FLOAT_EPS)
{
result = 0;
return;
}
// Calculate conductor fresnel
//
// Fresnel should be based on microfacet normal
// but we have no access to that from here, so just use
// view direction and surface normal instead
//
float NdotV = fabs(dot(N,-I));
vector ior_n, ior_k;
mx_artistic_to_complex_ior(reflectivity, edgecolor, ior_n, ior_k);
color F = mx_fresnel_conductor(NdotV, ior_n, ior_k);
F *= weight;
// Set ior to 0.0 to disable the internal dielectric fresnel
result = F * microfacet(distribution, N, U, roughness.alphaX, roughness.alphaY, 0.0, false);
}