forked from AcademySoftwareFoundation/MaterialX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmx_sheen_bsdf.glsl
More file actions
43 lines (32 loc) · 1.33 KB
/
mx_sheen_bsdf.glsl
File metadata and controls
43 lines (32 loc) · 1.33 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "lib/mx_microfacet_sheen.glsl"
void mx_sheen_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, float weight, vec3 color, float roughness, vec3 N, inout BSDF bsdf)
{
if (weight < M_FLOAT_EPS)
{
return;
}
N = mx_forward_facing_normal(N, V);
vec3 H = normalize(L + V);
float NdotL = clamp(dot(N, L), M_FLOAT_EPS, 1.0);
float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0);
float NdotH = clamp(dot(N, H), M_FLOAT_EPS, 1.0);
vec3 fr = color * mx_imageworks_sheen_brdf(NdotL, NdotV, NdotH, roughness);
float dirAlbedo = mx_imageworks_sheen_dir_albedo(NdotV, roughness);
bsdf.throughput = vec3(1.0 - dirAlbedo * weight);
// We need to include NdotL from the light integral here
// as in this case it's not cancelled out by the BRDF denominator.
bsdf.response = fr * NdotL * occlusion * weight;
}
void mx_sheen_bsdf_indirect(vec3 V, float weight, vec3 color, float roughness, vec3 N, inout BSDF bsdf)
{
if (weight < M_FLOAT_EPS)
{
return;
}
N = mx_forward_facing_normal(N, V);
float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0);
float dirAlbedo = mx_imageworks_sheen_dir_albedo(NdotV, roughness);
bsdf.throughput = vec3(1.0 - dirAlbedo * weight);
vec3 Li = mx_environment_irradiance(N);
bsdf.response = Li * color * dirAlbedo * weight;
}